mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Add some UUID support functions
Add uuid_extract_timestamp() and uuid_extract_version(). Author: Andrey Borodin Reviewed-by: Sergey Prokhorenko, Kirk Wolak, Przemysław Sztoch Reviewed-by: Nikolay Samokhvalov, Jelte Fennema-Nio, Aleksander Alekseev Reviewed-by: Peter Eisentraut, Chris Travers, Lukas Fittl Discussion: https://postgr.es/m/CAAhFRxitJv%3DyoGnXUgeLB_O%2BM7J2BJAmb5jqAT9gZ3bij3uLDA%40mail.gmail.com
This commit is contained in:
@ -14127,6 +14127,14 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
|
||||
<primary>gen_random_uuid</primary>
|
||||
</indexterm>
|
||||
|
||||
<indexterm>
|
||||
<primary>uuid_extract_timestamp</primary>
|
||||
</indexterm>
|
||||
|
||||
<indexterm>
|
||||
<primary>uuid_extract_version</primary>
|
||||
</indexterm>
|
||||
|
||||
<para>
|
||||
<productname>PostgreSQL</productname> includes one function to generate a UUID:
|
||||
<synopsis>
|
||||
@ -14141,6 +14149,28 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
|
||||
implement other standard algorithms for generating UUIDs.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
There are also functions to extract data from UUIDs:
|
||||
<synopsis>
|
||||
<function>uuid_extract_timestamp</function> (uuid) <returnvalue>timestamp with time zone</returnvalue>
|
||||
</synopsis>
|
||||
This function extracts a <type>timestamp with time zone</type> from UUID
|
||||
version 1. For other versions, this function returns null. Note that the
|
||||
extracted timestamp is not necessarily exactly equal to the time the UUID
|
||||
was generated; this depends on the implementation that generated the UUID.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<synopsis>
|
||||
<function>uuid_extract_version</function> (uuid) <returnvalue>smallint</returnvalue>
|
||||
</synopsis>
|
||||
This function extracts the version from a UUID of the variant described by
|
||||
<ulink url="https://tools.ietf.org/html/rfc4122">RFC 4122</ulink>. For
|
||||
other variants, this function returns null. For example, for a UUID
|
||||
generated by <function>gen_random_uuid</function>, this function will
|
||||
return 4.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<productname>PostgreSQL</productname> also provides the usual comparison
|
||||
operators shown in <xref linkend="functions-comparison-op-table"/> for
|
||||
|
Reference in New Issue
Block a user