diff --git a/pkg/sql/schemachanger/scgraph/graph.go b/pkg/sql/schemachanger/scgraph/graph.go index 518994b3f853..657ce889e941 100644 --- a/pkg/sql/schemachanger/scgraph/graph.go +++ b/pkg/sql/schemachanger/scgraph/graph.go @@ -18,6 +18,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb" "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/screl" "github.com/cockroachdb/errors" + "github.com/google/btree" ) // Graph is a graph whose nodes are *scpb.Nodes. Graphs are constructed during @@ -42,12 +43,12 @@ type Graph struct { // nodeDepEdgesFrom maps a Node from its dependencies. // A Node dependency is another target node which must be // reached before or concurrently with this node. - nodeDepEdgesFrom map[*scpb.Node][]*DepEdge + nodeDepEdgesFrom *btree.BTree // nodeDepEdgesTo maps a Node to its dependencies. // A Node dependency is another target node which must be // reached before or concurrently with this node. - nodeDepEdgesTo map[*scpb.Node][]*DepEdge + nodeDepEdgesTo *btree.BTree // opToNode maps from an operation back to the // opEdge that generated it as an index. @@ -79,8 +80,8 @@ func New(initial scpb.State) (*Graph, error) { g := Graph{ targetIdxMap: map[*scpb.Target]int{}, nodeOpEdgesFrom: map[*scpb.Node]*OpEdge{}, - nodeDepEdgesFrom: map[*scpb.Node][]*DepEdge{}, - nodeDepEdgesTo: map[*scpb.Node][]*DepEdge{}, + nodeDepEdgesFrom: btree.New(2), + nodeDepEdgesTo: btree.New(2), opToNode: map[scop.Op]*scpb.Node{}, entities: db, } @@ -150,20 +151,6 @@ func (g *Graph) GetOpEdgeFrom(n *scpb.Node) (*OpEdge, bool) { return oe, ok } -// GetDepEdgesFrom returns the unique outgoing op edge from the specified node, -// if one exists. -func (g *Graph) GetDepEdgesFrom(n *scpb.Node) ([]*DepEdge, bool) { - de, ok := g.nodeDepEdgesFrom[n] - return de, ok -} - -// GetDepEdgesTo returns the unique outgoing op edge to the specified node, -// if one exists. -func (g *Graph) GetDepEdgesTo(n *scpb.Node) ([]*DepEdge, bool) { - de, ok := g.nodeDepEdgesTo[n] - return de, ok -} - // AddOpEdges adds an op edges connecting the nodes for two statuses of a target. func (g *Graph) AddOpEdges( t *scpb.Target, from, to scpb.Status, revertible bool, ops ...scop.Op, @@ -213,8 +200,16 @@ func (g *Graph) AddDepEdge( return err } g.edges = append(g.edges, de) - g.nodeDepEdgesFrom[de.from] = append(g.nodeDepEdgesFrom[de.from], de) - g.nodeDepEdgesTo[de.to] = append(g.nodeDepEdgesTo[de.to], de) + g.nodeDepEdgesFrom.ReplaceOrInsert(&edgeTreeEntry{ + g: g, + edge: de, + order: fromTo, + }) + g.nodeDepEdgesTo.ReplaceOrInsert(&edgeTreeEntry{ + g: g, + edge: de, + order: toFrom, + }) return nil } @@ -321,3 +316,54 @@ func (g *Graph) GetNodeRanks() (nodeRanks map[*scpb.Node]int, err error) { } return rank, nil } + +// edgeTreeOrder order in which the edge tree is sorted, +// either based on from/to node indexes. +type edgeTreeOrder bool + +const ( + fromTo edgeTreeOrder = true + toFrom edgeTreeOrder = false +) + +// edgeTreeEntry BTree items for tracking edges +// in an ordered manner. +type edgeTreeEntry struct { + g *Graph + edge Edge + order edgeTreeOrder +} + +// Less implements btree.Item +func (e *edgeTreeEntry) Less(other btree.Item) bool { + o := other.(*edgeTreeEntry) + var a1, b1, a2, b2 *scpb.Node + switch e.order { + case fromTo: + a1, b1, a2, b2 = e.edge.From(), o.edge.From(), e.edge.To(), o.edge.To() + case toFrom: + a1, b1, a2, b2 = e.edge.To(), o.edge.To(), e.edge.From(), o.edge.From() + } + less, eq := compareNodes(e.g, a1, b1) + if eq { + less, _ = compareNodes(e.g, a2, b2) + } + return less +} + +// compareNodes compares two nodes in a graph. A nil nodes is the minimum value. +func compareNodes(g *Graph, a, b *scpb.Node) (less, eq bool) { + switch { + case a == b: + return false, true + case a == nil: + return true, false + case b == nil: + return false, false + case a.Target == b.Target: + return a.Status < b.Status, a.Status == b.Status + default: + aIdx, bIdx := g.targetIdxMap[a.Target], g.targetIdxMap[b.Target] + return aIdx < bIdx, aIdx == bIdx + } +} diff --git a/pkg/sql/schemachanger/scgraph/iteration.go b/pkg/sql/schemachanger/scgraph/iteration.go index 7011302611e8..74d8749a362f 100644 --- a/pkg/sql/schemachanger/scgraph/iteration.go +++ b/pkg/sql/schemachanger/scgraph/iteration.go @@ -13,6 +13,7 @@ package scgraph import ( "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb" "github.com/cockroachdb/cockroach/pkg/util/iterutil" + "github.com/google/btree" ) // NodeIterator is used to iterate nodes. Return iterutil.StopIteration to @@ -58,15 +59,30 @@ func (g *Graph) ForEachEdge(it EdgeIterator) error { type DepEdgeIterator func(de *DepEdge) error // ForEachDepEdgeFrom iterates the dep edges in the graph. -func (g *Graph) ForEachDepEdgeFrom(n *scpb.Node, it DepEdgeIterator) error { - edges := g.nodeDepEdgesFrom[n] - for _, e := range edges { - if err := it(e); err != nil { - if iterutil.Done(err) { - err = nil +func (g *Graph) ForEachDepEdgeFrom(n *scpb.Node, it DepEdgeIterator) (err error) { + g.nodeDepEdgesFrom.AscendGreaterOrEqual(&edgeTreeEntry{ + g: g, + edge: &DepEdge{ + from: n, + to: nil, + rule: "", + }, + order: fromTo, + }, + func(i btree.Item) bool { + e := i.(*edgeTreeEntry) + // End the iteration once the from nodes + // stop matching. + if e.edge.From() != n { + return false } - return err - } - } - return nil + if err = it(e.edge.(*DepEdge)); err != nil { + if iterutil.Done(err) { + err = nil + } + return false + } + return true + }) + return err } diff --git a/pkg/sql/schemachanger/scplan/testdata/alter_table b/pkg/sql/schemachanger/scplan/testdata/alter_table index c86e46fb4404..ce71b3282684 100644 --- a/pkg/sql/schemachanger/scplan/testdata/alter_table +++ b/pkg/sql/schemachanger/scplan/testdata/alter_table @@ -52,35 +52,35 @@ Stage 3 PrimaryIndexID: 1 TableID: 52 Stage 4 - *scop.MakeAddedPrimaryIndexPublic + *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly Index: EncodingType: 1 - ID: 2 + ID: 1 KeyColumnDirections: - 0 KeyColumnIDs: - 1 KeyColumnNames: - i - Name: new_primary_key - StoreColumnIDs: - - 2 - StoreColumnNames: - - j + Name: foo_pkey Unique: true Version: 4 TableID: 52 - *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly + *scop.MakeAddedPrimaryIndexPublic Index: EncodingType: 1 - ID: 1 + ID: 2 KeyColumnDirections: - 0 KeyColumnIDs: - 1 KeyColumnNames: - i - Name: foo_pkey + Name: new_primary_key + StoreColumnIDs: + - 2 + StoreColumnNames: + - j Unique: true Version: 4 TableID: 52 @@ -147,35 +147,35 @@ Stage 3 PrimaryIndexID: 1 TableID: 52 Stage 4 - *scop.MakeAddedPrimaryIndexPublic + *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly Index: EncodingType: 1 - ID: 2 + ID: 1 KeyColumnDirections: - 0 KeyColumnIDs: - 1 KeyColumnNames: - i - Name: new_primary_key - StoreColumnIDs: - - 2 - StoreColumnNames: - - j + Name: foo_pkey Unique: true Version: 4 TableID: 52 - *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly + *scop.MakeAddedPrimaryIndexPublic Index: EncodingType: 1 - ID: 1 + ID: 2 KeyColumnDirections: - 0 KeyColumnIDs: - 1 KeyColumnNames: - i - Name: foo_pkey + Name: new_primary_key + StoreColumnIDs: + - 2 + StoreColumnNames: + - j Unique: true Version: 4 TableID: 52 @@ -260,37 +260,37 @@ Stage 3 PrimaryIndexID: 1 TableID: 52 Stage 4 - *scop.MakeAddedPrimaryIndexPublic + *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly Index: EncodingType: 1 - ID: 2 + ID: 1 KeyColumnDirections: - 0 KeyColumnIDs: - 1 KeyColumnNames: - i - Name: new_primary_key - StoreColumnIDs: - - 2 - - 3 - StoreColumnNames: - - j - - k + Name: foo_pkey Unique: true Version: 4 TableID: 52 - *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly + *scop.MakeAddedPrimaryIndexPublic Index: EncodingType: 1 - ID: 1 + ID: 2 KeyColumnDirections: - 0 KeyColumnIDs: - 1 KeyColumnNames: - i - Name: foo_pkey + Name: new_primary_key + StoreColumnIDs: + - 2 + - 3 + StoreColumnNames: + - j + - k Unique: true Version: 4 TableID: 52 @@ -360,35 +360,35 @@ Stage 3 PrimaryIndexID: 1 TableID: 52 Stage 4 - *scop.MakeAddedPrimaryIndexPublic + *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly Index: EncodingType: 1 - ID: 2 + ID: 1 KeyColumnDirections: - 0 KeyColumnIDs: - 1 KeyColumnNames: - i - Name: new_primary_key - StoreColumnIDs: - - 2 - StoreColumnNames: - - a + Name: foo_pkey Unique: true Version: 4 TableID: 52 - *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly + *scop.MakeAddedPrimaryIndexPublic Index: EncodingType: 1 - ID: 1 + ID: 2 KeyColumnDirections: - 0 KeyColumnIDs: - 1 KeyColumnNames: - i - Name: foo_pkey + Name: new_primary_key + StoreColumnIDs: + - 2 + StoreColumnNames: + - a Unique: true Version: 4 TableID: 52 @@ -504,76 +504,76 @@ Stage 3 PrimaryIndexID: 1 TableID: 53 Stage 4 - *scop.MakeAddedPrimaryIndexPublic + *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly Index: EncodingType: 1 - ID: 2 + ID: 1 KeyColumnDirections: - 0 KeyColumnIDs: - 1 KeyColumnNames: - i - Name: new_primary_key - StoreColumnIDs: - - 2 - StoreColumnNames: - - a + Name: foo_pkey Unique: true Version: 4 TableID: 52 - *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly + *scop.MakeAddedPrimaryIndexPublic Index: EncodingType: 1 - ID: 1 + ID: 2 KeyColumnDirections: - 0 KeyColumnIDs: - 1 KeyColumnNames: - i - Name: foo_pkey + Name: new_primary_key + StoreColumnIDs: + - 2 + StoreColumnNames: + - a Unique: true Version: 4 TableID: 52 *scop.MakeColumnPublic ColumnID: 2 TableID: 52 - *scop.MakeAddedPrimaryIndexPublic + *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly Index: EncodingType: 1 - ID: 2 + ID: 1 KeyColumnDirections: - 0 KeyColumnIDs: - 2 KeyColumnNames: - rowid - Name: new_primary_key + Name: bar_pkey StoreColumnIDs: - 1 - - 3 StoreColumnNames: - j - - b Unique: true Version: 4 TableID: 53 - *scop.MakeDroppedPrimaryIndexDeleteAndWriteOnly + *scop.MakeAddedPrimaryIndexPublic Index: EncodingType: 1 - ID: 1 + ID: 2 KeyColumnDirections: - 0 KeyColumnIDs: - 2 KeyColumnNames: - rowid - Name: bar_pkey + Name: new_primary_key StoreColumnIDs: - 1 + - 3 StoreColumnNames: - j + - b Unique: true Version: 4 TableID: 53 diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_database b/pkg/sql/schemachanger/scplan/testdata/drop_database index 01c6c881d169..7d89c5d44846 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_database +++ b/pkg/sql/schemachanger/scplan/testdata/drop_database @@ -85,8 +85,21 @@ Stage 1 (non-revertible) TableID: 57 *scop.UpdateRelationDeps TableID: 57 + *scop.RemoveColumnDefaultExpression + ColumnID: 3 + TableID: 57 + *scop.UpdateRelationDeps + TableID: 57 *scop.MarkDescriptorAsDropped DescID: 54 + *scop.RemoveRelationDependedOnBy + DependedOnBy: 57 + TableID: 54 + *scop.RemoveColumnDefaultExpression + ColumnID: 1 + TableID: 57 + *scop.UpdateRelationDeps + TableID: 57 *scop.RemoveColumnDefaultExpression ColumnID: 1 TableID: 57 @@ -97,9 +110,11 @@ Stage 1 (non-revertible) TableID: 57 *scop.UpdateRelationDeps TableID: 57 - *scop.RemoveRelationDependedOnBy - DependedOnBy: 57 - TableID: 54 + *scop.RemoveColumnDefaultExpression + ColumnID: 2 + TableID: 57 + *scop.UpdateRelationDeps + TableID: 57 *scop.MarkDescriptorAsDropped DescID: 56 *scop.RemoveColumnDefaultExpression @@ -107,8 +122,16 @@ Stage 1 (non-revertible) TableID: 56 *scop.UpdateRelationDeps TableID: 56 + *scop.RemoveColumnDefaultExpression + ColumnID: 3 + TableID: 56 + *scop.UpdateRelationDeps + TableID: 56 *scop.MarkDescriptorAsDropped DescID: 55 + *scop.RemoveRelationDependedOnBy + DependedOnBy: 56 + TableID: 55 *scop.RemoveRelationDependedOnBy DependedOnBy: 58 TableID: 56 @@ -119,14 +142,9 @@ Stage 1 (non-revertible) TableID: 58 *scop.MarkDescriptorAsDropped DescID: 59 - *scop.RemoveRelationDependedOnBy - DependedOnBy: 60 - TableID: 58 *scop.RemoveRelationDependedOnBy DependedOnBy: 60 TableID: 59 - *scop.MarkDescriptorAsDropped - DescID: 60 *scop.RemoveRelationDependedOnBy DependedOnBy: 61 TableID: 59 @@ -135,8 +153,6 @@ Stage 1 (non-revertible) *scop.RemoveRelationDependedOnBy DependedOnBy: 64 TableID: 61 - *scop.MarkDescriptorAsDropped - DescID: 64 *scop.MarkDescriptorAsDropped DescID: 62 *scop.RemoveTypeBackRef @@ -147,6 +163,18 @@ Stage 1 (non-revertible) *scop.RemoveTypeBackRef DescID: 64 TypeID: 63 + *scop.RemoveRelationDependedOnBy + DependedOnBy: 60 + TableID: 58 + *scop.MarkDescriptorAsDropped + DescID: 60 + *scop.MarkDescriptorAsDropped + DescID: 64 + *scop.RemoveColumnDefaultExpression + ColumnID: 1 + TableID: 56 + *scop.UpdateRelationDeps + TableID: 56 *scop.RemoveColumnDefaultExpression ColumnID: 1 TableID: 56 @@ -157,14 +185,20 @@ Stage 1 (non-revertible) TableID: 56 *scop.UpdateRelationDeps TableID: 56 - *scop.RemoveRelationDependedOnBy - DependedOnBy: 56 - TableID: 55 + *scop.RemoveColumnDefaultExpression + ColumnID: 2 + TableID: 56 + *scop.UpdateRelationDeps + TableID: 56 *scop.MarkDescriptorAsDropped DescID: 53 *scop.MarkDescriptorAsDropped DescID: 52 Stage 2 (non-revertible) + *scop.DrainDescriptorName + TableID: 54 + *scop.CreateGcJobForDescriptor + DescID: 54 *scop.DrainDescriptorName TableID: 54 *scop.CreateGcJobForDescriptor @@ -173,6 +207,14 @@ Stage 2 (non-revertible) TableID: 57 *scop.CreateGcJobForDescriptor DescID: 57 + *scop.DrainDescriptorName + TableID: 57 + *scop.CreateGcJobForDescriptor + DescID: 57 + *scop.DrainDescriptorName + TableID: 55 + *scop.CreateGcJobForDescriptor + DescID: 55 *scop.DrainDescriptorName TableID: 55 *scop.CreateGcJobForDescriptor @@ -182,13 +224,13 @@ Stage 2 (non-revertible) *scop.CreateGcJobForDescriptor DescID: 60 *scop.DrainDescriptorName - TableID: 59 + TableID: 60 *scop.CreateGcJobForDescriptor - DescID: 59 + DescID: 60 *scop.DrainDescriptorName - TableID: 58 + TableID: 64 *scop.CreateGcJobForDescriptor - DescID: 58 + DescID: 64 *scop.DrainDescriptorName TableID: 64 *scop.CreateGcJobForDescriptor @@ -197,6 +239,30 @@ Stage 2 (non-revertible) TableID: 61 *scop.CreateGcJobForDescriptor DescID: 61 + *scop.DrainDescriptorName + TableID: 61 + *scop.CreateGcJobForDescriptor + DescID: 61 + *scop.DrainDescriptorName + TableID: 59 + *scop.CreateGcJobForDescriptor + DescID: 59 + *scop.DrainDescriptorName + TableID: 59 + *scop.CreateGcJobForDescriptor + DescID: 59 + *scop.DrainDescriptorName + TableID: 58 + *scop.CreateGcJobForDescriptor + DescID: 58 + *scop.DrainDescriptorName + TableID: 58 + *scop.CreateGcJobForDescriptor + DescID: 58 + *scop.DrainDescriptorName + TableID: 56 + *scop.CreateGcJobForDescriptor + DescID: 56 *scop.DrainDescriptorName TableID: 56 *scop.CreateGcJobForDescriptor diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_schema b/pkg/sql/schemachanger/scplan/testdata/drop_schema index c4ce0839f5ea..8d7b1f92bd5b 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_schema +++ b/pkg/sql/schemachanger/scplan/testdata/drop_schema @@ -148,8 +148,16 @@ Stage 1 (non-revertible) TableID: 54 *scop.UpdateRelationDeps TableID: 54 + *scop.RemoveColumnDefaultExpression + ColumnID: 3 + TableID: 54 + *scop.UpdateRelationDeps + TableID: 54 *scop.MarkDescriptorAsDropped DescID: 53 + *scop.RemoveRelationDependedOnBy + DependedOnBy: 54 + TableID: 53 *scop.RemoveRelationDependedOnBy DependedOnBy: 55 TableID: 54 @@ -160,14 +168,9 @@ Stage 1 (non-revertible) TableID: 55 *scop.MarkDescriptorAsDropped DescID: 56 - *scop.RemoveRelationDependedOnBy - DependedOnBy: 57 - TableID: 55 *scop.RemoveRelationDependedOnBy DependedOnBy: 57 TableID: 56 - *scop.MarkDescriptorAsDropped - DescID: 57 *scop.RemoveRelationDependedOnBy DependedOnBy: 58 TableID: 56 @@ -176,8 +179,6 @@ Stage 1 (non-revertible) *scop.RemoveRelationDependedOnBy DependedOnBy: 61 TableID: 58 - *scop.MarkDescriptorAsDropped - DescID: 61 *scop.MarkDescriptorAsDropped DescID: 59 *scop.RemoveTypeBackRef @@ -188,6 +189,18 @@ Stage 1 (non-revertible) *scop.RemoveTypeBackRef DescID: 61 TypeID: 60 + *scop.RemoveRelationDependedOnBy + DependedOnBy: 57 + TableID: 55 + *scop.MarkDescriptorAsDropped + DescID: 57 + *scop.MarkDescriptorAsDropped + DescID: 61 + *scop.RemoveColumnDefaultExpression + ColumnID: 1 + TableID: 54 + *scop.UpdateRelationDeps + TableID: 54 *scop.RemoveColumnDefaultExpression ColumnID: 1 TableID: 54 @@ -198,12 +211,18 @@ Stage 1 (non-revertible) TableID: 54 *scop.UpdateRelationDeps TableID: 54 - *scop.RemoveRelationDependedOnBy - DependedOnBy: 54 - TableID: 53 + *scop.RemoveColumnDefaultExpression + ColumnID: 2 + TableID: 54 + *scop.UpdateRelationDeps + TableID: 54 *scop.MarkDescriptorAsDropped DescID: 52 Stage 2 (non-revertible) + *scop.DrainDescriptorName + TableID: 53 + *scop.CreateGcJobForDescriptor + DescID: 53 *scop.DrainDescriptorName TableID: 53 *scop.CreateGcJobForDescriptor @@ -213,13 +232,13 @@ Stage 2 (non-revertible) *scop.CreateGcJobForDescriptor DescID: 57 *scop.DrainDescriptorName - TableID: 56 + TableID: 57 *scop.CreateGcJobForDescriptor - DescID: 56 + DescID: 57 *scop.DrainDescriptorName - TableID: 55 + TableID: 61 *scop.CreateGcJobForDescriptor - DescID: 55 + DescID: 61 *scop.DrainDescriptorName TableID: 61 *scop.CreateGcJobForDescriptor @@ -228,6 +247,30 @@ Stage 2 (non-revertible) TableID: 58 *scop.CreateGcJobForDescriptor DescID: 58 + *scop.DrainDescriptorName + TableID: 58 + *scop.CreateGcJobForDescriptor + DescID: 58 + *scop.DrainDescriptorName + TableID: 56 + *scop.CreateGcJobForDescriptor + DescID: 56 + *scop.DrainDescriptorName + TableID: 56 + *scop.CreateGcJobForDescriptor + DescID: 56 + *scop.DrainDescriptorName + TableID: 55 + *scop.CreateGcJobForDescriptor + DescID: 55 + *scop.DrainDescriptorName + TableID: 55 + *scop.CreateGcJobForDescriptor + DescID: 55 + *scop.DrainDescriptorName + TableID: 54 + *scop.CreateGcJobForDescriptor + DescID: 54 *scop.DrainDescriptorName TableID: 54 *scop.CreateGcJobForDescriptor diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_sequence b/pkg/sql/schemachanger/scplan/testdata/drop_sequence index 3f912b763e60..992c63fa5921 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_sequence +++ b/pkg/sql/schemachanger/scplan/testdata/drop_sequence @@ -16,6 +16,10 @@ Stage 2 (non-revertible) TableID: 52 *scop.CreateGcJobForDescriptor DescID: 52 + *scop.DrainDescriptorName + TableID: 52 + *scop.CreateGcJobForDescriptor + DescID: 52 create-table CREATE TABLE defaultdb.blog_posts (id INT PRIMARY KEY, val int DEFAULT nextval('defaultdb.sq1'), title text) @@ -37,6 +41,16 @@ Stage 1 (non-revertible) TableID: 53 *scop.UpdateRelationDeps TableID: 53 + *scop.RemoveColumnDefaultExpression + ColumnID: 2 + TableID: 53 + *scop.UpdateRelationDeps + TableID: 53 + *scop.RemoveColumnDefaultExpression + ColumnID: 2 + TableID: 54 + *scop.UpdateRelationDeps + TableID: 54 *scop.RemoveColumnDefaultExpression ColumnID: 2 TableID: 54 @@ -49,6 +63,10 @@ Stage 2 (non-revertible) TableID: 52 *scop.CreateGcJobForDescriptor DescID: 52 + *scop.DrainDescriptorName + TableID: 52 + *scop.CreateGcJobForDescriptor + DescID: 52 deps diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_table b/pkg/sql/schemachanger/scplan/testdata/drop_table index 54d707fea9bf..ae9b18c6efa5 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_table +++ b/pkg/sql/schemachanger/scplan/testdata/drop_table @@ -72,6 +72,11 @@ Stage 1 (non-revertible) TableID: 55 *scop.UpdateRelationDeps TableID: 55 + *scop.RemoveColumnDefaultExpression + ColumnID: 1 + TableID: 55 + *scop.UpdateRelationDeps + TableID: 55 *scop.MarkDescriptorAsDropped DescID: 56 *scop.RemoveSequenceOwnedBy @@ -81,6 +86,16 @@ Stage 1 (non-revertible) TableID: 55 *scop.UpdateRelationDeps TableID: 55 + *scop.RemoveColumnDefaultExpression + ColumnID: 2 + TableID: 55 + *scop.UpdateRelationDeps + TableID: 55 + *scop.RemoveColumnDefaultExpression + ColumnID: 3 + TableID: 55 + *scop.UpdateRelationDeps + TableID: 55 *scop.RemoveColumnDefaultExpression ColumnID: 3 TableID: 55 @@ -91,6 +106,16 @@ Stage 1 (non-revertible) TableID: 55 *scop.UpdateRelationDeps TableID: 55 + *scop.RemoveColumnDefaultExpression + ColumnID: 4 + TableID: 55 + *scop.UpdateRelationDeps + TableID: 55 + *scop.RemoveColumnDefaultExpression + ColumnID: 5 + TableID: 55 + *scop.UpdateRelationDeps + TableID: 55 *scop.RemoveColumnDefaultExpression ColumnID: 5 TableID: 55 @@ -104,6 +129,14 @@ Stage 2 (non-revertible) TableID: 57 *scop.CreateGcJobForDescriptor DescID: 57 + *scop.DrainDescriptorName + TableID: 57 + *scop.CreateGcJobForDescriptor + DescID: 57 + *scop.DrainDescriptorName + TableID: 56 + *scop.CreateGcJobForDescriptor + DescID: 56 *scop.DrainDescriptorName TableID: 56 *scop.CreateGcJobForDescriptor @@ -112,6 +145,10 @@ Stage 2 (non-revertible) TableID: 55 *scop.CreateGcJobForDescriptor DescID: 55 + *scop.DrainDescriptorName + TableID: 55 + *scop.CreateGcJobForDescriptor + DescID: 55 deps DROP TABLE defaultdb.shipments CASCADE; diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_view b/pkg/sql/schemachanger/scplan/testdata/drop_view index 48205a5edd42..b85584349b08 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_view +++ b/pkg/sql/schemachanger/scplan/testdata/drop_view @@ -23,6 +23,10 @@ Stage 2 (non-revertible) TableID: 53 *scop.CreateGcJobForDescriptor DescID: 53 + *scop.DrainDescriptorName + TableID: 53 + *scop.CreateGcJobForDescriptor + DescID: 53 deps DROP VIEW defaultdb.v1 @@ -73,14 +77,9 @@ Stage 1 (non-revertible) TableID: 53 *scop.MarkDescriptorAsDropped DescID: 54 - *scop.RemoveRelationDependedOnBy - DependedOnBy: 55 - TableID: 53 *scop.RemoveRelationDependedOnBy DependedOnBy: 55 TableID: 54 - *scop.MarkDescriptorAsDropped - DescID: 55 *scop.RemoveRelationDependedOnBy DependedOnBy: 56 TableID: 54 @@ -89,27 +88,32 @@ Stage 1 (non-revertible) *scop.RemoveRelationDependedOnBy DependedOnBy: 59 TableID: 56 - *scop.MarkDescriptorAsDropped - DescID: 59 *scop.RemoveTypeBackRef DescID: 59 TypeID: 57 *scop.RemoveTypeBackRef DescID: 59 TypeID: 58 + *scop.RemoveRelationDependedOnBy + DependedOnBy: 55 + TableID: 53 + *scop.MarkDescriptorAsDropped + DescID: 55 + *scop.MarkDescriptorAsDropped + DescID: 59 Stage 2 (non-revertible) *scop.DrainDescriptorName TableID: 55 *scop.CreateGcJobForDescriptor DescID: 55 *scop.DrainDescriptorName - TableID: 54 + TableID: 55 *scop.CreateGcJobForDescriptor - DescID: 54 + DescID: 55 *scop.DrainDescriptorName - TableID: 53 + TableID: 59 *scop.CreateGcJobForDescriptor - DescID: 53 + DescID: 59 *scop.DrainDescriptorName TableID: 59 *scop.CreateGcJobForDescriptor @@ -118,6 +122,26 @@ Stage 2 (non-revertible) TableID: 56 *scop.CreateGcJobForDescriptor DescID: 56 + *scop.DrainDescriptorName + TableID: 56 + *scop.CreateGcJobForDescriptor + DescID: 56 + *scop.DrainDescriptorName + TableID: 54 + *scop.CreateGcJobForDescriptor + DescID: 54 + *scop.DrainDescriptorName + TableID: 54 + *scop.CreateGcJobForDescriptor + DescID: 54 + *scop.DrainDescriptorName + TableID: 53 + *scop.CreateGcJobForDescriptor + DescID: 53 + *scop.DrainDescriptorName + TableID: 53 + *scop.CreateGcJobForDescriptor + DescID: 53 deps DROP VIEW defaultdb.v1 CASCADE