Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
<!-- doc/src/sgml/uuid-ossp.sgml -->

<sect1 id="uuid-ossp" xreflabel="uuid-ossp">
 <title>uuid-ossp</title>

 <indexterm zone="uuid-ossp">
  <primary>uuid-ossp</primary>
 </indexterm>

 <para>
  The <filename>uuid-ossp</> 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.
 </para>

 <sect2>
  <title><literal>uuid-ossp</literal> Functions</title>

  <para>
   <xref linkend="uuid-ossp-functions"> shows the functions available to
   generate UUIDs.
   The relevant standards ITU-T Rec. X.667, ISO/IEC 9834-8:2005, and RFC
   4122 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.
  </para>

  <table id="uuid-ossp-functions">
   <title>Functions for UUID Generation</title>
   <tgroup cols="2">
    <thead>
     <row>
      <entry>Function</entry>
      <entry>Description</entry>
     </row>
    </thead>
    <tbody>
     <row>
      <entry><function>uuid_generate_v1()</function><indexterm><primary>uuid_generate_v1</primary></indexterm></entry>
      <entry>
       <para>
        This function 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.
       </para>
      </entry>
     </row>
     <row>
      <entry><function>uuid_generate_v1mc()</function><indexterm><primary>uuid_generate_v1mc</primary></indexterm></entry>
      <entry>
       <para>
        This function generates a version 1 UUID but uses a random multicast
        MAC address instead of the real MAC address of the computer.
       </para>
      </entry>
     </row>
     <row>
      <entry><function>uuid_generate_v3(namespace uuid, name text)</function><indexterm><primary>uuid_generate_v3</primary></indexterm></entry>
      <entry>
       <para>
        This function 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 <function>uuid_ns_*()</> functions shown
        in <xref linkend="uuid-ossp-constants">.  (It could be any UUID in theory.)  The name is an identifier
        in the selected namespace.
       </para>

       <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.
       </para>
      </entry>
     </row>
     <row>
      <entry><literal>uuid_generate_v4()</literal></entry>
      <entry>
       <para>
        This function generates a version 4 UUID, which is derived entirely
        from random numbers.
       </para>
      </entry>
     </row>
     <row>
      <entry><literal>uuid_generate_v5(namespace uuid, name text)</literal></entry>
      <entry>
       <para>
        This function 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.
       </para>
      </entry>
     </row>
    </tbody>
   </tgroup>
  </table>

  <table id="uuid-ossp-constants">
   <title>Functions Returning UUID Constants</title>
   <tgroup cols="2">
    <tbody>
     <row>
      <entry><literal>uuid_nil()</literal></entry>
      <entry>
       <para>
        A <quote>nil</> UUID constant, which does not occur as a real UUID.
       </para>
      </entry>
     </row>
     <row>
      <entry><literal>uuid_ns_dns()</literal></entry>
      <entry>
       <para>
        Constant designating the DNS namespace for UUIDs.
       </para>
      </entry>
     </row>
     <row>
      <entry><literal>uuid_ns_url()</literal></entry>
      <entry>
       <para>
        Constant designating the URL namespace for UUIDs.
       </para>
      </entry>
     </row>
     <row>
      <entry><literal>uuid_ns_oid()</literal></entry>
      <entry>
       <para>
        Constant designating the ISO object identifier (OID) namespace for
        UUIDs.  (This pertains to ASN.1 OIDs, which are unrelated to the OIDs
        used in <productname>PostgreSQL</>.)
       </para>
      </entry>
     </row>
     <row>
      <entry><literal>uuid_ns_x500()</literal></entry>
      <entry>
       <para>
        Constant designating the X.500 distinguished name (DN) namespace for
        UUIDs.
       </para>
      </entry>
     </row>
    </tbody>
   </tgroup>
  </table>
 </sect2>

 <sect2>
  <title>Building <filename>uuid-ossp</></title>

  <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
   platforms.  <filename>uuid-ossp</> can now be built without the OSSP
   library on some platforms.  On FreeBSD, NetBSD, and some other BSD-derived
   platforms, suitable UUID creation functions are included in the
   core <filename>libc</> library.  On Linux, OS X, and some other
   platforms, suitable functions are provided in the <filename>libuuid</>
   library, which originally came from the <literal>e2fsprogs</> project
   (though on modern Linux it is considered part
   of <literal>util-linux-ng</>).  When invoking <filename>configure</>,
   specify <option>--with-uuid=bsd</option> to use the BSD functions,
   or <option>--with-uuid=e2fs</option> to
   use <literal>e2fsprogs</>' <filename>libuuid</>, or
   <option>--with-uuid=ossp</option> to use the OSSP UUID library.
   More than one of these libraries might be available on a particular
   machine, so <filename>configure</> does not automatically choose one.
  </para>

  <note>
   <para>
    If you only need randomly-generated (version 4) UUIDs,
    consider using the <function>gen_random_uuid()</> function
    from the <xref linkend="pgcrypto"> module instead.
   </para>
  </note>
 </sect2>

 <sect2>
  <title>Author</title>

  <para>
   Peter Eisentraut <email>peter_e@gmx.net</email>
  </para>

 </sect2>

</sect1>