Repository navigation
Fix ENUM and SET assignment compatibility with MySQL - #30683
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? |
Align legacy ENUM assignment diagnostics and assert failed INSERT SELECT and ALTER preserve data. Covers matrixorigin#30538.
1c3aeb4 to
18b6c69
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: 18b6c693d215f61b2aeae221dfae2b36f9645a88
Assessment: approve
Reviewed the complete 30-file delta, linked issue, callers, diagnostics ownership and test coverage. Shared parsing and runtime policy address the assignment contract without duplicating execution paths. No actionable defect remains.
Model: gpt-6-astra / xhigh
Session: 01a15209-2c6d-71e2-b8f3-aa17387fa283 · slot 2 · generation 0
Validation:
-
Reconciled exact-commit CI run 39534804649: normal coverage execution, race-test stages, shared build and static analysis succeeded.
-
The MySQL-protocol regression passed in 8.27 seconds, covering warning counts, prepared mode changes, strict rollback and sentinel reads.
-
All nine affected BVT files have successful reports; the new regression passed 74/74 statements without skips.
-
Cross-checked numeric fallback rules against MySQL 8.0.46 implementation: https://github.com/mysql/mysql-server/blob/mysql-8.0.46/sql/field.cc.
-
Local evidence audit passed with receipt checks/1792555410201631710-5.json. Verified clean source, patch contents, artifact hashes and retrieval receipts. Retained report: /home/xupeng/.local/state/mo-bot/jobs/ad6cd9326a2c4417f182631d/attempt-1/evidence-audit.json.
Limitations:
-
Reused CI; no local native-test or same-instance BVT repeat. Retained summaries omit individual pass lines for some fast unit tests.
-
No fresh MySQL differential or performance run; the author's 428-observation claim was not independently verified.
-
Decimal/floating assignments and the preexisting grouped ENUM sentinel/declared-empty ambiguity remain outside the fix.
Merge Queue Status
This pull request spent 4 hours 58 minutes 41 seconds in the queue, including 54 minutes running CI. Required conditions to merge
|
aptend
left a comment
There was a problem hiding this comment.
Deep review of exact head 18b6c69 against base/merge-base 63a964a. Read the complete 30-file delta, #30538, all review/discussion history and the empty inline/thread collections. No blocking findings.
Checked scalar/indexed parsing against the MySQL 8.0.46 Field_enum/Field_set implementation, including decimal spelling/length boundaries, end spaces, raw padded labels, quoted versus typed numbers, zero/empty members, overflow and full 64-bit SET masks. Current-execution strict/IGNORE policy, masked/null rows, hard metadata failures and bounded diagnostic ownership remain coherent. IGNORE literals now retain the runtime warning owner; the existing volatile conversions avoid bind-time policy capture. Stored ENUM zero is recovered safely for reversible ORDER/numeric display paths without a fresh-assignment warning. Strict import wrappers remain strict; no storage/wire/function-overload format changed. The documented decimal/floating and pre-existing declared-empty grouped-display ambiguity exclusions are not represented as fixed.
Independently verified and reused exact-head CI 39534804649: raw UT 119008922123/checkpoints cover owning moerr/types/external/function/plan/embed packages under race; the real MySQL-protocol regression explicitly passes in 8.27s. Normal coverage 119008955976 used -count=1 and exited 0 (83,335 pass events, no failures); raw SCA 119008922103 completed vet/molint and golangci-lint with 0 issues. All nine affected BVT files have successful execution reports across jobs 119011610880/119011610913: the new regression passes 74/74 with no skipped/failed/abnormal statements; existing add/drop retains six already-ignored statements, not counted as passes. Strict rejection/atomicity oracles are preserved or strengthened. Local gofmt/diff --check are clean.
No equivalent native builds/tests were repeated locally, and the author's 428-observation MySQL differential claim and same-instance BVT repetition were not independently reproduced.
…3269afc4b9d7dd232175fbf420b91a31849494f
## What type of PR is this? - [x] BUG ## Which issue(s) this PR fixes: Ref #30538 (follow-up: #30683 fixed the value side; this fixes the label side) ## What this PR does / why we need it: MySQL removes trailing spaces from ENUM members at `CREATE TABLE` and rejects members that are duplicates after that. MO stored labels verbatim, so `ENUM('a ','b')` kept `"a "`, and only the exact input `'a '` matched it: `'a'` and `'a '` were rejected (strict) or truncated to 0. | labels | input | before | after (= MySQL) | |---|---|---|---| | `'a ','b'` | `'a'` | 0 / error | 1 | | `'a ','b'` | `'a '` | 0 / error | 1 | | `'a','b'` | `'a '` | 1 | 1 | **Changes** - **DDL** (`build_util.go`): new `types.NormalizeEnumValues` trims trailing ASCII spaces from labels and rejects members equal case-insensitively after trimming (`duplicate enum member`), mirroring the existing `NormalizeSetValues`. Leading spaces, NBSP and tabs stay significant. - **Lookup** (`types.ParseEnum` and the batch `enumValueIndex` in `func_mo.go`): one pass comparing with trailing spaces trimmed on both sides, so tables created before this change with padded labels also match. Both paths keep identical semantics. **Behavior change for legacy definitions:** a table created earlier with labels equal after trimming (e.g. `ENUM(' ','red','')` from the #29840 test, which MySQL rejects) now resolves both `' '` and `''` to the first such label. Already-stored rows are unchanged. Tests that pinned the old raw-first matching were updated accordingly. **Tests** - New: `TestNormalizeEnumValues`, `TestEnumDDLRejectsMembersEqualAfterTrim`, ENUM cases in `TestEmptyDomainTypeReplay` (DDL → format → replay round trip). - Updated: `TestEnumAssignmentParsing`, `TestEnumValueIndexAssignmentBoundaries` (covers both linear and indexed paths), `TestMySQLSpecialOrderProvenanceRejectsNonReversibleEnum`, two `external` LOAD tests. - BVT `load_data/issue_29840_load_empty_enum_set.sql`: its table used `ENUM(' ','red','')`, now invalid DDL; switched to `ENUM('red','')` and added a statement asserting the duplicate DDL is rejected. - Unit tests pass locally for `pkg/container/types`, `pkg/sql/plan`, `pkg/sql/plan/function`, `pkg/sql/colexec/external`, `pkg/sql/compile`, `pkg/frontend`. - BVT: regenerated `.result` for `load_data/issue_29840_load_empty_enum_set` (member indexes shift; duplicate DDL rejected) and `dtype/enum` (padded labels now trimmed, so their display, `length`, `reverse`, `concat`, `rpad` and `find_in_set` results follow). Ran all 71 BVT case files that use `enum(` against a dev cluster built from this branch: 0 failures. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
What this PR does / why we need it:
Accept MySQL-compatible trailing spaces and decimal ENUM/SET spellings. Non-strict assignments and INSERT IGNORE now retain the ENUM error member or valid SET bits and report truncation warnings; strict assignments return 1265/01000 and preserve statement atomicity.
Share parsing between scalar and indexed conversion, resolve the current execution mode, keep warning retention bounded, and route IGNORE literals through runtime diagnostics. Preserve strict import parsing and recover stored ENUM ordinal zero safely for internal ORDER BY.
Validation: owning type/error/function/planner/external packages, public MySQL-protocol regression, 428 recorded MySQL oracle observations, full embed package, incremental vet/lint, and mo-tester comparisons of the new regression twice plus existing ENUM/SET/numeric cases.
Compatibility scope covers strings and signed/unsigned integer assignments. Existing raw padded ENUM labels remain valid. Decimal/floating conversion and the existing grouped sentinel/declared-empty ambiguity remain outside this change. Please leave the issue open for reporter verification after merge.