Skip to content

[Bug]: ALTER SET DEFAULT silently succeeds on AUTO_INCREMENT and generated columns #26844

Closed

Description

@Ariznawlll

Description

ALTER TABLE ... ALTER COLUMN ... SET DEFAULT reports success for AUTO_INCREMENT and generated columns but silently leaves the schema unchanged. Unsupported or invalid ALTER requests must be rejected rather than acknowledged as successful no-ops.

Reproduced 3/3 for both column kinds on current main commit 45a917d7f8f7b2f32c28ca0a734318875722a00e.

Reproduction

create database repro_alter_default;
use repro_alter_default;

create table ai(id bigint auto_increment, v int);
alter table ai alter column id set default 9;
show create table ai;

create table gen(id int, a int, g int as(a+1) stored);
alter table gen alter column g set default 9;
show create table gen;

Actual result

Both ALTER statements return success. However:

  • SHOW CREATE contains no default on either column;
  • information_schema.columns.column_default remains NULL;
  • the effective AUTO_INCREMENT/generated-column behavior is unchanged.

Running each statement on three independently created tables produces the same result. A normal-column control (alter column v set default 9) succeeds and exposes default 9 immediately.

Expected result

Because a user default cannot be applied to an AUTO_INCREMENT or generated column, the ALTER statement must return an explicit error and leave the table unchanged. It must not report successful DDL while discarding the requested action.

Analysis

AlterColumn builds a new default and writes it into the copied ColDef without rejecting AUTO_INCREMENT or generated columns. The later ALTER-copy/table-definition path does not retain that invalid default, so execution commits a schema equivalent to the original while returning success.

Activity

  1. added this to the MO-202608 milestone on Aug 9, 2026
  2. added
    kind/bug
    on Aug 9, 2026
  3. added theissue type on Aug 9, 2026
  4. added
    severity/s0
    and removed on Aug 9, 2026
  5. slyunnn commented on Aug 11, 2026

    @slyunnn

    Regression and extended verification for #26844 (2026-08-11)

    Verification environment

    • MatrixOne main: d01c85974f9540f8baa2e768ca86fea952941fe2
      • fix(hashjoin): broadcast const vectors in spill paths (#26938)
    • Fix commit: df49b097935ccd650d9f30016d5219228e053c5e
      • fix(plan): reject invalid ALTER COLUMN defaults (#26880)
    • MOTR branch: test/issue-26844-alter-set-default
    • MOTR commit: 8b6ae6d08d757ec01ff6d4d672ea3a6e6480f0c4
    • Topology: local single-node MatrixOne service.

    Regression verification

    Reproduced the original invalid ALTER COLUMN ... SET DEFAULT requests:

    • AUTO_INCREMENT column: rejected with error 1067.
    • Stored generated column: rejected with error 20301.
    • Virtual generated column: rejected with error 20301.

    All rejected operations left information_schema.columns.column_default as NULL; no invalid default was silently
    accepted.

    Extended verification

    • Happy path:

      • A normal column successfully accepts SET DEFAULT 9.
      • Inserting a row without that column stores 9.
      • DROP DEFAULT succeeds; a later omitted value becomes NULL.
    • Boundary coverage:

      • Both stored and virtual generated-column modes reject a user default.
      • AUTO_INCREMENT and generated columns are verified independently.
    • Unhappy path:

      • Each unsupported request returns an explicit error.
      • Rejected operations do not mutate the table’s default metadata.

    MOTR regression

    • Added:
      • suites/14_issue_regression/t/issue_26844_alter_set_default.test
      • suites/14_issue_regression/r/issue_26844_alter_set_default.result
    • Record: 19/19 statements passed.
    • Replay: 19/19 statements passed.

    Test-file changes

    The MOTR files were added to prevent successful no-op DDL from returning for unsupported defaults. They preserve valid
    normal-column behavior and verify rejection plus schema immutability for AUTO_INCREMENT, stored generated, and virtual
    generated columns. No MatrixOne service source code was modified.

    Final conclusion

    #26844 is fixed on current main: unsupported SET DEFAULT operations now fail explicitly instead of succeeding
    without applying the requested schema change.

    Suggested resolution: push and merge the MOTR regression PR, then close #26844.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions