Repository navigation
fix remaining date/time compatibility issues - #28932
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? |
aptend
left a comment
There was a problem hiding this comment.
Deep review of exact head a120d94 against base b9013dc. This is the first review: there are no prior reviews, inline threads, or author replies. I checked the full 44-file diff, temporal parsing/casts/arithmetic and metadata, JSON aggregate and update paths, and exact-head CI (all checks complete without failures). One correctness blocker remains:
[P1] pkg/sql/plan/function/temporal_locale.go:60-72 reads lc_time_names only via proc.GetResolveVariableFunc and silently falls back to en_US when that resolver is absent. Remote CN processes have no session-variable resolver, as pkg/vm/process/types.go:133-137 and process_codec_test.go explicitly note. The pipeline SessionInfo built in pkg/vm/process/process_codec.go:165-181 carries timezone and sql_mode but no lc_time_names; decoding at :480-500 cannot restore it. Therefore after SET lc_time_names='fr_FR', a table scan/projection evaluated on the initiating CN returns DAYNAME(d)='dimanche' or DATE_FORMAT(d,'%M')='décembre', while the same expression evaluated in a remote CN pipeline returns 'Sunday' or 'December'. The result depends on placement and can be persisted incorrectly by CTAS/INSERT SELECT. This PR specifically adds locale-sensitive execution in func_unary.go:11049-11150 and func_binary.go:4940, so this is a newly introduced cross-CN contract gap, not merely a missing test. Carry the effective locale in the process/session wire snapshot and use it when no resolver is present; add a two-CN regression using a non-English locale and table data. Current unit tests install a local resolver and do not exercise the remote path.
Non-blocking hygiene: git diff --check reports trailing whitespace in two changed func_uuid_versions.result rows.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 8840e8c against base b9013dc: APPROVE. I read the sole prior review and PR discussion (there are no inline threads or author replies), revisited the full 51-file change map, and checked both commits since the prior reviewed head a120d94.
The previously blocking cross-CN locale mismatch is closed: BuildProcessInfo now captures effective lc_time_names into pipeline.SessionInfo field 22, ConvertToProcessSessionInfo restores it, a forwarded process retains it, and temporalLocaleForProcess uses that snapshot when a remote CN has no session-variable resolver. The new codec and locale tests exercise these boundaries; the DAYNAME/DATE_FORMAT BVT adds a non-English table-data case. The final whitespace-only commit also closes the prior diff-check issue. I found no remaining verified blocker in the reviewed code.
Local exact-head validation: make thirdparties and make -C cgo; focused process codec, temporal locale/date-time function, and container/types tests passed; git diff --check passed. Current-head GitHub checks show 10 passes, 1 pending, 16 skips, so this is not a claim that all CI or mixed-version behavior has completed.
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed 0f34e1e. The previously reviewed production head 8840e8c is unchanged; the sole later commit adjusts two empty metadata fields in the UUID BVT result. I checked that delta and reused the prior full-contract review for the unchanged temporal/planner implementation. Exact-head CI is green and I found no new blocker.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of 0f34e1e against merge-base/base b9013dc. REQUEST_CHANGES. Reviewed the 51-file change map and the prior reviews, without subagents. The earlier same-version remote-locale finding is addressed by SessionInfo field 22, codec capture/restore and fallback; this does not close the independent compatibility/assignment findings below.
Design: sharing the process clock, session snapshot and existing JSON conversion owner is the right direction. The implementation is not yet a systemic closure: it overwrites a persisted function execution identity while leaving ordinary SQL on the old result domain, and uses expression copying / AST NULL special cases where evaluated assignment values and assignment policy should own the behavior. These are observable correctness problems, not a preference for additional abstraction. Ordinary bug-fix work does not need a new state machine or an RFC to address them.
QA/evidence: exact-head CI Required, Linux UT/SCA, compose/proxy BVT are successful; upgrade jobs are skipped. Existing author evidence covers focused temporal/plan tests and full types/process/aggexec, but the function package run was incomplete. I attempted the repository CGo wrapper with TestSpecialIntegerLegacyExecutionIdentities in an isolated exact-head worktree; it stopped before compilation because native artifacts were absent and primary-worktree reuse was rejected due to differing native inputs. No new local runtime pass is claimed. The inline findings are source-traced counterexamples, not claims that I executed their SQL locally. The current legacy identity test was changed to the new type/value, so its success no longer demonstrates compatibility with the original serialized expression.
Implementation/test/docs reviewed separately: no design document is changed. Direct MakeDate helper tests bypass the ordinary SQL binding that must be fixed; replacing the no-argument UNIX_TIMESTAMP expectation validates the implementation instead of the external oracle. Please add focused public-path controls for the findings, with stable metadata/value/diagnostic assertions rather than more redundant helper cases.
Performance/unhappy paths: ON UPDATE duplicates potentially expensive and volatile assignments per automatic column (see finding), and predicates are built even for tables without automatic columns. Locale resolution currently repeats per row/directive; consider resolving once per vector invocation. The old MakeDateString production entry is now unused, and JSON's private legacy temporal branches are retained largely for old direct tests; remove only genuinely superseded paths while preserving real persisted identities. The DST search has a finite transition bound; no new goroutine, lock wait, queue, or resource ownership transfer was introduced. I found no separate new lifecycle blocker in the JSON/timezone additions. Two UUID golden metadata rows still trigger diff --check trailing-whitespace diagnostics; these empty-field separators are not a merge blocker by themselves.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head dc2241a against base/merge-base 76862df. REQUEST_CHANGES. No subagents. Reviewed every changed hunk, the 17 claimed issue contracts, all prior reviews and all seven inline threads. Data/persisted-expression compatibility is in scope; mixed-version rolling upgrades are deliberately excluded.
The direction is sensible: use the existing process clock/session snapshot, preserve temporal type/FSP through the existing type join, share scalar JSON conversion, and preserve old persisted MAKEDATE execution identities while routing new SQL through the canonical integer-coercion owner. The remaining implementation is not a systemic closure: copied UPDATE expressions are used in place of evaluated assignment values, AST NULL-to-DEFAULT substitutions stand in for assignment policy, and new temporal loops/preprocessing bypass established precision, domain and diagnostic rules. The five inline findings below have concrete exact-head counterexamples, not just design preferences.
Prior-comment closure (all seven threads are marked resolved on GitHub, but two contracts remain open):
| Previous finding | Current assessment |
|---|---|
| Persisted MAKEDATE identity / new SQL DATE domain | Addressed: overloads 0/1 keep VARCHAR contracts, new SQL binds overload 2 through canonical integer conversion. Unchanged legacy serialized execution, public binding/folding, prepared reuse and persisted generated/check/default controls passed locally. |
| UPDATE RHS executed repeatedly | Still open: a public SQL-bound plan contains three RAND trees for one assignment; the sequential-assignment control contains one. |
| No-argument UNIX_TIMESTAMP must be integer seconds | Addressed; frozen fractional process-clock test returns integer 1704067200. |
| First TIMESTAMP selection / explicit ON UPDATE exclusion | The requested selection/exclusion changes are present in the DDL owner; this does not close the separate NULL-assignment contract. |
| Legacy TIMESTAMP NULL assignment | Still open: ordinary single-assignment UPDATE rejects NULL; INSERT and sequential UPDATE substitute a constant DEFAULT rather than current time. |
| Seventh fractional digit rounded before truncation | The destructive intermediate rounding has been addressed, but the new preprocessing introduces an independent grammar/IGNORE regression below. |
| DST-gap rejection versus IGNORE | Addressed for the tested matrix: VARCHAR and typed DATETIME sources × strict ordinary / strict IGNORE / non-strict assignment all passed with a real statement-runtime profile. |
The earlier same-version remote locale issue is also addressed by pipeline field 22, capture/restore/forwarding and the resolver-free snapshot fallback; process codec and locale tests passed.
Evidence and limits:
- Built native dependencies in an isolated exact-head worktree with make -j8 cgo; ran tests with the repository mo-cgo-test wrapper, Go 1.26.4 on darwin/arm64. No production edits or service SQL execution are claimed.
- Full local owning packages passed: pkg/container/types (1.724s), pkg/vm/process (1.664s), pkg/sql/colexec/aggexec (2.081s).
- Existing focused planner/function tests passed, including temporal arithmetic metadata, mixed numeric changed-row casting, MAKEDATE legacy/public/prepared/persisted paths, temporal truncation across sources, locale fallback and integer UNIX_TIMESTAMP.
- Independent planner probes compiled public SQL and inspected assignment dependencies. Independent runtime vector probes failed for TIMESTAMP ADDTIME/SUBTIME fraction/range controls, DATETIME-result interval arithmetic below the TIMESTAMP lower bound, and truncation-enabled IGNORE/valid-whitespace controls. Adjacent DATETIME, truncation-off, explicit CURRENT_TIMESTAMP and sequential UPDATE controls passed.
- Exact-head CI run 36679314943 is successful, including Linux UT/SCA, compose/proxy BVT and CI Required. That does not cover or invalidate the counterexamples.
- diff --check reports only two UUID golden rows containing trailing empty metadata fields; these separators are not a blocker.
Implementation, tests and docs were assessed separately: 52 changed files; handwritten production/proto +1476/-132, tests/goldens +616/-26, generated protobuf +132/-77; no documentation change. Ordinary focused bug fixes do not need an additional state machine or an RFC. The added unregistered MakeDate/makeDateRoundedInteger implementation is now called only by direct tests, duplicates canonical integer coercion, and should be removed along with tests that validate only that unused route. Keep genuinely required old serialized identities, not dead alternate implementations. New timestamp arithmetic loops should reuse the existing DATETIME arithmetic/parser/mask/error owner rather than maintaining a parallel reduced contract. Tests should assert public results/metadata/evaluation counts and policy contrasts; the current mostly scale-6 happy-path fixtures miss these boundaries.
Performance/unhappy paths: repeated UPDATE RHS evaluation is both a correctness bug and repeated per-row work. Locale lookup/copy currently repeats per row/format directive, and JSON temporal preflight/append performs conversion twice; hoist/reuse where ownership permits and measure representative vector workloads before claiming improvement. No benchmark speedup is claimed. JSON growth/admission/spill remain under the existing aggregate owner, and its lifecycle/spill/preflight tests passed. No new goroutine, queue or lock protocol is introduced; no additional verified lifecycle blocker was found.
Co-authored-by: jiangxinmeng1 <[email protected]>
Share normalized update assignment producers, invalidate session-dependent prepared plans through existing cache ownership, and apply exact numeric fraction truncation before parsing. Normalize legacy TIMESTAMP declarations independently of automatic-column position, preserve persisted defaults, and match promotion validation to accepted settings. Cover joined and sequential updates, prepared reuse/retry, numeric and masked casts, legacy DDL/replay, and persisted promotion settings. Remove unreachable MAKEDATE helpers and validate the registered SQL path. No coverage gate changes.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Rebased onto main 7ff3eac2e8f17c0d013178c287dc686b4360b0f0 and pushed 14ec3d1cfb0b685d6732ff0e972023657a66ae32 to this original PR (lease protected).
Pre-push independent model gate: passed, no remaining material blocker. Runtime verified gpt-6-astra / xhigh, final review session 01a10344-64f8-73e0-851c-bfe8b05b36f4, accepted correction fingerprint d45111382c44d3d0e0b9b61f64205ccd0509c67a8cf0a1f0ca599d6173c26005; committing the reviewed content does not change that evidence.
All five reproduced blockers are closed: joined UPDATE DEFAULT/volatile ownership and target guards; stale prepared locale/mode/default-policy plans; exact numeric fractional truncation before rounding; legacy TIMESTAMP nullability/default/replay policy; accepted persisted settings failing promotion. Removed unreachable MAKEDATE helpers and their direct-only tests; the registered SQL path is exercised instead. Existing sequential/simultaneous assignments, numeric diagnostics, and persisted overload/default ownership remain intact; no new cache state or alternate execution state machine.
Validation:
- Native/service builds and seven full owning-package checks with vet passed; affected checks rerun after source changes.
- Configured lint: 0 issues.
- Deterministic real SQL regression: 105/105 full-metadata comparisons passed, including JOIN no-op/swap/inactive/duplicate target sequence counts, prepared A→B→A and failed-rebuild retry, numeric masks/carry, and legacy NULL/default behavior.
- Fresh matching UT-only changed-block coverage: 595/781 = 76.18%, using the actual CI parser with unchanged >75% threshold and exclusions. No stale line offsets or old CI coverage profiles were merged.
Persisted data/expression compatibility was reviewed; mixed-version rolling upgrades are outside this task. Historical neighboring DAYNAME metadata-width mismatch is disclosed in the PR body, not claimed passed. Post-push CI remains pending and was not waited for.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head 91caf632ca8c45a15bc59b7c6557aa34612e5b7b against base/merge-base f1137a6cac72852be2ab2e5078b684b98f23d96c: REQUEST_CHANGES. No subagents; no production edits. Persisted data/expression compatibility is in scope; mixed-version upgrades are excluded.
The overall ownership direction is reasonable: materialize final assignment values once, use the existing assignment/default policy and prepared-plan invalidation owner, retain real persisted execution identities, and share temporal/JSON conversion. The four inline findings are current-head build, result-correctness and measured common-path cost problems. They do not require another state machine or framework.
Historical review closure
I read all prior reviews and all 12 inline threads, not just GitHub's resolved flags. The old correctness fixes remain present:
- MAKEDATE overloads 0/1 retain persisted VARCHAR execution; new SQL uses overload 2 / DATE and canonical integer coercion.
- UPDATE storage, changed-row tests and automatic columns consume the materialized final RHS; sequential/simultaneous, joined DEFAULT, inactive/duplicate-target and volatile-value controls are retained.
- Legacy TIMESTAMP NULL uses statement current time, not a constant DEFAULT; first-column automation, nullability, FSP, strict-zero admission and unchanged absent-default replay are covered.
- UNIX_TIMESTAMP() retains integer seconds. Fractional parsing preserves truncation before rounding without bypassing grammar/IGNORE handling; typed TIMESTAMP arithmetic uses the bound DATETIME domain/FSP and shared calendar diagnostics.
- Remote locale capture/decode/forwarding/fallback remains connected through session field 22. Existing prepared handles rebuild on successful effective locale/mode/default-policy changes and remain retryable after rebuild failure.
Not all historical engineering comments are closed: both callers of makeUpdateChangedRowsPredicate now pass true, but the false/RHS-copy branch remains; JSON's old private temporal helper branches and duplicate unreachable temporal switch cases remain; locale lookup/copy still occurs per row/directive. These are distinct from necessary persisted MAKEDATE compatibility and should not be retained solely to satisfy old helper tests.
Evidence and limits
- Unmodified-head repository CGo wrapper, Go 1.26.4, darwin/arm64: full planner package PASS (15.466s); full function package BUILD FAIL at the two obsolete
fEvalFnreferences. This is not a native/linker/environment failure. - For further diagnosis only, an external Go overlay supplied
type fEvalFn = executeLogicOfOverloadplus review probes; no tracked files or production functions were changed. With this alias, the existing full function suite passed 8.902s. That is not an unmodified-head pass. - Independent public SQL parsing -> BuildPlan -> expression execution reproduced French June %b and year-zero DAYNAME failures. July/ordinary-year controls passed. Direct vector tests independently reproduce both. The June oracle is MySQL's explicit locale table, not the new implementation's heuristic.
- A same-binary microbenchmark compares current ConvertToGoTime with the verbatim merge-base method: normal UTC conversion ~16 -> 53 ns/op; America/New_York ~21 -> 90 ns/op (three 300ms samples, Apple M4). This is component cost, not an end-to-end SQL slowdown claim.
- I also challenged typed-DATETIME DST masking: the direct helper violates a partial-mask expectation, but current FunctionExpressionExecutor compacts selected rows before execution. I am not reporting an unproven CASE/SQL failure from that direct-only probe.
- Prior owning-package and 105/105 real-SQL regression evidence is reused only for unchanged relevant closures. The main merge changed function fixtures and default binding, hence fresh function/planner validation above. No new service/BVT, full-CI or race pass is claimed; CI was not waited for.
Engineering and test quality
Reviewed the complete 61-file delta and implementation/tests/generated code separately: handwritten Go production +1770/-500; Go tests +1049/-18; generated protobuf +132/-77; remaining changes are proto/SQL/goldens; no documentation delta. The new deterministic NEXTVAL, same-handle A-B-A, NULL/default and arithmetic-boundary controls add real value. However, several new function cases use Run without Free (including the locale cases and new temporal coverage matrices), and TestTimestampTemporalResultPaths leaves its vectors/results unreleased. Use the main fixture's RunAndFree or immediate deferred Free, consolidating overlapping happy-path setup instead of growing parallel fixtures.
The production unhappy-path audit found no additional confirmed wait/cleanup blocker: existing Session EXECUTE/Close and aggregate admission/flush/free remain the owners; there are no new goroutines/queues, and the DST transition search is bounded. This does not erase the common-path CPU regression below. The two UUID golden trailing-empty-field whitespace warnings remain nonblocking.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Overall re-review at 1decb89: no unresolved material blocker. The four findings in review 5402525774 are closed: canonical evaluator integration, one-core DST conversion/status reuse, explicit French June/July abbreviations, and locale-aware year-zero DAYNAME. CI's extra-decay-point oracle now tests the accepted persisted domain rather than narrowing it.
The final gpt-6.1-sol/xhigh review also identified and closed JSON preflight's worker/session timezone mismatch: size and candidate bytes now share the captured session timezone with fill. Both UTC-worker year-boundary counterexamples failed before and passed after, with no post-preflight capacity growth, exact spill results, and one-byte-short rejection before publication. Existing UPDATE/scalar JSON ownership replaces unused branches; production follow-up net -102 lines. Persisted data/expression identities and all historical comment closures were reconciled; mixed-version rolling upgrades excluded.
Validation: seven owning packages with vet/instrumentation passed; exact failing promotion consumer matrix passed; full-metadata public SQL 105/105 passed; separate typed/string DST strict/non-strict/IGNORE checks passed; final build passed; configured scoped lint 0 issues. Fresh matching local changed-block coverage 603/774=77.91%, unchanged >75% policy. Approximate scalar benchmarks improve UTC and ordinary NY conversion with zero allocations, not an end-to-end claim. Design and overall review runtime verified gpt-6.1-sol/xhigh (sessions 01a1036d-7e09-76f0-add9-ced25f369d64 and 01a10380-1a7a-7d11-8562-ebac5ef08ff6), final reviewed diff bee94a72...648afae matches committed content. New CI is pending and was not waited or claimed passed.
Merge Queue Status
This pull request spent 17 seconds in the queue, including 1 second running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #28600
Fixes #28599
Fixes #28598
Fixes #28597
Fixes #28154
Fixes #28889
Fixes #28563
Fixes #28236
Fixes #28235
Fixes #28232
Fixes #28561
Fixes #28890
Fixes #28570
Fixes #28565
Fixes #28564
Fixes #28495
Fixes #28493
Already present on the upstream base, not newly fixed here: #28562, #28240.
Not fixed here: #28602; retaining invalid calendar components under ALLOW_INVALID_DATES requires a persisted representation design.
What this PR does / why we need it:
Consolidate remaining temporal compatibility behavior under existing owners:
Persisted data/expression compatibility is retained. Mixed-version rolling upgrade compatibility is not claimed. No new compatibility state machine, aggregation framework, or coverage-policy adjustment.
Validation
Local macOS arm64 / Go 1.26.4, against base f1137a6:
Post-push CI is pending and is not claimed passed. Historical neighboring DAYNAME full-metadata display-width mismatch remains outside this fix; its value comparisons passed, not its full-metadata fixture.