Repository navigation
fix temporal precision, prepared binding, and boundary semantics - #28316
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
There was a problem hiding this comment.
Deep re-review of exact head 08ff99b against current base fc621e3. REQUEST_CHANGES for three confirmed blockers (inline): the plan test package no longer compiles after the private binder signature change; the new mixed-version guard test fails on this tree because STR_TO_DATE overload 3 is locally valid; and the receiver-side guard added at this head still cannot protect an older CN, whose binary performs the unchecked slice access before this patch exists. A rolling-upgrade query with a dynamic two-argument STR_TO_DATE can therefore still fail on the old worker.
The earlier Decimal256 scale-26 double-rounding finding is closed: the current quotient/remainder implementation makes one half-up decision, and the focused plain/formatted boundary tests pass. I also rechecked the full 31-file PR diff, prepared-expression provenance, temporal type/width propagation, UNIX_TIMESTAMP NULL/invalid/pre-epoch paths, shared MICROSECOND bounds, AST serialization, CTAS metadata, optimizer boundary oracles, and the rebased delta. No additional lifecycle/concurrency blocker was found.
Independent exact-head evidence after make thirdparties and make -C cgo: pkg/sql/plan/function temporal tests pass; container/types and parser temporal tests pass; pkg/sql/plan fails to compile at mysql_special_types_test.go:241; TestGetFunctionByIdRejectsUnknownOverload fails because GetFunctionById returns nil error. The previous exact-head CI showed the same missing-argument compile failure in Ubuntu UT, coverage, and SCA; the newly pushed head's CI is still running.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 8fcef9b33e6ec38dc9a17fab17784ff154a0d824 against current base fc621e3616d229c7a29d0c80e73ed8eb1997459c, with the increment from my prior reviewed head 08ff99bb13e72570a1e6dd3a2dce10d6439830c1 checked separately and the complete diff rechecked. I read all four historical reviews and all four review threads, including their resolved/outdated state; there are no author replies in the threads and the only issue comment is the Qodo notice. The previous high-scale decimal rounding issue remains closed. Two of my three prior blockers are now closed: the unknown-overload test uses a genuinely invalid index and passes, and dynamic STR_TO_DATE/TO_DATE is lowered to legacy three-argument overload 0, so an old receiver no longer needs the removed overload 3. The remaining caller fix has its new argument in the wrong position, so pkg/sql/plan still does not compile. Exact-head reproduction after the required native setup: .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=10m -run 'Test(TemporalBindingUsesPrivatePreparedProvenance|FindInSetInternalArityIsPlannerOnly)$' ./pkg/sql/plan fails at mysql_special_types_test.go:241; the focused unknown-overload function test passes. Current-head Ubuntu UT, SCA, coverage, and CI Required checks report failure as well. The blocking correction is inline.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 508bbe9 against current base fc621e3. I read all historical reviews, every inline comment, the issue comment, and all five resolved review threads, then checked the increment from my prior reviewed head 8fcef9b separately and revalidated the complete-diff conclusions.
The sole increment is the one-line correction to the private binder test call: originalBoundExpr is now nil in the pointer slot and allowInternalFunctionArgs is true in the final boolean slot. This closes the remaining compile blocker. The earlier fixes remain intact: Decimal256 microseconds use one quotient/remainder rounding decision; the invalid-overload test is actually out of range; and dynamic STR_TO_DATE/TO_DATE is lowered to legacy overload 0 for older receivers.
Independent exact-head evidence after make thirdparties and make -C cgo: the focused pkg/sql/plan prepared-provenance and FIND_IN_SET tests pass, and the unknown-overload function test passes. git diff --check is clean. Exact-head shared build, SCA, coverage, and completed multi-CN BVT checks are green; Ubuntu UT is still in progress and skipped checks are not claimed as passes. I found no blocking issue.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Follow-up review completed at exact head 508bbe9. REQUEST_CHANGES: two confirmed boundary regressions remain.
Confirmed blockers
P2 — TIMESTAMP addition now aborts queries at the MICROSECOND calendar boundary.
Locations: pkg/container/types/datetime.go:559; consumer pkg/sql/plan/function/func_binary.go:1766, with callers at :2578 and :3017.
Counterexample:
SET time_zone = '+00:00';
CREATE TABLE temporal_boundary(ts TIMESTAMP(6));
INSERT INTO temporal_boundary VALUES ('9999-12-31 23:59:59.999999');
SELECT DATE_ADD(ts, INTERVAL 1 MICROSECOND) FROM temporal_boundary;
SELECT TIMESTAMPADD(MICROSECOND, 1, ts) FROM temporal_boundary;
The new primitive returns false before the existing consumers can produce their NULL-producing overflow sentinel. The callers instead propagate a generic out-of-range error, aborting the query rather than returning row-local NULL.
Fix: translate the primitive invalid-result status into the existing overflow sentinel. Add DATE_ADD and TIMESTAMPADD boundary matrices with ordinary/NULL neighbors, constants, columns, and prepared reuse.
P2 — String temporal addition turns lower-bound underflow into a non-NULL zero date.
Locations: pkg/container/types/datetime.go:549; consumer pkg/sql/plan/function/func_binary.go:1718-1731.
Counterexample:
SELECT DATE_ADD('0001-01-01 00:00:00', INTERVAL -2 MICROSECOND);
SELECT TIMESTAMPADD(MICROSECOND, -2, '0001-01-01 00:00:00');
The new primitive rejects the negative encoded result, but the string fallback recomputes Datetime(-2). Integer truncation makes its calendar conversion appear to be year 1, so it publishes ZeroDatetime without an error. Typed DATETIME follows a different path and returns NULL, so the existing typed boundary BVT does not catch this.
Fix: preserve the invalid-domain result and return the overflow sentinel; test string and typed inputs at -1, -2 microseconds, and the exact minimum.
Both blockers are source-confirmed; the SQL counterexamples were not executed against a live service. Prior Decimal256 rounding, legacy overload, and binder-argument findings were verified fixed.
Test evidence / unverified risks
Exact-head CI run 34450188620 passed Ubuntu UT, SCA, build, coverage, and active multi-CN BVT. Artifacts recorded FROM_UNIXTIME 72/72, STR_TO_DATE 115/115, optimizer datetime 18/18, and DATE_ADD 179 passed with 3 existing ignored. Compatibility and Darwin jobs were skipped.
Remaining gaps: DST transitions, scalar/vector boundary parity, binary prepared invalid-then-valid reuse, old persisted metadata, allocation-failure recovery, teardown repetition, mixed-version/downgrade/restore, fault injection, and benchmarks.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewed current head 3ab2c21 against main cd8e8d9, including the previous requested changes. No remaining concrete blocker found.
The previous high-scale FROM_UNIXTIME counterexample is addressed by one quotient/remainder rounding decision at microsecond precision, with carry normalized before the upper-bound check; the added scale-26 tests exercise both sides of the half boundary, including the maximum second. The previous binder-call compile issue and unknown-overload test are corrected. Dynamic STR_TO_DATE now uses the existing three-argument overload IDs rather than introducing the incompatible overload, while public three-argument calls are rejected and prepared rebinding retains the original typed marker.
I also checked temporal result scale/width propagation, row-local overflow NULL handling with valid neighboring rows, shared MICROSECOND calendar/overflow checks and window consumers, NULL handling, prepared-plan nonmutation, AST parse/format/parse and CTAS persistence coverage. The implementation adds no shared mutable execution state or new wire fields.
Non-blocking clarification: the PR body says non-NULL zero temporal input to UNIX_TIMESTAMP returns zero, but the implementation and explicit tests still retain NULL for ZeroTimestamp / '0000-00-00 00:00:00'. That is retained baseline behavior, not a new regression; please distinguish it from invalid-text and pre-epoch inputs in the summary.
Validation limits: this review is source/diff and regression-oracle analysis, not a new native build, live SQL/binary-protocol, mixed-version-cluster, or BVT execution. The owning-package and 1,963-check BVT results are author-reported evidence, not rerun results from this review. No CI waiting.
aunjgr
left a comment
There was a problem hiding this comment.
Re-reviewed exact head 3ab2c21 against cd8e8d9. Our earlier STR_TO_DATE wire-overload blocker is resolved: dynamic formats lower to the existing three-argument datetime overload, and prepared rebinding preserves the private typed marker without mutating the cached plan. Public callers still cannot supply that internal argument.
Reviewed the current 32-file change map and temporal production/test/BVT changes, including the intervening boundary fixes. Decimal FROM_UNIXTIME uses one quotient/remainder rounding decision, normalizes carry before the upper-bound check, and preserves declared scale through CTAS. MICROSECOND invalid-domain results now reach the row-local NULL sentinel for both timestamp and string callers. Ordinary/NULL neighbors, repeated prepared values, AST parse/format/parse and shared window/generate_series consumers are covered.
No remaining confirmed blocker. Reused current-head green CI and existing validation/review evidence; no new native build, live SQL, mixed-CN or BVT run. Nonblocking documentation correction: zero temporal UNIX_TIMESTAMP input still returns NULL in code/tests; invalid text and pre-epoch inputs return zero. Please distinguish these in the PR summary.
Merge Queue Status
This pull request spent 17 minutes 46 seconds in the queue, with no time running CI. Waiting for any of
All conditions
ReasonPull request #28316 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #28142 #28144 #28143 #28122 #28124 #28121 #28123
What this PR does / why we need it:
Temporal expressions now retain their value, precision, and public calling convention through binding, prepared execution, constant folding, and CTAS. In particular, decimal FROM_UNIXTIME stays on an exact decimal overload; a scale-3 input produces DATETIME(3), while higher precision rounds once to microseconds. Catalog precision and stored fractions agree.
Validation
make build-with-prebuilt-nativepassed.