Re: function for creating random id - Mailing list pgsql-general

From Michael Loftis
Subject Re: function for creating random id
Date
Msg-id 3CBBAE16.1020208@wgops.com
Whole thread Raw
In response to function for creating random id  (Moritz Sinn <moritz@freesources.org>)
Responses Re: function for creating random id  (Moritz Sinn <moritz@freesources.org>)
List pgsql-general
I've gotten intot he habit of using a sequence identifier, and couple
that with the current time then md5 sum that to create unique uids.
 Works our fairly well, and is atleast marginally difficult to guess.

Bruno Wolff III wrote:

>On Mon, Apr 15, 2002 at 05:51:53PM +0200,
>  Moritz Sinn <moritz@freesources.org> wrote:
>
>>hi,
>>
>>i've got a table called "user". every user should have a userid, which
>>is the primary key. this userid is a random number with up to 6 digits.
>>
>>but now the problem is that the id which is returned by getuid() could
>>already be in use.
>>so what is the best method to realize that?
>>
>
>Do the IDs really need to be random? Is the order that users were created
>in really secret information?
>
>If they don't, you can use a sequence to allocate IDs.
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
>http://www.postgresql.org/users-lounge/docs/faq.html
>



pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: 'cluster' messes up a table
Next
From: Maurice Balick
Date:
Subject: index problem (uses one index but not the other)