-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: cannot add a new sequence-populated column (or pg-compatible SERIAL) to an existing table, + bug #42508
Copy link
Copy link
Open
Labels
A-schema-changesA-sql-pgcompatSemantic compatibility with PostgreSQLSemantic compatibility with PostgreSQLC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.S-3-ux-surpriseIssue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)X-anchored-telemetryThe issue number is anchored by telemetry references.The issue number is anchored by telemetry references.docs-donedocs-known-limitation
Metadata
Metadata
Assignees
Labels
A-schema-changesA-sql-pgcompatSemantic compatibility with PostgreSQLSemantic compatibility with PostgreSQLC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.S-3-ux-surpriseIssue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)X-anchored-telemetryThe issue number is anchored by telemetry references.The issue number is anchored by telemetry references.docs-donedocs-known-limitation
Two problems in this issue
Because of the bug part, the severity is higher than if this was just a missing feature.
The limitation
Today the column backfiller is unable to execute sequence operations such as evaluating the
nextval()function.This makes it impossible to add a column that uses a sequence-based DEFAULT to an existing table.
For example:
Or:
The bug
A large problem with this limitation is that the error is only detected at runtime, not at compile-time. This means that an attempt to add such a column inside an explicit txn will violate atomicity with the dreaded XXA00 error (see #42061)
(the INSERT was committed, but the ALTER failed: atomicity anomaly)
Jira issue: CRDB-5351
Epic CRDB-60873