Skip to content

[Compatibility]: temporary tables reject column and rename ALTER operations #28303

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

74668fc

Other Environment Information

- MatrixOne was built from the commit above and started locally with etc/launch/launch.toml.
- MySQL comparison version: 8.0.45.
- Every ALTER operation was repeated on three independently created temporary tables.

Actual Behavior

MatrixOne rejects temporary-table ALTER operations that change columns or the
table name:

  • ADD COLUMN;
  • DROP COLUMN;
  • MODIFY COLUMN;
  • RENAME COLUMN;
  • RENAME TO.

Each operation returns:

alter table for temporary table is not yet implemented

The limitation is narrower than all temporary-table DDL. In the same build,
the following operations work correctly:

  • create, read, write, and transaction rollback;
  • session-local shadowing of a same-name permanent table;
  • automatic removal when the owning connection closes;
  • CREATE TEMPORARY TABLE ... AS SELECT;
  • CREATE INDEX on a temporary table;
  • ALTER TABLE ... ADD INDEX on a temporary table.

Expected Behavior

MatrixOne should alter a temporary table's columns and name within its owning
session, as MySQL 8.0.45 does. The change should remain session-local and should
not affect a same-name permanent table or another session.

Steps to Reproduce

CREATE DATABASE codex_temp_alter_0907;
USE codex_temp_alter_0907;

CREATE TEMPORARY TABLE tmp_add(id INT PRIMARY KEY, v INT);
ALTER TABLE tmp_add ADD COLUMN extra INT DEFAULT 7;
SHOW CREATE TABLE tmp_add;

CREATE TEMPORARY TABLE tmp_drop(id INT PRIMARY KEY, v INT);
ALTER TABLE tmp_drop DROP COLUMN v;
SHOW CREATE TABLE tmp_drop;

CREATE TEMPORARY TABLE tmp_modify(id INT PRIMARY KEY, v INT);
ALTER TABLE tmp_modify MODIFY COLUMN v BIGINT;
SHOW CREATE TABLE tmp_modify;

CREATE TEMPORARY TABLE tmp_rename_col(id INT PRIMARY KEY, v INT);
ALTER TABLE tmp_rename_col RENAME COLUMN v TO value_col;
SHOW CREATE TABLE tmp_rename_col;

CREATE TEMPORARY TABLE tmp_rename_table(id INT PRIMARY KEY, v INT);
ALTER TABLE tmp_rename_table RENAME TO tmp_renamed;
SHOW CREATE TABLE tmp_renamed;

-- Nearby controls that MatrixOne supports.
CREATE TEMPORARY TABLE tmp_add_idx(id INT PRIMARY KEY, v INT);
ALTER TABLE tmp_add_idx ADD INDEX idx_v(v);
SHOW CREATE TABLE tmp_add_idx;

CREATE TEMPORARY TABLE tmp_create_idx(id INT PRIMARY KEY, v INT);
CREATE INDEX idx_v ON tmp_create_idx(v);
SHOW CREATE TABLE tmp_create_idx;

CREATE TEMPORARY TABLE tmp_ctas AS SELECT 1 AS id, 10 AS v;
SELECT * FROM tmp_ctas;

Additional information

The general ALTER builder has an explicit temporary-table NYI guard in
pkg/sql/plan/build_alter_table.go. Index-specific DDL takes a different path
and already succeeds.

This is a remaining temporary-table capability gap after closed feature issue
#23251; that issue covered initial temporary-table implementation rather than
column and rename ALTER operations.

