Re: uuidv7 improperly accepts dates before 1970-01-01

From: Baji Shaik <baji(dot)pgdev(at)gmail(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: uuidv7 improperly accepts dates before 1970-01-01
Date: 2026-06-24 23:22:20
Message-ID: CA+fm-RPjp8fC-w50PApyhrfMqY4SA0zT5s1Nq=+03+ALcf+3+A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Thank you Masahiko, Tristan, Christophe, and Zsolt for the reviews and
feedback. Addressing the feedback in a single email.

Attached v2 addressing the feedback:

- Moved infinity check before timestamp arithmetic [Masahiko]
- Used INT64CONST() for the 48-bit constant [Masahiko]
- Added documentation for the valid timestamp range [Masahiko, Christophe]
- Added a test for '292230 years' to cover the overflow path
caught by pg_add_s64_overflow() [Zsolt Parragi]

0001 - Reject infinite intervals
0002 - Reject pre-epoch timestamps (with overflow-safe epoch conversion)
0003 - Reject timestamps beyond the 48-bit limit

Let me know if I have missed anything.

Thanks,
Baji Shaik.

Attachment Content-Type Size
v2-0001-Reject-infinite-intervals-in-uuidv7-interval.patch application/octet-stream 3.3 KB
v2-0003-Reject-timestamps-beyond-48-bit-limit-in-uuidv7-i.patch application/octet-stream 3.1 KB
v2-0002-Reject-pre-epoch-timestamps-in-uuidv7-interval.patch application/octet-stream 5.1 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Langote 2026-06-24 23:24:08 Re: BUG #19484: Segmentation fault triggered by FDW
Previous Message Jacob Champion 2026-06-24 21:57:13 REVOKE's CASCADE protection doesn't work with INHERITed table owners

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2026-06-24 23:29:22 Re: Support UUIDv6 in uuid_extract_timestamp()
Previous Message Masahiko Sawada 2026-06-24 23:07:06 Re: Report bytes and transactions actually sent downtream