Repository navigation
fix: preserve prepared table-function domains through consumers and CTAS - #29369
Merged
XuPeng-SH merged 5 commits intoSep 24, 2026
Merged
Conversation
XuPeng-SH
requested review from
LeftHandCold,
aptend and
aunjgr
as code owners
September 24, 2026 14:03
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? |
This was referenced Sep 24, 2026
XuPeng-SH
force-pushed
the
codex/fix-29349-29351-systemic
branch
from
September 24, 2026 16:16
f464d44 to
348d4e2
Compare
XuPeng-SH
force-pushed
the
codex/fix-29349-29351-systemic
branch
from
September 24, 2026 17:31
348d4e2 to
315ef45
Compare
XuPeng-SH
commented
Sep 24, 2026
XuPeng-SH
left a comment
Contributor
Author
There was a problem hiding this comment.
深度审查结论:未发现需要阻塞合并的正确性问题。
已核对参数域特化及下游消费者、CTAS 推导列与内部 INSERT 重建、UNNEST/HLL/bitmap/ENUM/SET、CEIL/FLOOR 标量精度与 MORPC v95 兼容门槛,以及参数副本在重试、释放和复用时的生命周期。另用本地 CTAS 边界探针验证了直接参数、算术表达式、COALESCE、generate_series 消费者和过滤条件,均通过。
当前 head 315ef452135f 的已启用 CI 检查均通过。我建议合并。
1 of 7 tasks
XuPeng-SH
added a commit
that referenced
this pull request
Sep 25, 2026
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes #29317 Fixes #29318 ## What this PR does / why we need it: Prepared SQL `EXECUTE` transported user variables as text and allowed provisional marker casts/numeric-prefix conversion to choose the wrong comparison domain for all-parameter `GREATEST`/`LEAST` and `FIELD`. Binary `FIELD` operands could also fall through to `DOUBLE` comparison. - Restore each SQL variable's source type at these variadic comparison operands before rebinding the complete tuple. Keep actual string operands as string boundaries; restore numeric literal peers only when the tuple has no actual string operand. - Route binary/text-only `FIELD` tuples through the existing byte-preserving, case-insensitive string implementation. Leave COM_STMT protocol typing and explicit SQL casts unchanged. - Pin the planner-generated vector-index overfetch `LEAST()` arithmetic to explicit `UINT64`, so execute-time variadic rebinding cannot reinterpret a prepared LIMIT as signed or decimal. Cover saturation boundaries and decimal inputs. - Add planner/function unit coverage and a public SQL BVT for mixed numeric/text values, binary NUL/case behavior, NULL, statement reuse, explicit casts, and numeric literal peers. Validation on base `2f25834093` (isolated local MatrixOne service): original three issue reproductions fail before the change and match direct SQL after it. `pkg/sql/plan` and `pkg/sql/plan/function` full CGo test suites pass. New BVT: 37/37 statements pass. Earlier GPT-6 Astra medium independent final review: no blockers. The subsequent two unsigned-overfetch commits have focused planner regression coverage and are included in the current final review. ## Latest-main rebase and current validation Rebased onto `matrixorigin/main@e914d98` (including #29369); new head `4876d85a92c2ef099bfd559771bd18abc7de3354`. Main moved `ParamValue` from `plan` to `executor`; the conflict resolution keeps the existing `plan.ParamValue` alias and relocates this PR's `SourceType` comment to the defining type in `pkg/util/executor/options.go`. `git range-diff` confirms all behavioral patches are retained; the other eight file diffs are byte-for-byte identical. `git diff --check` passes. Focused post-rebase CGo tests passed for prepared variadic source domains, unsigned/decimal vector overfetch boundaries, `FIELD` type handling, and the newly merged prepared `generate_series` consumers. The `pkg/sql/compile` CGo test binary also compiled and linked successfully. Full CI on this head is pending.
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes
Fixes #29306
Fixes #29307
Fixes #29311
Fixes #29313
Fixes #29314
Supersedes #29349 and #29351 by combining their prepared-argument fixes with the downstream consumer, CTAS, and protocol closures.
Root cause and changes
Prepared values cross SQL and MySQL protocol boundaries as bytes/text while some consumers need the assignment or packet domain. The original fixes specialized direct calls but left downstream plans, internally reparsed CTAS inserts, cached execution, and mixed-CN dispatch with stale or incompatible domains.
GENERATE_SERIESconsumers and result metadata at execution. Parameterized series gets a fresh runtime compilation because endpoint fractions and steps can change DATETIME scale without changing packet type. Real COM_STMT DATE/DATETIME packets keep temporal domain at series endpoints.UNNESTJSON arguments to an old-operator-compatible JSON domain without a 65,535-byte TEXT cast. Keep HLL/bitmap state in a lossless internal binary domain, and preserve ENUM/SET numeric provenance.The external MySQL protocol and persisted catalog/storage formats do not change. The approved rev4 design is
docs/design/20260924-prepared-argument-domains.md(SHA-2567079eb07827ac8f81d87cd146d33a290b963ee4389cfba4ff495d56f4e33ce0f). An earlier independent code review passed after its prior rebase; the current rebased head received a separate final review.Validation
Evidence was gathered on the equivalent pre-rebase patch
99e419e925;git range-diffmaps all five PR commits unchanged to head348d4e2f6donmainac46f1a09b. The sole new base change is inpkg/sql/colexec/externaland does not intersect this PR.mo-cgo-testwith-p 2 -count=1:pkg/defines,pkg/pb/plan,pkg/sql/plan,pkg/sql/compile,pkg/sql/colexec/table_function,pkg/frontend, andpkg/embedall passed.-n -g -o -p) passed twice on one ready instance forissue_29311_binary_state.sql(26/26),issue_29313_enum_set_aggregate.sql(16/16),issue_29314_scalar_precision.sql(33/33), andprepared_table_functions.sql(37/37). Created tables were absent after teardown.make build-with-prebuilt-native, incrementalgo vet, and incremental golangci-lint (0 issues) passed;git diff --checkand gofmt clean.On the previous remote head
f464d449bc, shared build and Ubuntu/x86 UT passed. ARM64 SCA found a missingrows.Err/Close in a test, fixed here. Both multi-CN BVT jobs failed during Quay MinIO image pulls before SQL (#29367; infrastructure fix #29370). UT Coverage timed out inCheckout MatrixOne sourcebefore tests, a recurrence of #28411; downstream Coverage lacked that producer and calculated no verdict. The new head's CI must be evaluated separately.Rollback: revert this PR's five commits; no data migration is required.
Latest-main rebase and current validation
Rebased onto
matrixorigin/main@44e5226a21(including #29370). New head:315ef452135f21335ff7e79281700cbd6ba127d2. The complete binary diff againstmainis byte-for-byte identical to the diff before rebase, andgit diff --checkpasses. Focused post-rebase CGo tests passed inpkg/sql/plan,pkg/sql/compile,pkg/frontend, andpkg/embed, including prepared series consumers, >65 KiB UNNEST, CTAS column mapping, precision protocol, temporal COM_STMT binding, and specialized-domain execution. The old BVT failures are not SQL test verdicts; CI on this new head is pending.