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.