Skip to content

[Bug]: Internal alias-prefixed columns create non-round-trippable indexes #26824

Closed

Description

@LeftHandCold

Reproduction

CREATE DATABASE alias_prefix;
USE alias_prefix;

CREATE TABLE t (
  id INT PRIMARY KEY,
  `__mo_alias_payload` VARCHAR(32),
  KEY idx_alias (`__mo_alias_payload`(2))
);

SHOW CREATE TABLE t;

Expected

The internal alias namespace must not be usable for user columns, or a legal user identifier must round-trip through SHOW CREATE with its index definition intact.

Actual

CREATE TABLE succeeds. SHOW CREATE TABLE produces an empty index key list and then fails to parse it:

ERROR 1105 (HY000): syntax error near ")"

The regular secondary-index builder and SHOW CREATE both identify aliases by the raw _mo_alias prefix, so a user column is mistaken for the hidden primary-key suffix.

Scope / duplicate check

This is distinct from #26823 (delimiter-safe prefix-length metadata), #26822 (stale metadata on column rename), #26818, and #26813. I searched recent MatrixOne issues for "__mo_alias", "alias prefix", "reserved column name index", and SHOW CREATE index syntax errors; none describe this collision.

Activity

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

    @LeftHandCold
    CollaboratorAuthor

    Fixed in d380dc711fe2df93f7cd69139f7f059f1fbf8251.

    The _mo_alias prefix is now explicitly reserved wherever user column names enter the planner:

    • CREATE TABLE
    • CREATE TABLE AS SELECT
    • ALTER TABLE ADD COLUMN
    • ALTER TABLE CHANGE COLUMN
    • ALTER TABLE RENAME COLUMN

    This matches the existing regular-index implementation, which uses the prefix for its hidden primary-key suffix. Rejecting the collision prevents new schemas from becoming non-round-trippable or producing an invalid empty key list in SHOW CREATE.

    Validation:

    • New white-box validation test.
    • New distributed coverage verifies every rejection path plus a normal CTAS control: 13/13.
    • Existing ALTER TABLE RENAME COLUMN suite: 269/269.
    • Existing ALTER TABLE CHANGE COLUMN suite: 923/923.
    • Full pkg/sql/plan test suite, 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, with an 08770e1 baseline comparison.

    Baseline: user columns in the internal __mo_alias_ namespace were accepted by CREATE TABLE, CTAS, ALTER ADD, CHANGE, and RENAME, producing non-round-trippable index metadata.
    Fix verification: all five entry points reject the namespace, including a mixed-case spelling. The resulting schema has zero user-visible __mo_alias_ columns and valid SHOW CREATE output for unaffected tables.

    Conclusion: the reported namespace-collision 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