Re: uuidv7 improperly accepts dates before 1970-01-01 - Mailing list pgsql-hackers

From Baji Shaik
Subject Re: uuidv7 improperly accepts dates before 1970-01-01
Date
Msg-id CA+fm-RN4eMEr2tzZU_mAV-=WfdmPXJ4Ea_GpmSS8=yStSy8onQ@mail.gmail.com
Whole thread
In response to Re: uuidv7 improperly accepts dates before 1970-01-01  (Masahiko Sawada <sawada.mshk@gmail.com>)
Responses Re: uuidv7 improperly accepts dates before 1970-01-01
Re: uuidv7 improperly accepts dates before 1970-01-01
Re: uuidv7 improperly accepts dates before 1970-01-01
Re: uuidv7 improperly accepts dates before 1970-01-01
List pgsql-hackers
On Thu, Jun 11, 2026 at 2:20 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
I think we should go ahead and add both upper and lower bound checks,
barring objections.

Thanks Masahiko. Here's a patch series that adds both boundary
checks along with the infinity check from my earlier patch:

  0001 - Reject timestamps before the Unix epoch (lower bound)
  0002 - Reject infinite intervals
  0003 - Reject timestamps beyond the 48-bit field limit (upper bound)

Christophe's original v1 covered the pre-epoch case; 0001 is
essentially the same fix with slightly different wording. I have
included it here so the series is self-contained and applies
cleanly on HEAD. Happy to drop it in favor of Christophe's
version if you prefer that.

The infinity check (0002) goes before the epoch conversion so
that uuidv7('infinity'::interval) gets a clear "infinite timestamps" 
message rather than falling through to the pre-epoch check 
with a confusing detail.

All three use ERRCODE_DATETIME_VALUE_OUT_OF_RANGE with errdetail.

Thanks, 
Baji Shaik.
Attachment

pgsql-hackers by date:

Previous
From: Zsolt Parragi
Date:
Subject: Re: [PATCH] Fix PITR pause bypass when initial XLOG_RUNNING_XACTS has subxid overflow
Next
From: Andrew Dunstan
Date:
Subject: Re: BackgroundPsql swallowing errors on windows