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

From: Baji Shaik <baji(dot)pgdev(at)gmail(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: zsolt(dot)parragi(at)percona(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: uuidv7 improperly accepts dates before 1970-01-01
Date: 2026-06-25 13:47:27
Message-ID: CA+fm-RN9UgAG2ew7T0Gum8RtZ4ZbyYvOLyyqAiuTWhsGEn3_zw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Wed, Jun 24, 2026 at 9:19 PM Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
wrote:

> From a user's perspective, it seems sufficient to know that the
> shifted timestamp falls outside the range supported by UUID v7. As a
> translator, I'm not particularly enthusiastic about adding more
> message variants when the distinction is not particularly useful to
> users.
>

Thanks for the feedback, Kyotaro. Good point. Attached v3 with all boundary
checks
using a single shared errdetail:

"UUID version 7 supports timestamps from 1970-01-01 to approximately year
10889."

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

I prefer keeping them as 3 patches since each addresses a distinct
failure mode and is easier to review/bisect independently. That said,
since 0002 and 0003 now share the same errdetail and are logically
the same validation (timestamp outside valid range), I'm happy to
merge them into one patch for v4 if preferred.

Thanks,
Baji Shaik.

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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2026-06-25 13:53:25 Re: BUG #19483: pg_upgrade fails with orphan records in pg_init_priv catalog table
Previous Message Sebastiaan Mannem 2026-06-25 13:43:32 Re: Out-of-Cycle release? (was Re: BUG #19490: Streaming standby on 16.14 stops applying WAL on MultiXactOffsetSLRU when primary is 16.8)

Browse pgsql-hackers by date

  From Date Subject
Next Message Nitin Jadhav 2026-06-25 13:48:01 Re: [PATCH] Fix minRecoveryPoint not advanced past checkpoint in CreateRestartPoint
Previous Message Dilip Kumar 2026-06-25 13:45:02 Re: Proposal: Conflict log history table for Logical Replication