Re: GUID for postgreSQL

Поиск
Список
Период
Сортировка
От Tino Wildenhain
Тема Re: GUID for postgreSQL
Дата
Msg-id 1122454174.30587.129.camel@Andrea.peacock.de
обсуждение исходный текст
Ответ на GUID for postgreSQL  ("Riaan van der Westhuizen" <riaan@huizensoft.co.za>)
Ответы Re: GUID for postgreSQL  (John DeSoi <desoi@pgedit.com>)
Список pgsql-general
Am Mittwoch, den 27.07.2005, 09:48 +0200 schrieb Riaan van der
Westhuizen:
> Hi All,
>
> We are a small developing house in South Africa, which is in the process of
> porting our Apps from
> MS SQL to PostgreSQL.  We use the newid() [globally unique identifier
> (GUID)] function in SQL a lot, and need the same for pg.
>
> Our development platform is .NET using c#.  We also plan to start using Mono
> C# in the future.
> We will be deploying PostgreSQL on Windows (2003 Server) and Linux (Ubuntu)
> platforms.
>
> We have search the web and found c code that can do this, but we do not have
> c programmers.
>
> Are there anybody that can help us compiling these for us, we need it on
> both OS’s?

I'd create a sequence:

CREATE SEQUENCE global_unique_id_seq;

and a function:

CREATE OR REPLACE FUNCTION newid()
  RETURNS text AS
$BODY$ SELECT nextval('global_unique_id_seq')::text; $BODY$
  LANGUAGE 'sql' VOLATILE;


now every call to newid() returns a garantied unique id for
say the next 18446744073709551616 calls.
Of course you can obfuscate the ID even more using
md5, include servername and so on, but this will not improve
security in any way (unless you mix data with 2nd database)


> This e-mail and any attachments thereto is confidential and
> is intended solely for the use of the addressee's.
> If you are not the intended recipient, be advised that any use,
> dissemination, forwarding, printing, or copying of this e-mail is strictly
> prohibited.
>
> Huizensoft (Pty) Ltd accepts no liability for any views or opinions
> expressed in
> this e-mail or for any loss or damages that may be suffered by any person
> whomsoever, arising from, or in connection with, or caused by, the use of
> this e-mail.
>
I'd skip this disclaimer as it is not relevant to law and makes the
company look a bit moronic (sorry) especially on mailinglists.

Tino


В списке pgsql-general по дате отправления:

Предыдущее
От: denis@edistar.com
Дата:
Сообщение: Re: Postgresql with max_connections=4096
Следующее
От: Kilian Hagemann
Дата:
Сообщение: Re: Query planner refuses to use index