Skip to content

sql/schemachanger: column prematurely turns to PUBLIC in ADD COLUMN ... UNIQUE #82953

@Xiang-Gu

Description

@Xiang-Gu

Describe the problem

CREATE TABLE t (i INT PRIMARY KEY);
EXPLAIN (ddl, viz) ALTER TABLE t ADD COLUMN j INT NOT NULL UNIQUE DEFAULT 34;

generates a graph like this one.

This graph is incorrect in that, during Post-Commit phase stage 7 of 13, the newly added column element transition into PUBLIC when the new primary index is ready and we swap it with the old primary index. However, the added unique index (created as a result of adding a unique column) is still in the BACKFILL_ONLY status before/after this stage.

The correct behavior should be that the primary index swap waits until the unique secondary index is also in the VALIDATED status, and then we do the primary index swap as well as making the unique secondary index PUBLIC in one stage.

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.GA-blockerT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)branch-release-22.2Used to mark GA and release blockers, technical advisories, and bugs for 22.2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions