forked from fboulnois/pg_uuidv7
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for more time precision per latest RFC spec.
- Loading branch information
Showing
5 changed files
with
36 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION | ||
\echo Use '''CREATE EXTENSION "pg_uuidv7"''' to load this file. \quit | ||
|
||
-- 48 bits for ms since unix epoch (rollover in 10899), 74 bits of randomness | ||
CREATE FUNCTION uuid_generate_v7(extra_ts_precision int = 0) | ||
RETURNS uuid | ||
AS 'MODULE_PATHNAME', 'uuid_generate_v7' | ||
VOLATILE STRICT LANGUAGE C PARALLEL SAFE; | ||
|
||
-- extract the timestamp from a v7 uuid | ||
CREATE FUNCTION uuid_v7_to_timestamptz(uuid) | ||
RETURNS timestamptz | ||
AS 'MODULE_PATHNAME', 'uuid_v7_to_timestamptz' | ||
VOLATILE STRICT LANGUAGE C PARALLEL SAFE; | ||
|
||
-- create a v7 uuid from a timestamp | ||
CREATE FUNCTION uuid_timestamptz_to_v7(timestamptz, zero bool = false) | ||
RETURNS uuid | ||
AS 'MODULE_PATHNAME', 'uuid_timestamptz_to_v7' | ||
VOLATILE STRICT LANGUAGE C PARALLEL SAFE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
comment = 'pg_uuidv7: create UUIDv7 values in postgres' | ||
default_version = '1.2' | ||
default_version = '1.3' | ||
module_pathname = '$libdir/pg_uuidv7' | ||
relocatable = true |