You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: prepared REGEXP rebinding ignores runtime text override and reports incorrect charset mismatch #29465
Prepared REGEXP expression rebinding ignores RuntimeStringText when the parameter's static source type is VARBINARY. Nested consumers can incorrectly fail with MySQL error 3995, even though the parameter executor and vector interpret the same value as text.
Discovered during the systematic review of #29462 (original performance issue #29429). This is a separate inherited correctness issue; the affected ResetParamRefRule.preparedExecutionParamType logic predates this review's source-binding prototype.
Reproduction evidence
A deterministic planner regression was added locally in pkg/sql/plan/prepared_binding_test.go, TestPreparedRegexpRuntimeTextOverride:
Build PREPARE domain_override FROM 'select regexp_substr(left(?, 1), ''a'')' using the normal prepared planner.
Call the existing FillValuesOfParamsInPlanWithSpecialization with a ParamValue containing Value: "abc", SourceType: VARBINARY, HasSourceType: true, and RuntimeStringDomain: RuntimeStringText.
Actual: Character set 'binary' cannot be used in conjunction with 'utf8mb4_general_ci' in call to regexp_substr.
Expected: bind successfully; the parameter vector's explicit text override takes precedence over the static string family, so the nested LEFT result is text.
The regression failed before the shared domain resolver extraction on the PR review worktree. This evidence is at the planner API boundary; an end-to-end SQL client reproduction has not yet been validated.
Root cause
ParamExpressionExecutor.Eval propagates the parameter vector's runtime string domain. Vector.GetIsBinaryStringAt gives an explicit text override precedence over static VARBINARY. In contrast, preparedExecutionParamType selects VARBINARY from SourceType/IsBinaryString without honoring that override. The nested REGEXP compatibility check consequently sees a different domain from execution.
Fix / validation plan
Use the same metadata-only domain resolver in the existing rebind path and the new source-binding path, honoring explicit runtime overrides before static string-family fallbacks. Preserve the distinction between direct markers, nested expression results, NULL markers, and untyped NULL literals. Add tests for both override directions, derived columns, and fixed binary/text peers.
Related PR: #29462. Fix and complete integration validation are in progress; this issue is not yet claimed resolved.
Activity
fix: restore prepared TPCC filter selectivity with per-binding proof (#…
Ariznawlll commentedon Oct 2, 2026
测试版本
maind50a2d475a406829f67127fef7b2ad4abc1c1d3d原问题验证
在上述 commit 运行 issue 对应的定向回归。prepared REGEXP 在 runtime text override 后使用实际 text domain;合法重绑不再误报 charset mismatch。
Happy Path 覆盖
覆盖文本/二进制 source、nested/derived expression 和重复执行。
Unhappy Path 覆盖
覆盖 binary charset mismatch、typed/bare NULL 与 domain 切换;只有真实不兼容输入报错。
白盒验证
关联修复 #29462 已进入当前
main。直接执行并检查的定向测试为:pkg/sql/plan/prepared_binding_test.go::TestPreparedRegexpRuntimeTextOverride及 regexp execute-rebind tests。回归测试
本问题依赖内部故障注入、并发时序、catalog/optimizer 状态或多组件协议边界,无法由普通 SQL golden 稳定构造,因此不放入 MOTR;回归保留在 MatrixOne UT/BVT 层。对应定向测试在精确 commit 上通过,且未修改用户工作区。
测试证据
d50a2d475a406829f67127fef7b2ad4abc1c1d3dpkg/sql/plan/prepared_binding_test.go::TestPreparedRegexpRuntimeTextOverride及 regexp execute-rebind tests测试结论
测试通过。