Skip to content

[Bug]: SHOW COLUMNS/FIELDS rejects WHERE parameter markers during PREPARE #32408

Closed

Description

@ck89119

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/mysql v1.9.3, explicit sql.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:

  1. MySQL binary COM_STMT_PREPARE (explicit driver prepare, not emulation).
  2. 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:

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:

  • TestSweepShowParameterControls independently 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

  1. added
    kind/bug
    on Nov 9, 2026
  2. added
    severity/s0
    and removed on Nov 9, 2026
  3. added a commit that references this issue on Nov 9, 2026
    22a02c5
  4. assigned and unassigned on Nov 9, 2026
  5. MatrixAdventurer commented on Nov 10, 2026

    @MatrixAdventurer
    Contributor

    核实结论:已修复可关闭。
    证据:修复 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智能体提交

  6. slyunnn commented on Nov 11, 2026

    @slyunnn

    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/main with a dual-state matrix: the pre-fix build still reproduces the reported show 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

    • Maintenance branch / remote commit: main at 553e16f52b — fix(parser): support quoted wildcards in DESCRIBE shortcuts (#32339); git merge-base confirms it contains fix merge 22a02c581feaf56cf5ce0c319bcac8635c901369 (PR fix(plan): preserve prepare context for SHOW COLUMNS WHERE parameters #32414, merged 2026-11-09 14:50 UTC). Single-branch verification: this is a main issue; 4.2-dev was not verified and no 4.2-dev result is claimed.
    • Associated fix: PR fix(plan): preserve prepare context for SHOW COLUMNS WHERE parameters #32414, fix(plan): preserve prepare context for SHOW COLUMNS WHERE parameters. Direction: the SHOW COLUMNS / SHOW FIELDS ... WHERE rewrite to SELECT previously always bound in non-prepare mode, so a parameter marker was rejected with 20301 (HY000): invalid input: only prepare statement can use ? expr under both COM_STMT_PREPARE and SQL PREPARE; the fix now propagates the prepare flag into the rewritten query, while other SHOW statements keep their original behaviour.
    • Binary / topology: local build from that exact main tip, go1.27.1 darwin/arm64; -version reports Git commit ID 553e16f52b, buildtime 1794380911; binary SHA256 33c50723cc82728d59a58d03ba7e879850db0493584d168eab998d79cfb887bc. Deployed as a fresh-data single-version 2 CN / 1 TN / 1 LogService + Proxy; Proxy 6001, CN1 16001, CN2 16002 were 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 (SQL PREPARE / EXECUTE USING); endpoint identity git_version() = 553e16f52b was asserted at every route-round. After the matrix the service was stopped and all three ports were released.
    • Pre-fix control binary: separate build from d39d8a4034 (2026-10-30, pre-fix ancestor), SHA256 2c16af1e4dd7afb194211233be625af96ebaaba588d2ddd944cfaf3476cb43fe, used to re-confirm the original failure mode on the same fixture.
    • Client / method: mysql-connector-python 26.10.0 with cursor(prepared=True) — real binary COM_STMT_PREPARE plus bound COM_STMT_EXECUTE, no driver emulation — and pymysql 2.2.8 for text-protocol statements and fixture/DDL; an untracked external probe drove both builds.

    What Was Covered

    • OK — pre-fix control (d39d8a4034): the four original parameter shapes — binary SHOW COLUMNS ... WHERE Field=?, binary SHOW FIELDS ... WHERE Field=?, binary SHOW COLUMNS ... WHERE Field=? on a view, and SQL-string PREPARE p FROM 'SHOW COLUMNS ... WHERE Field=?' — are all rejected with the 20301 only prepare statement can use ? expr class on every route (12/12), while the no-WHERE prepared SHOW COLUMNS and the literal-WHERE text form keep working on the same binary — proving the probe exercises exactly the broken prepare-context path.
    • OK — original reproduction on the fixed build through binary 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 (the c1 row), on Proxy 6001, CN1 16001 and CN2 16002, 2 rounds (6/6).
    • OK — true server-side binding: executing the prepared statement with a bound but non-existing name (no_such_col) returns an empty set, not a rejection (6/6).
    • OK — SHOW FIELDS FROM <db>.t WHERE Field=? through the binary protocol returns the c2 row (6/6).
    • OK — view target: SHOW COLUMNS FROM <db>.v WHERE Field=? returns the c1 row of the view (6/6).
    • OK — SQL-string PREPARE p FROM 'SHOW COLUMNS ... WHERE Field=?' plus SET @a and EXECUTE p USING @a returns the c1 row through every endpoint-round (6/6).
    • OK — multi-parameter predicate WHERE Field=? AND Type=? binds both markers and returns the matching column row (6/6).
    • OK — repeated execution with different bound values (c1 then c2) on the same connection returns the respective rows (6/6).
    • OK — cross-connection schema refresh: after ALTER TABLE ... ADD COLUMN c9 from a second connection, a fresh prepared SHOW COLUMNS ... WHERE Field=? bound to c9 returns the new column row (6/6).
    • OK — behaviour guards: the no-WHERE prepared SHOW COLUMNS FROM <db>.t keeps passing, and the plain COM_QUERY unbound marker (SELECT ?) is still rejected after the fix (6/6 each); sessions stay usable (SELECT 1) after every step.
    • OK — merged in-repo focused suites on the same tip: TestShowColumnsPreparedWhere (pkg/tests/issues, real driver + SQL PREPARE/EXECUTE, run with -count=2, both passes, ok ... 9.493s) and TestShowColumnsPreparePreservesWhereParameters + TestCoverage_buildShowColumns (pkg/sql/plan, ok ... 1.758s).
    • Failed — none.
    • Not covered — the full-repo CI suite declaration remains as noted in the hand-off: this round re-runs the fix-focused suites and adds the dual-state endpoint matrix, not the entire repository's CI surface.
    • Not covered — MatrixOne 4.2-dev: the fix merge and this issue target main; no 4.2-dev build was verified and no 4.2-dev conclusion is claimed.
    • Not covered — SHOW families beyond SHOW COLUMNS / SHOW FIELDS ... WHERE: the fix and this verification are scoped to the rewriter named above; no claim is made for other SHOW statements.

    Findings

    • Pre-fix control: RESULT mode=control checks=33 failed=0 (all bug-state expectations held: 12/12 20301 rejections plus passing parity guards).
    • Fixed build: RESULT mode=full checks=90 failed=0 across 6 endpoint-rounds (Proxy 6001 / CN1 16001 / CN2 16002, 2 rounds, 15 checks each).
    • The reported failure signature 20301 (HY000) invalid input: only prepare statement can use ? expr no 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.
    • Big-data regression: not required. The defect sits in the SHOW COLUMNS / SHOW FIELDS ... WHERE rewrite'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; the 12-shape × 6-endpoint-round matrix already pins the behaviour.
    • Engine-parallel verification: not applicable — metadata-statement path with no multi-worker execution semantics; endpoint-level multi-CN exposure (two CNs plus the Proxy route) is exercised instead.
    • Raw evidence archived locally: the dual-mode probe, control/full result JSONs and per-route logs, launch logs and binary identity records; available on request.

    MOTR / BVT Coverage

    • No new MOTR/BVT case was added by this round. The fix already landed with planner-level parameterized subtests (TestShowColumnsPreparePreservesWhereParameters), a real-driver binary-protocol regression (TestShowColumnsPreparedWhere, which .test files cannot express), and the metadata BVT extension in view_metadata_wire_headers (single/multi-parameter, view, schema-refresh controls — recorded as 38/38 by 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 main at 553e16f52b (contains fix merge 22a02c581f, PR #32414): SHOW COLUMNS / SHOW FIELDS ... WHERE with parameter markers now prepare and execute correctly through binary COM_STMT_PREPARE and SQL PREPARE ... EXECUTE USING for base tables and views across Proxy 6001, CN1 16001 and CN2 16002 (90/90 checks), with multi-parameter predicates, schema re-preparation and binding semantics confirmed, the unchanged statement families guarded, and the pre-fix 20301 rejection still reproducing on the d39d8a4034 control build under the identical matrix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions