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

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Baji Shaik <baji(dot)pgdev(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 19:23:08
Message-ID: CAD21AoBQQS0HqvCGwa-g3p5wC4MPUo-rHGKT6+MEnsY8uOMCJQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Thu, Jul 16, 2026 at 8:01 AM Baji Shaik <baji(dot)pgdev(at)gmail(dot)com> wrote:
>
> 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.

Thank you for reviewing the patch. Pushed.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zsolt Parragi 2026-07-16 19:50:57 Re: pg_hosts: Add pg_hosts_file_rules()
Previous Message Masahiko Sawada 2026-07-16 19:22:44 Re: Follow-up fixes for online wal_level change

Browse pgsql-bugs by date

  From Date Subject
Previous Message Tom Lane 2026-07-16 16:04:24 Re: CREATE INDEX with an expression in an INCLUDE column fails with XX000 "unrecognized node type" instead of 0A000 on master