Re: UUID v7
Masahiko Sawada <sawada.mshk@gmail.com>
From: Masahiko Sawada <sawada.mshk@gmail.com>
To: "Andrey M. Borodin" <x4mmm@yandex-team.ru>
Cc: Sergey Prokhorenko <sergeyprokhorenko@yahoo.com.au>, Jelte Fennema-Nio <postgres@jeltef.nl>, Michael Paquier <michael@paquier.xyz>, Aleksander Alekseev <aleksander@timescale.com>, pgsql-hackers mailing list <pgsql-hackers@postgresql.org>, Peter Eisentraut <peter@eisentraut.org>, Przemysław Sztoch <przemyslaw@sztoch.pl>, "David G. Johnston" <david.g.johnston@gmail.com>, Mat Arye <mat@timescaledb.com>, Matthias van de Meent <boekewurm+postgres@gmail.com>, Nikolay Samokhvalov <samokhvalov@gmail.com>, Junwang Zhao <zhjwpku@gmail.com>, Stepan Neretin <sncfmgg@gmail.com>
Date: 2024-11-19T19:06:35Z
Lists: pgsql-hackers
Attachments
- change_v33.patch (application/octet-stream) patch v33
On Tue, Nov 19, 2024 at 9:45 AM Andrey M. Borodin <x4mmm@yandex-team.ru> wrote: > > > > > On 19 Nov 2024, at 14:31, Andrey M. Borodin <x4mmm@yandex-team.ru> wrote: > > > > Done. > > Here's v33 intact + one more patch to add 2 bits of entropy on MacOS (to compensate lack of nanoseconds). > What do you think? > Thank you for updating the patch! I've reviewed the v33 patch and made some changes mostly for cosmetic things. Please review it to see if we accept these changes. I have one question about the additional patch: +#if defined(__darwin__) + /* + * On MacOS real time is truncted to microseconds. Thus, 2 least + * significant bits of increased_clock_precision are neither random + * (CSPRNG), nor time-dependent (in a sense - truly random). These 2 bits + * are dependent on other time-specific bits, thus they do not contribute + * to uniqueness. To make these bit random we mix in two bits from CSPRNG. + */ + uuid->data[7] = uuid->data[7] ^ (uuid->data[8] >> 6); +#endif I thought that the whole 12 bits in "rand_a" is actually time-dependent since we store 1/4096 fraction of sub-milliseconds. Am I missing something? Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com
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