Skip to content

[Bug]: Prefix indexes on quoted delimiter-bearing columns create unusable metadata #26823

Closed

Description

@LeftHandCold

Reproduction

CREATE DATABASE quoted_prefix_name;
USE quoted_prefix_name;

CREATE TABLE t (
  id INT PRIMARY KEY,
  `a:b` VARCHAR(32),
  KEY idx_col (`a:b`(2))
);

SHOW CREATE TABLE t;
INSERT INTO t VALUES (1, 'ab-long');

Expected

A quoted column name is legal. Prefix-index metadata must preserve it losslessly, so SHOW CREATE TABLE and DML should succeed.

Actual

The CREATE TABLE statement succeeds but stores:

{"prefix_lengths":"a:b:2"}

Both SHOW CREATE TABLE and INSERT fail with:

ERROR 20301 (HY000): invalid input: invalid index prefix length "a:b:2"

The colon-delimited prefix_lengths encoding cannot represent legal column names containing ':' (and likewise has an ambiguous comma separator).

Scope / duplicate check

This is distinct from #26822 (stale prefix metadata after a rename), #26818 (direct unique-index extra filters), and #26813 (covering prefix lookup). I searched recent MatrixOne issues for "prefix length", "prefix_lengths", "SHOW CREATE index", and "column name prefix index"; none cover quoted delimiter-bearing column names.

Activity

  1. self-assigned this
    on Aug 9, 2026
  2. LeftHandCold commented on Aug 9, 2026

    @LeftHandCold
    CollaboratorAuthor

    Fixed in c019ffe6053784841d6973095875006658ba7edf.

    Implementation:

    • Keep reading and writing the legacy prefix_lengths format for ordinary identifiers.
    • Use a lossless prefix_lengths_v2 JSON payload only when a column name contains ':' or ','.
    • Prefer v2 on read, validate malformed v2 metadata, and use the same writer when a RENAME COLUMN or CHANGE COLUMN operation changes a prefix-indexed name.

    Compatibility decision: existing catalog metadata remains unchanged; v2 is opt-in solely for names the legacy encoding could never represent correctly.

    Validation:

    • Added catalog round-trip/error tests and planner tests for both RENAME COLUMN and CHANGE COLUMN.
    • New distributed DDL coverage exercises CREATE TABLE, CREATE INDEX, ALTER TABLE ADD INDEX, metadata inspection, SHOW CREATE, flush, and FORCE/IGNORE INDEX: 28/28.
    • Existing prefix-index DML regression suite: 55/55.
    • Full pkg/catalog and pkg/sql/plan tests, controlled go vet, and make build passed.
  3. added a commit that references this issue on Aug 9, 2026
    ac33944
  4. LeftHandCold commented on Aug 11, 2026

    @LeftHandCold
    CollaboratorAuthor

    Validation result — fixed by #26829.

    Verified on the exact merge commit ac339444b558daf2c3d7fe63f755743449db7696.

    Baseline: a legal quoted column containing : or , was serialized through the ambiguous legacy prefix metadata, making SHOW CREATE and DML fail.
    Fix verification: the merge emits lossless prefix_lengths_v2 metadata (for example {"a:b":3,"c,d":2}) and successfully covers CREATE TABLE, CREATE INDEX, ALTER ADD INDEX, RENAME to a delimiter-bearing name, FORCE/IGNORE lookup, and post-flush reads. Protocol-v13 gating was covered by focused tests: v12 rejects the new format during rolling upgrade; v13 accepts it.

    Conclusion: the reported metadata-encoding defect is fixed. Closing.

  5. added 3 commits that reference this issue on Sep 17, 2026
    b5b2b81
    31e4bad
    0c59fbb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions