repr, expr: roll leap-second timestamps into the next minute - #38107
Closed
def- wants to merge 1 commit into
Closed
Conversation
chrono represents a parsed :60 second as 59 with nanos >= 1e9, a value that sorts before the following second while the epoch family (extract epoch, casts to mz_timestamp, timestamp subtraction, date_bin, precision rounding) counts it at or past that second. That breaks the monotonicity contracts persist filter pushdown narrows ranges with: an interior leap value escapes the endpoint-derived range, so a part holding one could be wrongly discarded. Roll :60 over at the parse boundary, matching Postgres, so the leap representation never enters a timestamp. TIME keeps it: rolling a time over would wrap to 00:00:00 and reverse its ordering, and the whole-second leap time is provably harmless (fractional leap seconds are rejected at parse for all types). add_date_time is the other way a leap representation reached a timestamp. It passed a leap-second TIME's raw nanos straight through, so DATE + TIME '23:59:60' still constructed one and disagreed with the equivalent timestamp literal. It now rolls over the same way. Both rollovers can overflow chrono's range: TIMESTAMP '262142-12-31 23:59:60' parses, because that is chrono's max date and the leap value passes the HIGH_DATE check, and adding the rollover second overflows. Overflow reports out of range in the timestamp, timestamptz, and DATE + TIME paths instead of panicking. Closes: PER-63 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
chrono represents a parsed :60 second as 59 with nanos >= 1e9, a value
that sorts before the following second while the epoch family (extract
epoch, casts to mz_timestamp, timestamp subtraction, date_bin, precision
rounding) counts it at or past that second. That breaks the monotonicity
contracts persist filter pushdown narrows ranges with: an interior leap
value escapes the endpoint-derived range, so a part holding one could be
wrongly discarded. Roll :60 over at the parse boundary, matching Postgres,
so the leap representation never enters a timestamp. TIME keeps it:
rolling a time over would wrap to 00:00:00 and reverse its ordering, and
the whole-second leap time is provably harmless (fractional leap seconds
are rejected at parse for all types).
add_date_time is the other way a leap representation reached a timestamp.
It passed a leap-second TIME's raw nanos straight through, so DATE + TIME
'23:59:60' still constructed one and disagreed with the equivalent
timestamp literal. It now rolls over the same way.
Both rollovers can overflow chrono's range: TIMESTAMP '262142-12-31
23:59:60' parses, because that is chrono's max date and the leap value
passes the HIGH_DATE check, and adding the rollover second overflows.
Overflow reports out of range in the timestamp, timestamptz, and
DATE + TIME paths instead of panicking.
Closes: PER-63
Builds on top of #38076