aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2024-03-19 09:30:24 +0100
committerPeter Eisentraut <peter@eisentraut.org>2024-03-19 09:32:04 +0100
commit794f10f6b920670cb9750b043a2b2587059d5051 (patch)
tree0615c2dddfc92ebb5d219d87f5c5f84830a4e365 /doc/src
parentd56cb42b54381d414f1f30929ca267e4768313c8 (diff)
downloadpostgresql-794f10f6b920670cb9750b043a2b2587059d5051.tar.gz
postgresql-794f10f6b920670cb9750b043a2b2587059d5051.zip
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
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/func.sgml30
1 files changed, 30 insertions, 0 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 3c52d90d3ab..5b225ccf4f5 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -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>
@@ -14142,6 +14150,28 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
</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
UUIDs.