fix(plan): reject invalid ALTER COLUMN defaults - #26880
Conversation
# Conflicts: # pkg/sql/plan/coverage_regression_test.go
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review — approve
Reviewed exact head 2f4b955b0b26cd109cf0f9237fcd27df11f7c0f2 against merge-base 8be242b25bf9a44d73a3b1cc1db75fd0264a293c.
No blocking issue found.
The new guards reject SET DEFAULT for auto-increment and both stored and virtual generated columns before assigning to CopyTableDef, so planner failure cannot publish a partially changed schema. The normal-column path and DROP DEFAULT behavior remain unchanged. The test matrix includes the three rejected metadata states, a normal-column control, copied-definition immutability, and public SQL checks that verify post-error schema and insert behavior.
Correctness, compatibility, performance, and unhappy-path review are clean: the change adds only constant-time checks on a DDL planning path; the existing temporary AST remains released by its defer; no new waits, shared state, resource ownership, or unbounded growth are introduced. The branch is one unrelated commit behind current main, and the merge is clean.
Validation on the exact head:
- focused planner regressions passed;
- full
./pkg/sql/plantests passed under the controlled CGo environment; - planner build and vet passed;
- CI executed
alter_table_set_default_restrictions.sql, and the required CI rollup is green.
What type of PR is this?
Which issue(s) this PR fixes:
issue #26844
What this PR does / why we need it:
Reject
ALTER TABLE ... ALTER COLUMN ... SET DEFAULTfor auto-increment and generated columns before mutating the copied table definition. This prevents successful no-op DDL when the requested default cannot be persisted.Add planner unit tests for auto-increment, stored generated, and virtual generated columns, plus distributed SQL coverage that verifies rejected operations leave the schema unchanged and valid defaults still work.