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

Đang mở
#33,397 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@matrix-meow đang làm issue này rồi.

Từ ngày 27/11/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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.

Ngôn ngữ chính
Go
Star
1.9k
Fork
312
Merge trung bình
21 giờ 57 phút
Pull request đã merge (30 ngày)
730

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của matrixorigin/matrixone

Tất cả issue của matrixorigin/matrixone

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.