Skip to content

refactor: add integer parameter binding contract - #28989

Merged
XuPeng-SH merged 24 commits into
matrixorigin:mainfrom
ck89119:issue-28977-main
Sep 18, 2026
Merged

XuPeng-SH merged 24 commits into
matrixorigin:mainfrom
ck89119:issue-28977-main

Conversation

@ck89119

@ck89119 ck89119 commented Sep 16, 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:

issue #28977

Design review

What this PR does / why we need it:

Establishes the foundation for parameter-owned integer coercion and migrates only SUBSTRING_INDEX as the representative consumer.

  • adds shared private integer-argument CAST execution contracts without changing public CAST or assignment semantics;
  • lets function metadata declare canonical integer parameters and keeps legacy overload identities executable but unavailable to new binding;
  • preserves exact DECIMAL, approximate FLOAT, explicit REAL, text-prefix, signed/unsigned, NULL, selector, and prepared source behavior;
  • adds MORPC v85 worker placement, send-time destination validation, receiver admission, and persisted-expression publication gates;
  • verifies persisted DEFAULT/generated/CHECK expressions and prepared source changes.

The integer-parameter contract uses MORPC v85. The merged base owns v82 for the fulltext2 probe-tail contract, v83 for bounded COALESCE string domains, and v84 for extended discrete percentile input types; all independent gates are preserved and the latest protocol is v85. This supersedes older issue/PR text that referred to v76 or v84 for integer coercion.

Source-dependent bit/temporal consumer rebinding and all remaining function migrations are intentionally deferred to #28978, #28979, #28980, and #28981. Those migrations must reuse the approved contract and return to design review if they need new semantics, identities, protocol versions, or compatibility mechanisms.

Validation:

  • owning package suites passed;
  • make build passed on the original implementation revision;
  • incremental golangci-lint: 0 issues on the original implementation revision;
  • changed-block coverage: 433/533 = 81.2% on the original implementation revision;
  • generated BVT: 41/41 passed twice on one instance on the original implementation revision;
  • after merging the current main and resolving the MORPC allocation conflict, pkg/sql/plan/function, pkg/sql/plan, and pkg/sql/compile passed with the repository CGo wrapper.

Latest regression validation (515cc5bdc3, Go 1.26.4, Darwin/arm64):

  • planner suite passed with typecheck and atomic coverage; compile/function/pb-plan/defines suites passed;
  • real SQL PREPARE and COM_STMT query/write regressions passed under -race with coverage, including optimized column/subquery peers, explicit CHAR boundaries, bare GROUP BY/UNION parameters, and aggregate/window sources;
  • TestCTASDivisionByZero also passed locally under -race; this does not establish the cause of its earlier CI timeout;
  • legacy func_string_substringindex.test: reproduced the exact five overflow mismatches, generated/reviewed the new error expectations, then passed 81/81 twice on one instance;
  • related BVT passed: integer_parameter_coercion.sql 41/41 and function_substring_index.sql 97/97;
  • incremental vet/lint and diff checks passed; changed intersecting statement blocks for this repair: 72/75 (96.0%), not whole-PR coverage;
  • remote CI success is not claimed.

Latest temporal regression validation (689d97a74f, Go 1.26.4, Darwin/arm64):

  • raw COM_STMT TIME zero/day/negative/fractional values passed through prepared SELECT and repeated/cache execution;
  • raw TIME(6), DATETIME(6), and TIMESTAMP(6) INSERT round trips preserve .499999 and .500000;
  • pkg/frontend and the complete issue fixture passed; modified frontend production blocks covered 13/14 statements;
  • vet and incremental golangci-lint passed with 0 issues;
  • the red required coverage run failed only in unrelated optools/TestUTHeartbeatStopDuringSleepRegistration/int (exit status 93); no passing remote CI is claimed.

Latest receiver-admission validation (917fb76310, Go 1.26.4, Darwin/arm64):

  • decoded private CAST 5–8 now reject invalid arity, source domains, target markers/types, and result types before execution;
  • focused receiver tests, full pkg/sql/compile, and full pkg/pb/plan passed; new admission statements covered 21/21;
  • rollout common-floor documentation corrected from <81 to <85;
  • vet and incremental golangci-lint passed with 0 issues.

Latest source-allowlist validation (cc6e0abd4e, Go 1.26.4, Darwin/arm64):

  • receiver admission now reuses the plan numeric predicate and rejects unsupported INT128/UINT128 sources;
  • all 256 wire type IDs were checked against the registry contract for private CAST overloads 5–8;
  • focused receiver tests, full pkg/sql/compile, full pkg/pb/plan, vet, and incremental lint passed; changed production statements covered 2/2.

# Conflicts:
#	pkg/defines/const.go
#	pkg/pb/plan/string_literal_form.go
#	pkg/sql/plan/base_binder.go
#	pkg/sql/plan/persisted_ip.go
#	pkg/sql/plan/utils.go
@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 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.

Deep review(head 12f2f56)

结论:REQUEST_CHANGES。发现 1 个 P2 契约问题;未确认 P0/P1。另有独立的设计审批门槛未关闭。

  • [P2] 未物化 RuntimeType 的 COM_STMT 参数被一概解释为 TEXT。见 visit_plan_rule.go:3720-3723。现有 DATE/TIME/DATETIME/TIMESTAMP 的 binary protocol payload 会解码为日期字符串,但 binaryProtocolPrepareParamDomains 没有 temporal 分支,导致 HasRuntimeType 不设置;新 rebind 将其固定为 TEXT,CAST5 会按整数前缀解析,未使用 sidecar 中的真实协议类型。

最小反例:prepare substring_index(a.b.c,.,?),以 MYSQL_TYPE_DATE 绑定 2024-01-02。该路径可能把 count 解释为 2024 并返回整个字符串,而 typed SQL 输入会被 source allowlist 拒绝,导致同一 source type/value 因客户端协议不同而出现不同结果。建议在物化/rebind 边界保留真实协议类型,并补 raw DATE/TIME packet 与 VAR_STRING 对照测试。

其余数值边界、NULL、类型切换、prepared 生命周期、planner 消费者、远端 placement 和资源路径未发现新的确定性缺陷。

此外,设计审批记录仍为 Pending:design 文档 351-357。head 文档已补 v85 修订,但 PR 正文仍锁定旧设计 revision 2645ef7;请更新精确 revision 并记录审批。

CI build、Ubuntu UT、SCA、coverage、multi-CN BVT 和 CI Required 已通过;upgrade compatibility jobs skipped,不能据此宣称跨版本升级/回滚实测通过。CI:https://github.com/matrixorigin/matrixone/actions/runs/35223986744

@aptend aptend 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.

Blocking findings: receiver admission does not validate private CAST 5–8 signatures, and the approved mixed-version design still gives contradictory v84/v85 rollout boundaries. I reproduced the receiver gap with a negative unit counterexample: a v85 pipeline carrying CAST 5 over a DATE source was accepted by validateRemoteExpressionPipelineProtocol (nil error), even though only CAST 8 owns temporal permission. Targeted integer conversion, planner, compile protocol, and frontend temporal tests otherwise pass at this exact head.

Comment thread pkg/sql/compile/remoterun.go Resolved

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

Deep review (Astra medium, exact head 689d97a)

REQUEST_CHANGES.

P1 — Mandatory design approval is still pending

At docs/design/CLAUDE_INTEGER_PARAMETER_BINDING_CONTRACT_DESIGN.md:353, the design approval remains Pending. Line 355 supersedes the approval of 0fb3d35, and the current PR review record contains no approval of the replacement design.

This change introduces private execution identities and changes distributed and persisted-expression compatibility, triggering the mandatory design-first gate. Please obtain a traceable maintainer approval of the exact revised design, covering the v85 compatibility and persistence contracts, before implementation approval.

No additional implementation finding is being asserted because the missing design approval blocks the required full review gate.

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

Deep review (Astra medium, exact head cc6e0ab)

APPROVE.

Reviewed all 34 changed files against base 780ef93. No concrete blocking findings remain after tracing conversion boundaries, prepared-plan reuse, relevant consumers, remote/catalog admission, cleanup/error paths, and test architecture.

The maintainer approval covers design revision 0fb3d35. Subsequent v85 documentation corrections and receiver signature checks conform to that design.

Reused exact-head CI run 35317544680: build, Ubuntu UT, static analysis, coverage, and both multi-CN BVT jobs passed. Upgrade jobs were skipped; this review does not claim end-to-end upgrade/rollback validation.

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

kind/documentation Improvements or additions to documentation kind/enhancement kind/refactor Code refactor size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants