Skip to content

fix(sql): cast mixed ENUM and SMALLINT UNSIGNED operands - #32358

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
aptend:fix/astra-meow-31901
Nov 8, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
aptend:fix/astra-meow-31901

Conversation

@aptend

@aptend aptend commented Nov 7, 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:

Fixes #31901

What this PR does / why we need it:

An ENUM column compared with a SMALLINT UNSIGNED column could bind mismatched physical vectors for equality (and panic), while ordered comparisons and arithmetic could fail to bind. After ENUM normalization both operands look like uint16, so the diagonal incorrectly reported that no cast was needed.

Retain the original ENUM identity and force the existing ordinal-to-uint16 cast only for a mixed ENUM/uint16 pair, in either operand order. ENUM/ENUM and ENUM/varchar label comparisons, display metadata, ordinary uint16 pairs and other numeric widening routes keep their existing behavior.

Regression coverage follows bound column expressions into the real vector executor, including WHERE roots, both operand orders and NULLs. A public native SQL fixture additionally checks five operators, ordered WHERE id sets, labels, real prepared execution with repeated/NULL parameters, strict-mode typed rejection (1265/01000), rejected-row absence, and reuse of the same connection and prepared statement after rejection. The fixture releases its shared cluster, cursors, statements, connection, session mode and owned database.

Validation on upstream main e8765aa231ee96df74119caba74c558ab650e067, with this worktree's native artifacts and CGO enabled:

  • Production-only overlay: focused function and planner regressions fail semantically on the unfixed implementation (both original exit 1). Focused function GREEN and the corrected planner suite pass; planner selection includes TestEnumSmallintUnsignedPlanCoercion (eight subtests) and TestEnumSmallintUnsignedBoundExpressionExecution. An earlier planner run failed because the test assumed one filter node; the final test walks every retained predicate consumer.
  • Repository-pinned incremental SCA, 336 explicit packages covering changed packages, tests and affected reverse dependencies: molint and golangci-lint both exit 0, 0 issues. After adding the public fixture, its owning package was checked again with both pinned analyzers (exit 0, 0 issues); the other unchanged packages reuse the source-bound evidence. No linter was disabled.

Exact expanded 336-package SCA command:

