Home Explore Blog CI



postgresql

1st chunk of `doc/src/sgml/uuid-ossp.sgml`
f469825efa22979ad2fe5c3b955d3607551ca3d4250c47ad0000000100000fa1
<!-- doc/src/sgml/uuid-ossp.sgml -->

<sect1 id="uuid-ossp" xreflabel="uuid-ossp">
 <title>uuid-ossp &mdash; a UUID generator</title>

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

 <para>
  The <filename>uuid-ossp</filename> 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 <productname>PostgreSQL</productname>.  See <xref
  linkend="functions-uuid"/> for built-in ways to generate UUIDs.
 </para>

 <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>

 <sect2 id="uuid-ossp-functions-sect">
  <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
   <ulink url="https://datatracker.ietf.org/doc/html/rfc4122">RFC 4122</ulink>
   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="1">
     <thead>
      <row>
       <entry role="func_table_entry"><para role="func_signature">
        Function
       </para>
       <para>
        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
        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 role="func_table_entry"><para role="func_signature">
        <indexterm><primary>uuid_generate_v1mc</primary></indexterm>
        <function>uuid_generate_v1mc</function> ()
        <returnvalue>uuid</returnvalue>
       </para>
       <para>
        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 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>
       </para>
       <para>
        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_*()</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.
       </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>

Title: uuid-ossp Module for UUID Generation in PostgreSQL
Summary
The `uuid-ossp` module in PostgreSQL provides functions for generating universally unique identifiers (UUIDs) using standard algorithms (versions 1, 3, 4, and 5). It also offers functions to generate special UUID constants. While core PostgreSQL offers built-in UUID generation, this module caters to more specific requirements. The module is trusted and can be installed by non-superusers with CREATE privilege.