Repository navigation
Fix SQL compatibility regressions across aggregates, casts, and prepared DML - #32002
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: d0fa0bba8a15148e9a3dcf3a9d49fc129ed2c780
Assessment: request_changes
The PR reuses the existing assignment casts, aggregate executors, and warning sink. The maintained SQL tests pass for the previously reported derived DECIMAL, catalog default, and conflict-update cases. A top-level UNION ALL still loses the numeric meaning of direct hexadecimal literals before DECIMAL assignment.
Model: gpt-6.2-sol / xhigh
Session: 01a1feb0-0427-7772-9d89-786820ec84a5 · slot 1 · generation 2
- P2
pkg/sql/plan/bind_insert.go:5494: Insert direct hexadecimal literals into a DECIMAL column with nonzero scale through a top-level UNION ALL. For example, insertSELECT 0x3e8 UNION ALL SELECT 0x64intoDECIMAL(4,1).
Impact: Strict mode accepts the statement and stores10.0,100.0even though0x3e8represents 1000 and exceeds the destination range. INSERT IGNORE stores the same values and emits zero warnings. An equivalent UNION ALL using decimal integers rejects the strict write atomically.
Evidence: The binder requiresprojectByAstto recover direct literals. The ordinary set-operation path atpkg/sql/plan/query_builder.go:5381leaves that field empty, so assignment interprets the bytes as coefficients at the destination scale. The MySQL protocol probe confirmed the result and the strict single-branch and decimal-integer controls. Preserve the literal origin of each direct branch through assignment so the existing DECIMAL range checks apply, while preserving the established derived-table and stored-definition behavior. Seeclosure-probe.jsonlandchecks/1795325001157499619-2.json.
Validation:
-
Isolation preflight, native build and input fingerprint verification, and
git diff --checkcompleted successfully. Receipts and logs are retained in the diagnostic directory. -
Selected race tests passed in
pkg/container/types,pkg/sql/colexec/aggexec,pkg/sql/plan/function, andpkg/sql/plan. The integer assignment and catalog default SQL tests also passed under race. Seefocused-race.jsonlandchecks/1795324854627434270-2.json. -
TestPR32002ReviewBoundariesandTestIssue31161ColumnDefaultMetadatapassed through the MySQL frontend on the non-race retry. Seefocused-sql.jsonlandchecks/1795324954679419339-2.json. -
The retained MySQL protocol probes confirmed the UNION ALL result and exercised stored FLOAT and DOUBLE rounding, FROM_DAYS operand types, and CHAR equality through INTERSECT and UNION. See
boundary-probe-retry.jsonl,closure-probe.jsonl, and their receipts.
Limitations:
-
The broader SQL regression reached the three-minute test timeout under race while it was still running. The successful retry covered it without race instrumentation.
-
The frozen CI snapshot reports successful multi-CN BVT and offline Python checks. Live Arrow and shutdown-upgrade coverage rely on earlier evidence. The local rounding and FROM_DAYS probes exercised MatrixOne without a live MySQL reference comparison.
Signed-off-by: XuPeng-SH <[email protected]>
|
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: b1bc02f6be5089846431ce076055e1eae802d0ac
Assessment: approve
The revised UNION path materializes radix literals as bytes before DECIMAL assignment, matching the supplied MySQL 8.0.45 control. Strict mode rejects invalid bytes atomically with error 1366. IGNORE stores zero and reports a warning for each invalid value. The fix reuses the shared set resolver, assignment casts, aggregate executors, and warning sink. Direct radix assignments and catalog defaults retain their established behavior.
Model: gpt-6.2-sol / xhigh
Session: 01a1feb0-0427-7772-9d89-786820ec84a5 · slot 1 · generation 2
Validation:
-
Focused planner, cast, and aggregate tests passed. See components-final.jsonl and checks/1795339938845628942-2.json.
-
The two-CN MySQL-protocol regression and an independent set-domain probe passed. They covered strict rejection, IGNORE warnings, nested sets, DISTINCT, LIMIT, and prepared rebinding. See sql-final.jsonl and checks/1795340088690051352-2.json.
-
The catalog-default metadata test reached PASS before its enclosing command timed out. See sql-retry.jsonl and checks/1795339993971529349-2.json.
-
Two offline Python tests passed, including conversion of widened MEDIAN results to Arrow Decimal256 values. See python-arrow-final.stdout and checks/1795339619560671119-2.json.
-
Verified the frozen 117-file delta, native inputs, clean checkout, and all 34 discussion entries. See validation-audit.log and discussion-assessment.json.
Limitations:
-
The broad local race run timed out. The successful local Go and SQL retries used ordinary instrumentation.
-
The distributed JDBC BVT and shutdown-upgrade results are author-reported. The local Python check exercised offline Arrow conversion.
🚫 Left the queue · pull request dequeued18 min in the queue, with no time running CI. So far
Reason Pull request #32002 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.
To get back in the queue
Merge conditions not met when it left the queue
Tick the box to put this pull request back in the merge queue (same as
2 merge conditions met
Times in UTC · dashboard · how the merge queue works |
What type of PR is this?
Which issue(s) this PR fixes:
Closes #28562, #28485, #28230, #28119, #28024, #27340, #27332.
What this PR does / why we need it:
Return SQL NULL when a finite DOUBLE input makes
DEGREESoverflow, and mark the result nullable for CTAS even when its source column is NOT NULL. Preserve CHAR PAD SPACE provenance throughCOALESCEandIFNULLkeys.Widen
MEDIAN(DECIMAL(38,s))to an exactDECIMAL(39,s+1)result and returnSUM(INT)asDECIMAL(32,0), including the single-group reuse path.Preserve prepared ENUM/SET parameter markers until the execution binding selects the label or numeric converter.
Apply DML assignment bounds and SQL-mode behavior to integer, DECIMAL, BINARY/VARBINARY, and DATE paths. Strict mode rejects invalid writes; non-strict and IGNORE adjust values and emit warnings. Preserve DATE text in strict VALUES assignments and clip rounded DECIMAL-to-integer values with 1264 warnings when adjustment is allowed. Keep safe literal fast paths and unchanged stored DECIMAL projections to preserve DML planning.
The CTAS
TIMESTAMPADDunit and preparedDATE_ADD/DATE_SUBcases were already fixed on the earlier base; this PR verifies their status alongside the remaining consolidated fixes.Release native test vectors, aggregate executors, and mpools when assertions fail. The merged MEDIAN flush-error fixture uses valid 37-digit inputs so it still exercises result ownership after
DECIMAL(38,s)widening.Preserve grouped outer-join domain pruning when bounded integer
SUMnow returns DECIMAL; keep unsafe bounds rejected. Update spill-recovery and dictionary-pipeline tests for the widened result type after merging upstream/main.Handle signed magnitude overflow, exponent notation, negative unsigned strings, and out-of-range numeric prefixes with trailing text when non-strict or IGNORE integer assignment clamps to target bounds. Detect discarded DATE clock fields before fractional rounding, warn on DECIMAL scale loss for literal and quoted inputs, map precision 39–76 to Arrow Decimal256, and allow nested MEDIAN over Decimal256.
Accept Decimal256 values in
APPROX_PERCENTILE, including the widened result of groupedMEDIAN(DECIMAL(38,s))in stored views. Retain the decimal precision and scale and use the existing quantile sketch, rounding rule, and mergeable state format.Include the original VALUES row in integer assignment range warnings, including MEDIUMINT.
Validation of the rebase and follow-up
d88197a97fb. All eight patches match their pre-rebase diffs.TestPR32002ReviewBoundaries. Incremental gofmt, diff check, go vet, golangci-lint, and molint passed.2.0from both a grouped DECIMAL median view and a derived table. AnINSERT IGNOREinto TINYINT stored1,127and reported warning 1264 at row 2. An isolated shutdown upgrade from v4.2.8 preserved the result of a stored percentile view over grouped DECIMAL medians.Earlier validation
mainat517e169538, complete CGo-linked tests passed forpkg/sql/plan/functionandpkg/sql/plan(26.0s and 70.5s at that revision). The previously failingTestSQLTaskAlterAfterTriggerOnRealStoragepassed three consecutive local runs with coverage instrumentation. CGo-configured-vet=allpassed for both packages. Focused tests cover CTAS nullability, strict DATE VALUES rejection and valid-date control, and DECIMAL VALUES in strict, non-strict, and IGNORE modes. Direct DECIMAL assignment tests cover signed and unsigned targets, three DECIMAL widths, and rounding boundaries.pkg/sql/colexec/aggexec,pkg/sql/colexec/group, andpkg/sql/compile; the focused dictionary-pipeline race regression passed. Earlier local SQL BVT and MySQL binary-protocol checks covered DML modes, aggregate types, CHAR keys, and prepared ENUM/SET.Mixed VALUES diagnostics follow-up
Integer assignment follow-up
DECIMAL radix assignment follow-up
0x64storing10.0and0xffffstoring6553.5inDECIMAL(4,1)on the previous head. The fixed build stores100.0for the first input, rejects the second in strict mode, and stores999.9with one warning 1264 in non-strict or IGNORE mode. The regression checks that strict rejection preserves the previously stored row.03f5d055321e. All ten earlier patches are unchanged by rebase. The follow-up passed independent design and code review.Vector rebase and radix assignment compatibility
7f6729277e5a. The aggregate and VALUES operators follow upstream MPool and batch selection ownership while preserving Decimal256 MEDIAN and original VALUES warning ordinals.51.0000while its declared default was0.0051.0.0051when a new row was inserted on the rebased binary. The focused BVT passed all 45 statement comparisons with JDBC header comparison disabled. The Go SQL regression independently checked both column-default metadata surfaces.Derived DECIMAL assignment and conflict-action columns
da97e91e194d, which removed the old vector binary flag. Use the upstream argument flag for integer and opaque binary inputs. Preserve DECIMAL coefficient conversion through projected binary CHAR/VARCHAR and pass the unsigned admission result to the outer cast as text.Set-operation DECIMAL assignment follow-up
A standalone hexadecimal literal can supply its numeric magnitude to a DECIMAL assignment. A SQL set operation instead materializes the column in its resolved string domain. MySQL 8.0.45 rejects the reported binary UNION ALL in strict mode with 1366. IGNORE and non-strict mode store two zeros and report two 1366 warnings.
The shared set-column resolution materializes binary winners as VARBINARY or BLOB and applies implicit text winners. Width is bounded in bytes for binary results. Prepared type refresh uses the same rule. DECIMAL and UNSIGNED checks consume the completed set result, so DISTINCT, ORDER BY and LIMIT retain their own row semantics. Byte strings containing a spelling such as
0x10follow the decimal text grammar. Direct literals and stored-definition decoding retain their original owners.The rebase onto
46079446d00dcarries all 14 previous patches. The 57 checks matched stored results and diagnostic codes for 19 cases against MySQL 8.0.45, including strict and IGNORE assignments, lexical and range failures, UNSIGNED DECIMAL256, stronger text collation, and atomic ODKU rejection. Seven CTAS domain checks, the CTE and prepared reuse, DISTINCT, LIMIT, and raw-byte controls also passed.The two new planner and DECIMAL executor regressions passed under race. Incremental static checks for the PR's changed Go packages passed with zero findings. Validation used the new regressions and standalone SQL probes.
Set column metadata and diagnostics
The set planner measures literal byte lengths when it materializes a binary column. The shared literal constructor keeps the character width expected by ordinary string expressions. Normal and prepared set planning share the same byte bound calculation and collation resolution. This restores the existing CTAS and JDBC metadata while preserving the payload of HEX and BIT set branches.
DECIMAL assignment still consumes the completed set result under its resolved string domain. The reviewed UNION example rejects the whole strict write with 1366. With IGNORE it stores two zeros and emits one 1366 warning per value, matching the reported MySQL control. The existing diagnostic formatter now repairs malformed bytes in its bounded samples so clients can read both warnings.
Rebased on
f3be95188736. The first 14 patches are equivalent and the metadata and warning changes are included in the final set column commit. Local two-CN JDBC comparison passed all 216 executed checks, including the four previously failing binary-function metadata checks in PROXY. One existing case was skipped by its BVT tag. The public SQL regression, focused warning race, and incremental lint passed. Full short race suites passed for planner and casts before the final warning formatter change, which has separate race coverage.The publication lock test passed in local race runs on clean main and the final candidate. An earlier candidate run failed in a different subcase from the CI account-creation timeout. The new CI run will retest it in the Linux runner environment.