make --no-print-directory static-check-selected STATIC_CHECK_PACKAGES="./cmd/mo-inspect ./cmd/mo-object-tool ./cmd/mo-object-tool/ckp ./cmd/mo-service ./cmd/mo-tool ./pkg/backup ./pkg/bootstrap ./pkg/bootstrap/versions ./pkg/bootstrap/versions/v1_2_0 ./pkg/bootstrap/versions/v1_2_1 ./pkg/bootstrap/versions/v1_2_2 ./pkg/bootstrap/versions/v1_2_3 ./pkg/bootstrap/versions/v2_0_0 ./pkg/bootstrap/versions/v2_0_1 ./pkg/bootstrap/versions/v2_0_2 ./pkg/bootstrap/versions/v2_0_3 ./pkg/bootstrap/versions/v2_1_0 ./pkg/bootstrap/versions/v2_2_0 ./pkg/bootstrap/versions/v3_0_0 ./pkg/bootstrap/versions/v4_0_0 ./pkg/bootstrap/versions/v4_0_1 ./pkg/bootstrap/versions/v4_0_2 ./pkg/bootstrap/versions/v4_0_3 ./pkg/bootstrap/versions/v4_0_4 ./pkg/bootstrap/versions/v4_0_5 ./pkg/bootstrap/versions/v4_0_6 ./pkg/bootstrap/versions/v4_0_7 ./pkg/catalog ./pkg/cdc ./pkg/cnservice ./pkg/cnservice/cnclient ./pkg/common/docfilter ./pkg/common/pubsub ./pkg/common/rscthrottler ./pkg/compare ./pkg/config ./pkg/datalink ./pkg/datasync ./pkg/embed ./pkg/fileservice ./pkg/frontend ./pkg/frontend/databranchutils ./pkg/frontend/test ./pkg/frontend/test/mock_lock ./pkg/frontend/test/mock_moserver ./pkg/frontend/test/mock_shard ./pkg/frontend/test/mock_task ./pkg/fulltext ./pkg/fulltext/plugin ./pkg/fulltext/plugin/compile ./pkg/fulltext/plugin/idxcron ./pkg/fulltext/plugin/iscp ./pkg/fulltext/plugin/plan ./pkg/fulltext/plugin/runtime ./pkg/fulltext/plugin/search ./pkg/fulltext2 ./pkg/fulltext2/plugin ./pkg/fulltext2/plugin/compile ./pkg/fulltext2/plugin/coverage ./pkg/fulltext2/plugin/idxcron ./pkg/fulltext2/plugin/iscp ./pkg/fulltext2/plugin/plan ./pkg/fulltext2/plugin/runtime ./pkg/fulltext2/plugin/search ./pkg/gossip ./pkg/hakeeper ./pkg/hakeeper/checkers ./pkg/hakeeper/checkers/cnservice ./pkg/hakeeper/checkers/logservice ./pkg/hakeeper/checkers/proxy ./pkg/hakeeper/checkers/syshealth ./pkg/hakeeper/checkers/tnservice ./pkg/hakeeper/operator ./pkg/hakeeper/task ./pkg/iceberg/api ./pkg/iceberg/catalog ./pkg/iceberg/dml ./pkg/iceberg/io ./pkg/iceberg/maintenance ./pkg/iceberg/metadata ./pkg/iceberg/ref ./pkg/iceberg/write ./pkg/incrservice ./pkg/indexplugin ./pkg/indexplugin/all ./pkg/indexplugin/catalog ./pkg/indexplugin/compile ./pkg/indexplugin/coverage ./pkg/indexplugin/idxcron ./pkg/indexplugin/iscp ./pkg/indexplugin/maintenance ./pkg/indexplugin/plan ./pkg/indexplugin/search ./pkg/indexplugin/search/planreader ./pkg/iscp ./pkg/lockservice ./pkg/logservice ./pkg/objectio ./pkg/objectio/ioutil ./pkg/objectio/mergeutil ./pkg/partitionprune ./pkg/partitionservice ./pkg/pb/pipeline ./pkg/pb/shard ./pkg/predefine ./pkg/proxy ./pkg/publication ./pkg/queryservice ./pkg/shardservice ./pkg/sort ./pkg/sql/colexec ./pkg/sql/colexec/adaptivetop ./pkg/sql/colexec/aggexec ./pkg/sql/colexec/apply ./pkg/sql/colexec/connector ./pkg/sql/colexec/cteaccount ./pkg/sql/colexec/dedupjoin ./pkg/sql/colexec/deletion ./pkg/sql/colexec/dependent ./pkg/sql/colexec/dispatch ./pkg/sql/colexec/external ./pkg/sql/colexec/external/arrowio ./pkg/sql/colexec/externalwrite ./pkg/sql/colexec/fill ./pkg/sql/colexec/filter ./pkg/sql/colexec/fuzzyfilter ./pkg/sql/colexec/group ./pkg/sql/colexec/hashbuild ./pkg/sql/colexec/hashjoin ./pkg/sql/colexec/icebergdelete ./pkg/sql/colexec/icebergwrite ./pkg/sql/colexec/indexbuild ./pkg/sql/colexec/indexjoin ./pkg/sql/colexec/insert ./pkg/sql/colexec/intersect ./pkg/sql/colexec/intersectall ./pkg/sql/colexec/limit ./pkg/sql/colexec/lockop ./pkg/sql/colexec/loopjoin ./pkg/sql/colexec/merge ./pkg/sql/colexec/mergeblock ./pkg/sql/colexec/mergecte ./pkg/sql/colexec/mergedelete ./pkg/sql/colexec/mergeorder ./pkg/sql/colexec/mergerecursive ./pkg/sql/colexec/mergetop ./pkg/sql/colexec/minus ./pkg/sql/colexec/minusall ./pkg/sql/colexec/mongoscan ./pkg/sql/colexec/multi_update ./pkg/sql/colexec/offset ./pkg/sql/colexec/order ./pkg/sql/colexec/output ./pkg/sql/colexec/partition ./pkg/sql/colexec/postdml ./pkg/sql/colexec/preinsert ./pkg/sql/colexec/preinsertsecondaryindex ./pkg/sql/colexec/preinsertunique ./pkg/sql/colexec/product ./pkg/sql/colexec/productl2 ./pkg/sql/colexec/projection ./pkg/sql/colexec/rightdedupjoin ./pkg/sql/colexec/runtimefilter ./pkg/sql/colexec/sample ./pkg/sql/colexec/shuffle ./pkg/sql/colexec/spillutil ./pkg/sql/colexec/table_clone ./pkg/sql/colexec/table_function ./pkg/sql/colexec/table_scan ./pkg/sql/colexec/timewin ./pkg/sql/colexec/top ./pkg/sql/colexec/unionall ./pkg/sql/colexec/value_scan ./pkg/sql/colexec/vectorquery ./pkg/sql/colexec/vectorscan ./pkg/sql/colexec/window ./pkg/sql/compile ./pkg/sql/compile/siriusbridge ./pkg/sql/crt ./pkg/sql/datastream ./pkg/sql/foreignext ./pkg/sql/foreigntvf ./pkg/sql/iceberg ./pkg/sql/internal/materialized ./pkg/sql/internal/ordersites ./pkg/sql/internal/topsites ./pkg/sql/kafka ./pkg/sql/models ./pkg/sql/mongodb ./pkg/sql/parsers ./pkg/sql/parsers/dialect/mysql ./pkg/sql/parsers/dialect/postgresql ./pkg/sql/parsers/example ./pkg/sql/parsers/tree ./pkg/sql/plan ./pkg/sql/plan/explain ./pkg/sql/plan/function ./pkg/sql/plan/function/ctl ./pkg/sql/plan/function/fault ./pkg/sql/plan/rule ./pkg/sql/plan/substrait ./pkg/sql/subscriptionmetadata ./pkg/sql/util ./pkg/sql/util/csvparser ./pkg/stage ./pkg/stage/stageutil ./pkg/taskservice ./pkg/tests/arrowload ./pkg/tests/dml ./pkg/tests/issues ./pkg/tests/issues/internal/joinspill ./pkg/tests/issues/isolated ./pkg/tests/partition ./pkg/tests/service ./pkg/tests/shard ./pkg/tests/sqlintegration ./pkg/tests/sqlintegration/multicn ./pkg/tests/testutils ./pkg/tests/txn ./pkg/tests/upgrade ./pkg/testutil ./pkg/tnservice ./pkg/tools/checkpointtool ./pkg/tools/checkpointtool/interactive ./pkg/tools/objecttool ./pkg/tools/objecttool/interactive ./pkg/tools/toolfs ./pkg/txn/client ./pkg/txn/service ./pkg/txn/storage/mem ./pkg/txn/storage/tae ./pkg/util/executor ./pkg/util/executor/test ./pkg/util/export ./pkg/util/export/etl ./pkg/util/export/example ./pkg/util/file ./pkg/util/metric/mometric ./pkg/util/status ./pkg/util/sysview ./pkg/util/test ./pkg/util/trace/impl/motrace ./pkg/util/trace/impl/motrace/example ./pkg/vectorindex ./pkg/vectorindex/brute_force ./pkg/vectorindex/cache ./pkg/vectorindex/cachegen ./pkg/vectorindex/cagra ./pkg/vectorindex/cagra/plugin ./pkg/vectorindex/cagra/plugin/compile ./pkg/vectorindex/cagra/plugin/idxcron ./pkg/vectorindex/cagra/plugin/plan ./pkg/vectorindex/cagra/plugin/runtime ./pkg/vectorindex/cagra/plugin/search ./pkg/vectorindex/cuvs ./pkg/vectorindex/cuvs/idxcron ./pkg/vectorindex/hnsw ./pkg/vectorindex/hnsw/plugin ./pkg/vectorindex/hnsw/plugin/compile ./pkg/vectorindex/hnsw/plugin/idxcron ./pkg/vectorindex/hnsw/plugin/iscp ./pkg/vectorindex/hnsw/plugin/plan ./pkg/vectorindex/hnsw/plugin/runtime ./pkg/vectorindex/hnsw/plugin/search ./pkg/vectorindex/idxcron ./pkg/vectorindex/indexfile ./pkg/vectorindex/ivfflat ./pkg/vectorindex/ivfflat/plugin ./pkg/vectorindex/ivfflat/plugin/compile ./pkg/vectorindex/ivfflat/plugin/idxcron ./pkg/vectorindex/ivfflat/plugin/iscp ./pkg/vectorindex/ivfflat/plugin/plan ./pkg/vectorindex/ivfflat/plugin/runtime ./pkg/vectorindex/ivfflat/plugin/search ./pkg/vectorindex/ivfpq ./pkg/vectorindex/ivfpq/plugin ./pkg/vectorindex/ivfpq/plugin/compile ./pkg/vectorindex/ivfpq/plugin/idxcron ./pkg/vectorindex/ivfpq/plugin/plan ./pkg/vectorindex/ivfpq/plugin/runtime ./pkg/vectorindex/ivfpq/plugin/search ./pkg/vectorindex/memory ./pkg/vectorindex/sqlexec ./pkg/vectorindex/usearchex ./pkg/vm ./pkg/vm/engine ./pkg/vm/engine/ckputil ./pkg/vm/engine/cmd_util ./pkg/vm/engine/disttae ./pkg/vm/engine/disttae/cache ./pkg/vm/engine/disttae/logtailreplay ./pkg/vm/engine/readutil ./pkg/vm/engine/tae/blockio ./pkg/vm/engine/tae/catalog ./pkg/vm/engine/tae/db ./pkg/vm/engine/tae/db/checkpoint ./pkg/vm/engine/tae/db/dbutils ./pkg/vm/engine/tae/db/gc/v3 ./pkg/vm/engine/tae/db/merge ./pkg/vm/engine/tae/db/test ./pkg/vm/engine/tae/db/test/compatibility ./pkg/vm/engine/tae/db/testutil ./pkg/vm/engine/tae/iface/data ./pkg/vm/engine/tae/iface/handle ./pkg/vm/engine/tae/iface/rpchandle ./pkg/vm/engine/tae/iface/txnif ./pkg/vm/engine/tae/index/indexwrapper ./pkg/vm/engine/tae/logstore ./pkg/vm/engine/tae/logstore/driver ./pkg/vm/engine/tae/logstore/driver/batchstoredriver ./pkg/vm/engine/tae/logstore/driver/entry ./pkg/vm/engine/tae/logstore/driver/logservicedriver ./pkg/vm/engine/tae/logstore/entry ./pkg/vm/engine/tae/logstore/wal ./pkg/vm/engine/tae/logtail ./pkg/vm/engine/tae/logtail/service ./pkg/vm/engine/tae/mergesort ./pkg/vm/engine/tae/model ./pkg/vm/engine/tae/options ./pkg/vm/engine/tae/rpc ./pkg/vm/engine/tae/tables ./pkg/vm/engine/tae/tables/jobs ./pkg/vm/engine/tae/tables/txnentries ./pkg/vm/engine/tae/tables/updates ./pkg/vm/engine/tae/tasks ./pkg/vm/engine/tae/testutils/config ./pkg/vm/engine/tae/txn/txnbase ./pkg/vm/engine/tae/txn/txnimpl ./pkg/vm/engine/test ./pkg/vm/engine/test/testutil ./pkg/vm/message ./pkg/vm/pipeline ./pkg/vm/process ./test/iceberg ./test/manual/issue28140 ./test/mongodb"

