Skip to content

fix(sql): preserve fractional TIMESTAMPADD SECOND intervals - #30286

Merged
mergify[bot] merged 19 commits into
matrixorigin:mainfrom
iamlinjunhong:fix/timestampadd-fractional-seconds-30203
Oct 20, 2026
Merged

mergify[bot] merged 19 commits into
matrixorigin:mainfrom
iamlinjunhong:fix/timestampadd-fractional-seconds-30203

Conversation

@iamlinjunhong

@iamlinjunhong iamlinjunhong commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Related to #30203; leave open for reporter verification.

What this PR does / why we need it:

Preserve fractional TIMESTAMPADD SECOND intervals through typed normalization, including decimal/approximate sources, prepared execution, warning/NULL rules and assignment boundaries. Preserve published main functions 599/600 and capabilities through 123, including unsigned DECIMAL DIV, unary temporal results and nonblocking row-lock admission. Append normalizer 601 and gate its execution/persistence at capability 124, allocated as official main latest + 1. Sender, receiver, persisted definitions and prepared-plan invalidation cover immediate-predecessor rollback 123→124→123.

Reuse the existing DUMP/LOAD declaration, budget, cancellation, validation and transactional publication owners. Verify complete expression bindings across applicable historical eras; only division enumerates precision increments. Format 3 carries verified bindings for future writes as well as copied rows; readers retain v1/v2/v3 handling and old readers explicitly reject unsupported format 3. Every supplied expression must match one complete era; mixed-node forgeries fail. Current SQL retains main semantics.

Observe timezone and locale dependencies in DEFAULT expressions before folding, including DATETIME/VARCHAR/numeric/UUID results and localized temporal names. Try all cheap precision/era bindings first, all cheap locale-only bindings second, and exhaustive timezone/joint witnesses last. Named locations retain historical second offsets and DST; a private resolver preserves effective locale precedence. The parent session, diagnostics and catalog trees remain unchanged. Unrecoverable historical custom/unavailable timezone rules fail closed. Candidate descriptors retain dependency flags rather than expression graphs; the shared one-million-node budget and cancellation remain in force. No new global cache, goroutine, validator, storage codec or per-row candidate enumeration is introduced.

Historical DECIMAL DIV definitions retain their pre-v121 physical casts, signed overload and result width through a bounded dump-only era. Persisted-origin verification skips only CREATE-time strict zero-temporal default admission, allowing previously admitted DATE/DATETIME/TIMESTAMP definitions under a strict backup session. A literal-only pre-normalization candidate preserves genuine old TIMESTAMP DEFAULT 0 bindings; ordinary DDL keeps main's canonical zero normalization and strict rejection. The historical epoch-zero assignment remains rejected with 1366 in strict and permissive modes; preserving that metadata does not claim the old default becomes a valid future value.

Rebase onto official main c7bd2e7 also accounts for string DATE/DATETIME nullability changes. A private binding-only context reproduces the prior inference at the shared owner, while current binding and runtime conversions retain main semantics. Finite whole-origin eras cover prior-PR fractional bindings and published pre-fractional/pre-DIV/pre-special definitions. No NotNullable normalization or per-node era mixing is allowed; the descriptor bound is 31×6 under the existing total node budget. Genuine incoming f9271d9 definitions provide an independent frozen oracle.

Main's schema-unique CHECK names remain strictly checked. Historical public fixtures use the same logical table names in three reused schemas; they transplant verified old expression trees while retaining trusted current CHECK identities. The v1 ambiguity control reuses the empty seed table, preserving matching names, no-row rejection and subsequent fresh fractional semantics. CHECK replacement/clear/rename/stale-version rollback retains the existing transactional owner. RFC revision 17 records the compatibility and protocol allocation.

The default roundtrip fixture retains the previous CI correction: each of its eighteen scenarios owns a 90-second context and leased connection, initializes all relevant session values, and uses independent qualified cleanup. Setup/catalog inspection have separate bounded contexts. New temporal historical subcases also own their allowance. No retry, sleep, skip or timeout inflation is added.

