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-RM5sNuGrufK7cMstQu=3BJrXxLzsMYp6GGiKBOBn2cE4g@mail.gmail.com
Whole thread
Responses Re: uuidv7 improperly accepts dates before 1970-01-01
List pgsql-hackers
On Mon, Jun 29, 2026 at 6:18 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
It does the range validation on the Unix-epoch value, after converting
back from the shifted PostgreSQL-epoch timestamp. Can we compare
pre-compute the Unix-epoch timestamp resentable window in
PostgreSQL-epoch units against the shifted PostgreSQL-epoch timestamp
before converting it back to the Unix epoch? That way, we don't need
to worry about the overflow.

Let's merge these two if statements as they use the same error message.

Thanks for the review. Attached v4 addressing your feedback:

- 0002 now pre-computes the valid timestamp range in PostgreSQL-epoch
 units (UUIDV7_MIN_TIMESTAMP / UUIDV7_MAX_TIMESTAMP) and validates
 the shifted TimestampTz directly, before converting to Unix epoch.
 This eliminates the overflow concern entirely.

- The pre-epoch and upper-bound checks are merged into a single if statement.

0001 (infinite intervals) is unchanged from v3.

Thanks,
Baji Shaik 
Attachment

pgsql-hackers by date:

Previous
From: Florin Irion
Date:
Subject: Re: [PATCH] pg_get_domain_ddl: DDL reconstruction function for CREATE DOMAIN statement
Next
From: Nisha Moond
Date:
Subject: Re: Support EXCEPT for TABLES IN SCHEMA publications