Skip to content

Commit 652deb3

Browse files
committed
Mark the functions as "parallel safe"
Also, make the COMMENT use the full function signature.
1 parent a3f5a92 commit 652deb3

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

sql/uuidv7-sql--1.0.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ AS $$
1616
from 1 for 6),
1717
52, 1),
1818
53, 1), 'hex')::uuid;
19-
$$ LANGUAGE sql volatile;
19+
$$ LANGUAGE sql volatile parallel safe;
2020

21-
COMMENT ON FUNCTION uuidv7 IS
21+
COMMENT ON FUNCTION uuidv7(timestamptz) IS
2222
'Generate a uuid-v7 value with a 48-bit timestamp (millisecond precision) and 74 bits of randomness';
2323

2424

@@ -40,9 +40,9 @@ AS $$
4040
substring(uuid_send(gen_random_uuid()) from 9 for 8)
4141
, 'hex')::uuid
4242
from (select extract(epoch from $1)*1000 as t_ms) s
43-
$$ LANGUAGE sql volatile;
43+
$$ LANGUAGE sql volatile parallel safe;
4444

45-
COMMENT ON FUNCTION uuidv7_sub_ms IS
45+
COMMENT ON FUNCTION uuidv7_sub_ms(timestamptz) IS
4646
'Generate a uuid-v7 value with a 60-bit timestamp (sub-millisecond precision) and 62 bits of randomness';
4747

4848
/* Extract the timestamp in the first 6 bytes of the uuidv7 value.
@@ -54,7 +54,7 @@ AS $$
5454
select to_timestamp(
5555
right(substring(uuid_send($1) from 1 for 6)::text, -1)::bit(48)::int8 -- milliseconds
5656
/1000.0);
57-
$$ LANGUAGE sql immutable strict;
57+
$$ LANGUAGE sql immutable strict parallel safe;
5858

5959
COMMENT ON FUNCTION uuidv7_extract_timestamp(uuid) IS
6060
'Return the timestamp stored in the first 48 bits of the UUID v7 value';
@@ -68,7 +68,7 @@ AS $$
6868
placing substring(int8send(floor(extract(epoch from $1) * 1000)::bigint) from 3)
6969
from 1 for 6),
7070
'hex')::uuid;
71-
$$ LANGUAGE sql stable strict;
71+
$$ LANGUAGE sql stable strict parallel safe;
7272

7373
COMMENT ON FUNCTION uuidv7_boundary(timestamptz) IS
7474
'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

Comments
 (0)