Skip to content

[Bug]: COM_STMT_PREPARE rejects DESC/DESCRIBE for tables and views #32390

Closed

Description

@ck89119

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Searched open and closed issues/PRs for DESC + PREPARE, DESCRIBE + COM_STMT_PREPARE, ClientPreparedStatement, prepareable_stmt, and DESC/DESCRIBE titles. No dedicated duplicate was found.

Related but distinct: #30890 / PR #32339 concern column-name/quoted-wildcard filters in DESCRIBE shortcuts; #25429 concerned binary PREPARE of REPLACE. This report concerns rejection of plain DESC/DESCRIBE at native PREPARE, before filtering or result metadata is produced.

Branch Name

main (frozen acceptance 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; standalone LOG/TN/CN configuration.
  • Others: Go 1.27.1; github.com/go-sql-driver/mysql v1.9.3 using explicit PrepareContext and interpolateParams=false.
  • Independent client check: MySQL Connector/J 8.0.15 with useServerPrepStmts=true&emulateUnsupportedPstmts=false.
  • Compatibility control: MySQL 8.4.10 in an isolated container.
  • Tested ordinary MatrixOne binary SHA256: 0ae125cb624dccd50c342821cecc696d5db64a3f86d9c217fa26e0e502d4614a.

Actual Behavior

COM_STMT_PREPARE rejects all four plain statements below with error 1064 / SQLSTATE 42000:

DESC claude_s5_desc_prepare.src;
DESCRIBE claude_s5_desc_prepare.src;
DESC claude_s5_desc_prepare.v;
DESCRIBE claude_s5_desc_prepare.v;

Both the ordinary base table and the View contain one x INT column. The failure occurs at PREPARE, before EXECUTE or result-header comparison.

Representative captured error:

Error 1064 (42000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 57 near " claude_s5_desc_prepare.src";

Protocol controls on the same MatrixOne candidate:

Statement family COM_QUERY SQL PREPARE ... FROM '...' + EXECUTE COM_STMT_PREPARE + EXECUTE
DESC / DESCRIBE base table PASS PASS FAIL at PREPARE
DESC / DESCRIBE View PASS PASS FAIL at PREPARE
SHOW COLUMNS FROM View PASS PASS PASS
SHOW FULL COLUMNS FROM View PASS PASS PASS

The independent Go probe recorded 17/21 passing observations and exactly these four failures; cleanup succeeded. The equivalent MySQL 8.4.10 control recorded 21/21 PASS, including all four binary DESC/DESCRIBE cases. The missing-object negative control allows rejection at PREPARE or EXECUTE, since MySQL may defer that check to EXECUTE.

Driver fallback can hide this bug. Connector/J with unsupported-statement emulation enabled silently returns com.mysql.cj.jdbc.ClientPreparedStatement after the server-side prepare fails. With emulation disabled, connection.prepareStatement("desc ...") throws SQLSyntaxErrorException from ServerPreparedStatement.serverPrepare. Merely setting useServerPrepStmts=true is therefore not proof of binary-protocol coverage.

Expected Behavior

For a valid, authorized base table or View, native PREPARE of DESC and DESCRIBE should succeed and EXECUTE should return the same logical column description as the direct/SQL-prepared form, as on MySQL 8.4.10.

The fix should preserve MatrixOne's existing SHOW result contract (including its additional Comment column on ordinary SHOW), current authorization, and normal errors for missing/inaccessible objects. This issue does not request unrelated EXPLAIN syntax or a broad SHOW metadata redesign.

Steps to Reproduce

Create this minimal fixture on an owned test instance:

CREATE DATABASE claude_s5_desc_prepare;
CREATE TABLE claude_s5_desc_prepare.src (x INT);
CREATE VIEW claude_s5_desc_prepare.v AS SELECT x FROM claude_s5_desc_prepare.src;

Use an explicit server-side prepare, not a driver-emulated query. In Go, establish a connection with github.com/go-sql-driver/mysql v1.9.3 and run the following core operations from the validated probe:

ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

db, err := sql.Open("mysql", "dump:111@tcp(127.0.0.1:6001)/?timeout=5s&readTimeout=20s&interpolateParams=false")
if err != nil { panic(err) }
defer db.Close()
conn, err := db.Conn(ctx)
if err != nil { panic(err) }
defer conn.Close()

for _, query := range []string{
    "desc claude_s5_desc_prepare.src",
    "describe claude_s5_desc_prepare.src",
    "desc claude_s5_desc_prepare.v",
    "describe claude_s5_desc_prepare.v",
    "show columns from claude_s5_desc_prepare.v",
    "show full columns from claude_s5_desc_prepare.v",
} {
    func() {
        stmt, err := conn.PrepareContext(ctx, query) // COM_STMT_PREPARE
        fmt.Printf("PREPARE %q: %v\n", query, err)
        if err != nil { return }
        defer stmt.Close()
        rows, err := stmt.QueryContext(ctx) // COM_STMT_EXECUTE
        if err != nil { panic(err) }
        defer rows.Close()
        columns, err := rows.Columns()
        if err != nil { panic(err) }
        fmt.Printf("EXECUTE columns: %v\n", columns)
        for rows.Next() {} // Drain this description before the next statement.
        if err := rows.Err(); err != nil { panic(err) }
    }()
}

Required imports: context, database/sql, fmt, time, and _ "github.com/go-sql-driver/mysql". Run inside a Go module with that driver dependency. Replace the local address/credentials as needed; the first four PREPARE calls fail on the tested MatrixOne candidate, while both SHOW controls succeed.

Direct and SQL-string-PREPARE controls:

DESC claude_s5_desc_prepare.src;
DESC claude_s5_desc_prepare.v;
PREPARE desc_control FROM 'DESC claude_s5_desc_prepare.v';
EXECUTE desc_control;
DEALLOCATE PREPARE desc_control;
DROP DATABASE claude_s5_desc_prepare;

These SQL controls do not exercise native COM_STMT_PREPARE.

Additional information

Static localization at the tested commit

  • Native PREPARE handling applies rewrite policy and then wraps the payload as the non-string PREPARE <name> FROM <statement> form.
  • prepareable_stmt admits show_stmt and explain_plan_stmt, but not the table-description branch.
  • explain_stmt lowers explain_sym unresolved_object_name to tree.ShowColumns. SQL string PREPARE follows a different grammar path, explaining why that control succeeds.

The change should close this specific acceptance mismatch without bypassing rewrite/authorization handling or indiscriminately admitting every EXPLAIN variant. Generated parser output should be regenerated through the repository tooling, not edited manually.

Regression checks for the eventual fix

  • Plain DESC and DESCRIBE for both base tables and Views through real binary PREPARE/EXECUTE, plus direct and SQL-string-PREPARE controls.
  • Prepared and execution column metadata, repeated execution, and changes made by another connection (DDL/rebuild); retain existing SHOW/FULL SHOW expectations.
  • Missing-object and permission rejection, cleanup/connection usability after errors, and no client-emulation fallback masquerading as a pass.

Scope and attribution

Found during S5 acceptance for #29440 after #32259 / PR #32328. This issue reports the confirmed compatibility failure on the commit above; it does not reopen those items or assert overall S5 completion.

The same four failures were also observed in an archived 52cb + WIP binary. That is not a clean base-branch run. No clean pre-#32328 base was tested, so this report makes no claim that the bug was already present on clean base or that #32328 has been ruled out as a regression source. No product fix was made during this validation.

Activity

  1. added
    kind/bug
    on Nov 9, 2026
  2. added
    severity/s0
    and removed on Nov 9, 2026
  3. Ariznawlll commented on Nov 9, 2026

    @Ariznawlll
    Collaborator

    结论

    测试不通过。当前 main 的原生二进制 PREPARE 仍拒绝普通 DESC/DESCRIBE;直接文本语句可正常返回列定义。

    关键证据

    • 版本:main@c99234dcf4c94d1ff9d372917cd35041f1a3a682,隔离本地 CN,运行时 git_version() 为 c99234dcf4。
    • 在 3 个独立数据库上,mysql-connector-python cursor(prepared=True) 实际发送二进制 PREPARE;DESC/DESCRIBE 对 base table 与普通 view 全部在 PREPARE 阶段返回 1064。
    • 同库直接文本 DESC table、DESCRIBE view 均返回 x INT 列元数据;失败后连接可继续 SELECT 1,每轮测试库已删除。
    • 初次文本对照连接未选数据库,结果作废;修正为先选库后重跑,才计入上述对照。

    待解决点

    • 未验证 Connector/J 驱动及执行阶段的列元数据;本轮确认的是实际二进制协议 PREPARE 阶段拒绝。
  4. added a commit that references this issue on Nov 9, 2026
    6a2b299
  5. assigned and unassigned on Nov 9, 2026
  6. slyunnn commented on Nov 11, 2026

    @slyunnn

    Regression and extended verification for #32390 (2026-11-11)

    Re-verified end to end on the latest origin/main with real binary-protocol clients: native COM_STMT_PREPARE of plain DESC/DESCRIBE now succeeds for base tables and views, and the pre-fix rejection is still reproducible on the pre-fix control build. Result: Fixed.

    Verification Environment

    • origin/main commit: 45917e803f2915f6f0838b2b2fe9f591fc5b6018 — fix(plan): fold contradictory same-column predicates to near-zero estimates (#32502); confirmed by git merge-base to contain fix merge 6a2b29954749d5a47820ed429cfa8a6c4793682f.
    • Associated fix: PR fix(parser): allow native PREPARE of DESC/DESCRIBE #32399, fix(parser): allow native PREPARE of DESC/DESCRIBE (merge 6a2b29952b... alias 6a2b299547, merged 2026-11-09). Direction: extract the table-description grammar productions into a shared rule and admit that rule in prepareable_stmt, so native PREPARE ... FROM <statement> accepts DESC/DESCRIBE while unrelated EXPLAIN variants (including FOR CONNECTION) stay outside the prepare boundary.
    • Binary: locally built single-process mo-service from that origin/main commit, go1.27.1 darwin/arm64 (GOEXPERIMENT=simd); -version reports Git commit ID 45917e803f, buildtime 1794370498; module stamp SHA256 a66e792499b046d200add687af9b30488059c777e3341642a04e43397b21cec6. Runtime identity re-checked at every endpoint-round: git_version() = 45917e803f (12/12 consistent).
    • Pre-fix control binary: separate build from 2026 the same week (d39d8a4034, pre-fix ancestor), SHA256 2c16af1e4dd7afb194211233be625af96ebaaba588d2ddd944cfaf3476cb43fe, used only to re-confirm the original failure mode.
    • Topology: local macOS arm64, fresh data directory, single-binary single-version deployment 2 CN / 1 TN / 1 LogService + Proxy. All three routes were connected and exercised: Proxy 6001, CN1 16001, CN2 16002; every scenario below ran through each route over both the MySQL text protocol and the native binary protocol (COM_STMT_PREPARE). Clients: mysql-connector-python 26.10.0 with cursor(prepared=True) (real server-side prepare, no driver emulation) and pymysql 2.2.8 for text-protocol statements. Health checks alone do not count as endpoint coverage. After the full matrix the service was stopped and all three ports were released (no lingering listeners).
    • Parallel execution: the matrix ran sequentially per endpoint-round; endpoint-level multi-CN exposure exists by construction (two CNs plus the Proxy route). No engine-parallel path is engaged by DESC/DESCRIBE prepare/execute.

    What Was Covered

    • OK — original reproduction (pre-fix control, d39d8a4034): the four statements from the issue body — DESC <db>.t1;, DESCRIBE <db>.t1;, DESC <db>.v;, DESCRIBE <db>.v; — are rejected at COM_STMT_PREPARE with 1064 (42000): SQL parser error on every route (12/12 expected rejections), while the same statements over COM_QUERY, SQL-string PREPARE ... FROM, and binary-prepared SHOW COLUMNS FROM keep working on the same connections — confirming the probe genuinely exercises the binary protocol and reproducing the reported symptom exactly.
    • OK — original reproduction on the fixed build: all four statements prepare and execute successfully through Proxy 6001, CN1 16001, CN2 16002 in 2 rounds (24/24), returning the same column metadata as the text form (e.g. ('x','int','YES','',NULL,'','') for both table and view targets).
    • OK — unqualified form: prepared DESC t1 through the default database matches the text result on every endpoint-round (6/6).
    • OK — repeated execution: re-preparing and re-executing DESC <db>.t1; returns byte-identical metadata across repetitions (6/6).
    • OK — statement-family regression guards: binary-prepared SHOW COLUMNS FROM/SHOW FULL COLUMNS FROM and SQL-string PREPARE ... FROM 'DESC ...' + EXECUTE all keep passing (6/6 each) — the fix did not narrow existing prepareable statements.
    • OK — missing object: prepared DESC <ghost>.t1 now fails with the semantic error 1049 (42000): Unknown database ... instead of the syntax error (6/6); the session remains usable after the error (SELECT 1, 6/6).
    • OK — privilege-less user: a restricted account can log in and connect, its prepared DESC on the admin-owned table is rejected with 20101 (HY000): internal error: do not have privilege to execute the statement (non-syntax, as before the fix), and the session stays usable (6/6).
    • OK — cross-connection DDL refresh: after ALTER TABLE ... ADD COLUMN y from a second connection on the same CN service, a fresh prepared DESC of the table sees columns ('x','y'); after DROP VIEW + CREATE VIEW ... AS SELECT y, a fresh prepared DESCRIBE <db>.v returns the new view definition — matching the text form on every endpoint-round (6/6).
    • OK — connection usability after every error path and per-round hygiene: SELECT 1 after each failure (6/6), each route-round used its own fixture database and test user, all dropped before the next round; each endpoint-round asserted git_version() identity (12/12).
    • Failed — none.
    • Not covered — Connector/J driver stack specifically (the issue mentions it): the binary-protocol path is covered by mysql-connector-python prepared cursors here and by the fix PR's in-repo Go binary-protocol tests; Connector/J was not exercised in this round.
    • Not covered — K8s/TKE deployment forms, mixed-version rolling upgrades: single-version local deployment per this regression's scope.
    • Not covered — EXPLAIN ... FOR CONNECTION and other EXPLAIN variants at native prepare: explicit non-goal of the fix (they remain outside prepareable_stmt by design).

    Findings

    • Control run (pre-fix): RESULT mode=control checks=39 failed=0 (all expectations for the bug state held — four 1064-rejections per route plus parity controls).
    • Fixed build: RESULT mode=full checks=126 failed=0 across 6 endpoint-rounds (Proxy 6001 / CN1 16001 / CN2 16002, 2 rounds).
    • Big-data regression: not required. The defect lives in native PREPARE grammar admission (parser / frontend statement boundary); outcome class has no dependency on row count, LIMIT, block/batch boundaries, memory/spill, concurrency scale, skew, network transfer, or index state, so data volume cannot change the result; endpoint-round repetition already pins the behavior.
    • Engine-parallel verification: not applicable for the same reason; endpoint-level multi-CN coverage (two CNs plus the Proxy route) is exercised instead.
    • Raw evidence archived locally: probe.py, probe.log, results.json (full run) and control/probe.log, control/results-control.json (pre-fix control), binary-identity.txt, launch logs; details available on request.

    MOTR / BVT Coverage

    • No new MOTR/BVT case was added for this verification. The fix already landed with in-repo coverage: typed parser tests (pkg/sql/parsers/dialect/mysql/prepare_description_test.go), a real binary-protocol regression suite (pkg/tests/issues/prepare_description_test.go — tables and views, repeated execution, PREPARE/EXECUTE column metadata, cross-connection DDL refresh, missing objects, permission rejection, connection usability after errors), and a BVT extension (view_metadata_wire_headers prepare controls). MOTR .test files cannot express COM_STMT_PREPARE (it is a binary-protocol command, not server-side SQL-string PREPARE), so this round contributes the deployed-cluster, multi-endpoint, connector-level evidence instead, and no duplicate case is proposed.

    Final Conclusion

    Fixed — verified on origin/main at 45917e803f (contains fix merge 6a2b299547, PR #32399): native COM_STMT_PREPARE of plain DESC/DESCRIBE for base tables and views now succeeds and returns the same metadata as the text form through Proxy 6001, CN1 16001 and CN2 16002 alike, with 126/126 checks passing; missing objects and privilege failures degrade to their proper semantic errors (not 1064), existing prepareable statement families are unaffected, and the pre-fix build still reproduces the original 1064 rejection (12/12), which no longer occurs on the fixed build.

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