You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sql/uuidv7-sql--1.0.sql
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -16,9 +16,9 @@ AS $$
16
16
from1 for 6),
17
17
52, 1),
18
18
53, 1), 'hex')::uuid;
19
-
$$ LANGUAGE sql volatile;
19
+
$$ LANGUAGE sql volatile parallel safe;
20
20
21
-
COMMENT ON FUNCTION uuidv7 IS
21
+
COMMENT ON FUNCTION uuidv7(timestamptz) IS
22
22
'Generate a uuid-v7 value with a 48-bit timestamp (millisecond precision) and 74 bits of randomness';
23
23
24
24
@@ -40,9 +40,9 @@ AS $$
40
40
substring(uuid_send(gen_random_uuid()) from9 for 8)
41
41
, 'hex')::uuid
42
42
from (select extract(epoch from $1)*1000as t_ms) s
43
-
$$ LANGUAGE sql volatile;
43
+
$$ LANGUAGE sql volatile parallel safe;
44
44
45
-
COMMENT ON FUNCTION uuidv7_sub_ms IS
45
+
COMMENT ON FUNCTION uuidv7_sub_ms(timestamptz) IS
46
46
'Generate a uuid-v7 value with a 60-bit timestamp (sub-millisecond precision) and 62 bits of randomness';
47
47
48
48
/* Extract the timestamp in the first 6 bytes of the uuidv7 value.
@@ -54,7 +54,7 @@ AS $$
54
54
select to_timestamp(
55
55
right(substring(uuid_send($1) from1 for 6)::text, -1)::bit(48)::int8 -- milliseconds
56
56
/1000.0);
57
-
$$ LANGUAGE sql immutable strict;
57
+
$$ LANGUAGE sql immutable strict parallel safe;
58
58
59
59
COMMENT ON FUNCTION uuidv7_extract_timestamp(uuid) IS
60
60
'Return the timestamp stored in the first 48 bits of the UUID v7 value';
@@ -68,7 +68,7 @@ AS $$
68
68
placing substring(int8send(floor(extract(epoch from $1) *1000)::bigint) from3)
69
69
from1 for 6),
70
70
'hex')::uuid;
71
-
$$ LANGUAGE sql stable strict;
71
+
$$ LANGUAGE sql stable strict parallel safe;
72
72
73
73
COMMENT ON FUNCTION uuidv7_boundary(timestamptz) IS
74
74
'Generate a non-random uuidv7 with the given timestamp (first 48 bits) and all random bits to 0. As the smallest possible uuidv7 for that timestamp, it may be used as a boundary for partitions.';
0 commit comments