agora inbox for pgsql-bugs@postgresql.org
help / color / mirror / Atom feedFrom: Andrey Borodin <x4mmm@yandex-team.ru>
To: Christophe Pettus <xof@thebuild.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: uuidv7 improperly accepts dates before 1970-01-01
Date: Sat, 25 Apr 2026 17:26:51 +0500
Message-ID: <966B5430-8ECD-48FA-B56F-22452D9CDBBF@yandex-team.ru> (raw)
In-Reply-To: <799A70FA-6E5C-4118-99EB-2FBBE1CBAC54@thebuild.com>
References: <799A70FA-6E5C-4118-99EB-2FBBE1CBAC54@thebuild.com>
> On 25 Apr 2026, at 05:19, Christophe Pettus <xof@thebuild.com> wrote:
>
> "Don't do that" is one answer, but for good hygiene, here's a patch that adds a < 0 check and a regression test.
Hi Christophe!
We intentionally left ability to overflow unix_ts_ms bits. In some cases one might want to
intentionally break time locality by using construction like SELECT uuidv7(INTERVAL '1000 years' * shard_id);
This will give time locality for UUIDs generated on each shard. We consulted with RFC authors
about this feature, and they confirmed that shifting time is compliant with RFC wording.
We wrote the specific test that ensures vast space for shift, but not unlimited.
Time shifting would become a footgun if we throw an exception when overflown.
If you use SELECT uuidv7(INTERVAL '-1000 years'); for generating identifiers, they will still be unique and
time-local, and more over - they will be ascending for a single backend. So no documented guarantees
are broken.
Thank you!
Best regards, Andrey Borodin.
view thread (23+ messages) latest in thread
Message-ID: <966B5430-8ECD-48FA-B56F-22452D9CDBBF@yandex-team.ru>
Permalink: ../../966B5430-8ECD-48FA-B56F-22452D9CDBBF@yandex-team.ru/
Also on: postgresql.org/message-id/966B5430-8ECD-48FA-B56F-22452D9CDBBF@yandex-team.ru
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: x4mmm@yandex-team.ru, xof@thebuild.com, pgsql-bugs@lists.postgresql.org
Subject: Re: uuidv7 improperly accepts dates before 1970-01-01
In-Reply-To: <966B5430-8ECD-48FA-B56F-22452D9CDBBF@yandex-team.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox