BUG #19738: `uuidv7(interval)` rejects sub-millisecond timestamps within the final 48-bit millisecond

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: theshallow27(at)gmail(dot)com
Subject: BUG #19738: `uuidv7(interval)` rejects sub-millisecond timestamps within the final 48-bit millisecond
Date: 2026-10-02 22:36:49
Message-ID: 19738-659d03aaa312f3b8@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19738
Logged by: Shallow
Email address: theshallow27(at)gmail(dot)com
PostgreSQL version: 18.6
Operating system: Linux
Description:

UUIDv7 stores a 48-bit Unix-millisecond timestamp, and PostgreSQL's
documentation says its timestamp also includes sub-millisecond precision. A
shifted timestamp 250 microseconds into the final representable millisecond
is
rejected as out of range, although its millisecond field is still the
maximum
valid value.

**Reproduction:**

```sql
SELECT uuidv7(
(timestamptz '1970-01-01 UTC'
+ interval '281474976710655 milliseconds'
+ interval '250 microseconds')
- clock_timestamp()
);
```

**Actual result:** SQLSTATE `22008`, `timestamp out of range for UUID
version 7`.

**Expected result:** Generate a UUIDv7 whose 48-bit millisecond timestamp is
`2^48 - 1`, preserving the permitted sub-millisecond component.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2026-10-02 22:37:31 BUG #19739: Parameterized first autocommit statement can have different `transaction_timestamp()` and `statement
Previous Message PG Bug reporting form 2026-10-02 22:36:20 BUG #19737: Empty `JSON_OBJECT` cannot use documented `ON NULL` or unique-key clauses