Repository navigation
fix(plan): MySQL implicit boolean semantics for ENUM/SET, BIT literals and JSON conditions - #31492
Conversation
f10ef47 to
67d17dd
Compare
…s and JSON conditions Restore the MySQL boolean/numeric coercion contracts for the consolidated group matrixorigin#30931: ENUM/SET truthiness, BIT value-literal folds and in-domain JSON IF/CASE conditions. - ENUM/SET boolean contexts consume the stored ordinal/bitmap instead of display text, with identity-based storage recovery across grouping, DISTINCT and derived boundaries; ambiguous declarations fail closed with a typed error, and MatrixOne-native sessions keep base behavior. - BIT value literals fold their numeric payload in MySQL-mode boolean contexts; genuine strings keep raw-byte text truth. - IF/CASE admit JSON scalar conditions with MySQL conditional numeric coercion; JSON null selects the ELSE branch distinct from SQL NULL, and the strict JSON->BOOL cast outside IF/CASE is preserved. - Versioned remote/persisted expression contracts: the MORPCVersion135 feature and the same-version cross-mode consumption gate cover ENUM storage-truth and T_json conditions, while SET storage conditions stay exempt - their numeric executors are unchanged, so native sessions keep base access to SET persisted/generated expressions. - Design revision 8 is committed at docs/design/20261027-implicit-boolean-semantics-enum-set-bit-json.md. UT/BVT regressions cover the five-row truth tables, WHERE/logical operators, CAST zones, BIT-literal matrices incl. prepared execution, JSON reference vectors, persisted generated-column round-trips, and native/MySQL mode pairing through ordinary and server-prepared execution. Related to matrixorigin#30931 Related to matrixorigin#30930 Related to matrixorigin#30932
…c test The SCA job of CI run 40629398512 (attempt 1) failed at the license-header gate: pkg/sql/colexec/evaluate_case_json_bool_test.go was the only file in the checked tree without a valid Matrix Origin license header. Prepend the canonical 14-line header, byte-identical to the other new files in this PR. No code change.
c209aee to
adc62e8
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-local · review
Commit: 0d022fcced4279c304fb6b1690fbb900f9d298ba
Assessment: request_changes
The existing P2 protocol-gate finding remains open. The author accepted its removal, but that revision has not been pushed. The SET expectation corrections are supported.
Model: gpt-6-astra / xhigh
Session: 01a1869d-999c-7481-b340-ae4a63e8cee4 · slot 1 · generation 2
- P2
pkg/defines/const.go:173: This expression-semantics change still introduces MORPCVersion135 and extends remote and persisted-expression gates. The unchanged shutdown-upgrade contract explicitly prohibits new per-feature versions and gate extensions; neither permitted exception applies here.
Impact: The bump feeds a durable HAKeeper floor raise and admission/revalidation cycle, while affected multi-CN expressions acquire capability checks and fallback/refusal paths. Remove this PR’s version bump and version-gate wiring, retaining unrelated existing gates and the separate session-mode protections, including the SET exemption. This is a design-policy violation, not a demonstrated production failure.
Evidence: upgrade-compatibility.md:16-42 under .agents/skills/mo-dev/references; pkg/sql/compile/expression_protocol.go:63-73,162-163; pkg/sql/plan/persisted_ip.go:247-248; pkg/logservice/store.go:1170-1176; pkg/hakeeper/view_metadata_admission.go:600-607,649-678. Supplied issue_comments:6514067680 accepts removal but explicitly reports no pushed implementation.
Validation:
-
Read the complete 42-file delta and reconciled all six discussion keys; saved review-plan.md, discussion-assessment.json, review-record.md and validation-ledger.json.
-
git diff --check passed: checks/1793331506586125618-2.json; retained diff-check stdout/stderr logs.
-
Source and artifact audit passed: checks/1793331506836256439-2.json; verified frozen head, unchanged source/policy, patch inventory and exact discussion coverage.
-
Supplied head-matched CI snapshot reports successful build, UT, SCA, coverage and proxy/pessimistic multi-CN BVT.
Limitations:
-
Dependent implementation validation stopped at the design blocker; no new Go tests, BVT runs or benchmarks were executed.
-
Raw CI logs, author local validation logs and the proposed local revision 9 were not supplied.
…tracts Design revision 9 of the shared design doc rescopes D8 after the mo-bot round-9 review (PR matrixorigin#31492 CHANGES_REQUESTED): under the repository's shutdown-only upgrade contract (.agents/skills/mo-dev/references/upgrade-compatibility.md) peers inside one cluster always run the same binary, so the corrected conditional- boolean semantics ship without a per-feature protocol version and without version gates - the fence protected an unsupported mixed-version deployment while durably tripping the HAKeeper floor-raise and admission machinery. - Unmint MORPCVersion135 and restore MORPCLatestVersion = MORPCVersion134; pkg/defines/const.go is byte-equal to main again and every pre-existing gate row for the 104-134 features stays untouched. - Remove the JSONBooleanConditionContracts version-gate wiring: the remoterun encode floor raise and the below-135 delivery refusal, the remoteExpressionProtocolVersion requirement, the remote-destination version tuple, and the persisted feature->version table row (the parameterized helper is inlined back into RequiredPersistedExpressionProtocolVersion). - The share-walk flag keeps exactly one consumer: the same-version cross-mode consumption gate RequireMySQLConditionalBooleanConsumption (SET storage exempt per finding F8), so MySQL-mode sessions serve persisted ENUM/JSON contract definitions while native-mode sessions keep base's typed refusal; the walk-side comments are reworded to the mode-gate purpose. - Delete the fence-only tests (pkg/sql/compile/boolean_condition_ contracts_protocol_test.go, pkg/hakeeper/view_metadata_boolean_ contracts_test.go, pkg/cnservice/view_metadata_boolean_contracts_test.go in full; the persisted floor/reader-lacking/gate-simulation tests and the cross-mode version-simulation test within kept files) and add TestBooleanConditionContractDetectionOnBoundExpressions pinning the feature walk over real bound ENUM/JSON expressions with a zero requirement from RequiredPersistedExpressionProtocolVersion and numeric negative controls. The three members' recorded truth values are untouched by this removal; the two frozen issue_30931 BVT cases and their two-binary receipts (fixed 259/259 vs pristine base 153/259) remain valid. Post-repair focused validation (repository CGo environment): changed-closure go build green; go vet over pkg/defines, pkg/pb/plan, pkg/hakeeper, pkg/cnservice, pkg/sql/plan, pkg/sql/compile exit 0; gofmt clean; the 22-test plan retention battery and the 86-test Persist battery green; full pkg/pb/plan ok; compile TestViewMetadataSender*/TestJSONStringConsumer* ok. Design revision 9 (independent design-review PASS 2026-10-30, content hash dd7f1b0a57e9e4e486ca21e039f3d19fc850c6b78d171b57c286ba38a80984d5) is committed at docs/design/20261027-implicit-boolean-semantics-enum-set-bit-json.md. Related to matrixorigin#30931 Related to matrixorigin#30930 Related to matrixorigin#30932
|
Addressed — the accepted removal is now on the branch. This review assessed Every anchor of the P2 finding was re-verified at the pushed head:
Validation receipts on the pushed commit (repository CGo environment; logs retained): changed-closure build exit 0; Re-requesting your review of head |
|
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: a811f13760b6aa6442d2f9d98e4d02da2cb8026b
Assessment: approve
The prior protocol-gate blocker is resolved. Review of the complete delta, affected consumers and discussion found no actionable defects. Native-mode behavior, the SET exemption and documented cross-block recovery boundaries remain intact.
Model: gpt-6-astra / xhigh
Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2
Validation:
-
Recovered attempt-1 review after verifying unchanged source fingerprints, patch, discussion and substantive validation evidence.
-
git diff --check passed; receipt: attempt-2/checks/1793345260102194981-3.json; retained diff-check logs.
-
Static audit passed: frozen head, clean source, 35-file inventory, gate removal, design hash and all nine discussion keys. Receipt: attempt-2/checks/1793345260133926561-3.json; retained static-review-audit logs.
-
Supplied head-matched CI reports successful build, UT, SCA, coverage and proxy/pessimistic multi-CN BVT. Reused semantically matching author-reported BVT and prepared-statement evidence.
-
Saved review-plan.md, discussion-assessment.json, source-closure.md and validation-ledger.json in attempt-2.
Limitations:
-
No new Go tests, SQL/JDBC executions, upgrade tests or benchmarks were run locally.
-
Raw CI and author validation logs were unavailable; supplied execution reports were not independently reproduced.
🚫 Left the queue1 h 50 min in the queue, with no time running CI. So far
Reason Pull request #31492 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.
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. Merge conditions: 2 of 3 metThis pull request
The batch, tested in place
Tick the box to put this pull request back in the merge queue (same as
Times in UTC · dashboard · how the merge queue works |
What type of PR is this?
Which issue(s) this PR fixes:
Related to #30931
Related to #30930
Related to #30932
What this PR does / why we need it:
Consolidated group #30931: ENUM/SET truthiness, BIT value literals, JSON IF/CASE conditions. Each defect traces to a surface consuming display text or a strict cast where the stored payload was required.
Root causes
IF(e,1,0)/IF(s,1,0)returned 0 for every nonzero ordinal/bitmap,WHERE e/sande AND 1failed with 'a' is not a valid bool expression', grouped/DISTINCT boundaries lost storage identity, and numeric SET IN/NOT IN comparisons re-parsed labels after a review-round condition narrowing. On the persisted path the binder binds raw storage (uint64/T_enum), which base already evaluates correctly - so the r8 round also removed an over-broad feature classification that refused native sessions access to SET generated expressions base serves.b'1'/b'0'reached the raw-byte text truth paths instead of their numeric payload in logical operators, NOT/XOR, IF/CASE and prepared execution. BIT columns stay with [Bug]: DECIMAL values in a boolean context (AND/OR/NOT/XOR/CASE WHEN/WHERE) fail with 'bad value [DECIMAL64 BOOL]' #30922 by acceptance checklist.iffCheck/caseCheckexcluded T_json conditions and the table-path CASE evaluator assumed a BOOL condition vector (panic on a JSON vector); the strictjsonScalarToBoolcast path was also applied inside IF/CASE.Fix (approved design revision 9, committed at docs/design/20261027-implicit-boolean-semantics-enum-set-bit-json.md, content hash dd7f1b0a57e9e4e486ca21e039f3d19fc850c6b78d171b57c286ba38a80984d5)
MORPCLatestVersionbump and no version gate; the provisional MORPCVersion135 fence and its remote/persisted gate wiring from design revisions 2-8 are removed. The sharedJSONBooleanConditionContractswalk has exactly one consumer, the same-version cross-mode consumption gate for persisted T_json conditions and ENUM storage-truth expressions (RequireMySQLConditionalBooleanConsumption); SET storage conditions are exempt (revision 8 / review finding F8, retained) because their numeric executors are unchanged - native sessions keep base access to SET persisted/generated expressions across authoring, SELECT, INSERT and UPDATE, and no base-supported catalog definition is native-inaccessible.Issue -> test proof (all commands run in the isolated validation environment of the agent run; receipts preserved in the run logs)
test/distributed/cases/dtype/issue_30931_enum_set_bool_truthiness.testandissue_30931_consolidated_boolean_semantics.test(230 statements incl. the five-row truth tableIF/S+0values,WHERE e-> 1,2,4,5 andWHERE s-> 1,2,5, logical operators, CAST zones, grouping/DISTINCT boundaries, tiered zone cells, the native/MySQL DML pairs, the SET numeric-IN restores and the 29-statement SET persisted section). Two-binary receipts: fixed binary 259/259 across the two cases (consolidated 230/230 + enum_set 29/29, zero corruption hits); pristine base binary 153/259 with exactly the pre-fix contract-cell failures and every r8 SET persisted statement green (base-compatible parity). Focused UT:go test ./pkg/sql/plan -run 'TestIfConditionBindsEnumSetStorage|TestWherePredicateCastsEnumSetStorage|TestLogicalOperatorsAndCaseCastEnumSetStorage|TestNumericSetInListRecoversStorageAcrossBoundaries|TestExplicitBoolCastBindsGroupedStorage|TestCrossBlockExplicitBoolCastFailsClosed|TestBooleanConditionContractDetectionOnBoundExpressions|TestSetStorageConditionsExemptFromBooleanContracts|TestCrossModeConsumptionGateRequiresMySQLMode'- red on the pre-fix tree, green after (native-mode and zone controls included).b'1' AND 1,b'0' AND 1,NOT b'1', XOR,CASE WHEN b'1', ordinary and server-prepared execution, and native-mode DML assignment rejections with alive checks - green on the fixed binary and red on base in the same two-binary cycles; Connector/J battery 25/25 PASS lines incl. prepared reexecute/rebind and connection-usability-after-error.tjxpersisted generated-column round-trip (catalog authoring, INSERT/UPDATE recompute, SELECT reread, native typed refusals with alive checks and no rows written, MySQL retry committing) - green on the fixed binary, red on base in the same cycles.Test commands (validation ladder actually executed)
go test ./pkg/sql/planfull package (ok; repeated each revision round),make buildgreen each round.bash run.sh -p test/distributed/cases/dtype -m run -t 1 -r 100 -i issue_30931_consolidated_boolean_semantics,issue_30931_enum_set_bool_truthinessagainst the fixed binary and against the pristine base binary (same lock files, second frozen result) - fixed 259/259, base 153/259 with every new r8 statement green, failure population identical to the previous round (sorted diff empty).enumset_where_eas ServerPreparedStatement, rebinds,json_conditions,connection_usable_after_error,source_rows_unchanged: 25/25 PASS.go vet+golangci-lint --new-from-revover all changed packages (this run).Residual risks
Rebase receipt (2026-10-28, conflict resolution)
make buildgreen (binary stamped 67d17dd). BVT pair re-run on the rebased binary: genRS regeneration of the consolidated case is byte-identical to the committed frozen .result (SHA256 7280b83da7c7f8f76c5a06336bb8c7bbcbd0990b10a5c221291a3a4f3ef8df65), both frozen cases 259/259 at 100% (230/230 + 29/29, zero corruption hits), and main's merged behavior introduces no drift in any of the 230 expectation cells. Connector/J server-prepared battery: 25/25 PASS incl. rebinds, json conditions, connection_usable_after_error, source_rows_unchanged. Owned validation services for both runs shut down cleanly with all 27xxx listeners released.SCA receipt (2026-10-28, CI run 40629398512 attempt 1, job "Matrixone CI execution / SCA Test on Linux/arm64")
pkg/sql/colexec/evaluate_case_json_bool_test.go, added by this PR without the Apache-2.0 Matrix Origin header. The other 33 PR-changed .go files were valid, so the gate failure is fully attributable to that file.make static-check-selectedover every PR-owned package reproduces CI's passing SCA baseline: the pinned molint recipe prints the identical pre-existing finding set seen in the green run of merged PR fix: correct ROUND/TRUNCATE extreme-digits overflow and make VARIANCE raise out-of-range (#31154, #31355) #31434 (run 40610550148) with zero new diagnostics from this PR, and golangci-lint v2.14.0 (the pinned recipe version) reports 0 issues.Rebase receipt 2 (2026-10-28, conflict resolution onto e9dc8c4)
check = legacyFloatStringCheck(ctx, check, args)immediately beforeswitch check.status- the same spot this PR added the two D11 gates (native-mode IFF/CASE legacy condition admission, ENUM->BOOL cast-pair gate). Semantic resolution keeps both, in main's order: the D11 gates first, then main's legacyFloatStringCheck as the final pre-switch override. In MySQL-contract mode the gates are inert and binding is byte-identical to main; in native mode the gates restore pre-contract admission first and the catalog-repair float-width narrowing (LegacyFloatStringBounds; it only adjusts float64->varchar(34) cast widths under succeedWithCast) then applies exactly as on main. range-diff confirms the replay is otherwise hunk-identical and the PR diff/file set is unchanged versus the previous head.make buildgreen (exit=0, mo-service binary stamped CommitID adc62e8);go test ./pkg/sql/plan/functionok 84.022s (full package - upstream's func_cast_test.go plus this PR's func_cast_enum_bool_test/operatorSet_test additions);go test ./pkg/sql/planok 375.972s (full package - this PR's boolean-contract batteries plus main's float_string_/integer_precision/numeric_context suites, all green on the merged semantics); targeted batteries green: pkg/sql/colexec TestEvalCaseJsonCondition ok 3.894s, pkg/sql/colexec/group TestGroupJointGroupingFlagsPreserveStorageTruthOnActiveArms ok 2.204s, pkg/sql/compile TestBooleanConditionContract* ok 3.969s, pkg/cnservice TestCNViewMetadataSameGenerationFutureFloorPoisonsWithoutRevocation ok 2.850s, pkg/hakeeper TestPersistedFloorExpiryReleasesWithoutShutdownEvidence ok 1.325s, and pkg/defines + pkg/pb/plan ok (0.856s/2.592s, run right after the rebase with the equivalent plain environment). All three issue proofs (ENUM/SET IF/WHERE/logic recovery, BIT-literal payloads, JSON IF/CASE in-domain evaluation) are exercised inside those packages on the new base; every step exit=0.CI-alignment receipt (2026-10-29, compose-pessimistic BVT failure in run 40665475705, job 122744108573)
group by ... count(*)queries over theSET('', 'a')andSET('z', '', 'a')fixtures carried pre-contract expectations that merged the zero bitmap with the empty-label member into one display group. Under this PR's D1 composite (display, storage) group key those rows are separate groups that both display''exactly like MySQL (recorded MySQL 8.3.0 reference; the analogous fixture documents MySQL duplicate-key 1062 in mysql_compat_enum_set_numeric.result), so the buried rows were stale relative to the reviewed contract.GROUP BY x ORDER BY xover an empty-label declaration the corrected rows cluster the equal-display groups together (the fix(plan): preserve ENUM and SET identity for ordering and aggregates #29177 canonical-display order key is intentionally preserved) rather than interleaving members by raw storage value as MySQL would; the grouped truth contract itself is unaffected and the same-block/oracle batteries pin it. CI re-runs the full BVT population on the new head.CI Requiredgate, confirming the set.sql alignment on the CI population.Design revision 9 receipt (2026-10-30, review-driven fence removal)