Thread: Question about uuid_generate_v3

Question about uuid_generate_v3

From
Godofredo Contreras
Date:
Hi,

First of all, I am new to this list and I'm not sure if it is the
correct one to post technical questions. If it is not please tell me
which one I should use.

Recently I installed postgresql 9.1beta3 on a Windows 7 machine to start
testing uuid generation. I correctly installed the functions in my
public schema, however when I run the following sql sentence  SELECT
uuid_generate_v3(uuid_ns_url(), 'http://www.cit.com') I always get the
same result "b2c61380-d1b2-3ca8-a63b-c45d4e0da06a".

Not sure if this is a bug or if I am doing something wrong or if I
missunderstood that uuid_generate_v3 should be generating differente
uuids in every different call to the function.

Has someone faced the same problem? in case of yes could you please
share your solution with me?

Thank you
Godofredo Contreras

Re: Question about uuid_generate_v3

From
Adrian Klaver
Date:
On Saturday, July 23, 2011 8:39:52 am Godofredo Contreras wrote:
> Hi,
>
> First of all, I am new to this list and I'm not sure if it is the
> correct one to post technical questions. If it is not please tell me
> which one I should use.
>
> Recently I installed postgresql 9.1beta3 on a Windows 7 machine to start
> testing uuid generation. I correctly installed the functions in my
> public schema, however when I run the following sql sentence  SELECT
> uuid_generate_v3(uuid_ns_url(), 'http://www.cit.com') I always get the
> same result "b2c61380-d1b2-3ca8-a63b-c45d4e0da06a".
>
> Not sure if this is a bug or if I am doing something wrong or if I
> missunderstood that uuid_generate_v3 should be generating differente
> uuids in every different call to the function.
>
> Has someone faced the same problem? in case of yes could you please
> share your solution with me?

From the docs http://www.postgresql.org/docs/9.0/interactive/uuid-ossp.html:

"The name parameter will be MD5-hashed, so the cleartext cannot be derived from
the generated UUID. The generation of UUIDs by this method has no random or
environment-dependent element and is therefore reproducible. "

You might want to look at one of the other functions listed at the above page.

>
> Thank you
> Godofredo Contreras

--
Adrian Klaver
adrian.klaver@gmail.com

Re: Question about uuid_generate_v3

From
Godofredo Contreras
Date:
Thank you Adrian for clarifying this. I will use uuid_generate_v1 or
uuid_generate_v4 instead of uuid_generate_v3.

Regards
Godofredo Contreras
El 23/07/2011 11:31 a.m., Adrian Klaver escribió:
> On Saturday, July 23, 2011 8:39:52 am Godofredo Contreras wrote:
>> Hi,
>>
>> First of all, I am new to this list and I'm not sure if it is the
>> correct one to post technical questions. If it is not please tell me
>> which one I should use.
>>
>> Recently I installed postgresql 9.1beta3 on a Windows 7 machine to start
>> testing uuid generation. I correctly installed the functions in my
>> public schema, however when I run the following sql sentence  SELECT
>> uuid_generate_v3(uuid_ns_url(), 'http://www.cit.com') I always get the
>> same result "b2c61380-d1b2-3ca8-a63b-c45d4e0da06a".
>>
>> Not sure if this is a bug or if I am doing something wrong or if I
>> missunderstood that uuid_generate_v3 should be generating differente
>> uuids in every different call to the function.
>>
>> Has someone faced the same problem? in case of yes could you please
>> share your solution with me?
>  From the docs http://www.postgresql.org/docs/9.0/interactive/uuid-ossp.html:
>
> "The name parameter will be MD5-hashed, so the cleartext cannot be derived from
> the generated UUID. The generation of UUIDs by this method has no random or
> environment-dependent element and is therefore reproducible. "
>
> You might want to look at one of the other functions listed at the above page.
>
>> Thank you
>> Godofredo Contreras