Repository navigation
fix(plan): align DECIMAL DIV result domains with MySQL - #30171
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? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: a4533042f03420b2f73aea9039cf4bc318c0783c
Assessment: request_changes
Reviewed the complete 24-file delta and affected callers. The arithmetic and protocol changes use appropriate existing owners, but view expansion breaks the new narrow schema contract.
Model: gpt-6-astra / xhigh
Session: 01a12d8f-7dea-77c2-a565-38d45b5564e4 · slot 0 · generation 0
- P2
pkg/sql/plan/output_column_provenance.go:142: Create a view v as SELECT d DIV 2 AS q from a DECIMAL(10,3) column, then create a table or another view as SELECT q FROM v.
Impact: The first view publishes INT, but both transparent consumers publish BIGINT. View expansion clears the DIV display provenance while retaining the 64-bit expression type. Restore the view's narrowed output domain before clearing this provenance, and cover CTAS-through-view and nested views.
Evidence: The real SQL probe TestReviewDecimalDivBoundaries observed v.q=int and direct.q=int, but via_view.q=bigint and nested.q=bigint. Retained in attempt-1/sql-boundaries.log, lines 1823–1846; check receipt 1791980263836546687-6.json records exit 1 at the frozen head.
Validation:
-
Artifacts retained under /home/xupeng/.local/state/mo-bot/jobs/74191a4ba439ac697c6ee24f/attempt-1; review-evidence-audit.json reconciles all five terminal receipts, source fingerprints and artifact hashes. Source remains unchanged.
-
Isolation preflight passed. After the repository wrapper diagnosed missing native prerequisites, recovery verified 192 current native inputs and 46 retained build outputs against their original Make receipt and log.
-
Focused resolver, kernel, vector, schema, prepared-statement and protocol tests passed across five packages, including both SQL integration rounds. Receipt 1791980350215170980-3.json: exit 0; focused-contracts.log.
-
Additional SQL probes confirmed the view-consumer defect; fixed unsigned-peer prepared expressions and active zero-divisor controls passed.
-
Unsigned kernel benchmark: 2665 ns per 256-row batch, 0 B/op and 0 allocs/op on AMD Ryzen 9 7900X.
-
Supplied exact-head CI snapshot reports successful build, UT, SCA and BVT checks; these do not cover the demonstrated missing view-consumer assertion.
Limitations:
-
No full-suite rerun or mixed-binary cluster execution locally; compatibility checks exercised placement, serialization, receiver admission and persisted protocol floors.
-
Kernel measurements exclude cast-vector and full-query costs; no base-relative performance comparison was made.
-
The linked issue's full body and MySQL transcript were not supplied; review used the behavioral contract stated in the frozen PR evidence.
aptend
left a comment
There was a problem hiding this comment.
Deep review of exact head a4533042f03420b2f73aea9039cf4bc318c0783c, declared base/merge-base 5a0570ea70083c9365719009a5ed8d7618f9ed91. Read all 24 file deltas, the full linked issue/discussion, historical reviews/comments/threads, and the resolver/kernel, prepared specialization, provenance/DDL/view-expansion and protocol producer/receiver/persisted-expression consumers. This is a focused correction of the existing DIV contract, not a new subsystem/ownership architecture; the ordinary-fix design exemption applies.
The new unsigned arithmetic and direct narrow CTAS/view cases pass, including uint64 maximum, negative fractions truncating to zero, prepared signed/unsigned reuse and ODKU failure preserving its seed. One P2 schema-boundary defect remains: a completed INT view is transparently materialized/expanded as BIGINT; the unsigned form similarly becomes BIGINT UNSIGNED. I independently reproduced the existing review candidate and extended it to both signedness domains.
Validation on this frozen head:
- Complete
function,plan,compile,pb/plannormal suites: 7,271 roots / 29,228 named passes; nine existing skips. Complete race suites: 7,270 roots / 29,227 named passes, the same nine skips. Native provenance is verified by the repository wrapper. - Seven new resolver/kernel/vector/schema/persisted/remote/wire roots each passed another 100 individual race repetitions. B=30s and measured T=0 except schema T=0.02s => N=100 for each.
- Committed
TestDecimalIntegerDivPublicContractspassed both same-instance rounds. Additional native SQL counterexample ran two rounds with direct-view/direct-CTAS controls and CTAS-through-view/nested-view consumers in signed and unsigned domains. All values remained 2; eight direct controls passed, and all eight transparent-consumer schema assertions failed with int -> bigint / int unsigned -> bigint unsigned. - Original
dtype/issue_30158_decimal_div_domain.testand its committed result: normal mo-tester comparison 29/29 in each of two rounds, zero ignored/abnormal statements and database teardown checked. The initial BVT attempt hit the tester's dotted-parent path resolution; a dot-free owned temporary root corrected that harness issue without changing SQL, expected results or assertions. - Exact-head CI Required and coverage producers are verified green. Current upstream main
fd4767e488dc111db02c9119cd46dfe78af1ee23still advertises v112; v113 is therefore not falsely reported as a current-main collision. Historical overload zero and old-worker rejection have direct protocol-test evidence; no mixed-binary deployment is claimed.
Please restore the completed view's declared narrowed output domain before clearing DIV display provenance, and cover CTAS-through-view and nested views for signed and unsigned operands. This is incomplete closure of the newly introduced INT view schema contract, not a claim that the merge-base already published INT. Temporary probes/worktrees are cleaned up after review.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 2b9f6f860a6969868c64c6f24568a74c67f1e534
Assessment: approve
Reviewed the complete 25-file delta and affected callers. Resolver-owned domain inference, existing batch execution and protocol gates form a coherent design. The completed-view cast restores the published INT/INT UNSIGNED domain before provenance is cleared, closing the prior review finding. No actionable defects remain.
Model: gpt-6-astra / xhigh
Session: 01a12d8f-7dea-77c2-a565-38d45b5564e4 · slot 0 · generation 0
Validation:
-
Evidence retained under /home/xupeng/.local/state/mo-bot/jobs/7e84cb4bc77df57d09dff031/attempt-1. review-evidence-audit.json reconciles commands, source fingerprints, terminal receipts and logs. Source remains unchanged.
-
Isolation preflight passed. Native recovery verified 192 matching inputs and 62 artifacts against the original repository build-owner receipt and log.
-
Focused checks passed: 11 root tests and 91 named tests across function, planner, protobuf, compile and SQL integration packages, including a 2,000-case independent arithmetic oracle and both public SQL rounds. Receipt: 1792008413676538013-5.json.
-
Independent SQL composition checks passed for transparent view consumers, ENUM/SET outputs, grouping, DISTINCT, CTE/order, NULLs, wide UNION and fixed unsigned prepared operands. Receipt: 1792008549047847190-3.json.
-
Unsigned kernel benchmark measured 2685 ns per 256-row batch, 0 B/op and 0 allocs/op. Receipt: 1792008580571243696-3.json.
-
The supplied exact-head CI snapshot reports successful build, Ubuntu UT, coverage, SCA and proxy/pessimistic multi-CN BVT checks.
-
Final evidence audit passed. Its initial comparison failure was solely the coordinator patch's omitted final newline; both audit outcomes are retained.
Limitations:
-
Local execution was focused; no full-suite, standalone mo-tester, race-suite or mixed-binary deployment rerun. Compatibility checks covered serialization, placement, destination/receiver admission and persisted protocol floors.
-
Kernel measurements exclude operand cast vectors, view projections and full-query costs; no base-relative benchmark was performed. These added costs are bounded, with existing signed kernels and protocol probing retained.
-
Raw CI/author logs and the linked issue's full body/MySQL transcript were not supplied. Review used the frozen PR contract, source and independently executed checks.
2b9f6f8 to
d16c0e9
Compare
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed the complete 25-file delta at c2a6945. No blocking findings.
Display/schema inference is separated from the 64-bit arithmetic domain. I checked original-operand unsigned selection, legacy overload-zero behavior, exact unsigned scaling and its bounded overflow fallback, negative quotients truncating to zero, full uint64 boundaries, selection/NULL/division-by-zero handling, and transparent versus completed view/CTAS boundaries. The display-length formula agrees with the official MySQL 8.0.46 Item_func_div_int::result_precision implementation, including the 19-digit precision cap before sign adjustment: https://github.com/mysql/mysql-server/blob/mysql-8.0.46/sql/item_func.cc . The apparent unsigned-width concern therefore was not a valid finding.
The new overload and display contract have v116 placement, actual-destination, receiver and persisted-expression checks; old signed plans retain their original overload. Prepared signed/unsigned reuse and ODKU failure retaining the existing row are covered through the public SQL path. Reused the exact-head green CI and the targeted/package/public regression evidence rather than repeating equivalent broad runs.
c2a6945 to
70c46e4
Compare
70c46e4 to
0690ede
Compare
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-xupeng · review
Commit: 5c87744c9ca96e111423e36908e46064acb9a3f4
Assessment: approve
Reviewed the complete 26-file delta. The view-consumer defect is fixed, existing arithmetic and compatibility owners are preserved, and no actionable unresolved finding remains.
Model: gpt-6-astra / xhigh
Session: 01a14d34-4e51-79a3-a62d-6c9c16279dc8 · slot 0 · generation 0
Validation:
-
Verified the frozen head, merge base, complete patch and clean checkout.
-
Twelve focused test roots passed across function, planner, protobuf-plan, compile and colexec, covering unsigned arithmetic, schema boundaries, warnings and protocol admission. The combined command timed out before public SQL completed; only those five package passes are credited.
-
Built native prerequisites from 193 matching inputs through the repository build owner; provenance verification and isolation preflight passed.
-
Reconciled command/source/exit receipts with retained logs in attempt-1/validation-map.json; receipt-audit.log passed.
-
Frozen current-head CI reports successful Ubuntu UT, arm64 SCA, coverage and proxy/pessimistic multi-CN BVT. These are status records, not independently inspected per-test logs.
Limitations:
-
Local public SQL execution and supplementary arithmetic-oracle/prepared-binding probes remained unexecuted after bounded build/link timeouts. Existing committed regression coverage was reviewed; these timeouts are not product-test failures.
-
Older referenced execution artifacts were unavailable. No live MySQL comparison or fresh performance measurement was performed.
Reuse scalar division diagnostics after successful unsigned DECIMAL DIV evaluation. Keep arithmetic errors and selected-row semantics unchanged, and cover warning policy, runtime folding, and real SQL mode controls.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-xupeng · review
Commit: c7e635f8b27809ed8ef4c97750a4d86de99af3cd
Assessment: approve
Reviewed the complete 26-file delta and affected owners and callers. The prior view-consumer defect is closed. Arithmetic domains, prepared inference, warnings, schema boundaries and v121 compatibility checks are coherent; no actionable unresolved findings remain.
Model: gpt-6-astra / xhigh
Session: 01a14d34-4e51-79a3-a62d-6c9c16279dc8 · slot 0 · generation 0
Validation:
-
Verified the frozen range, complete patch and unchanged source checkout.
-
Isolation preflight passed. The file-scoped protobuf protocol test passed all four cases using the supplied test executor; receipt 1792392110151052762-3.json and protocol-focused.log.
-
Reviewed committed kernel, vector, planner, prepared-statement, protocol, SQL-service and BVT coverage, including ODKU failure preserving the existing row.
-
Frozen current-head CI reports successful build, Ubuntu UT, arm64 SCA, coverage and proxy/pessimistic multi-CN BVT.
-
Reconciled command/source/exit receipts with retained logs in attempt-1/review-evidence-audit.json; receipt-audit.log passed.
Limitations:
-
The initial CGo-disabled package test failed before execution because external tests require the native allocator. The subsequent focused pass does not establish a full-package pass.
-
No local native arithmetic, planner, SQL-service, BVT, race, mixed-binary or performance rerun. CI evidence consists of supplied status records, not independently inspected per-test logs.
-
The linked issue body and MySQL reference transcript were not supplied.
aptend
left a comment
There was a problem hiding this comment.
Re-reviewed exact head c7e635f8b27809ed8ef4c97750a4d86de99af3cd against actual base/merge-base 8ef2eaf4d923bdb4136dd81a50850e8eced0f368. Read all six historical reviews, comments/replies and the resolved thread, compared with my previous a4533042… review, and inspected the complete 26-file diff and affected consumers. No remaining blocker found. This is an ordinary correction using existing arithmetic/schema/diagnostic/protocol owners, so the feature-design exemption applies.
My previous signed/unsigned completed-view finding is genuinely closed: expansion now inserts an executable INT/INT UNSIGNED conversion before clearing DIV display provenance, rather than merely relabeling a 64-bit vector. Native public tests verify both outer CTAS and nested views, folded/derived/ordered cases, NULLs and negative unsigned failures in two same-instance rounds. Prepared signed/unsigned reuse and failing ODKU retaining the original row also pass.
Fresh native validation: five complete normal and race packages (function, plan, compile, colexec, pb/plan); committed public SQL test normal/race and one additional race repetition (measured T=33.75s => N=1); ten separately measured focused race roots, N=100 each; independent deterministic big.Int oracle with 2,000 scale/sign/zero/overflow cases under race. All completed successfully. Two pre-existing named case skips remain explicit, not counted as executed. Exact-head CI run 39205930048 succeeded, including Ubuntu UT/coverage and proxy/pessimistic multi-CN BVT.
The standalone BVT test/result blobs are unchanged from my prior successful 29/29 twice runner evidence; I reused that narrowly for its unchanged arithmetic/schema transcript, not as a fresh standalone runner invocation. The changed view and warning closures have fresh public execution evidence. No live MySQL or real mixed-binary deployment/performance claim: precision/sign and truncation were cross-checked against MySQL 8.0.46 arithmetic source; v121 is above current main's v120, and placement/actual destination/receiver/persisted checks preserve the independent coordinator-only dependent-program fence.
| Unhappy-path question | Closure |
|---|---|
| Q1 — ownership/admission | Existing decimal batch wrapper owns input/output selection and NULL state; unsigned kernel borrows slices, bounded scaling fallback does not retain state. |
| Q2 — failure/rejection | Zero/masked/NULL handling, strict DML and range errors, bounded SELECT warning collection, and seed-preserving ODKU validated. |
| Q3 — reuse/compatibility | Prepared domain transitions, completed-view boundaries, stable historical overload zero, and predecessor-version rejection verified. |
Merge Queue Status
This pull request spent 1 hour 1 second in the queue, including 59 minutes 15 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
What this PR does / why we need it:
DECIMAL DIV currently publishes BIGINT for narrow CTAS/view outputs and loses an unsigned integer operand's result domain during implicit casts. A negative quotient can consequently reach INSERT ... ON DUPLICATE KEY UPDATE and replace an existing row.
Derive DIV display precision and signedness from the original DECIMAL/integer operands. Keep 64-bit arithmetic and infer INT/BIGINT independently at CTAS/view schema boundaries, including folded constants and transparent projections.
Add a stable unsigned DECIMAL DIV overload using exact Decimal256 arithmetic. Accept the full uint64 range and negative fractions truncating to zero; reject negative nonzero or overflowing results before downstream writes. Preserve legacy overload 0 and integer/BIT execution contracts.
Preserve typed peers during prepared parameter inference and require MORPC v121 for the new expression contract at worker placement, send/receive, and persisted-expression boundaries. Preserve the independent coordinator-only fence for dependent subquery programs.
Preserve SELECT division-by-zero diagnostics for unsigned DECIMAL DIV through the existing bounded warning collector, while retaining strict DML and out-of-range errors.
Validation:
dtype/issue_30158_decimal_div_domain.test: normal mo-tester comparison twice, 29/29 statements each, no skips, with database cleanup checks.MySQL reference behavior comes from the issue's MySQL 8.0.46 execution and inspection of that version's arithmetic/view/CTAS source. This change validates result domains and out-of-range failures; it does not reproduce MySQL's context-specific DML error wording. Local checks passed; CI is pending. The reporter should verify the issue after merge.