Skip to content

fix: align prepared temporal result types with MySQL - #31141

Merged
mergify[bot] merged 9 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/c7fcb227be432124adb28f46a0fd3c52abafc6323e8ac172adb91f424a1eab0e
Nov 1, 2026
Merged

mergify[bot] merged 9 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/c7fcb227be432124adb28f46a0fd3c52abafc6323e8ac172adb91f424a1eab0e

Conversation

@iamlinjunhong

@iamlinjunhong iamlinjunhong commented Oct 25, 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:

Please leave both issues open for reporter verification after merge.

What this PR does / why we need it:

Direct prepared FROM_UNIXTIME parameters now expose DATETIME(6), including integer and decimal3 inputs, while ordinary inputs and explicit casts retain their existing precision. Prepared DATE_ADD/DATE_SUB calendar intervals infer DATE or DATETIME(6) from the bound calendar source and preserve its clock and fractions. SELECT retains its widened type for the prepared handle; CTAS infers each execution independently.

This follows up on #30224: that PR fixed the HOUR/TEXT case but selected DATE for calendar-only intervals without considering datetime inputs. It made no FROM_UNIXTIME kernel change because the original precision-0 expectation already passed. The corrected MySQL 8.0.46 baseline requires prepared precision 6; the DATE_ADD retest identifies the remaining DAY/MONTH loss.

Reuse the existing parser for observation-only classification, rebuild generated CTAS result casts, and bind typed sources before lossy conversions. Bounded immutable SELECT history participates in cache identity, generation reset, publication and retry checks. Internal CTAS population can rebind temporal consumers while preserving actual writer destinations. Compact fractional/ISO clocks survive string-result formatting, including parser-accepted surrounding whitespace.

Observational classification shares the DATE/DATETIME/fraction grammar without emitting discarded error reports. Context-aware conversion retains the caller's reporting policy and existing diagnostics. Existing incomplete/zero/malformed calendar behavior from #30311 is preserved; this is not a general date-grammar compatibility change. No new execution ABI or protocol epoch.

Rebased onto official main bbfe55669a1440424914d45a283a1d0e36f722fa. The conflict resolution preserves main's rejection of public calls to plan-internal unsigned DECIMAL functions, then applies this PR's context-aware calendar inference. Upstream temporal warning folding and conversion policies remain intact. No new execution ABI or protocol epoch.

Validation for ef81e86644edcf47ea2e5be0ad5e8aeae3b17a11 (Go 1.27.1, Darwin/arm64), newly executed:

  • Full pkg/sql/plan and pkg/sql/plan/function tests (mo-cgo-test -count=1 -timeout=240s) pass: 66.667s / 10.034s. This includes the internal DECIMAL call guard, temporal warning folding, prepared SELECT/CTAS and writer-destination contracts.
  • Focused frontend prepared DATE/DATETIME/TIMESTAMP, temporal history/cache/retry and integer-assignment tests pass (1.755s); related temporal/context parsing tests pass (0.519s).
  • Both existing real-service cases pass normal mo-tester comparison (-n -g -o) twice: prepared_temporal_results.sql 208/208 and interval_operator_string_operand.sql 31/31. Database teardown verified after every run; the owned service exited cleanly. An initial runner path-lookup failure executed no SQL and is excluded from these results.
  • Configured golangci-lint/vet and main-pinned molint pass for all four PR packages. Formatting, error-construction policy, whitespace and delivery-artifact checks pass. The new service binary builds successfully; deterministic CGo testing reuses the previously verified 191-blob native export because all native/build inputs are unchanged.

Reused prior unchanged parser/diagnostic and real binary TIMESTAMP boundary evidence. No new MySQL differential, race or multi-CN result is claimed. The starting head ddb817e91a4b52c9e475fbacf3c06b3438df71a0 has successful required CI, attempt 2 and review approval. CI for this rebased delivery is pending.

@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 kind/bug Something isn't working kind/enhancement kind/test-ci labels Oct 25, 2026
@matrix-meow matrix-meow added the size/XL Denotes a PR that changes [1000, 1999] lines label Oct 25, 2026
@XuPeng-SH

XuPeng-SH commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 0e7da712f44cea55431b42d2686d39035e6917c3

Review completed. Read the assessment.

@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: 0e7da712f44cea55431b42d2686d39035e6917c3

Assessment: request_changes

Reviewed the complete delta, callers, cache/retry lifecycle, tests, and frozen discussion. The bounded immutable temporal history fits the existing prepared-statement owners, and targeted metadata, CTAS, writer, and lifecycle tests pass. One regression remains: supposedly observational classification emits server error reports for successful NULL arithmetic.

