Repository navigation
executor: add columns of a create set's types to live tables - #735
Merged
Merged
Conversation
Signed-off-by: Armand Parajon <armand@squareup.com>
aparajon
marked this pull request as ready for review
December 4, 2026 11:23
aparajon
requested review from
JashLal,
Kiran01bm,
eeSeeGee,
jayjanssen,
jemiahw and
morgo
as code owners
December 4, 2026 11:23
Collaborator
|
🤖 Reviewed
I reviewed the full diff statically. The automated review result was unavailable. No local tests were run; review of surrounding source at this exact head was limited to the full diff. |
JashLal
approved these changes
Dec 4, 2026
A create set refuses ADD COLUMN IF NOT EXISTS. When the column already exists, PostgreSQL skips the add, and the set would commit its enum type with a column of another type left in place. Before the set runs, the executor now asks the server what each added column costs, with the add-column probe the planner uses. It refuses the set unless every column is proven to add on the catalog alone. A column whose type rewrites the table, such as a domain with a CHECK, would otherwise rewrite it under the set's lock. The probe now names a type the same change creates by its bare name when the statement qualifies it with the altered table's schema, so a column of app.order_kind resolves to the probe's copy of the type. Signed-off-by: Armand Parajon <armand@squareup.com>
Collaborator
Author
|
🤖 Both findings are fixed in e05e83c.
— Claude Code (Claude Opus 5.5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A change that creates an enum type and adds a column of it to a table the target already holds has no way to commit both together. A create set holds only new types and new tables. Run as separate steps, the type commits first, so a failed ALTER leaves the type behind with no column using it. A caller that wants all or nothing has to refuse the change and ask for two.
What
CreateSetgainsAlters: changes to live tables, each apreflight.CheckTableproof plus anALTER TABLEstatement. They run after the set's types and tables, in the same transaction, so the change makes all of them or none.NOT NULLwithout a default. Anything else isErrCreateSetAlter, before anything runs.ACCESS EXCLUSIVE, so each attempt first waits out the altered tables' long-lived readers and writers.PlanCreateSetWithAlterslists the alters last and admits them as execution does.PlanCreateSetis unchanged.Before and after
A change creates
order_kindand addskind order_kindto the liveorderstable, and the ALTER fails, for example because the column already exists.How
An alter is checked twice: against its proof, and by its parsed operations through
statement.ParseOps, so the shape rule comes from the real grammar. The live-table lock wait reusesawaitLockQueue. An altered table's entry replaces the writers-only entry a foreign key would give the same table. The statements run under the schema thenpublic, the search path a native attempt uses.Risk
The new path runs only when a caller passes
Alters. Existing sets run exactly as before. Upholds ST-7: each alter runs only against the table its proof verified. Upholds LK-2: alters run under the set'slock_timeoutand bounded retry, after the holder wait.Upgrade notes
None.
PlanCreateSetandCreateSetwithoutAltersare unchanged.🤖 Generated with Claude Code