Public fixture package SCA command: make --no-print-directory static-check-selected STATIC_CHECK_PACKAGES="./pkg/tests/issues" (the emitted analyzer commands select only that package).

  • Public SQL fixture: repository CGO wrapper compiled ./pkg/tests/issues with -c once; the resulting binary ran -test.v -test.timeout=15m -test.run='^TestIssue31901EnumSmallintUnsignedNumericCoercion$' once. Parent and scene passed (5.78s / 0.12s); original child wait, foreground owner and CLI/OS exits were all 0. No retry or zero-selection claim. The actual held 1000-port lease, all TCP/UDP snapshots, private HAKeeper target and exact binary/process identity were verified; the post-stop snapshots contain no owned sockets.
  • Native test binary SHA256: 64384bbd4d2f0b648e1abbb5a080c32a3dbd7cfec69f0413cc64e410d0cd0e69 (Go 1.27.1, CGO=1). Raw evidence is retained locally under /home/mo/.local/share/matrixone-matrix-meow-intake/batches/meow-31901/out/ in validation5-current-main-focused-CGO-and-SCA-intake68, return7-Kimi-missing-filter-plan-and-SCA-patrol144, return10-public-fixture-SCA-CGO-binary-and-binding-intake69 and return12-one-real-native-consumer-intake69.

Public CI and multi-CN topology remain to be evaluated on the published HEAD; no full-package/race pass is claimed by these focused results.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH

XuPeng-SH commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: d1023d77f14c649433aa42036068cc1c3a07ce8a

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

Assessment: approve

The mixed ENUM/uint16 case now uses the existing ordinal cast in either operand order while preserving neighboring coercion and label semantics. Regression coverage reuses existing planner, executor and shared SQL fixtures. No actionable findings remain.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Reviewed the complete four-file delta, linked issue, coercion consumers, value/NULL oracles and fixture cleanup; both discussion entries are accounted for.

  • Local source/format/evidence audit passed: checks/1794099300916809868-3.json and source-audit.log.

  • Reused frozen-head successful UT, SCA, coverage and PROXY/PESSIMISTIC multi-CN BVT metadata; author-reported focused RED/GREEN and native SQL results remain attributed.

Limitations:

  • No local Go/native or public SQL rerun. Raw CI and author execution logs were not supplied.

@mergify mergify Bot added the queued label Nov 8, 2026
@mergify

mergify Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue · pull request dequeued

58 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Sun 8 Nov, 00:57 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 01:55 · b86c8d8

Reason

Pull request #32358 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.

To get back in the queue

  • Push a change if one is needed: the pull request is queued again once its queue conditions match.
  • If no change is needed, tick the box below to queue it again as it is.

Merge conditions not met when it left the queue

  • any of · required by GitHub branch protection:
    • check-neutral = CI Required
    • check-skipped = CI Required
    • check-success = CI Required

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

  • Requeue this pull request
2 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection

Times in UTC · dashboard · how the merge queue works

This branch was previously deployed

1 inactive deployment
ci — b86c8d80 Deployed Nov 8, 2026 by mergify[bot]
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/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: comparing an ENUM column with a SMALLINT UNSIGNED column panics (type mismatch casting SMALLINT UNSIGNED vector to []types.Enum)

3 participants