postgresql/src/backend/utils
Masahiko Sawada a5419bc72e Fix timestamp overflow in UUIDv7 implementation.
The uuidv7_interval() function previously converted a shifted
microsecond-precision timestamp (64-bit integer) to another 64-bit
integer representing a timestamp with nanosecond precision. This
conversion caused overflow for dates beyond the year 2262. The
millisecond and sub-millisecond parts were then extracted from this
nanosecond-precision timestamp and stored in UUIDv7 values.

With this commit, the millisecond and sub-millisecond parts are stored
directly into the UUIDv7 value without being converted back to a
nanosecond precision timestamp. Following RFC 9562, the timestamp is
stored as an unsigned integer, enabling support for dates up to the
year 10889.

Reported and fixed by Andrey Borodin, with cosmetic changes and
regression tests by me.

Reported-by: Andrey Borodin <x4mmm@yandex-team.ru>
Author: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/96DEC2D9-659A-40E8-B7BA-AF5D162A9E21@yandex-team.ru
2025-03-28 09:39:11 -07:00
..
activity aio: Add io_method=io_uring 2025-03-26 19:49:13 -04:00
adt Fix timestamp overflow in UUIDv7 implementation. 2025-03-28 09:39:11 -07:00
cache Add some opfamily support functions to lsyscache.c 2025-03-18 11:17:43 +01:00
error Fix guc_malloc calls for consistency and OOM checks 2025-03-27 22:57:34 +01:00
fmgr Introduce PG_MODULE_MAGIC_EXT macro. 2025-03-26 11:06:12 -04:00
hash pg_noreturn to replace pg_attribute_noreturn() 2025-03-13 12:37:26 +01:00
init aio: Infrastructure for io_method=worker 2025-03-18 11:54:01 -04:00
mb Use PG_MODULE_MAGIC_EXT in our installable shared libraries. 2025-03-26 11:11:02 -04:00
misc Fix guc_malloc calls for consistency and OOM checks 2025-03-27 22:57:34 +01:00
mmgr pg_noreturn to replace pg_attribute_noreturn() 2025-03-13 12:37:26 +01:00
resowner aio: Basic subsystem initialization 2025-03-17 18:51:33 -04:00
sort Add ExecCopySlotMinimalTupleExtra(). 2025-03-24 22:05:53 -07:00
time Improve snapmgr.c comment 2025-03-11 23:28:38 +02:00
.gitignore Rearrange makefile rules for running Gen_fmgrtab.pl. 2018-05-03 17:54:18 -04:00
errcodes.txt Update copyright for 2025 2025-01-01 11:21:55 -05:00
Gen_dummy_probes.pl Update copyright for 2025 2025-01-01 11:21:55 -05:00
Gen_fmgrtab.pl Update copyright for 2025 2025-01-01 11:21:55 -05:00
generate-errcodes.pl Update copyright for 2025 2025-01-01 11:21:55 -05:00
Makefile Update copyright for 2025 2025-01-01 11:21:55 -05:00
meson.build Update copyright for 2025 2025-01-01 11:21:55 -05:00
postprocess_dtrace.sed Update copyright for 2025 2025-01-01 11:21:55 -05:00
probes.d Update copyright for 2025 2025-01-01 11:21:55 -05:00