UUID generation functions

Started by Peter Eisentrautabout 19 years ago3 messageshackers
Jump to latest
#1Peter Eisentraut
peter_e@gmx.net

I have built some UUID generation functions using the library at
<http://www.ossp.org/pkg/lib/uuid/&gt;. This should cover all the usual ways to
do it, and it also provides some special constants that could be useful.

I have attached the code, but the code is actually against 8.2 with uuid
defined as a domain over text, because I needed this functionality in a
current project. I will adjust the code for the real uuid type in 8.3 if
wanted.

What should I do with this? contrib?

Example output:

test=# select uuid_nil();
uuid_nil
--------------------------------------
00000000-0000-0000-0000-000000000000
(1 row)

test=# select uuid_ns_dns();
uuid_ns_dns
--------------------------------------
6ba7b810-9dad-11d1-80b4-00c04fd430c8
(1 row)

test=# select uuid_ns_url();
uuid_ns_url
--------------------------------------
6ba7b811-9dad-11d1-80b4-00c04fd430c8
(1 row)

test=# select uuid_ns_oid();
uuid_ns_oid
--------------------------------------
6ba7b812-9dad-11d1-80b4-00c04fd430c8
(1 row)

test=# select uuid_ns_x500();
uuid_ns_x500
--------------------------------------
6ba7b814-9dad-11d1-80b4-00c04fd430c8
(1 row)

test=# select uuid_make_v1();
uuid_make_v1
--------------------------------------
ca06523c-e826-11db-8418-001aa008dc89
(1 row)

test=# select uuid_make_v1mc();
uuid_make_v1mc
--------------------------------------
cb9df960-e826-11db-bbd1-03614e7a3ea6
(1 row)

test=# select uuid_make_v3(uuid_ns_url(), 'http://www.postgresql.org&#39;);
uuid_make_v3
--------------------------------------
cf16fe52-3365-3a1f-8572-288d8d2aaa46
(1 row)

test=# select uuid_make_v4();
uuid_make_v4
--------------------------------------
ca16279c-f15d-4a33-a066-b657b338ccd8
(1 row)

test=# select uuid_make_v5(uuid_ns_url(), 'http://www.postgresql.org&#39;);
uuid_make_v5
--------------------------------------
e1ee1ad4-cd4e-5889-962a-4f605a68d94e
(1 row)

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Attachments:

pg-ossp-uuid.tar.gzapplication/x-tgz; name=pg-ossp-uuid.tar.gzDownload
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#1)
Re: UUID generation functions

Peter Eisentraut <peter_e@gmx.net> writes:

I have built some UUID generation functions using the library at
<http://www.ossp.org/pkg/lib/uuid/&gt;. This should cover all the usual ways to
do it, and it also provides some special constants that could be useful.

What should I do with this? contrib?

Adding a new outside dependency in contrib seems to require configure
support. If you're willing to do that I have no objection.

regards, tom lane

#3Roman Neuhauser
neuhauser@sigpipe.cz
In reply to: Peter Eisentraut (#1)
Re: UUID generation functions

# peter_e@gmx.net / 2007-04-11 14:27:47 +0200:

I have built some UUID generation functions using the library at
<http://www.ossp.org/pkg/lib/uuid/&gt;. This should cover all the usual ways to
do it, and it also provides some special constants that could be useful.

There's already a mapping for PostgreSQL in the library, is it bad?

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991