diff --git a/pkg/sql/schemachanger/scexec/scmutationexec/references.go b/pkg/sql/schemachanger/scexec/scmutationexec/references.go index 9aececa7ffb1..20ef3048a585 100644 --- a/pkg/sql/schemachanger/scexec/scmutationexec/references.go +++ b/pkg/sql/schemachanger/scexec/scmutationexec/references.go @@ -294,11 +294,11 @@ func updateBackReferencesInSequences( return nil } -func (i *immediateVisitor) RemoveViewBackReferencesInRelations( - ctx context.Context, op scop.RemoveViewBackReferencesInRelations, +func (m *immediateVisitor) RemoveBackReferencesInRelations( + ctx context.Context, op scop.RemoveBackReferencesInRelations, ) error { for _, relationID := range op.RelationIDs { - if err := removeViewBackReferencesInRelation(ctx, i, relationID, op.BackReferencedViewID); err != nil { + if err := removeViewBackReferencesInRelation(ctx, m, relationID, op.BackReferencedID); err != nil { return err } } @@ -306,7 +306,7 @@ func (i *immediateVisitor) RemoveViewBackReferencesInRelations( } func removeViewBackReferencesInRelation( - ctx context.Context, m *immediateVisitor, relationID, viewID descpb.ID, + ctx context.Context, m *immediateVisitor, relationID, backReferencedID descpb.ID, ) error { tbl, err := m.checkOutTable(ctx, relationID) if err != nil || tbl.Dropped() { @@ -315,7 +315,7 @@ func removeViewBackReferencesInRelation( } var newBackRefs []descpb.TableDescriptor_Reference for _, by := range tbl.DependedOnBy { - if by.ID != viewID { + if by.ID != backReferencedID { newBackRefs = append(newBackRefs, by) } } diff --git a/pkg/sql/schemachanger/scop/immediate_mutation.go b/pkg/sql/schemachanger/scop/immediate_mutation.go index a37a7542b776..5106e9d01156 100644 --- a/pkg/sql/schemachanger/scop/immediate_mutation.go +++ b/pkg/sql/schemachanger/scop/immediate_mutation.go @@ -447,12 +447,12 @@ type UpdateBackReferencesInSequences struct { SequenceIDs []descpb.ID } -// RemoveViewBackReferencesInRelations removes back references to a view in +// RemoveBackReferencesInRelations removes back references to a view in // the specified tables, views or sequences. -type RemoveViewBackReferencesInRelations struct { +type RemoveBackReferencesInRelations struct { immediateMutationOp - BackReferencedViewID descpb.ID - RelationIDs []descpb.ID + BackReferencedID descpb.ID + RelationIDs []descpb.ID } // SetColumnName renames a column. diff --git a/pkg/sql/schemachanger/scop/immediate_mutation_visitor_generated.go b/pkg/sql/schemachanger/scop/immediate_mutation_visitor_generated.go index 675c2e017475..9a373efd7d63 100644 --- a/pkg/sql/schemachanger/scop/immediate_mutation_visitor_generated.go +++ b/pkg/sql/schemachanger/scop/immediate_mutation_visitor_generated.go @@ -75,7 +75,7 @@ type ImmediateMutationVisitor interface { UpdateTypeBackReferencesInTypes(context.Context, UpdateTypeBackReferencesInTypes) error RemoveBackReferenceInTypes(context.Context, RemoveBackReferenceInTypes) error UpdateBackReferencesInSequences(context.Context, UpdateBackReferencesInSequences) error - RemoveViewBackReferencesInRelations(context.Context, RemoveViewBackReferencesInRelations) error + RemoveBackReferencesInRelations(context.Context, RemoveBackReferencesInRelations) error SetColumnName(context.Context, SetColumnName) error SetIndexName(context.Context, SetIndexName) error SetConstraintName(context.Context, SetConstraintName) error @@ -365,8 +365,8 @@ func (op UpdateBackReferencesInSequences) Visit(ctx context.Context, v Immediate } // Visit is part of the ImmediateMutationOp interface. -func (op RemoveViewBackReferencesInRelations) Visit(ctx context.Context, v ImmediateMutationVisitor) error { - return v.RemoveViewBackReferencesInRelations(ctx, op) +func (op RemoveBackReferencesInRelations) Visit(ctx context.Context, v ImmediateMutationVisitor) error { + return v.RemoveBackReferencesInRelations(ctx, op) } // Visit is part of the ImmediateMutationOp interface. diff --git a/pkg/sql/schemachanger/scplan/internal/opgen/opgen_view.go b/pkg/sql/schemachanger/scplan/internal/opgen/opgen_view.go index 61014a4d21bc..e69b52ba2a33 100644 --- a/pkg/sql/schemachanger/scplan/internal/opgen/opgen_view.go +++ b/pkg/sql/schemachanger/scplan/internal/opgen/opgen_view.go @@ -51,13 +51,13 @@ func init() { TypeIDs: this.UsesTypeIDs, } }), - emit(func(this *scpb.View) *scop.RemoveViewBackReferencesInRelations { + emit(func(this *scpb.View) *scop.RemoveBackReferencesInRelations { if len(this.UsesRelationIDs) == 0 { return nil } - return &scop.RemoveViewBackReferencesInRelations{ - BackReferencedViewID: this.ViewID, - RelationIDs: this.UsesRelationIDs, + return &scop.RemoveBackReferencesInRelations{ + BackReferencedID: this.ViewID, + RelationIDs: this.UsesRelationIDs, } }), ), diff --git a/pkg/sql/schemachanger/scplan/testdata/alter_table_drop_column b/pkg/sql/schemachanger/scplan/testdata/alter_table_drop_column index bcca17b701f2..3f5b181cb46d 100644 --- a/pkg/sql/schemachanger/scplan/testdata/alter_table_drop_column +++ b/pkg/sql/schemachanger/scplan/testdata/alter_table_drop_column @@ -387,8 +387,8 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 24 MutationType ops BackReferencedDescriptorID: 108 TypeIDs: - 104 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 108 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 108 RelationIDs: - 107 *scop.RemoveDroppedColumnType @@ -1376,8 +1376,8 @@ PostCommitNonRevertiblePhase stage 1 of 3 with 25 MutationType ops BackReferencedDescriptorID: 108 TypeIDs: - 104 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 108 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 108 RelationIDs: - 107 *scop.RemoveDroppedColumnType diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_database b/pkg/sql/schemachanger/scplan/testdata/drop_database index ec3c6e866bec..09076481b486 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_database +++ b/pkg/sql/schemachanger/scplan/testdata/drop_database @@ -830,27 +830,27 @@ PreCommitPhase stage 2 of 2 with 89 MutationType ops - 108 *scop.MarkDescriptorAsDropped DescriptorID: 111 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 111 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 111 RelationIDs: - 109 *scop.MarkDescriptorAsDropped DescriptorID: 112 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 112 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 112 RelationIDs: - 111 *scop.MarkDescriptorAsDropped DescriptorID: 113 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 113 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 113 RelationIDs: - 111 - 112 *scop.MarkDescriptorAsDropped DescriptorID: 114 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 114 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 114 RelationIDs: - 112 *scop.MarkDescriptorAsDropped @@ -864,8 +864,8 @@ PreCommitPhase stage 2 of 2 with 89 MutationType ops TypeIDs: - 115 - 116 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 117 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 117 RelationIDs: - 114 *scop.DrainDescriptorName diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_index b/pkg/sql/schemachanger/scplan/testdata/drop_index index f0b2c38757de..64a240b31d13 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_index +++ b/pkg/sql/schemachanger/scplan/testdata/drop_index @@ -702,8 +702,8 @@ PreCommitPhase stage 2 of 2 with 10 MutationType ops ops: *scop.MarkDescriptorAsDropped DescriptorID: 105 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 105 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 105 RelationIDs: - 104 *scop.MakePublicSecondaryIndexWriteOnly @@ -1070,8 +1070,8 @@ PreCommitPhase stage 2 of 2 with 12 MutationType ops ops: *scop.MarkDescriptorAsDropped DescriptorID: 107 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 107 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 107 RelationIDs: - 106 *scop.RemoveColumnDefaultExpression diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_owned_by b/pkg/sql/schemachanger/scplan/testdata/drop_owned_by index 92d62fa6801c..2ba0eb382b13 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_owned_by +++ b/pkg/sql/schemachanger/scplan/testdata/drop_owned_by @@ -548,8 +548,8 @@ PreCommitPhase stage 2 of 2 with 57 MutationType ops - 107 *scop.MarkDescriptorAsDropped DescriptorID: 110 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 110 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 110 RelationIDs: - 108 *scop.MarkDescriptorAsDropped @@ -563,8 +563,8 @@ PreCommitPhase stage 2 of 2 with 57 MutationType ops TypeIDs: - 111 - 112 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 113 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 113 RelationIDs: - 110 *scop.DrainDescriptorName diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_schema b/pkg/sql/schemachanger/scplan/testdata/drop_schema index 4211191459a9..77bb08969ee6 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_schema +++ b/pkg/sql/schemachanger/scplan/testdata/drop_schema @@ -1728,27 +1728,27 @@ PreCommitPhase stage 2 of 2 with 68 MutationType ops - 105 *scop.MarkDescriptorAsDropped DescriptorID: 107 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 107 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 107 RelationIDs: - 106 *scop.MarkDescriptorAsDropped DescriptorID: 108 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 108 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 108 RelationIDs: - 107 *scop.MarkDescriptorAsDropped DescriptorID: 109 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 109 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 109 RelationIDs: - 107 - 108 *scop.MarkDescriptorAsDropped DescriptorID: 110 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 110 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 110 RelationIDs: - 108 *scop.MarkDescriptorAsDropped @@ -1762,8 +1762,8 @@ PreCommitPhase stage 2 of 2 with 68 MutationType ops TypeIDs: - 111 - 112 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 113 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 113 RelationIDs: - 110 *scop.DrainDescriptorName diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_table b/pkg/sql/schemachanger/scplan/testdata/drop_table index 44f2fc5ba190..842ea3011950 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_table +++ b/pkg/sql/schemachanger/scplan/testdata/drop_table @@ -371,8 +371,8 @@ PreCommitPhase stage 2 of 2 with 43 MutationType ops DescriptorID: 110 *scop.MarkDescriptorAsDropped DescriptorID: 111 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 111 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 111 RelationIDs: - 109 *scop.DrainDescriptorName diff --git a/pkg/sql/schemachanger/scplan/testdata/drop_view b/pkg/sql/schemachanger/scplan/testdata/drop_view index b6209925e2f3..333e35ad5f00 100644 --- a/pkg/sql/schemachanger/scplan/testdata/drop_view +++ b/pkg/sql/schemachanger/scplan/testdata/drop_view @@ -76,8 +76,8 @@ PreCommitPhase stage 2 of 2 with 9 MutationType ops ops: *scop.MarkDescriptorAsDropped DescriptorID: 105 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 105 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 105 RelationIDs: - 104 *scop.DrainDescriptorName @@ -605,27 +605,27 @@ PreCommitPhase stage 2 of 2 with 45 MutationType ops ops: *scop.MarkDescriptorAsDropped DescriptorID: 105 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 105 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 105 RelationIDs: - 104 *scop.MarkDescriptorAsDropped DescriptorID: 106 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 106 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 106 RelationIDs: - 105 *scop.MarkDescriptorAsDropped DescriptorID: 107 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 107 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 107 RelationIDs: - 105 - 106 *scop.MarkDescriptorAsDropped DescriptorID: 108 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 108 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 108 RelationIDs: - 106 *scop.MarkDescriptorAsDropped @@ -635,8 +635,8 @@ PreCommitPhase stage 2 of 2 with 45 MutationType ops TypeIDs: - 109 - 110 - *scop.RemoveViewBackReferencesInRelations - BackReferencedViewID: 111 + *scop.RemoveBackReferencesInRelations + BackReferencedID: 111 RelationIDs: - 108 *scop.DrainDescriptorName diff --git a/pkg/sql/schemachanger/testdata/explain/drop_index_with_materialized_view_dep b/pkg/sql/schemachanger/testdata/explain/drop_index_with_materialized_view_dep index 5121ea642c4a..8545dacb89a4 100644 --- a/pkg/sql/schemachanger/testdata/explain/drop_index_with_materialized_view_dep +++ b/pkg/sql/schemachanger/testdata/explain/drop_index_with_materialized_view_dep @@ -107,7 +107,7 @@ Schema change plan for DROP INDEX ‹defaultdb›.‹public›.‹v2›@‹idx │ │ └── PUBLIC → ABSENT IndexName:{DescID: 106, Name: v3_pkey, IndexID: 1} │ └── 12 Mutation operations │ ├── MarkDescriptorAsDropped {"DescriptorID":106} - │ ├── RemoveViewBackReferencesInRelations {"BackReferencedViewID":106} + │ ├── RemoveBackReferencesInRelations {"BackReferencedID":106} │ ├── RemoveColumnDefaultExpression {"ColumnID":2,"TableID":106} │ ├── MakePublicSecondaryIndexWriteOnly {"IndexID":2,"TableID":105} │ ├── DrainDescriptorName {"Namespace":{"DatabaseID":100,"DescriptorID":106,"Name":"v3","SchemaID":101}} diff --git a/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_with_materialized_view_dep b/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_with_materialized_view_dep index a3c44d917ff7..366b5a323e56 100644 --- a/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_with_materialized_view_dep +++ b/pkg/sql/schemachanger/testdata/explain_verbose/drop_index_with_materialized_view_dep @@ -730,8 +730,8 @@ EXPLAIN (ddl, verbose) DROP INDEX idx CASCADE; │ ├── • MarkDescriptorAsDropped │ │ DescriptorID: 106 │ │ -│ ├── • RemoveViewBackReferencesInRelations -│ │ BackReferencedViewID: 106 +│ ├── • RemoveBackReferencesInRelations +│ │ BackReferencedID: 106 │ │ RelationIDs: │ │ - 105 │ │