Model: gpt-6-astra / xhigh

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

  • P2 pkg/container/types/datetime.go:220: Execute prepared SELECT DATE_ADD(?, INTERVAL ? DAY) with a malformed string such as 'review-canary-invalid-date' and a NULL interval count.
    Impact: The statement correctly returns NULL, but result-type inference now emits an error report before arithmetic can skip conversion. With the production reporter installed, this creates spurious error-level logs and potentially error_info records, plus error formatting and stack-allocation work on each execution. Make classification avoid reportable error construction, including nested parser calls, and add a diagnostic-side-effect regression test.
    Evidence: The new ClassifyTemporalString discards parseDatetime's error, but moerr construction already invokes errutil's reporter. TestReviewTemporalObservation recorded one report during binding at this head and none at the merge base; both executions returned NULL successfully. Direct classifier probes also recorded two reports for '2024-00-28'. See temporal-probes.log and base-probes.log, backed by receipts 1792965996134949386-3.json and 1792966058286456178-3.json.

Validation:

  • Artifacts are retained under /home/xupeng/.local/state/mo-bot/jobs/154a378a80236e1f8493b008/attempt-1. Preflight passed; exact native inputs were exported and built through top-level make cgo, receipt 1792965881485559985-6.json.

  • Focused planner, function, and frontend tests passed: temporal result contracts, writer consumers, SELECT history, interval-count markers, NULL intervals, string formatting, history publication/cache, and retry declaration generations. Receipt 1792966118382311270-4.json; focused-contracts.log.

  • Candidate diagnostic probes failed as described; the NULL-interval probe passed with verified merge-base source overlays. A separate TIMESTAMP clock-loss probe failed at both revisions and was excluded as preexisting. Both probe commands exited 1; the base command was not an overall pass.

  • Evidence audit passed: source remained unchanged, native input/artifact hashes matched, and baseline overlays matched Git objects. Receipt 1792966122723977476-3.json; evidence-audit.log and review-artifact-index.json.

  • Frozen exact-head CI reports successful unit, coverage, static-analysis, PROXY BVT, and PESSIMISTIC BVT jobs.

Limitations:

  • No fresh service-level MySQL differential or BVT run was performed; raw author differential artifacts and linked issue bodies were not supplied.

  • Local tests used normal mode and an instrumented error reporter. Production logging consequences were traced through the existing ReportError implementation; no throughput benchmark was run.

@XuPeng-SH

XuPeng-SH commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 7aed527ddcb93b81df0b3f38c400f4b4d8f3c4f5

Review completed. Read the assessment.

@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: 7aed527ddcb93b81df0b3f38c400f4b4d8f3c4f5

Assessment: approve

Reviewed the complete delta and affected consumers. The parser-reporting and typed TIMESTAMP findings are resolved. Prepared history, cache/retry handling, CTAS inference and writer destinations remain coherent. No actionable findings remain.

Model: gpt-6-astra / xhigh

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

Validation:

  • Reviewed all 18 changed files, linked issue context and all 11 discussion items; saved review-plan.md, review-notes.md and discussion-assessment.json.

  • Reused frozen successful current-head build, UT, SCA and proxy/multi-CN BVT outcomes.

  • Reviewed regression coverage for metadata, fractional values, parser diagnostics, fresh typed-source handles, history publication, retries and CTAS.

  • Static audit passed: source identity and cleanliness, diff whitespace, patch scope and discussion coverage. Receipt: checks/1793206463535667610-4.json; logs: audit-v2.stdout.log and audit-v2.stderr.log.

Limitations:

  • No local Go tests, service execution, benchmarks or MySQL differential were run during this review.

  • Raw CI logs were not supplied. Author-reported focused tests and 208/208 SQL runs remain attributed reports, not independently reproduced executions.

@aunjgr aunjgr 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.

Approved after re-review. The previously reported TIMESTAMP clock-loss issue is fixed, with fresh-handle SQL and binary-protocol DATE/DATETIME/TIMESTAMP controls and a CTAS case. I also checked the interval-operator integration and reused the unchanged portions of my earlier review, passing product CI and the documented validation. I did not run a separate local service test.

@iamlinjunhong

Copy link
Copy Markdown
Contributor Author

@Mergifyio refresh

@mergify

mergify Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

refresh

✅ Pull request refreshed

@mergify

mergify Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as 950ef51 at 06:09 UTC

1 h 36 min in the queue, 1 h of it CI.

So far

  • ✅ Entered the queue Sun 1 Nov, 04:33 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Passed · in place
  • ✅ Merged 06:09 · 950ef51 · squash
3 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = CI Required
    • check-neutral = CI Required
    • check-skipped = CI Required

Times in UTC · dashboard · how the merge queue works

This branch was previously deployed

1 inactive deployment
ci — 0e3624ac Deployed Nov 1, 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/test-ci size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants