-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
schemachanger: generalized statement-time execution
This change makes it possible to plan and execute the following change correctly: BEGIN; DROP TABLE foo; CREATE UNIQUE INDEX idx ON bar (x); COMMIT; Inside the transaction, the table is seen as dropped right after the DROP TABLE statement executes, but the table is not seen as dropped by other transactions until the new, unrelated index has been validated, at which point the schema change can no longer fail. Fixes #88294. Significant changes: - descs.Collection has a new ResetUncommitted method. - scstage.BuildStages is rewritten with unrolled loops and a new scheme: statement phase has revertible op-edges, pre-commit has two stages, one which resets the uncommitted state by scheduling the new scop.UndoAllInTxnImmediateMutationOpSideEffects op, which triggers a call to ResetUncommitted. - This happens in scexec.executeMutationOps, which is now split into two pieces, the first one which executes ops whose side-effects can be undone by ResetUncommitted, and the other which handles those which can’t. - These ops implement scop.ImmediateMutationOp and scop.DeferredMutationOp respectively. - These have their own visitors with their own state and their own dependencies. This all means that we can handle DROPs properly now: the TXN_DROPPED element state is removed as are all the synthetic descriptor manipulations (outside of index and constraint validation, that is). Furthermore, the scgraph.PreviousTransactionPrecedence edge kind no longer serves any purpose and has been replaced by PreviousStagePrecedence everywhere. There’s a bunch of other more-or-less related changes, mostly as a consequence to the above: - scbuild.Build must produce a tighter target set: no-op targets are elided. - nstree.MutableCatalog has new methods for deleting comments and zone configs which are useful. - sctestdeps.TestState has better storage layers modelling (in-memory > stored > committed) - Added missing “relation dropped before column|index no longer public” rules which fix DROP COLUMN CASCADE when the column is referenced in a view. - scgraph.Graph has a new GetOpEdgeTo method which is useful. - added debug info to assertion error messages in scstage.BuildStages to make debugging easier during development. - EXPLAIN (DDL) output has a nicer root node label which puts the last statement first. Release note: None
- Loading branch information
Marius Posta
committed
Jan 26, 2023
1 parent
4858095
commit 083e17a
Showing
305 changed files
with
18,772 additions
and
5,515 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.