[Bug]: Prepared SHOW CREATE TABLE is not invalidated by cross-session COPY ALTER
メンテナーはふだん 1 日以内に返信
@matrix-meow がすでに取り組んでいます。
2026年11月27日 から。
評価
この issue はまだ評価されていません。
説明
Description
Tested on MatrixOne main c0cef5c9cce2164fedd201c188bfffe4d2d09a96 (version() = 8.0.30-MatrixOne-v1.3.0, git_version() = c0cef5c), single CN.
A SQL-level prepared SHOW CREATE TABLE is not invalidated by COPY ALTER committed in another session. Repeated EXECUTE continues returning the definition captured at PREPARE time, even though direct SHOW CREATE, a new PREPARE, and prepared SHOW COLUMNS all see the current schema.
The same missing dependency also lets a snapshot-qualified prepared SHOW CREATE succeed after its named snapshot has been dropped.
Minimal two-session reproduction
-- S0
CREATE TABLE t(a INT,b INT);
-- S1
PREPARE p_create FROM 'SHOW CREATE TABLE t';
PREPARE p_columns FROM 'SHOW COLUMNS FROM t';
EXECUTE p_create;
EXECUTE p_columns;
-- S2, using autocommit; wait for the ALTER to commit successfully
ALTER TABLE t ALGORITHM=COPY,ADD COLUMN c INT DEFAULT 7;
-- S1
EXECUTE p_create;
Actual result: the prepared result still contains only a and b; there is no c.
Expected result: EXECUTE rebuilds or invalidates the old plan and returns the current definition containing c INT DEFAULT 7.
The initial executions are intentional: they warm the logical/compiled-plan reuse path before the cross-session DDL.
Positive controls
After the stale EXECUTE above, all of these see column c:
-- S1
SHOW CREATE TABLE t;
EXECUTE p_columns;
PREPARE fresh_create FROM 'SHOW CREATE TABLE t';
EXECUTE fresh_create;
A same-session COPY ADD also refreshes the prepared statement correctly. The defect therefore requires the PREPARE session and DDL session to be different; it is not an uncommitted-DDL artifact or a general catalog-cache delay.
Other affected COPY operations
The same stale-result behavior was reproduced after each of these cross-session operations:
ALTER TABLE t ALGORITHM=COPY,DROP COLUMN b;
ALTER TABLE t ALGORITHM=COPY,RENAME COLUMN b TO b_renamed;
ALTER TABLE t ALGORITHM=COPY,CHANGE COLUMN b b_changed BIGINT;
ALTER TABLE t ALGORITHM=COPY,MODIFY COLUMN payload VARCHAR(32);
For DROP/RENAME/CHANGE, the old prepared result retains the old column. For MODIFY, it retains VARCHAR(8) instead of the new VARCHAR(32). Direct SHOW CREATE and fresh PREPARE controls return the correct new definition in every case.
Snapshot lifecycle symptom
For a snapshot-qualified prepared SHOW CREATE:
- While the named snapshot exists, the old prepared statement correctly returns the historical definition, matching direct historical reads.
- After another session drops that snapshot, the old prepared SHOW CREATE still executes successfully and returns the PREPARE-time definition.
- In contrast, the old prepared SELECT, direct SHOW CREATE, and a fresh PREPARE all report that the snapshot no longer exists.
This is included in the same report because it has the same empty-dependency root cause; it is not a claim that historical reads while the snapshot exists are wrong.
Root cause
pkg/sql/plan/build_show.go:buildShowCreateTable resolves the table and generates the complete DDL, then rewrites SHOW CREATE into a literal query of the form:
SELECT '<table>', '<CREATE TABLE text>'
That literal SELECT has no table scan from which normal dependency extraction can recover the target table, and this path does not call setShowMetadataDependencies.
In addition, collectPrepareDdlSchemas in pkg/sql/plan/build_dcl.go handles ALTER/CREATE/DROP and related statements but has no ShowCreateTable case. The resulting Prepare.Schemas is empty, so the cross-session EXECUTE schema validation in pkg/frontend/computation_wrapper.go has no object to invalidate. The preparing session's own DDL generation does not advance when another session commits the ALTER.
Prepared SHOW COLUMNS captures its target through setShowMetadataDependencies, explaining the positive control. Snapshot-qualified SHOW CREATE is likewise reduced to literals, so the named-snapshot lifecycle check is bypassed as well.
Validation
All five COPY operation shapes were reproduced in two independent fresh-database runs, with the direct/fresh/prepared-SHOW-COLUMNS controls and base-row checks. The snapshot lifecycle sequence was also independently repeated. Every ALTER itself succeeded; this report concerns stale metadata after successful DDL, not data loss or failure atomicity.
Duplicate check
Open and closed searches covered PREPARE/EXECUTE with SHOW CREATE, stale plans, dependency/invalidation, COPY ALTER, and snapshot lifecycle. No matching issue was found.
Closed #25986 fixed prepared schema-changing DDL that reused stale validation state; it does not cover the SHOW CREATE literal-rewrite entry point, which is still absent from collectPrepareDdlSchemas. Closed #26882 concerns COM_QUERY view plan caching, and closed #29180 concerns Connector/J server-prepared SELECT * result metadata. Neither owns this SQL-level prepared SHOW CREATE path. Open architecture trackers such as #32278 do not contain this reproduction.
- 主要言語
- Go
- スター
- 1.9k
- フォーク
- 312
- 平均マージ
- 21時間 57分
- マージ済み PR(30日)
- 730
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
matrixorigin/matrixone のほかの issue
-
kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
matrixorigin/matrixone#33363 ·
メンテナーはふだん 1 日以内に返信
-
kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
matrixorigin/matrixone#33362 ·
メンテナーはふだん 1 日以内に返信
-
SLEEP rejects NULL and negative durations that MySQL accepts対応中かも @XuPeng-SH が 7 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
matrixorigin/matrixone#32653 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: TestChangeWatchProxy loses its first tenant connection during PingContext in Ubuntu CI対応中かも @XuPeng-SH が今日担当しました。 オープンkind/bug needs-triage
matrixorigin/matrixone#33371 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: TestDaemonClaimSQLRoundTrip exhausts its shared deadline during the stale claim update in Ubuntu CI対応中かも @XuPeng-SH が今日担当しました。 オープンkind/bug needs-triage
matrixorigin/matrixone#33370 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
matrixorigin/matrixone の issue をすべて見る
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
area/ui-schema good first issue type/bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 4 日以内に返信
-
A vessel you are not flying should draw dim grey, orbit and arrow (ADR 0041), not in its own colourオープンready-for-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
jasonfen/terminal-space-program#1020 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
router-for-me/CLIProxyAPI#8573 ·
メンテナーはふだん 9 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
sipeed/picoclaw#3477 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信