Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Searched open/closed issues and PRs for SHOW COLUMNS with PREPARE/parameters, the exact only prepare statement can use error, and prepared SHOW work. No dedicated duplicate was found in these searches.
Related but distinct: #32390 concerns plain DESC/DESCRIBE rejection in the binary PREPARE grammar; #25425 concerns CTAS parameters; #27332 concerns ENUM/SET assignment. PR #29391 supports SHOW PUBLICATIONS LIKE parameters, not the SHOW COLUMNS/FIELDS WHERE rewrite reported here.
Branch Name
main (frozen S5 validation candidate; ordinary build, without the integration tag)
Commit ID
89ca3dbbf6d594d7614b8e1ca80f6b0300ed3cd2
Other Environment Information
- Hardware parameters: Linux/arm64 container, 4 CPU limit, 6 GiB memory limit.
- OS type: Linux/arm64 in Docker on an Apple Silicon host; isolated standalone LOG/TN/CN configuration.
- Others: Go 1.27.1 client,
github.com/go-sql-driver/mysqlv1.9.3, explicitsql.Conn.PrepareContext,interpolateParams=false. - Independent compatibility control: MySQL 8.4.10 in a separate owned container.
- Ordinary MatrixOne binary SHA256:
0ae125cb624dccd50c342821cecc696d5db64a3f86d9c217fa26e0e502d4614a. - Evidence was collected on the commit above. Newer main was consulted only for issue delivery/templates, not retested here.
Actual Behavior
A valid parameter marker in SHOW COLUMNS ... WHERE Field=? is rejected at PREPARE with:
Error 20301 (HY000): invalid input: only prepare statement can use ? expr
This occurs for both a base table and an ordinary View, through both:
- MySQL binary
COM_STMT_PREPARE(explicit driver prepare, not emulation). - SQL
PREPARE p FROM 'show columns ... where Field=?'.
The statement is already being prepared, but the WHERE parameter reaches binding without a prepared context. No EXECUTE is reached.
| Surface/control, for both table and View | MatrixOne | MySQL 8.4.10 |
|---|---|---|
Text SHOW COLUMNS ... WHERE Field='x' |
PASS | PASS |
Binary-prepared SHOW COLUMNS ... WHERE Field='x' |
PASS | PASS |
Binary-prepared SHOW COLUMNS ... WHERE Field=? |
20301 at PREPARE | PASS |
SQL-string-prepared SHOW COLUMNS ... WHERE Field=? |
20301 at PREPARE | PASS |
Prepared SELECT column_name ... FROM information_schema.columns ... AND column_name=? |
PASS | PASS |
The initial surface sweep also reproduced the WHERE-marker failure with SHOW FIELDS, SHOW FULL COLUMNS, and SHOW FULL FIELDS. These are grouped here rather than filed as separate bugs.
Not part of this report: SHOW COLUMNS ... LIKE ?. MySQL 8.4.10 itself rejects that form with 1064. The supported WHERE Field=? predicate is the compatibility witness; the initial overbroad LIKE-marker assumption was retained and explicitly excluded.
Expected Behavior
For an authorized table or View, SHOW COLUMNS/FIELDS with a parameterized WHERE expression should prepare and execute successfully, as in MySQL 8.4.10. Binding x must select the x column; binding a nonmatching name must return an empty row set with the normal result metadata.
Preserve authorization, dependency refresh, quoted identifiers, and the existing MatrixOne SHOW result contract, including the additional Comment column on ordinary SHOW. This issue does not request new LIKE-marker syntax or a uniform MySQL/MO header layout.
Steps to Reproduce
Create the minimal fixture on an owned test instance:
CREATE DATABASE claude_s5_params;
CREATE TABLE claude_s5_params.src(x INT, y VARCHAR(9));
CREATE VIEW claude_s5_params.v AS SELECT x,y FROM claude_s5_params.src;
-- Passing direct control.
SHOW COLUMNS FROM claude_s5_params.v WHERE Field='x';
-- Run each PREPARE independently: both fail on MatrixOne.
PREPARE p_table FROM 'show columns from claude_s5_params.src where Field=?';
PREPARE p_view FROM 'show columns from claude_s5_params.v where Field=?';On MySQL 8.4.10, these PREPAREs succeed; the corresponding executions return the x column definition:
SET @f='x';
EXECUTE p_table USING @f;
EXECUTE p_view USING @f;
DEALLOCATE PREPARE p_table;
DEALLOCATE PREPARE p_view;For the binary entry point, connect with go-sql-driver/mysql and interpolateParams=false. On the same authenticated connection, the validated core operation is:
// Imports: context, database/sql; register github.com/go-sql-driver/mysql.
func queryShow(ctx context.Context, conn *sql.Conn, query string) error {
stmt, err := conn.PrepareContext(ctx, query) // Actual COM_STMT_PREPARE.
if err != nil {
return err
}
defer stmt.Close()
rows, err := stmt.QueryContext(ctx, "x")
if err != nil {
return err
}
defer rows.Close()
for rows.Next() {
// The full probe checks fixed column headers and the x:int row.
}
return rows.Err()
}
// Each returns error 20301 on MatrixOne, before QueryContext.
queryShow(ctx, conn, "show columns from claude_s5_params.src where Field=?")
queryShow(ctx, conn, "show columns from claude_s5_params.v where Field=?")Explicit driver PREPARE is essential: substituting a literal or using client-prepared emulation exercises a passing control instead. In a mysql CLI script, use separate invocations or --force to continue past the expected PREPARE errors; deallocate only handles that were successfully created. Finally:
DROP DATABASE claude_s5_params;Additional information
Static localization at the tested commit:
buildShowColumnspasses its WHERE AST intoreturnByWhereAndBaseSQL, which installs it on a rewritten SELECT.getReturnDdlBySelectStmtcallsBuildPlan(ctx, stmt, false)rather than preserving prepared binding context.BaseBinder's ParamExpr check then raises the captured error.
Unlike #32390, SHOW itself parses successfully here, and SQL-string PREPARE fails as well as binary PREPARE. A DESC grammar-only fix does not establish coverage of this rewrite/binding boundary.
Evidence and scope:
TestSweepShowParameterControlsindependently separates literal text, literal binary, parameterized binary, parameterized SQL-string, and parameterized information_schema SELECT, for both table and View.- Four parameterized SHOW leaves fail on MatrixOne; their MySQL counterparts pass. The final MySQL parameter/quoted-empty control selection has 2 top-level / 18 named PASS events; this is not a claim that MatrixOne's entire sweep passed.
- Additional quoted/escaped-name, FULL FIELDS literal, and empty-result controls passed on both engines. The connection remained usable, fixture cleanup was verified, and owned services exited normally.
- Exact diagnostic source versions, raw errors, candidate/binary hashes, and terminal statuses are retained in the completed S5 archive. No product tests were rerun merely to create this issue.
- No clean baseline comparison was performed. Introduction/regression attribution, including any relationship to fix(view): align historical authorization and metadata compatibility #32328, is undetermined.
Discovered during #29440 S5 acceptance. No product fix is included in this report.
Activity
fix(plan): preserve prepare context for SHOW COLUMNS WHERE parameters (…
MatrixAdventurer commentedon Nov 10, 2026
核实结论:已修复可关闭。
证据:修复 PR #32414 已于 2026-11-09 合入 main(base=main,单 PR)。根因覆盖:SHOW COLUMNS/FIELDS ... WHERE 重写为 SELECT 时此前始终在非 prepare 模式绑定,参数标记在 SQL PREPARE/COM_STMT_PREPARE 下被拒(修复前 8 个参数化 planner 子用例全部报 only prepare statement can use ? expr);修复后 prepare flag 显式传入重写后的查询,其余 SHOW 语句保持原行为。回归测试:TestShowColumnsPreparedWhere(真实驱动 interpolateParams=false 与 SQL PREPARE/EXECUTE,-count=2 通过);planner 参数化子用例修复后全过;元数据 BVT 扩展(单/多参数、视图、schema 刷新)38/38 两轮比对通过。还缺:PR 自述验证为本机环境,全仓 CI 与全量 issues 套件未声明通过。
@ck89119 请按 issue 步骤复现确认后关闭。
本操作由LW授权的MOI智能体提交
slyunnn commentedon Nov 11, 2026
Regression and extended verification for #32408 (2026-11-11)
Per the verification hand-off in this comment, the merged fix for #32408 was independently re-verified on the latest
origin/mainwith a dual-state matrix: the pre-fix build still reproduces the reportedshow columns ... where Field=?rejection, and the fixed build binds and executes the parameter through every original shape across all three endpoints. Result: Fixed.Verification Environment
mainat553e16f52b—fix(parser): support quoted wildcards in DESCRIBE shortcuts (#32339);git merge-baseconfirms it contains fix merge22a02c581feaf56cf5ce0c319bcac8635c901369(PR fix(plan): preserve prepare context for SHOW COLUMNS WHERE parameters #32414, merged 2026-11-09 14:50 UTC). Single-branch verification: this is amainissue;4.2-devwas not verified and no4.2-devresult is claimed.fix(plan): preserve prepare context for SHOW COLUMNS WHERE parameters. Direction: theSHOW COLUMNS/SHOW FIELDS ... WHERErewrite toSELECTpreviously always bound in non-prepare mode, so a parameter marker was rejected with20301 (HY000): invalid input: only prepare statement can use ? exprunder bothCOM_STMT_PREPAREand SQLPREPARE; the fix now propagates the prepare flag into the rewritten query, while otherSHOWstatements keep their original behaviour.maintip,go1.27.1darwin/arm64;-versionreports Git commit ID553e16f52b, buildtime1794380911; binary SHA25633c50723cc82728d59a58d03ba7e879850db0493584d168eab998d79cfb887bc. Deployed as a fresh-data single-version2 CN / 1 TN / 1 LogService + Proxy; Proxy6001, CN116001, CN216002were all connected and exercised — every scenario below ran through each of the three endpoints over both the MySQL binary protocol (server-prepared cursors with real parameter binding) and the text protocol (SQLPREPARE/EXECUTE USING); endpoint identitygit_version()=553e16f52bwas asserted at every route-round. After the matrix the service was stopped and all three ports were released.d39d8a4034(2026-10-30, pre-fix ancestor), SHA2562c16af1e4dd7afb194211233be625af96ebaaba588d2ddd944cfaf3476cb43fe, used to re-confirm the original failure mode on the same fixture.mysql-connector-python 26.10.0withcursor(prepared=True)— real binaryCOM_STMT_PREPAREplus boundCOM_STMT_EXECUTE, no driver emulation — andpymysql 2.2.8for text-protocol statements and fixture/DDL; an untracked external probe drove both builds.What Was Covered
d39d8a4034): the four original parameter shapes — binarySHOW COLUMNS ... WHERE Field=?, binarySHOW FIELDS ... WHERE Field=?, binarySHOW COLUMNS ... WHERE Field=?on a view, and SQL-stringPREPARE p FROM 'SHOW COLUMNS ... WHERE Field=?'— are all rejected with the20301only prepare statement can use ? exprclass on every route (12/12), while the no-WHEREpreparedSHOW COLUMNSand the literal-WHEREtext form keep working on the same binary — proving the probe exercises exactly the broken prepare-context path.COM_STMT_PREPARE:SHOW COLUMNS FROM <db>.t WHERE Field=?prepares and executes with the bound parameter and returns the same filtered metadata as the literal text form (thec1row), on Proxy6001, CN116001and CN216002,2rounds (6/6).no_such_col) returns an empty set, not a rejection (6/6).SHOW FIELDS FROM <db>.t WHERE Field=?through the binary protocol returns thec2row (6/6).SHOW COLUMNS FROM <db>.v WHERE Field=?returns thec1row of the view (6/6).PREPARE p FROM 'SHOW COLUMNS ... WHERE Field=?'plusSET @aandEXECUTE p USING @areturns thec1row through every endpoint-round (6/6).WHERE Field=? AND Type=?binds both markers and returns the matching column row (6/6).c1thenc2) on the same connection returns the respective rows (6/6).ALTER TABLE ... ADD COLUMN c9from a second connection, a fresh preparedSHOW COLUMNS ... WHERE Field=?bound toc9returns the new column row (6/6).WHEREpreparedSHOW COLUMNS FROM <db>.tkeeps passing, and the plainCOM_QUERYunbound marker (SELECT ?) is still rejected after the fix (6/6each); sessions stay usable (SELECT 1) after every step.TestShowColumnsPreparedWhere(pkg/tests/issues, real driver + SQLPREPARE/EXECUTE, run with-count=2, both passes,ok ... 9.493s) andTestShowColumnsPreparePreservesWhereParameters+TestCoverage_buildShowColumns(pkg/sql/plan,ok ... 1.758s).4.2-dev: the fix merge and this issue targetmain; no4.2-devbuild was verified and no4.2-devconclusion is claimed.SHOWfamilies beyondSHOW COLUMNS/SHOW FIELDS ... WHERE: the fix and this verification are scoped to the rewriter named above; no claim is made for otherSHOWstatements.Findings
RESULT mode=control checks=33 failed=0(all bug-state expectations held:12/1220301rejections plus passing parity guards).RESULT mode=full checks=90 failed=0across6endpoint-rounds (Proxy6001/ CN116001/ CN216002,2rounds,15checks each).20301 (HY000) invalid input: only prepare statement can use ? exprno longer occurs for any original shape on the fixed build, while it still reproduces deterministically on the pre-fix control — the endpoints, fixture objects and statements being identical between control and fixed runs.SHOW COLUMNS/SHOW FIELDS ... WHERErewrite's prepare-context propagation (planner binding), so the outcome class is fully determined by statement shape and parameter binding, independent of row counts,LIMIT, block/batch boundaries, memory/spill, concurrency scale, skew, network transfer, index state or resource scale; the12-shape ×6-endpoint-round matrix already pins the behaviour.MOTR / BVT Coverage
TestShowColumnsPreparePreservesWhereParameters), a real-driver binary-protocol regression (TestShowColumnsPreparedWhere, which.testfiles cannot express), and the metadata BVT extension inview_metadata_wire_headers(single/multi-parameter, view, schema-refresh controls — recorded as38/38by the fix author and green in the merge-time CI). This round re-ran the focused suites on the current tip and contributed the dual-state, three-endpoint, two-protocol matrix instead of duplicating landed coverage.Final Conclusion
Fixed — verified on
mainat553e16f52b(contains fix merge22a02c581f, PR #32414):SHOW COLUMNS/SHOW FIELDS ... WHEREwith parameter markers now prepare and execute correctly through binaryCOM_STMT_PREPAREand SQLPREPARE ... EXECUTE USINGfor base tables and views across Proxy6001, CN116001and CN216002(90/90checks), with multi-parameter predicates, schema re-preparation and binding semantics confirmed, the unchanged statement families guarded, and the pre-fix20301rejection still reproducing on thed39d8a4034control build under the identical matrix.