[Bug]: RENAME COLUMN leaves stale partition expression and unreplayable SHOW CREATE

Abierto
#33,397 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@matrix-meow ya está trabajando en esto.

Desde el 27/11/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

kind/bug needs-triage

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Searched open and closed issues for RENAME COLUMN with partition keys/expressions, stale SHOW CREATE partition definitions, and column a does not exist. Closed #26839 is the analogous stale-name problem for CHECK constraint SQL only; it does not cover partition expressions. #30256 concerns dependencies within one combined ALTER, and #12927 is a general partition optimization feature request. None covers this standalone RENAME leaving stale partition metadata.

Branch Name

main

Commit ID

c0cef5c9cce2164fedd201c188bfffe4d2d09a96

Other Environment Information

  • Hardware parameters: single-CN local deployment
  • OS type: macOS
  • Others: reproduced in two independent databases; git_version() = c0cef5c

Actual Behavior

After renaming a column used by PARTITION BY RANGE(a), the column definition is renamed to x, but SHOW CREATE TABLE still declares PARTITION BY RANGE(a).

Consequences:

  1. Replaying the emitted SHOW CREATE output under a different table name fails with Error 1054 invalid input: column a does not exist.
  2. ALTER TABLE ... ADD PARTITION on the renamed table fails with the same Error 1054.
  3. Existing rows remain readable, so this is stale schema metadata rather than data loss.
  4. Renaming x back to a makes ADD PARTITION and writes to the new partition work again.

A control table with the same initial definition accepts ADD PARTITION when no rename is performed.

Expected Behavior

RENAME COLUMN must update the partitioning expression and the persisted CREATE SQL atomically with the column definition. SHOW CREATE should use PARTITION BY RANGE(x), its output should be replayable, and subsequent partition maintenance should resolve the renamed key.

Steps to Reproduce

DROP DATABASE IF EXISTS repro_partition_rename;
CREATE DATABASE repro_partition_rename;
USE repro_partition_rename;

CREATE TABLE pt(id INT PRIMARY KEY, a INT, b INT)
PARTITION BY RANGE(a)(
  PARTITION p0 VALUES LESS THAN(10),
  PARTITION p1 VALUES LESS THAN(20)
);
INSERT INTO pt VALUES(1,1,10),(2,11,20);

ALTER TABLE pt RENAME COLUMN a TO x;
SHOW CREATE TABLE pt;

The resulting definition contains the renamed column but the old partition expression:

CREATE TABLE `pt` (
  `id` int NOT NULL,
  `x` int DEFAULT NULL,
  `b` int DEFAULT NULL,
  PRIMARY KEY (`id`)
)
PARTITION BY RANGE (`a`) (
  PARTITION p0 VALUES LESS THAN (10),
  PARTITION p1 VALUES LESS THAN (20)
);

Take that actual SHOW CREATE output, change only the table name from pt to pt_replay, and execute it:

Error 1054: invalid input: column a does not exist

Partition maintenance on the original renamed table fails in the same way:

ALTER TABLE pt ADD PARTITION(
  PARTITION p2 VALUES LESS THAN(30)
);
-- Error 1054: invalid input: column a does not exist

SELECT * FROM pt ORDER BY id;
-- (1,1,10),(2,11,20): old rows are still readable

-- Recovery control:
ALTER TABLE pt RENAME COLUMN x TO a;
ALTER TABLE pt ADD PARTITION(
  PARTITION p2 VALUES LESS THAN(30)
); -- succeeds
INSERT INTO pt VALUES(3,21,30);   -- succeeds

Additional Information

Static inspection of pkg/sql/plan/build_alter_rename_column.go shows updateRenameColumnInTableDef updating column definitions and several dependent expressions, but not rewriting the partition expression or its corresponding stored Createsql. The renamed column catalog and the stale partition metadata therefore disagree immediately after the successful ALTER.

Lenguaje dominante
Go
Estrellas
1.9k
Forks
312
Merge medio
21 h 57 min
PR fusionados (30 d)
730

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de matrixorigin/matrixone

Todos los issues de matrixorigin/matrixone

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.