Validation

  • Full owning-package UTs pass with count=1, vet=all and bounded timeouts: defines, protobuf plan, functions, planner, compile and frontend. Planner completes in 93.425 seconds. Immediate-predecessor admission and prepared-plan rollback cover 123→124→123.
  • Genuine incoming f9271d9 definitions reproduce four constant-expression failures before the fix. Eight frozen pre-8dd bindings, current/pre-fractional/pre-DIV composition, impossible metadata and mixed-nullability negative controls pass after the fix. The new fixture is captured independently of the compatibility binder.
  • Configured static checks cover all eight affected Go packages. The new nil-Context finding was corrected to context.Background; the final function/SQL-integration checks report zero issues, and SQL integration was checked again after its last fixture change. No linter suppression was added.
  • CHECK replacement, clearing, rename and stale-version rollback pass through the real transactional publication/failure owner.
  • Real SQL default/historical roundtrips and both deterministic session/cleanup deadline controls pass in normal and race modes with matrixone_test, short mode, count=1 and vet enabled. Normal package time is 11.311 seconds (default root 7.59; historical root 2.59); race time is 23.567 seconds (16.48 and 4.35). All eighteen default scenarios and historical TIMESTAMPADD, signed/unsigned DIV and three new temporal constant subcases pass; cluster admission, services and port leases are released. These are local Darwin/arm64 results, not Linux CI equivalence or an identical-scope performance comparison.

Unchanged fractional arithmetic/source-domain, historical persistence, session search, cancellation and lifecycle evidence from the approved incoming head is reused where its semantic inputs are unchanged. The prior Linux CI run 39284877039 exposed the shared 90-second scenario deadline addressed by the retained session-ownership regression; this rebase does not attribute unrelated latency or rerun that old run.

No deployed mixed-version binary validation is claimed. Independent design and final overall review use gpt-6-astra / medium. New-head CI starts after push and is pending.

CI correction: composed CHECK renames

Run 39352183291 attempt 1 failed four assertions in database/check_constraints.sql on Linux/x64 compose-pessimistic multi-CN BVT. After a combined table/column rename, SHOW CREATE and error 3819 retained combo_chk_1 rather than combo2_chk_1; recreating combo then failed with duplicate constraint name 3822. Coverage stopped at prerequisites_ready=false without calculating a coverage verdict, and CI Required reported the upstream standalone failure.

ReplaceDef already precedes composed rename requests. Publish its deep-cloned CHECK set at that ordered request boundary, allowing subsequent table/column rename requests to retain final names and expressions. Remove the late replacement CHECK overwrite; version preflight, charset handling, guarded LOAD publication, alias isolation and rollback snapshots remain unchanged. There is no protocol, row-evaluation, synchronization or allocation-count change.

Validation: The strengthened regression fails four rename cases before the fix and passes all seven cases after it, including replacement, clearing, stale-version rejection, table-only rename and both table/column orders. Deep-clone alias isolation and rollback to the original names/checks are asserted. The full disttae short-mode package passes with count=1 and vet=all (7.222 seconds). Vet and the configured incremental linter pass for both affected packages with zero issues. Real SQL tests for implicit-commit rename, all eighteen default roundtrips and historical TIMESTAMPADD/DIV/temporal roundtrips pass in 11.519 seconds. The two new ALTER subcases each take 0.04 seconds, reuse the existing cluster/pool/database and independently bound their sessions. They assert SHOW CREATE final generated and unchanged explicit names, error 3819 naming, zero rows after rejection, valid insertion and successful old-name reuse. Services and leases are released. Independent gpt-6-astra / medium design and final overall review report PASS; unchanged compatibility, protocol and race evidence is reused. New-head CI remains pending. Existing BVT expectations are retained. The failure is attributed to this PR; no unrelated issue or old-run rerun is used. The independent TPC-H module added to newer main does not change this request path, so no unrelated rebase is included.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added the kind/bug Something isn't working label Oct 15, 2026
@matrix-meow matrix-meow added the size/L Denotes a PR that changes [500,999] lines label Oct 15, 2026
@iamlinjunhong
iamlinjunhong force-pushed the fix/timestampadd-fractional-seconds-30203 branch from 5a71d6c to d0228b1 Compare October 15, 2026 16:12
@XuPeng-SH

XuPeng-SH commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: d0228b103ca0f950a378ddb31c275d8e096d5f53

Review completed. Read the assessment.

@XuPeng-SH

XuPeng-SH commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 401e90ee943bf08d254d6e87db438a7cd4151ced

Review completed. Read the assessment.

@XuPeng-SH

XuPeng-SH commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-xupeng · superseded

Commit: 401e90ee943bf08d254d6e87db438a7cd4151ced

"interrupted"

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 401e90ee943bf08d254d6e87db438a7cd4151ced

Assessment: request_changes

Reviewed the complete 41-file delta, callers, compatibility paths and supplied review concerns. Fractional interval normalization appropriately reuses existing temporal arithmetic, and historical binding reconstruction retains established ownership. However, the expanded dump verifier introduces a confirmed backup/restore regression for valid zero-TIMESTAMP defaults.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

  • P2 pkg/sql/plan/table_dump_binding.go:221: Create source and destination tables with a TIMESTAMP DEFAULT '0000-00-00 00:00:00' under SET sql_mode='', and create a metadata dump. After SET sql_mode=DEFAULT, both another DUMP of the source and LOAD into the destination fail.
    Impact: Existing valid tables become undumpable and their dumps unloadable under the normal strict SQL mode. Verification inherits the reader's sql_mode and re-applies CREATE-time zero-date admission checks. Preserve persisted-expression verification independently of that reader policy while retaining whole-tree equality, and add cross-mode DUMP/LOAD regression coverage.
    Evidence: Public SQL integration reproduces Error 20301: table dump cannot verify bound default expression a. The new call reaches buildDefaultExprWithColumnsObserved's IsStrictNoZeroDateMode rejection; the candidate process overrides locale but retains sql_mode. Both operations pass with the complete merge-base Go overlay, and permissive-mode controls pass at the candidate. Retained evidence: review-zero-planner.log, focused-tests.jsonl and base-public.jsonl, reconciled in validation-audit.json.

Validation:

  • Verified the frozen head, complete patch and clean source; matched 11,553 archived files. Preflight, repository-owned native build and native provenance verification succeeded.

  • Ran focused tests across function, planner, compiler, frontend, disttae and SQL integration with vet enabled and the supplied isolated executor. All 97 selected existing test roots and 489 subtests passed. The overall command exited 1 solely because the added zero-default regression test failed.

  • Verified the baseline overlay against merge-base contents and unchanged native/module inputs. The zero-default DUMP and LOAD tests both passed at the baseline.

  • The 1,024-row DECIMAL normalizer microbenchmark measured typed conversion 4.6–28 times faster than lexical conversion, reducing 1,025–2,049 allocations to one per batch.

  • Independently reconciled nine command/source/exit receipts with retained logs and overlay hashes. Audit passed: /home/xupeng/.local/state/mo-bot/jobs/5c99ebbf19f5a10bf70f4c70/attempt-1/validation-audit.json.

Limitations:

  • Frozen CI reports success, but local_validation contained no reusable worker artifacts. Local execution was focused; no full-suite, deployed mixed-version or restart run was performed.

  • Cross-timezone division-binding probes fail at both revisions. Candidate rejection took approximately 5.4 seconds versus 15 milliseconds at baseline; this is a higher bounded failure cost, not a newly introduced functional rejection.

  • The linked issue #30203 reproduction was not included in the supplied evidence; reporter-specific closure is not claimed.

@iamlinjunhong

Copy link
Copy Markdown
Contributor Author

已针对 review 5573698920 完成修复,本地提交 129d977cc8fc2e8b36bd2bd59e1d829f7681b403 将随本次原分支更新发布。

默认值绑定现在显式区分新建 DDL 与持久化来源验证。后者仅跳过 CREATE 时的严格零 TIMESTAMP 准入检查;绑定、赋值转换、折叠、协议检查和完整表达式精确比较均保留。读取会话的 SQL mode 与诊断不变,普通 CREATE 和后续写入仍执行各自的准入策略。

修复前,定向测试复现严格读取会话下的 20301。修复后,历史零默认值的直接及载荷验证通过,伪造值和类型被拒绝,严格新建表在验证前后仍被拒绝。完整 planner 和配置化静态检查通过;真实 SQL 的宽松创建、严格 DUMP/LOAD/再次 DUMP、会话模式保持、严格 CREATE 1067,以及后续宽松插入实际零默认值全部通过。测试服务与 admission/端口租约已释放,独立最终审阅为 PASS。

RFC revision 15 记录此边界;没有协议版本变化。新 head CI 将由推送触发。

@XuPeng-SH

XuPeng-SH commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: f9271d9780cb47b60ede8cd4b4210ebae5b934fd

Review completed. Read the assessment.

@XuPeng-SH

XuPeng-SH commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-xupeng · superseded

Commit: f9271d9780cb47b60ede8cd4b4210ebae5b934fd

PR closed or head changed

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: f9271d9780cb47b60ede8cd4b4210ebae5b934fd

Assessment: approve

Reviewed the complete 42-file delta, design, callers and recorded concerns. Fractional normalization reuses established arithmetic and protocol owners; historical binding verification preserves stored semantics with bounded work and transactional rollback. The precision-search and strict-mode zero-default regressions are resolved. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

Validation:

  • Isolation preflight and repository-owned native build passed. Verified 193 native inputs, seven artifacts and unchanged source.

  • Focused normal tests with vet passed: 105 roots and 527 subtests across six packages.

  • Real SQL passed 18 default DUMP/LOAD scenarios and historical TIMESTAMPADD/DIV round trips, including future writes and CHECK enforcement.

  • Deadline isolation and CHECK rollback tests passed under race instrumentation, then each passed 100 repetitions.

  • DECIMAL normalization measured one allocation per 1,024-row batch versus 1,025–2,049 for lexical controls, with approximately 4.7–27× faster conversion.

  • Receipts and retained logs reconciled in /home/xupeng/.local/state/mo-bot/jobs/b7577752212a37d820222d4f/attempt-1/validation-audit.json. Final audit receipt checks/1792437734951953767-4.json exited 0; the superseded provenance diagnostic is explicitly recorded.

Limitations:

  • Unsupported historical session settings, unavailable timezone rules and exhausted reconstruction budgets retain documented fail-closed behavior; exhaustive verification can be costly.

  • No local full-suite, standalone BVT comparison, deployed mixed-version or restart run. Benchmarks measure conversion, not SQL throughput.

  • local_validation was empty; raw CI/author logs and linked issue #30203’s body were unavailable. Frozen CI success summaries were supporting evidence only.

@mergify

mergify Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-19 19:23 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🚫 Left the queue — 2026-10-20 00:46 UTC · at f9271d9780cb47b60ede8cd4b4210ebae5b934fd

This pull request spent 5 hours 23 minutes 29 seconds in the queue, with no time running CI.

Reason

Pull request #30286 has been dequeued

Queue conditions are not satisfied:

  • -conflict [📌 queue requirement]

Hint

You 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.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

@mergify

mergify Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-20 03:55 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-10-20 06:40 UTC · at 743e749a1e33d6c845bb73999e8c82d297a2b657 · squash

This pull request spent 2 hours 45 minutes 16 seconds in the queue, including 1 hour 13 minutes 41 seconds running CI.

Required conditions to merge

This branch was previously deployed

1 inactive deployment
ci — 08fe9a47 Deployed Oct 20, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/enhancement kind/refactor Code refactor kind/test-ci size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants