summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/uuid-ossp.html
blob: 2d6bfc39cf2fb28253a6521fe4647051a9ace903 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>F.49. uuid-ossp</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="unaccent.html" title="F.48. unaccent" /><link rel="next" href="xml2.html" title="F.50. xml2" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">F.49. uuid-ossp</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="unaccent.html" title="F.48. unaccent">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules">Up</a></td><th width="60%" align="center">Appendix F. Additional Supplied Modules</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="xml2.html" title="F.50. xml2">Next</a></td></tr></table><hr /></div><div class="sect1" id="UUID-OSSP"><div class="titlepage"><div><div><h2 class="title" style="clear: both">F.49. uuid-ossp</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="uuid-ossp.html#id-1.11.7.58.5">F.49.1. <code class="literal">uuid-ossp</code> Functions</a></span></dt><dt><span class="sect2"><a href="uuid-ossp.html#id-1.11.7.58.6">F.49.2. Building <code class="filename">uuid-ossp</code></a></span></dt><dt><span class="sect2"><a href="uuid-ossp.html#id-1.11.7.58.7">F.49.3. Author</a></span></dt></dl></div><a id="id-1.11.7.58.2" class="indexterm"></a><p>
  The <code class="filename">uuid-ossp</code> module provides functions to generate universally
  unique identifiers (UUIDs) using one of several standard algorithms.  There
  are also functions to produce certain special UUID constants.
  This module is only necessary for special requirements beyond what is
  available in core <span class="productname">PostgreSQL</span>.  See <a class="xref" href="functions-uuid.html" title="9.14. UUID Functions">Section 9.14</a> for built-in ways to generate UUIDs.
 </p><p>
  This module is considered <span class="quote"><span class="quote">trusted</span></span>, that is, it can be
  installed by non-superusers who have <code class="literal">CREATE</code> privilege
  on the current database.
 </p><div class="sect2" id="id-1.11.7.58.5"><div class="titlepage"><div><div><h3 class="title">F.49.1. <code class="literal">uuid-ossp</code> Functions</h3></div></div></div><p>
   <a class="xref" href="uuid-ossp.html#UUID-OSSP-FUNCTIONS" title="Table F.32. Functions for UUID Generation">Table F.32</a> shows the functions available to
   generate UUIDs.
   The relevant standards ITU-T Rec. X.667, ISO/IEC 9834-8:2005, and
   <a class="ulink" href="https://tools.ietf.org/html/rfc4122" target="_top">RFC 4122</a>
   specify four algorithms for generating UUIDs, identified by the
   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.
  </p><div class="table" id="UUID-OSSP-FUNCTIONS"><p class="title"><strong>Table F.32. Functions for UUID Generation</strong></p><div class="table-contents"><table class="table" summary="Functions for UUID Generation" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
        Function
       </p>
       <p>
        Description
       </p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.11.7.58.5.3.2.2.1.1.1.1" class="indexterm"></a>
        <code class="function">uuid_generate_v1</code> ()
        → <code class="returnvalue">uuid</code>
       </p>
       <p>
        Generates a version 1 UUID.  This involves the MAC
        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.
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.11.7.58.5.3.2.2.2.1.1.1" class="indexterm"></a>
        <code class="function">uuid_generate_v1mc</code> ()
        → <code class="returnvalue">uuid</code>
       </p>
       <p>
        Generates a version 1 UUID, but uses a random multicast
        MAC address instead of the real MAC address of the computer.
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.11.7.58.5.3.2.2.3.1.1.1" class="indexterm"></a>
        <code class="function">uuid_generate_v3</code> ( <em class="parameter"><code>namespace</code></em> <code class="type">uuid</code>, <em class="parameter"><code>name</code></em> <code class="type">text</code> )
        → <code class="returnvalue">uuid</code>
       </p>
       <p>
        Generates a version 3 UUID in the given namespace using
        the specified input name.  The namespace should be one of the special
        constants produced by the <code class="function">uuid_ns_*()</code> functions
        shown in <a class="xref" href="uuid-ossp.html#UUID-OSSP-CONSTANTS" title="Table F.33. Functions Returning UUID Constants">Table F.33</a>.  (It could be any UUID
        in theory.)  The name is an identifier in the selected namespace.
       </p>
       <p>
        For example:

</p><pre class="programlisting">
SELECT uuid_generate_v3(uuid_ns_url(), 'http://www.postgresql.org');
</pre><p>

        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.
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">uuid_generate_v4</code> ()
        → <code class="returnvalue">uuid</code>
       </p>
       <p>
        Generates a version 4 UUID, which is derived entirely
        from random numbers.
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">uuid_generate_v5</code> ( <em class="parameter"><code>namespace</code></em> <code class="type">uuid</code>, <em class="parameter"><code>name</code></em> <code class="type">text</code> )
        → <code class="returnvalue">uuid</code>
       </p>
       <p>
        Generates a version 5 UUID, which works like a version 3
        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.
       </p></td></tr></tbody></table></div></div><br class="table-break" /><div class="table" id="UUID-OSSP-CONSTANTS"><p class="title"><strong>Table F.33. Functions Returning UUID Constants</strong></p><div class="table-contents"><table class="table" summary="Functions Returning UUID Constants" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
        Function
       </p>
       <p>
        Description
       </p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">uuid_nil</code> ()
        → <code class="returnvalue">uuid</code>
       </p>
       <p>
        Returns a <span class="quote"><span class="quote">nil</span></span> UUID constant, which does not occur as a
        real UUID.
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">uuid_ns_dns</code> ()
        → <code class="returnvalue">uuid</code>
       </p>
       <p>
        Returns a constant designating the DNS namespace for UUIDs.
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">uuid_ns_url</code> ()
        → <code class="returnvalue">uuid</code>
       </p>
       <p>
        Returns a constant designating the URL namespace for UUIDs.
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">uuid_ns_oid</code> ()
        → <code class="returnvalue">uuid</code>
       </p>
       <p>
        Returns a constant designating the ISO object identifier (OID) namespace for
        UUIDs.  (This pertains to ASN.1 OIDs, which are unrelated to the OIDs
        used in <span class="productname">PostgreSQL</span>.)
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">uuid_ns_x500</code> ()
        → <code class="returnvalue">uuid</code>
       </p>
       <p>
        Returns a constant designating the X.500 distinguished name (DN)
        namespace for UUIDs.
       </p></td></tr></tbody></table></div></div><br class="table-break" /></div><div class="sect2" id="id-1.11.7.58.6"><div class="titlepage"><div><div><h3 class="title">F.49.2. Building <code class="filename">uuid-ossp</code></h3></div></div></div><p>
   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 <a class="ulink" href="http://www.ossp.org/pkg/lib/uuid/" target="_top">http://www.ossp.org/pkg/lib/uuid/</a>, it is not well
   maintained, and is becoming increasingly difficult to port to newer
   platforms.  <code class="filename">uuid-ossp</code> can now be built without the OSSP
   library on some platforms.  On FreeBSD and some other BSD-derived
   platforms, suitable UUID creation functions are included in the
   core <code class="filename">libc</code> library.  On Linux, macOS, and some other
   platforms, suitable functions are provided in the <code class="filename">libuuid</code>
   library, which originally came from the <code class="literal">e2fsprogs</code> project
   (though on modern Linux it is considered part
   of <code class="literal">util-linux-ng</code>).  When invoking <code class="filename">configure</code>,
   specify <code class="option">--with-uuid=bsd</code> to use the BSD functions,
   or <code class="option">--with-uuid=e2fs</code> to
   use <code class="literal">e2fsprogs</code>' <code class="filename">libuuid</code>, or
   <code class="option">--with-uuid=ossp</code> to use the OSSP UUID library.
   More than one of these libraries might be available on a particular
   machine, so <code class="filename">configure</code> does not automatically choose one.
  </p></div><div class="sect2" id="id-1.11.7.58.7"><div class="titlepage"><div><div><h3 class="title">F.49.3. Author</h3></div></div></div><p>
   Peter Eisentraut <code class="email">&lt;<a class="email" href="mailto:peter_e@gmx.net">peter_e@gmx.net</a>&gt;</code>
  </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="unaccent.html" title="F.48. unaccent">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="xml2.html" title="F.50. xml2">Next</a></td></tr><tr><td width="40%" align="left" valign="top">F.48. unaccent </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="40%" align="right" valign="top"> F.50. xml2</td></tr></table></div></body></html>