Activity

  1. added this to the MO-202609 milestone on Sep 7, 2026
  2. added
    kind/bug
    on Sep 7, 2026
  3. added theissue type on Sep 7, 2026
  4. added
    ai-easy
    on Sep 8, 2026
  5. slyunnn commented on Sep 9, 2026

    @slyunnn

    Regression and extended verification for #28303 (2026-09-09)

    Verification Environment

    • MatrixOne baseline: latest local origin/main at f0c31cd4b830be32442cf329e0a3fb08aa9c16c3 — feat(load): add bounded Arrow IPC ingestion path (#28145).
    • Related fix: PR #28324, fix: support altering temporary table columns and names, merged as ad225722a0bc0d0de1e7fdde8ca2cb38807c1a7b. The merge commit is an ancestor of the baseline.
    • Topology: freshly built standalone deployment from the baseline; one mo-service hosts LOG/HAKeeper, one TN, and one CN. No Proxy and no second CN were used.
    • Endpoints: CN MySQL 127.0.0.1:6001; TN 127.0.0.1:19000; Log/HAKeeper 127.0.0.1:32001.
    • Clients and protocol: mysql CLI, PyMySQL, and MOTR/PyMySQL over MySQL wire protocol via TCP to 127.0.0.1:6001.

    What Was Covered

    • OK: Original scenario: a temporary table accepts ALTER TABLE ... ADD COLUMN, DROP COLUMN, MODIFY COLUMN, RENAME COLUMN, and RENAME TO.
    • OK: Happy path: added defaults are materialized, INT to BIGINT accepts 2147483648, rows survive every successful ALTER, and the renamed column/table remain queryable.
    • OK: Session-local behavior: two independent MySQL-protocol connections prove that a temporary tmp_alter shadows only its owner connection; same-name permanent tmp_alter and tmp_renamed tables remain unchanged in the other connection before and after the temporary rename.
    • OK: Unhappy path: narrowing BIGINT 2147483648 to TINYINT returns ERROR 1690, while the original temporary table and all 3 rows remain available.
    • OK: Unhappy path: renaming to an occupied temporary-table name returns ERROR 1050; the source alias and rows remain intact.
    • OK: Boundary and transaction path: add-column plus rename inside BEGIN is visible before ROLLBACK; after ROLLBACK, the old name and original schema/data return and the temporary transaction alias returns ERROR 1146.
    • OK: Compatibility control: ALTER TABLE ... ADD INDEX on a temporary table remains usable.
    • OK: The related fix BVT includes an additional multi-session observer path and checks copy-table cleanup in mo_catalog.
    • Not covered: Proxy, multi-CN, JDBC, TKE, restart, and upgrade paths. The affected contract is session-local temporary-table DDL and has no dependency on routing, persistence across restart, or client-specific encoding.
    • Not covered: a fresh live MySQL 8.0.45 comparison and automatic temporary-table removal after connection close; these are unchanged controls, not modified by PR fix: support altering temporary table columns and names #28324.

    Findings

    The main baseline contains the fix and no longer rejects the five column/name ALTER forms for temporary tables. The new behavior preserves owner-session scope, rows, defaults, index behavior, and transactional rollback. Failed conversion and name-collision operations preserve the prior temporary relation instead of leaving a partial replacement.

    Large-data regression is not required. This issue is a session-local DDL/catalog transformation; it does not depend on row count, block/batch boundaries, memory/spill, concurrency, skew, network transfer, or resource scale. Two seeded rows plus one widened BIGINT value are the minimum stable data set that exercises success, null/default preservation, conversion failure, and rollback without adding unrelated CI cost.

    MOTR / BVT Coverage

    • Added MOTR regression: suites/14_issue_regression/t/issue_28303_temp_table_alter.test and suites/14_issue_regression/r/issue_28303_temp_table_alter.result.
    • Recorded once and replayed twice against the freshly built baseline. Each run passed 38 statements with 0 failures.
    • Independent backup branch: test/issue-28303-temp-table-alter, commit 1d113a5. No issue-specific PR was created.

    Final Conclusion

    Fixed. The current main contains the associated fix, and the original scenario plus happy-path, error-preservation, transaction, boundary, session-scope, and index-control verification pass. Large-data regression is not needed for the reasons above.

  6. slyunnn commented on Sep 18, 2026

    @slyunnn

    Regression and extended verification for #28303 (2026-09-18)

    Verification Environment

    • Verified source: eed6ff8727454fe1ec7ea8cd8d368e08c1deefbd — fix: preserve numeric source types at integer assignment boundaries (#29061).
    • Related fix: ad225722a0bc0d0de1e7fdde8ca2cb38807c1a7b — fix: temporary table DDL limitations (#28324).
    • Topology: 2 CN / 1 TN / 1 Log service / Proxy. Proxy 6001, CN1 16001, and CN2 16002 were each reachable.
    • Client protocol: MySQL text protocol through mysql; the DDL sequence was sent as one semicolon-separated COM_QUERY request.

    What Was Covered

    • OK — Original temporary-table DDL flow: CREATE TEMPORARY TABLE, INSERT, ALTER ... ADD COLUMN, DROP COLUMN, MODIFY COLUMN, RENAME COLUMN, RENAME TO, and a final aggregate assertion.
    • OK — Happy path: the final COUNT(*) = 1 AND MAX(value_col) = 10 assertion returned 1 after FROM t_renamed.
    • OK — Endpoint coverage: the same single-packet flow passed through Proxy 6001, CN1 16001, and CN2 16002.
    • OK — Comparison path: the same flow passed for both temporary and regular tables on all three endpoints.
    • OK — Existing BVT: test/distributed/cases/temporary/temporary_table_limitation.sql passed with 130 successful, 0 failed, and 7 ignored checks.
    • OK — Unhappy-path diagnosis: the earlier ERROR 1054 was reproduced only when the test SQL omitted FROM t_renamed; this is normal SQL name resolution, not a MatrixOne catalog-visibility regression.
    • Not covered — Cross-version compatibility and a separate external MySQL comparison were not needed for this MatrixOne-specific temporary-table DDL issue.

    Findings

    The recheck found no regression in #28303 on the latest main. The previously reported 1054 came from an invalid aggregate query with no table source. After adding FROM t_renamed, the full multi-statement sequence passed consistently.

    Large-data regression is not needed: this issue concerns DDL metadata and session behavior, not row count, block/batch boundaries, memory/spill, concurrency, data skew, or network/resource scale.

    MOTR / BVT Coverage

    No MOTR change was added because existing BVT coverage passed and no product defect or missing stable regression scenario remained after correcting the validation SQL. No new issue branch, commit, or PR is required.

    Final Conclusion

    Fixed — #28303 remains fixed on the verified latest main; no new MatrixOne or MOTR change is required.

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

Metadata

Metadata

Assignees

Labels

ai-easykind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions