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-RMG8QU5sWuw62rhuz=32LRxPDYgLxbtBWCWRD1=ztRq1g@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
List pgsql-hackers
On Tue, Jul 14, 2026 at 2:16 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote:

I guess we don't need to name it with the prefix UUIDV7 as the offset
value is actually not limited to UUIDv7. How about renaming it to
PG_UNIX_EPOCH_OFFSET_US?

+-- uuidv7: a large but in-range forward shift is accepted
+SELECT uuid_extract_timestamp(uuidv7('1000 years'::interval)) > now()
+ '999 years'::interval;

I've merged two patches into one and made some cosmetic changes and
the above suggestions. I'm going to push it, barring objections.

Thanks for the review and the cleanup! v6 looks good to me.

The rename to PG_UNIX_EPOCH_OFFSET_US makes sense, and replacing
the 292230 years test with the in-range forward shift is a nice improvement.

No objections from my side.

Thanks,
Baji Shaik

pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: WAL compression setting after PostgreSQL LZ4 default change
Next
From: Andrey Rachitskiy
Date:
Subject: Re: pg19b1: TRAP: failed Assert("pgstat_bktype_io_stats_valid(bktype_shstats, MyBackendType)")