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

Baji Shaik <baji.pgdev@gmail.com>

From: Baji Shaik <baji.pgdev@gmail.com>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>, zsolt.parragi@percona.com, pgsql-hackers@lists.postgresql.org
Date: 2026-07-03T16:34:51Z
Lists: pgsql-hackers

Attachments

On Mon, Jun 29, 2026 at 6:18 PM Masahiko Sawada <sawada.mshk@gmail.com>
wrote:

> It does the range validation on the Unix-epoch value, after converting
> back from the shifted PostgreSQL-epoch timestamp. Can we compare
> pre-compute the Unix-epoch timestamp resentable window in
> PostgreSQL-epoch units against the shifted PostgreSQL-epoch timestamp
> before converting it back to the Unix epoch? That way, we don't need
> to worry about the overflow.
>
> Let's merge these two if statements as they use the same error message.
>

Thanks for the review. Attached v4 addressing your feedback:

- 0002 now pre-computes the valid timestamp range in PostgreSQL-epoch
 units (UUIDV7_MIN_TIMESTAMP / UUIDV7_MAX_TIMESTAMP) and validates
 the shifted TimestampTz directly, before converting to Unix epoch.
 This eliminates the overflow concern entirely.

- The pre-epoch and upper-bound checks are merged into a single if
statement.

0001 (infinite intervals) is unchanged from v3.

Thanks,
Baji Shaik

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. COPY TO FORMAT JSON: respect column list order