Skip to content

executor: judge a create set's changes to a live table together - #739

Merged
aparajon merged 2 commits into
mainfrom
armand/create-set-alters-per-table
Dec 4, 2026
Merged

aparajon merged 2 commits into
mainfrom
armand/create-set-alters-per-table

Conversation

@aparajon

@aparajon aparajon commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Why

A create set can add columns of its new enum types to a live table. The differ writes one ALTER TABLE per added column, so a change that adds status order_status and a nullable note text to orders reaches the set as two statements. The note statement was refused on its own for adding no column of a type the set creates, which refused the whole table.

What

  • Each ALTER TABLE is still checked on its own for what it adds: only plain columns, with no IF NOT EXISTS, constraint, generated value, computed default or NOT NULL without a default.
  • The rule that a table must add a column of a new type now applies to the table's changes taken together, so the plain column runs in the set beside the new type's column.
  • A table whose changes add no column of a new type is still refused, and the refusal names the table.
  • The server's catalog-only proof still runs for every column before the set runs.

Upgrade notes

None.

🤖 Generated with Claude Code

The differ writes one ALTER TABLE per added column. A change that adds
a column of a new enum type and a plain column to the same table
therefore reaches a create set as two statements, and the plain
column's statement was refused for adding no column of a type the set
creates.

Admission now checks every statement on its own for what it adds, and
requires the changes to each table, taken together, to add at least
one column of a type the set creates. A table whose changes add none
is still refused, naming the table.

Signed-off-by: Armand Parajon <armand@squareup.com>
@aparajon
aparajon marked this pull request as ready for review December 4, 2026 17:36
@JashLal

JashLal commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

🤖 I reviewed the full diff at b67e08f and found no merge blockers. Planning and execution apply the same per-table enum rule, each statement still has to pass its own checks, and execution requires PostgreSQL to prove every column can be added without a scan or rewrite before starting the transaction. The original statement order is preserved.

One optional test improvement in pkg/executor/create_set_alter_integration_test.go: exercise the existing checked-domain refusal with the enum column and the domain column in separate ALTER TABLE statements. That would directly cover the newly admitted statement shape and verify that the catalog proof rejects the domain column before creating the enum or adding either column.

GitHub CI passed its unit tests and PostgreSQL 14–18 matrix. I reviewed the code statically.

This was a local static review; I did not run tests. Builderbot review retrieval was unavailable due to a DNS resolution failure.

A table's changes are now judged together, so a checked-domain column
can reach a create set as its own ALTER TABLE beside the enum column.
The catalog proof refuses it before the type is created or either
column is added.

Signed-off-by: Armand Parajon <armand@squareup.com>
@aparajon

aparajon commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

🤖 Thanks. I added the suggested test in bb7cbad. The subtest "a column whose type rewrites the table, in an ALTER TABLE of its own" sends the enum column and the checked-domain column as separate ALTER TABLE statements. The catalog proof refuses quantity before anything runs: the enum is not created and neither column is added.

— Claude Code (Claude Opus 5.5)

@aparajon
aparajon merged commit 612f1f1 into main Dec 4, 2026
18 checks passed
@aparajon
aparajon deleted the armand/create-set-alters-per-table branch December 4, 2026 18:32
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.

2 participants