Skip to content

feat(schema): ignore column-neutral ALTER TABLE actions and EXCLUDE - #65

Merged
omer-cengel merged 1 commit into
masterfrom
feature/ignore-column-neutral-alter-table-actions
Oct 10, 2026
Merged

omer-cengel merged 1 commit into
masterfrom
feature/ignore-column-neutral-alter-table-actions

Conversation

@omer-cengel

Copy link
Copy Markdown
Member

Summary

Real migration histories and pg_dump --schema-only snapshots contain many ALTER TABLE actions that never change a column, such as OWNER TO, SET DEFAULT, identity changes, and row-level security switches, and CREATE TABLE statements with EXCLUDE constraints. These were rejected, so such schemas could not load. They are now ignored. Any other action is still rejected, and the diagnostic now quotes the offending action.

Changes

  • Ignore ALTER COLUMN actions that cannot change a column's type or nullability: SET/DROP DEFAULT, SET STATISTICS, SET STORAGE, SET COMPRESSION, DROP EXPRESSION, and identity changes (ADD GENERATED ... AS IDENTITY, SET GENERATED, sequence options, RESTART, DROP IDENTITY). The column itself is not looked up.
  • Ignore table-level actions that cannot change a column: row-level security switches, ATTACH/DETACH PARTITION, OWNER TO, trigger and rule switches, VALIDATE CONSTRAINT, REPLICA IDENTITY, CLUSTER ON, SET WITHOUT CLUSTER, SET WITHOUT OIDS, storage parameters, SET TABLESPACE, SET LOGGED/UNLOGGED, SET ACCESS METHOD, [NO] INHERIT, and [NOT] OF. The table must still exist unless IF EXISTS is given.
  • The parser reports some actions as text that runs to the end of the statement. That text is now split at top-level commas with the SQL lexer, and every part must be one of the ignored table-level actions. A modeled action written after one, as in OWNER TO app, ADD COLUMN x int, is rejected instead of being silently skipped.
  • Rejected actions now read Unsupported ALTER TABLE action: <action> at line <n>, for example SET SCHEMA archive.
  • CREATE TABLE accepts named and unnamed EXCLUDE table constraints and does not record them.
  • The PostgreSQL schema documentation lists every ignored action, the rule for actions written as trailing text, and the new diagnostic.

Scope and non-goals

  • The modeled actions (ADD/DROP/RENAME COLUMN, RENAME TO, TYPE, SET/DROP NOT NULL) behave as before.
  • SET SCHEMA stays rejected. ALTER TYPE actions and their messages are unchanged.
  • Statements the parser cannot read, such as ALTER COLUMN ... SET DATA TYPE, ALTER COLUMN ... SET (...), and ALTER CONSTRAINT, keep their existing handling.
  • Constraints added by ALTER TABLE are still not recorded. KEY/INDEX table constraints stay rejected.
  • An ignorable action written after an action that is only reported as trailing text is rejected rather than ignored. Writing it first, or in its own statement, loads.

ALTER TABLE actions that cannot change a column's existence, name, type,
or nullability are now ignored: SET/DROP DEFAULT, SET STATISTICS,
STORAGE, and COMPRESSION, DROP EXPRESSION, identity changes, row-level
security switches, partition attachment, OWNER TO, trigger and rule
switches, VALIDATE CONSTRAINT, REPLICA IDENTITY, clustering, storage
parameters, tablespace, logging, access method, inheritance, and OF.
Actions the parser reports only as trailing text are split at top-level
commas and each one must be such an action, so a modeled action written
after one is rejected instead of skipped. Any other action is rejected
as "Unsupported ALTER TABLE action: <action> at line <n>". CREATE TABLE
now accepts EXCLUDE table constraints without recording them.
@omer-cengel
omer-cengel merged commit e2c0607 into master Oct 10, 2026
7 checks passed
@omer-cengel
omer-cengel deleted the feature/ignore-column-neutral-alter-table-actions branch October 10, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant