Commit 46f8aed
repr, expr: roll leap-second timestamps into the next minute
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>1 parent bb4a614 commit 46f8aed
3 files changed
Lines changed: 84 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
347 | 356 | | |
348 | | - | |
349 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
350 | 361 | | |
351 | 362 | | |
352 | 363 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
528 | | - | |
529 | | - | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
530 | 534 | | |
531 | 535 | | |
532 | 536 | | |
533 | 537 | | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
534 | 561 | | |
535 | 562 | | |
536 | 563 | | |
| |||
569 | 596 | | |
570 | 597 | | |
571 | 598 | | |
572 | | - | |
| 599 | + | |
| 600 | + | |
573 | 601 | | |
574 | 602 | | |
575 | 603 | | |
| |||
2236 | 2264 | | |
2237 | 2265 | | |
2238 | 2266 | | |
| 2267 | + | |
| 2268 | + | |
| 2269 | + | |
| 2270 | + | |
| 2271 | + | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
2239 | 2278 | | |
2240 | 2279 | | |
2241 | 2280 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
188 | 217 | | |
189 | 218 | | |
190 | 219 | | |
| |||
0 commit comments