Skip to content

fix(plan): MySQL implicit boolean semantics for ENUM/SET, BIT literals and JSON conditions - #31492

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-30931-main-8c225c46
Oct 30, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-30931-main-8c225c46

Conversation

@gouhongshen

@gouhongshen gouhongshen commented Oct 28, 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:

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

Fix (approved design revision 9, committed at docs/design/20261027-implicit-boolean-semantics-enum-set-bit-json.md, content hash dd7f1b0a57e9e4e486ca21e039f3d19fc850c6b78d171b57c286ba38a80984d5)

  • Stored-payload truth for ENUM ordinals/SET bitmasks across IF, CASE WHEN, predicates and logical operators, via identity-based recovery (direct storage, hidden grouped slot, reversible-label decode) that fails closed with a typed error for ambiguous declarations; every boundary keeps exact grouped identity (D6/D10) and explicit CAST ... AS BOOL consumes storage on every grouping/DISTINCT/derived boundary.
  • One mode gate (D11): MySQL-mode statements evaluate the corrected contracts; MATRIXONE_NATIVE statements keep byte-identical base behavior on every boolean surface, incl. DML assignment casts and the native joins of logservice/persisted write paths.
  • BIT value literals use the numeric payload in MySQL-mode boolean contexts; DML assignments keep base's raw-payload rejection in native mode.
  • JSON scalar conditions evaluate in-domain with MySQL conditional numeric coercion; JSON null selects ELSE and stays distinct from SQL NULL; strict JSON->BOOL cast is preserved outside IF/CASE; prepared/binary execution is covered, and the persisted T_json generated-column round-trip carries the same-version cross-mode consumption gate (tjx): MySQL-mode sessions serve it, native-mode sessions keep base's typed refusal.
  • Remote/persisted compatibility (design revision 9): under the repository's shutdown-only upgrade contract every in-cluster peer runs the same binary, so the corrected contracts ship with NO per-feature protocol version, no MORPCLatestVersion bump and no version gate; the provisional MORPCVersion135 fence and its remote/persisted gate wiring from design revisions 2-8 are removed. The shared JSONBooleanConditionContracts walk 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)

  • [Bug]: ENUM and SET values are false in IF() and rejected in WHERE despite nonzero ordinals #30931: test/distributed/cases/dtype/issue_30931_enum_set_bool_truthiness.test and issue_30931_consolidated_boolean_semantics.test (230 statements incl. the five-row truth table IF/S+0 values, WHERE e -> 1,2,4,5 and WHERE 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).
  • [Bug]: BIT value literals fail in logical operators despite numeric semantics #30930: BIT-literal cells inside the consolidated case - 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.
  • [Compatibility]: IF and CASE WHEN reject JSON scalar conditions accepted by MySQL #30932: seven-row JSON IF/CASE reference vectors (0,1,1,0,1,0,0 with JSON null distinct from SQL NULL), prepared JSON cells and the tjx persisted 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/plan full package (ok; repeated each revision round), make build green each round.
  • mo-tester pair on the two frozen cases: 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_truthiness against 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).
  • Connector/J server-prepared battery incl. enumset_where_e as ServerPreparedStatement, rebinds, json_conditions, connection_usable_after_error, source_rows_unchanged: 25/25 PASS.
  • Final self-check pre-commit: gofmt + go vet + golangci-lint --new-from-rev over all changed packages (this run).

Residual risks

  • Zone-3 fail-closure is deliberate: ambiguous empty-label/duplicate-label declarations reject cross-block boolean/CAST recovery with a typed error instead of guessing (MySQL keeps separate groups; the loud error is the safe choice).
  • Native mode is intentionally the pre-change surface: it keeps base's text-truth quirks (including the historical BIT-payload byte in the native DML error) so upgrades stay byte-compatible; the corrected semantics are the MySQL-mode default.
  • Rollout follows the repository's shutdown-only upgrade contract (design revision 9): releases restart every in-cluster peer onto the same binary, so the corrected contracts carry no per-feature protocol version and raise no HAKeeper floor; mixed-version execution inside one cluster is an unsupported deployment mode, not a condition this PR fences. The one retained hazards surface is same-version cross-mode: native-mode sessions refuse persisted ENUM/JSON contract definitions through the consumption gate.
  • BIT columns remain out of scope (tracked by [Bug]: DECIMAL values in a boolean context (AND/OR/NOT/XOR/CASE WHEN/WHERE) fail with 'bad value [DECIMAL64 BOOL]' #30922), and JSON conditional semantics outside IF/CASE keep the strict pre-change cast. Broader CI suites (full distributed BVT, frontend/disttae) remain for CI; the focused batteries and the two frozen cases carry the reproduction-and-repair proof.

Rebase receipt (2026-10-28, conflict resolution)

  • main advanced to f847803 and minted MORPCVersion132-134 in the same const-block tail this PR claims 135 in, so Mergify's auto-update failed to merge and the PR went CONFLICTING. Resolution: rebased onto f847803; pkg/defines/const.go keeps main's ladder verbatim (132 decimal float rounding, 133 typed JSON MIN/MAX, 134 ordered ODKU baseline) and applies only this PR's semantic delta: MORPCVersion135 + MORPCLatestVersion = MORPCVersion135 (net +2/-1 vs main) - historical: superseded by design revision 9 below, which removed the mint so pkg/defines/const.go is byte-equal to main again. The provisional whole-block realignment (and its anticipation comment) was dropped so the file carries no formatting churn; every protocol gate and constant is byte-equal to the reviewed design. All other overlapping files (plan/colexec/compile/pb-plan protocol surfaces) auto-merged and both sides' feature floors (132/133/134 from main + 135 from this PR) coexist and compose.
  • Post-rebase validation on the merged tree: full-package UT green for pkg/sql/plan (ok 48.089s), pkg/sql/plan/function (ok 15.672s), pkg/pb/plan + pkg/defines, plus targeted green for the PR batteries in pkg/sql/colexec/colexec group, pkg/sql/compile (PR boolean-condition contracts + main's Float/JSONMinMax/ODKU/LASTInsertID protocol neighbors incl. TestProtocol132FloatComposesWithJSON133AndODKU134), pkg/cnservice and pkg/hakeeper view-metadata/floor tests; make build green (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.
  • The pristine-base red pairing (153/259 with the pre-fix failure population) remains valid from the pre-rebase round: the frozen cases, expected results, and the defect's pre-fix refusal receipts are unchanged by the rebase, and the rebased fixed binary reproduces the identical green population, so the red/green discrimination is carried by the same paired evidence.
    SCA receipt (2026-10-28, CI run 40629398512 attempt 1, job "Matrixone CI execution / SCA Test on Linux/arm64")
  • The SCA job failed at the license-header gate before any analyzer ran: license-eye v0.4.0's full check (full mode forced by an infra-side config-pin mismatch; scope-only effect) reported exactly one invalid file in CI's 73758-file tree - 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.
  • Fix (follow-up commit on this branch): prepend the canonical 14-line header, byte-identical to this PR's other new files. Comment-only diff, zero behavior change: gofmt-clean, and the two focused UTs in the file re-run green on the fixed tree.
  • Exact-mode local replay of the stages that attempt never reached: license-eye header check on the fixed tree now reports 0 invalid files (dep check clean too), and make static-check-selected over 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)

  • main advanced again (df8bfd6 -> e9dc8c4): fix: widen integer addition and multiplication #31088 integer add/mul widening, fix(plan): a MATCH used as a condition is whether the index returned the row #31476 MATCH-as-condition row flag, docs(python-sdk): remove historical validation artifacts #31506 python-sdk validation artifacts removal, and fix(sql): align approximate numeric text notation with MySQL #30316 MySQL approximate-numeric text notation (FLOAT/DOUBLE scalar and JSON number printing, historical catalog DOUBLE->string width-32 repair). GitHub reported this PR CONFLICTING at head c209aee (mergeStateStatus DIRTY).
  • Resolution: rebased both commits onto e9dc8c4 (new head adc62e8; force-with-lease push, remote prerequisite exactly c209aee). The single textual conflict was pkg/sql/plan/function/function.go, where fix(sql): align approximate numeric text notation with MySQL #30316 added check = legacyFloatStringCheck(ctx, check, args) immediately before switch 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.
  • All other overlapping files (base_binder.go, bind_context.go, func_cast.go, query_builder.go, types.go, utils.go - touched upstream by fix(sql): align approximate numeric text notation with MySQL #30316/fix: widen integer addition and multiplication #31088) auto-merged; the merged hunks (IFNULL common-value contract refactor, legacy float-string bound propagation in ddlExpressionContext, integer-precision metadata) were audited and have no interaction with the boolean-contract surfaces. pkg/pb/plan/string_literal_form.go is hand-maintained support code (the plan_string_literal_form postprocess only patches plan.pb.go/api.pb.go), so the regenerated pkg/pb/plan/plan.pb.go upstream carries no regeneration drift for this PR. BVT expectation sensitivity: the two frozen issue-30931 cases touch no FLOAT/DOUBLE/DECIMAL surface and their JSON cells print only strings and integers ("0.5", "1e2", {"x": 1}, [1, 2], true, null), so fix(sql): align approximate numeric text notation with MySQL #30316's numeric-notation change cannot shift any of the 230+29 expectation cells; the 259/259 fixed-binary receipts from the merged-tree round remain the contract evidence and CI re-runs the full BVT pair.
  • Post-rebase validation on the rebased tree (all commands with the repository CGO environment; logs preserved under the loop artifacts for issue-30931/rebase2-evidence/): make build green (exit=0, mo-service binary stamped CommitID adc62e8); go test ./pkg/sql/plan/function ok 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/plan ok 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)

  • The multi-CN e2e BVT job ran all 662 assigned scripts and failed only dtype/set.sql rows 51/60/69: the three group by ... count(*) queries over the SET('', 'a') and SET('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.
  • Fix: commit 0d022fc "test(dtype): align set.sql grouped empty-label SET expectations with D1 contract" - the three grouped count rows in test/distributed/cases/dtype/set.result (merged ('',2) group becomes two ('',1) groups; group output stays the display label) and a rewritten stale comment in test/distributed/cases/dtype/set.sql (GROUP BY keys the stored bitmap; DISTINCT keeps one row per display label; grouped ORDER BY sorts by the canonical bitmap of the surviving display).
  • Verified locally on the head binary (BuildTime 1793166448, CommitID adc62e8) with CI-identical mo-tester flags (run.sh -n -g -o, dtype case root): pre-change red set.sql 84/87 failing exactly rows 51/60/69 with the same data diff CI reported; post-change green 314/314 statements 100% (set.sql 87/87, issue_28687 17/17, issue_30538 74/74, issue_30931_enum_set_bool_truthiness 29/29, mysql_compat_enum_set_numeric 107/107); wider neighbor battery 934/934 at 100% (binary_string_function_semantics 157, enum_1 88, enum_index_update 107, issue_30931_consolidated_boolean_semantics 230, mysql_compat_type_conversion 25 plus the repeated four enum_set files). Red/green detail and command/status receipts: /private/tmp/issue-30931-run/tests/ci-set-red-run2.log, ci-set-green-run.log, ci-set-final-cycle.log (mo-tester exit 0, SUCCESS RATE 100%).
  • Note on one nuance: for GROUP BY x ORDER BY x over 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.
  • Delivery: pushed to the PR head branch as plain fast-forward adc62e8 -> 0d022fc (this PR is cross-repository with its head branch in the gouhongshen/matrixone fork; an initial push aimed at upstream origin was refused by the repository-wide "not-create-branch" ruleset 19657232, which restricts branch creation there for non-maintainers). Fresh CI ran to completion on the new head (MatrixOne ALL CI run 40799186983, completed 2026-10-29T02:38:13Z, conclusion: success): 13 successful, 16 skipped, 0 failing, 0 pending - green across UT on Ubuntu/x86, UT Coverage, SCA on Linux/arm64, multi-CN e2e BVT (compose pessimistic and proxy modes) and the required CI Required gate, confirming the set.sql alignment on the CI population.

Design revision 9 receipt (2026-10-30, review-driven fence removal)

  • The 2026-10-30 mo-bot review (CHANGES_REQUESTED at 0d022fc) found one P2 design-policy blocker: the per-feature MORPCVersion135 mint plus remote and persisted expression version gates conflicts with the repository's shutdown-only upgrade contract (.agents/skills/mo-dev/references/upgrade-compatibility.md:13-40 - peers inside one cluster always run the same binary; do not mint per-feature versions, bump MORPCLatestVersion for a feature, gate on capability checks, or extend existing gates for new features); the review explicitly supported the SET expectation corrections. The finding was verified anchor by anchor and answered at fix(plan): MySQL implicit boolean semantics for ENUM/SET, BIT literals and JSON conditions #31492 (comment).
  • The design was revised BEFORE implementation per feature-design-review.md and independently PASSed with zero findings: revision 9, committed at docs/design/20261027-implicit-boolean-semantics-enum-set-bit-json.md, content hash dd7f1b0a57e9e4e486ca21e039f3d19fc850c6b78d171b57c286ba38a80984d5 - section 7 rewritten to the same-binary remote/persisted contract, section 8 rejects the fence alternative, section 9 removes the fence batteries, and acceptance criterion (7) pins "no version minted, MORPCVersion134 stays MORPCLatestVersion".
  • Repair commit a811f13 "fix(plan): remove the per-feature MORPC gate for implicit boolean contracts" implements deviation items 6-9: MORPCVersion135 unminted and MORPCLatestVersion = MORPCVersion134 restored (pkg/defines/const.go is byte-equal to main again); the four gate wires removed - the remoterun encode floor raise + 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 walk-side comments reworded to the mode-gate purpose. Every pre-existing gate row for features 104-134 stays untouched, and the share-walk flag JSONBooleanConditionContracts keeps exactly one consumer: the same-version cross-mode consumption gate RequireMySQLConditionalBooleanConsumption with the F8 SET exemption.
  • Fence-only tests deleted: pkg/sql/compile/boolean_condition_contracts_protocol_test.go (TestBooleanConditionContractPlacementEncodeAndRefusal, TestBooleanConditionContractStreamConfirmationCoversGateVersion, TestBooleanConditionContractPersistedGatesOnBoundExpressions and the compile-side version-floor detection test), pkg/hakeeper/view_metadata_boolean_contracts_test.go (TestPersistedFloorExpiryReleasesWithoutShutdownEvidence) and pkg/cnservice/view_metadata_boolean_contracts_test.go (TestCNViewMetadataSameGenerationFutureFloorPoisonsWithoutRevocation) in full, plus TestRequiredPersistedBooleanConditionContractsFloor, TestPersistedBooleanContractsPassThroughReaderLackingDetector and TestPersistedBooleanContractsGateSimulations in persisted_ip_boolean_contracts_test.go and TestGeneratedColumnAssignmentCastRaisesPersistedFloor in boolean_contracts_cross_mode_test.go. Retained green: TestSetStorageConditionsExemptFromBooleanContracts verbatim, the native-mode/cross-mode/semantic batteries, and the new plan-side TestBooleanConditionContractDetectionOnBoundExpressions pinning the feature walk over real bound ENUM/JSON expressions with RequiredPersistedExpressionProtocolVersion = 0 and numeric negative controls - the executable record that the feature adds no row to the durable feature->version table.
  • Post-repair focused validation (repository CGo environment; logs preserved in the run artifacts for issue-30931): changed-closure go build green; go vet over pkg/defines, pkg/pb/plan, pkg/hakeeper, pkg/cnservice, pkg/sql/plan and pkg/sql/compile exit 0 (the hakeeper/cnservice test sets still compile after the fence-file deletions); gofmt clean over all changed files; the 22-test plan retention battery green (22 PASS / 0 FAIL: detection + SET exemption + cross-mode consumption gate + native-mode parity + the ENUM/SET/BIT semantic batteries); go test -run Persist ./pkg/sql/plan/ green (86 PASS / 0 FAIL); full pkg/pb/plan package ok; pkg/sql/compile TestViewMetadataSender*|TestJSONStringConsumer* ok - main's pre-existing protocol gates for other features compose unchanged.
  • Semantics unchanged: the repair deletes gating only, so every recorded expected value of all three members keeps standing and the paired two-binary BVT receipts (fixed 259/259 vs pristine base 153/259 on the two frozen issue_30931 dtype cases) remain valid; CI re-runs the full population at the new head a811f13.

@mergify mergify Bot added the kind/bug Something isn't working label Oct 28, 2026
@matrix-meow matrix-meow added the size/XXL Denotes a PR that changes 2000+ lines label Oct 28, 2026
@gouhongshen
gouhongshen force-pushed the agent/issue-30931-main-8c225c46 branch from f10ef47 to 67d17dd Compare October 28, 2026 03:55
…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.
@XuPeng-SH

XuPeng-SH commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 0d022fcced4279c304fb6b1690fbb900f9d298ba

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

Copy link
Copy Markdown
Contributor Author

Addressed — the accepted removal is now on the branch. This review assessed 0d022fcced, and the "revision has not been pushed" observation was correct at that time. The approved repair was pushed right after, and the branch head is now a811f13760 — "fix(plan): remove the per-feature MORPC gate for implicit boolean contracts" (12 files, +151/−992).

Every anchor of the P2 finding was re-verified at the pushed head:

  • Version unminted: MORPCVersion135 no longer exists anywhere in the code (git grep MORPCVersion135 matches only the design document's own disposition record); pkg/defines/const.go keeps MORPCLatestVersion at MORPCVersion134 and is byte-identical to main again, so no HAKeeper floor raise or admission/revalidation cycle is fed by this PR any more.
  • Gate wiring removed: pkg/sql/compile/remoterun.go (encode floor + below-floor refusal), pkg/sql/compile/expression_protocol.go (protocol requirement feeding the multi-CN placement fallback) and pkg/sql/compile/expression_destination_protocol.go are all byte-identical to main; the persisted feature→version row is deleted from pkg/sql/plan/persisted_ip.go, which now adds only the session-mode consumption gate. All pre-existing gates for other features are untouched.
  • The permitted session-mode protections are kept, per your instruction: the walk stays only as the detector for RequireMySQLConditionalBooleanConsumption — a native-vs-MySQL session check on the catalog-boundary rebinds, with the F8 SET exemption (retained TestSetStorageConditionsExemptFromBooleanContracts).
  • The fence-only tests went with the fence (compile protocol requirement, destination tuple, hakeeper/cnservice admission, version-mapping simulation); the walk-detection and cross-mode batteries stayed.

Validation receipts on the pushed commit (repository CGo environment; logs retained): changed-closure build exit 0; go vet exit 0 over the six changed packages (hakeeper/cnservice test sets still compile after the deletions); gofmt clean; plan retention battery 22/22 PASS; the Persist battery 86/86 PASS; full pkg/pb/plan ok; compile TestViewMetadataSender*|TestJSONStringConsumer* ok. On the new head the CI shared-build check already completed SUCCESS (other jobs still running). The issue's two-binary BVT receipts remain in effect (fixed binary 259/259 vs base 153/259), since the repair deletes only gating, not semantics. The SET expectation corrections you supported are kept exactly as reviewed. Design revision 9 (docs/design/20261027-implicit-boolean-semantics-enum-set-bit-json.md, SHA256 dd7f1b0a57e9e4e486ca21e039f3d19fc850c6b78d171b57c286ba38a80984d5) records the fence removal and is linked in the description's "Design revision 9 receipt" section.

Re-requesting your review of head a811f13760.

@XuPeng-SH

XuPeng-SH commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: a811f13760b6aa6442d2f9d98e4d02da2cb8026b

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: 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.

@mergify mergify Bot added the queued label Oct 30, 2026
@mergify

mergify Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue

1 h 50 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Fri 30 Oct, 07:29 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 09:19 · 6ab7fe9

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.

The author needs to enable "Allow edits from maintainers" on this pull request.

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.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Merge conditions: 2 of 3 met

This pull request

Condition Required by
✅ #review-threads-unresolved = 0 GitHub branch protection
✅ github-review-approved GitHub branch protection

The batch, tested in place

Condition Required by
❌ any of: check-neutral = CI Required, check-skipped = CI Required, check-success = CI Required GitHub branch protection

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

Times in UTC · dashboard · how the merge queue works

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/bug Something isn't working size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants