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

From: Baji Shaik <baji(dot)pgdev(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Zsolt Parragi <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-07-16 15:01:00
Message-ID: CA+fm-RMG8QU5sWuw62rhuz=32LRxPDYgLxbtBWCWRD1=ztRq1g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Tue, Jul 14, 2026 at 2:16 PM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2026-07-16 15:23:23 BUG #19554: No match for argument: postgresql18-server Error: Unable to find a match: postgresql18-server
Previous Message PG Bug reporting form 2026-07-16 14:12:34 BUG #19553: Wrong results from nested LEFT JOINs over an empty subquery (regression since v16)

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Rachitskiy 2026-07-16 15:03:00 Re: pg19b1: TRAP: failed Assert("pgstat_bktype_io_stats_valid(bktype_shstats, MyBackendType)")
Previous Message Tomas Vondra 2026-07-16 15:00:58 Re: WAL compression setting after PostgreSQL LZ4 default change