Re: UUID v7
Jelte Fennema-Nio <postgres@jeltef.nl>
From: Jelte Fennema-Nio <postgres@jeltef.nl>
To: "Andrey M. Borodin" <x4mmm@yandex-team.ru>
Cc: Sergey Prokhorenko <sergeyprokhorenko@yahoo.com.au>, Aleksander Alekseev <aleksander@timescale.com>, pgsql-hackers mailing list <pgsql-hackers@postgresql.org>, Przemysław Sztoch <przemyslaw@sztoch.pl>, Nick Babadzhanian <pgnickb@gmail.com>, Mat Arye <mat@timescaledb.com>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>, Tom Lane <tgl@sss.pgh.pa.us>, Daniel Gustafsson <daniel@yesql.se>, Matthias van de Meent <boekewurm+postgres@gmail.com>, Nikolay Samokhvalov <samokhvalov@gmail.com>, "Kyzer Davis (kydavis)" <kydavis@cisco.com>, Andres Freund <andres@anarazel.de>, "brad@peabody.io" <brad@peabody.io>, Kirk Wolak <wolakk@gmail.com>
Date: 2024-01-16T20:25:58Z
Lists: pgsql-hackers
On Tue, 16 Jan 2024 at 19:17, Andrey M. Borodin <x4mmm@yandex-team.ru> wrote: > Jelte, what is your opinion on naming the function which extracts timestamp from UUID v7? I looked at a few more datatypes: json, jsonb & hstore. The get_ prefix is not used there at all, so I'm still opposed to that. But they seem to use either an _to_ or an _extract_ infix. _to_ is then used for conversion of the whole object, and _extract_ is used to extract a subset. So I think _extract_ would fit well here. On Fri, 5 Jan 2024 at 11:57, Sergey Prokhorenko <sergeyprokhorenko@yahoo.com.au> wrote: > When naming functions, I would advise using the shorter abbreviation uuidv7 from the new version of the RFC instead of uuid_v7. I also agree with that, uuid_v7 looks weird to my eyes. The RFC also abbreviates them as UUIDv7 (without a space). The more I look at it the more I also think the gen_ prefix is quite strange, and I already thought the gen_random_uuid name was quite weird. But now that we will also have a uuidv7 I think it's even stranger that one uses the name from the RFC. The name of gen_random_uuid was taken verbatim from pgcrypto, without any discussion on the list[0]: > Here is a proposed patch for this. I did a fair bit of looking around > in other systems for a naming pattern but didn't find anything > consistent. So I ended up just taking the function name and code from > pgcrypto. So currently my preference for the function names would be: - uuidv4() -> alias for gen_random_uuid() - uuidv7() - uuidv7(timestamptz) - uuid_extract_ver(uuid) - uuid_extract_var(uuid) - uuidv7_extract_time(uuid) [0]: https://www.postgresql.org/message-id/flat/6a65610c-46fc-2323-6b78-e8086340a325%402ndquadrant.com#76e40e950a44aa8b6844297e8d2efe2c
Commits
-
Fix timestamp overflow in UUIDv7 implementation.
- a5419bc72e22 18.0 landed
-
Add UUID version 7 generation function.
- 78c5e141e9c1 18.0 landed
-
Add some UUID support functions
- 794f10f6b920 17.0 landed