2010-09-20 22:08:53 +02:00
|
|
|
<!-- doc/src/sgml/uuid-ossp.sgml -->
|
2007-11-11 00:30:46 +01:00
|
|
|
|
2011-05-08 04:29:20 +02:00
|
|
|
<sect1 id="uuid-ossp" xreflabel="uuid-ossp">
|
2007-11-11 00:30:46 +01:00
|
|
|
<title>uuid-ossp</title>
|
2007-12-06 05:12:10 +01:00
|
|
|
|
2007-11-11 00:30:46 +01:00
|
|
|
<indexterm zone="uuid-ossp">
|
|
|
|
<primary>uuid-ossp</primary>
|
|
|
|
</indexterm>
|
|
|
|
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
The <filename>uuid-ossp</filename> module provides functions to generate universally
|
2007-12-06 05:12:10 +01:00
|
|
|
unique identifiers (UUIDs) using one of several standard algorithms. There
|
|
|
|
are also functions to produce certain special UUID constants.
|
2019-07-14 14:30:27 +02:00
|
|
|
This module is only necessary for special requirements beyond what is
|
|
|
|
available in core <productname>PostgreSQL</productname>. See <xref
|
|
|
|
linkend="functions-uuid"/> for built-in ways to generate UUIDs.
|
2007-12-06 05:12:10 +01:00
|
|
|
</para>
|
|
|
|
|
2020-02-13 21:02:35 +01:00
|
|
|
<para>
|
|
|
|
This module is considered <quote>trusted</quote>, that is, it can be
|
|
|
|
installed by non-superusers who have <literal>CREATE</literal> privilege
|
|
|
|
on the current database.
|
|
|
|
</para>
|
|
|
|
|
2007-11-11 00:30:46 +01:00
|
|
|
<sect2>
|
2007-12-06 05:12:10 +01:00
|
|
|
<title><literal>uuid-ossp</literal> Functions</title>
|
|
|
|
|
2007-11-11 00:30:46 +01:00
|
|
|
<para>
|
2017-11-23 15:39:47 +01:00
|
|
|
<xref linkend="uuid-ossp-functions"/> shows the functions available to
|
2010-08-10 22:42:01 +02:00
|
|
|
generate UUIDs.
|
2020-12-01 13:36:30 +01:00
|
|
|
The relevant standards ITU-T Rec. X.667, ISO/IEC 9834-8:2005, and
|
|
|
|
<ulink url="https://tools.ietf.org/html/rfc4122">RFC 4122</ulink>
|
|
|
|
specify four algorithms for generating UUIDs, identified by the
|
2007-11-11 00:30:46 +01:00
|
|
|
version numbers 1, 3, 4, and 5. (There is no version 2 algorithm.)
|
|
|
|
Each of these algorithms could be suitable for a different set of
|
|
|
|
applications.
|
|
|
|
</para>
|
|
|
|
|
2010-08-10 22:42:01 +02:00
|
|
|
<table id="uuid-ossp-functions">
|
2007-12-06 05:12:10 +01:00
|
|
|
<title>Functions for UUID Generation</title>
|
2020-05-07 20:25:18 +02:00
|
|
|
<tgroup cols="1">
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
Function
|
|
|
|
</para>
|
2007-11-11 00:30:46 +01:00
|
|
|
<para>
|
2020-05-07 20:25:18 +02:00
|
|
|
Description
|
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
<indexterm><primary>uuid_generate_v1</primary></indexterm>
|
|
|
|
<function>uuid_generate_v1</function> ()
|
|
|
|
<returnvalue>uuid</returnvalue>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Generates a version 1 UUID. This involves the MAC
|
2007-11-11 00:30:46 +01:00
|
|
|
address of the computer and a time stamp. Note that UUIDs of this
|
|
|
|
kind reveal the identity of the computer that created the identifier
|
|
|
|
and the time at which it did so, which might make it unsuitable for
|
|
|
|
certain security-sensitive applications.
|
2020-05-07 20:25:18 +02:00
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
<indexterm><primary>uuid_generate_v1mc</primary></indexterm>
|
|
|
|
<function>uuid_generate_v1mc</function> ()
|
|
|
|
<returnvalue>uuid</returnvalue>
|
2007-11-11 00:30:46 +01:00
|
|
|
</para>
|
|
|
|
<para>
|
2020-05-07 20:25:18 +02:00
|
|
|
Generates a version 1 UUID, but uses a random multicast
|
2007-11-11 00:30:46 +01:00
|
|
|
MAC address instead of the real MAC address of the computer.
|
2020-05-07 20:25:18 +02:00
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
<indexterm><primary>uuid_generate_v3</primary></indexterm>
|
|
|
|
<function>uuid_generate_v3</function> ( <parameter>namespace</parameter> <type>uuid</type>, <parameter>name</parameter> <type>text</type> )
|
|
|
|
<returnvalue>uuid</returnvalue>
|
2007-11-11 00:30:46 +01:00
|
|
|
</para>
|
|
|
|
<para>
|
2020-05-07 20:25:18 +02:00
|
|
|
Generates a version 3 UUID in the given namespace using
|
2007-11-11 00:30:46 +01:00
|
|
|
the specified input name. The namespace should be one of the special
|
2020-05-07 20:25:18 +02:00
|
|
|
constants produced by the <function>uuid_ns_*()</function> functions
|
|
|
|
shown in <xref linkend="uuid-ossp-constants"/>. (It could be any UUID
|
|
|
|
in theory.) The name is an identifier in the selected namespace.
|
2007-11-11 00:30:46 +01:00
|
|
|
</para>
|
2010-08-10 22:42:01 +02:00
|
|
|
<para>
|
|
|
|
For example:
|
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
SELECT uuid_generate_v3(uuid_ns_url(), 'http://www.postgresql.org');
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
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.
|
2020-05-07 20:25:18 +02:00
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
<function>uuid_generate_v4</function> ()
|
|
|
|
<returnvalue>uuid</returnvalue>
|
2010-08-10 22:42:01 +02:00
|
|
|
</para>
|
2007-11-11 00:30:46 +01:00
|
|
|
<para>
|
2020-05-07 20:25:18 +02:00
|
|
|
Generates a version 4 UUID, which is derived entirely
|
2007-11-11 00:30:46 +01:00
|
|
|
from random numbers.
|
2020-05-07 20:25:18 +02:00
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
<function>uuid_generate_v5</function> ( <parameter>namespace</parameter> <type>uuid</type>, <parameter>name</parameter> <type>text</type> )
|
|
|
|
<returnvalue>uuid</returnvalue>
|
2007-11-11 00:30:46 +01:00
|
|
|
</para>
|
|
|
|
<para>
|
2020-05-07 20:25:18 +02:00
|
|
|
Generates a version 5 UUID, which works like a version 3
|
2007-11-11 00:30:46 +01:00
|
|
|
UUID except that SHA-1 is used as a hashing method. Version 5 should
|
|
|
|
be preferred over version 3 because SHA-1 is thought to be more secure
|
|
|
|
than MD5.
|
2020-05-07 20:25:18 +02:00
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
2007-11-11 00:30:46 +01:00
|
|
|
</table>
|
|
|
|
|
2010-08-10 22:42:01 +02:00
|
|
|
<table id="uuid-ossp-constants">
|
2007-12-06 05:12:10 +01:00
|
|
|
<title>Functions Returning UUID Constants</title>
|
2020-05-07 20:25:18 +02:00
|
|
|
<tgroup cols="1">
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
Function
|
|
|
|
</para>
|
2007-11-11 00:30:46 +01:00
|
|
|
<para>
|
2020-05-07 20:25:18 +02:00
|
|
|
Description
|
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
<function>uuid_nil</function> ()
|
|
|
|
<returnvalue>uuid</returnvalue>
|
2007-11-11 00:30:46 +01:00
|
|
|
</para>
|
|
|
|
<para>
|
2020-05-07 20:25:18 +02:00
|
|
|
Returns a <quote>nil</quote> UUID constant, which does not occur as a
|
|
|
|
real UUID.
|
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
<function>uuid_ns_dns</function> ()
|
|
|
|
<returnvalue>uuid</returnvalue>
|
2007-11-11 00:30:46 +01:00
|
|
|
</para>
|
|
|
|
<para>
|
2020-05-07 20:25:18 +02:00
|
|
|
Returns a constant designating the DNS namespace for UUIDs.
|
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
<function>uuid_ns_url</function> ()
|
|
|
|
<returnvalue>uuid</returnvalue>
|
2007-11-11 00:30:46 +01:00
|
|
|
</para>
|
|
|
|
<para>
|
2020-05-07 20:25:18 +02:00
|
|
|
Returns a constant designating the URL namespace for UUIDs.
|
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
<function>uuid_ns_oid</function> ()
|
|
|
|
<returnvalue>uuid</returnvalue>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Returns a constant designating the ISO object identifier (OID) namespace for
|
2007-12-06 05:12:10 +01:00
|
|
|
UUIDs. (This pertains to ASN.1 OIDs, which are unrelated to the OIDs
|
2017-10-09 03:44:17 +02:00
|
|
|
used in <productname>PostgreSQL</productname>.)
|
2020-05-07 20:25:18 +02:00
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
<function>uuid_ns_x500</function> ()
|
|
|
|
<returnvalue>uuid</returnvalue>
|
2007-11-11 00:30:46 +01:00
|
|
|
</para>
|
|
|
|
<para>
|
2020-05-07 20:25:18 +02:00
|
|
|
Returns a constant designating the X.500 distinguished name (DN)
|
|
|
|
namespace for UUIDs.
|
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
2007-11-11 00:30:46 +01:00
|
|
|
</table>
|
|
|
|
</sect2>
|
2007-12-06 05:12:10 +01:00
|
|
|
|
2014-05-28 01:42:08 +02:00
|
|
|
<sect2>
|
2017-10-09 03:44:17 +02:00
|
|
|
<title>Building <filename>uuid-ossp</filename></title>
|
2014-05-28 01:42:08 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
Historically this module depended on the OSSP UUID library, which accounts
|
|
|
|
for the module's name. While the OSSP UUID library can still be found
|
|
|
|
at <ulink url="http://www.ossp.org/pkg/lib/uuid/"></ulink>, it is not well
|
|
|
|
maintained, and is becoming increasingly difficult to port to newer
|
2017-10-09 03:44:17 +02:00
|
|
|
platforms. <filename>uuid-ossp</filename> can now be built without the OSSP
|
2014-05-28 01:42:08 +02:00
|
|
|
library on some platforms. On FreeBSD, NetBSD, and some other BSD-derived
|
|
|
|
platforms, suitable UUID creation functions are included in the
|
2017-10-09 03:44:17 +02:00
|
|
|
core <filename>libc</filename> library. On Linux, macOS, and some other
|
|
|
|
platforms, suitable functions are provided in the <filename>libuuid</filename>
|
|
|
|
library, which originally came from the <literal>e2fsprogs</literal> project
|
2014-05-28 01:42:08 +02:00
|
|
|
(though on modern Linux it is considered part
|
2017-10-09 03:44:17 +02:00
|
|
|
of <literal>util-linux-ng</literal>). When invoking <filename>configure</filename>,
|
2014-05-28 01:42:08 +02:00
|
|
|
specify <option>--with-uuid=bsd</option> to use the BSD functions,
|
|
|
|
or <option>--with-uuid=e2fs</option> to
|
2017-10-09 03:44:17 +02:00
|
|
|
use <literal>e2fsprogs</literal>' <filename>libuuid</filename>, or
|
2014-05-28 01:42:08 +02:00
|
|
|
<option>--with-uuid=ossp</option> to use the OSSP UUID library.
|
|
|
|
More than one of these libraries might be available on a particular
|
2017-10-09 03:44:17 +02:00
|
|
|
machine, so <filename>configure</filename> does not automatically choose one.
|
2014-05-28 01:42:08 +02:00
|
|
|
</para>
|
|
|
|
</sect2>
|
|
|
|
|
2007-11-11 00:30:46 +01:00
|
|
|
<sect2>
|
|
|
|
<title>Author</title>
|
2007-12-06 05:12:10 +01:00
|
|
|
|
2007-11-11 00:30:46 +01:00
|
|
|
<para>
|
|
|
|
Peter Eisentraut <email>peter_e@gmx.net</email>
|
|
|
|
</para>
|
2007-12-06 05:12:10 +01:00
|
|
|
|
2007-11-11 00:30:46 +01:00
|
|
|
</sect2>
|
|
|
|
|
2007-12-06 05:12:10 +01:00
|
|
|
</sect1>
|