Repository navigation
Description
Is there an existing issue for the same bug?
I searched open and closed MatrixOne issues and PRs for RENAME COLUMN with prefix indexes, prefix_lengths metadata, SHOW CREATE after a rename, and unique-index metadata migration.
This is distinct from:
- [Bug]: Prefix-index covering queries drop values longer than the indexed prefix #26813: an existing prefix index's covering read path treated a truncated value as complete; it does not involve DDL or stale metadata after a rename.
- [Bug]: Extra predicates on a single-column unique index decode the raw key as a tuple #26818: an extra predicate on an ordinary single-column unique index decoded its direct key as a tuple; it does not alter index definitions.
- [Bug]: Prepared SELECT returns a different column after RENAME COLUMN #25622: a prepared SELECT keeps an old column binding after RENAME COLUMN, rather than corrupting ordinary-index prefix metadata.
- [Bug]: DATA BRANCH MERGE and PICK cannot apply changes after an equivalent column rename #26062: data branch merge/pick after an equivalent rename, not hidden-index DDL maintenance.
Branch Name
main
Commit ID
08770e1beeb23239c91165492f2fe85243a3c66a
Other Environment Information
- Local single-node MatrixOne on Linux
- MySQL client against port 6001
- Reproduced again in a current local main build
- The failure persists after an explicit TN flush
Actual Behavior
RENAME COLUMN updates the visible index part and the mo_indexes.column_name row, but leaves the old column name in mo_indexes.algo_params.prefix_lengths.
For UNIQUE KEY uq_a(a(4)), after renaming a to renamed_a:
SHOW CREATE TABLEdisplaysUNIQUE KEY uq_a (renamed_a)and loses(4);- catalog metadata says
column_name=renamed_abutalgo_params={"prefix_lengths":"a:4"}; - a value with the already-used four-character prefix can be inserted, violating the original unique-prefix constraint;
- after flush, a forced hidden-index lookup for the original row returns no row while
IGNORE INDEXreturns it.
Expected Behavior
Renaming a column must preserve the prefix-index definition and unique-prefix semantics. All name-bearing index metadata must move atomically from a:4 to renamed_a:4, and forced/base-table reads must agree before and after flush.
Steps to Reproduce
Run the expected-error insert separately so the client can continue.
DROP DATABASE IF EXISTS rename_prefix_repro;
CREATE DATABASE rename_prefix_repro;
USE rename_prefix_repro;
CREATE TABLE t (
id INT PRIMARY KEY,
a VARCHAR(32),
UNIQUE KEY uq_a(a(4))
);
INSERT INTO t VALUES (1, 'abcd-one');
-- Correct before RENAME: ERROR 1062 Duplicate entry 'abcd'.
INSERT INTO t VALUES (9, 'abcd-control');
ALTER TABLE t RENAME COLUMN a TO renamed_a;
SHOW CREATE TABLE t;
-- Wrong: UNIQUE KEY uq_a (renamed_a), with the (4) prefix omitted.
SELECT name, column_name, ordinal_position, algo_params
FROM mo_catalog.mo_indexes
WHERE database_id = (
SELECT dat_id FROM mo_catalog.mo_database
WHERE datname = 'rename_prefix_repro'
)
ORDER BY name, ordinal_position;
-- uq_a | renamed_a | 1 | {"prefix_lengths":"a:4"}
-- Wrong: should fail the same unique prefix, but succeeds.
INSERT INTO t VALUES (2, 'abcd-two');
SELECT id, renamed_a FROM t ORDER BY id;
-- 1 | abcd-one
-- 2 | abcd-two
SELECT id, renamed_a
FROM t FORCE INDEX(uq_a)
WHERE renamed_a = 'abcd-one';
-- before flush: 1 | abcd-one
SELECT mo_ctl('dn', 'flush', 'rename_prefix_repro.t');
SELECT id, renamed_a
FROM t FORCE INDEX(uq_a)
WHERE renamed_a = 'abcd-one';
-- wrong: empty result
SELECT id, renamed_a
FROM t IGNORE INDEX(uq_a)
WHERE renamed_a = 'abcd-one';
-- correct: 1 | abcd-oneAdditional Information
build_alter_rename_column.go updates IndexDef.Parts and the mo_indexes.column_name catalog row, but does not rewrite ordinary-index IndexAlgoParams. Prefix lengths are encoded as a column:length mapping, so later DML and planner code cannot match the renamed part to its prefix length.
The rename operation needs to parse the prefix-length metadata, replace only the renamed key while preserving other index parameters and multi-part entries, then persist the updated params together with the part and catalog-column rewrite.
Please retain black-box coverage for:
- unique prefix duplicate rejection before and after rename;
- SHOW CREATE and mo_indexes metadata before/after;
- same-prefix insert after rename;
- FORCE versus IGNORE reads across a flush;
- multi-part indexes with only one prefixed part, ensuring unrelated params remain unchanged.
Activity
LeftHandCold commentedon Aug 9, 2026
Fixed locally in commit 9b7629e901e13abed8b64670aba50238e487f70f.
The rename path now rewrites the matching key in ordinary-index prefix_lengths metadata and persists the updated algo_params together with the index-part/catalog column rename. Other prefix entries and flat params are retained; vector/plugin index metadata remains on its existing hook path.
Validated on a locally built MO service:
LeftHandCold commentedon Aug 9, 2026
Follow-up fix: ALTER TABLE ... CHANGE COLUMN has an independent planner path. It now renames prefix-length metadata together with the indexed column name.
Commit: 8e1c18823ad39356838fd24d2813b2832ad8417e
Validation:
fix(ddl): preserve prefix index metadata on column rename (matrixorig…
fix(ddl): preserve prefix metadata in CHANGE COLUMN (matrixorigin#26822)
fix(ddl): preserve prefix index metadata on column rename (matrixorig…
fix(ddl): preserve prefix metadata in CHANGE COLUMN (matrixorigin#26822)
fix: harden regular prefix index correctness (#26829)
LeftHandCold commentedon Aug 11, 2026
Validation result — fixed by #26829.
Verified on the exact merge commit
ac339444b558daf2c3d7fe63f755743449db7696, with an08770e1baseline comparison.Baseline: RENAME left
algo_params.prefix_lengthskeyed by the old column, SHOW CREATE lost the prefix length, duplicate-prefix INSERT was accepted, and FORCE could miss the original row after flush.Fix verification: RENAME and CHANGE preserve
(N)in SHOW CREATE and rewrite the persisted metadata to the new name. A duplicate prefix is rejected, valid DML remains correct, and FORCE equals IGNORE both before and after flush. The regression coverage also validates INSERT/UPDATE/DELETE after rename. Malformed/stale historical metadata now fails closed for DML rather than silently writing inconsistent index data.Conclusion: the reported DDL/catalog correctness defect is fixed. Closing.
fix: harden regular prefix index correctness (matrixorigin#26829)
fix: harden regular prefix index correctness (matrixorigin#26829)
fix: harden regular prefix index correctness (matrixorigin#26829)