Re: UUID v7
x4mmm@yandex-team.ru
From: "Andrey M. Borodin" <x4mmm@yandex-team.ru>
To: Przemysław Sztoch <przemyslaw@sztoch.pl>
Cc: Andrey Borodin <amborodin86@gmail.com>,
Jelte Fennema <postgres@jeltef.nl>,
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>,
PostgreSQL Hackers <pgsql-hackers@postgresql.org>,
"brad@peabody.io" <brad@peabody.io>,
"wolakk@gmail.com" <wolakk@gmail.com>,
sergeyprokhorenko@yahoo.com.au
Date: 2024-01-04T18:20:11Z
Lists: pgsql-hackers
Attachments
- v8-0001-Implement-UUID-v7-as-per-IETF-draft.patch (application/octet-stream) patch v8-0001
- v8-0002-Add-optional-argument-unix_ts_ms-to-gen_uuid_v7.patch (application/octet-stream) patch v8-0002
Hello Przemysław, thanks for your interest in this patch! > On 3 Jan 2024, at 04:37, Przemysław Sztoch <przemyslaw@sztoch.pl> wrote: > > 1. Is it possible to add a function that returns the version of the generated uuid? > It will be very useful. > I don't know if it's possible, but I think there are bits in the UUID that inform about the version. What do you think if we have functions get_uuid_v7_ver(uuid) and get_uuid_v7_var(uuid) to extract bit fields according to [0] ? Or, perhaps, this should be one function with two return parameters? It's not in a patch yet, I'm just considering how this functionality should look like. > 2. If there is any doubt about adding the function to the main sources (standard development in progress), in my opinion you can definitely add this function to the uuid-ossp extension. From my POV we can just have this function in the core. OSSP support for UUID seems more or less dead [1]: "Newsflash: 04-Jul-2008: Released OSSP uuid 1.6.2". Or do I look into wrong place? > 3. Wouldn't it be worth including UUID version 6 as well? The standard in [0] says "Systems that do not involve legacy UUIDv1 SHOULD use UUIDv7 Section 5.7 instead." If there's a point in developing v6 - I'm OK to do so. > 4. Sometimes you will need to generate a uuid for historical time. There should be an additional function gen_uuid_v7(timestamp). Done, please see patch attached. But I changed signature to gen_uuid_v7(int8), to avoid messing with bytes from user who knows what they want. Or do you think gen_uuid_v7(timestamp) would be more convenient? Thanks! Best regards, Andrey Borodin. [0] https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-14#uuidv7 [1] http://www.ossp.org/
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