diff --git a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/helpers.go b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/helpers.go index a4d897f3b35c..46e61338bb1b 100644 --- a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/helpers.go +++ b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/helpers.go @@ -136,8 +136,10 @@ func errMsgPrefix(b BuildCtx, id catid.DescID) string { func dropElementWhenDroppingDescriptor(b BuildCtx, e scpb.Element) { switch t := e.(type) { case *scpb.ColumnType: + //lint:ignore SA1019 IsRelationBeingDropped is deprecated t.IsRelationBeingDropped = true case *scpb.SecondaryIndexPartial: + //lint:ignore SA1019 IsRelationBeingDropped is deprecated t.IsRelationBeingDropped = true } b.Drop(e) diff --git a/pkg/sql/schemachanger/scpb/elements.proto b/pkg/sql/schemachanger/scpb/elements.proto index 5742e5aeb618..1f5c30e38546 100644 --- a/pkg/sql/schemachanger/scpb/elements.proto +++ b/pkg/sql/schemachanger/scpb/elements.proto @@ -177,7 +177,7 @@ message ColumnType { // // TODO(postamar): remove this when we can have more expressive rule defs // See the dep rules for how this is used, and why it's not ideal. - bool is_relation_being_dropped = 10; + bool is_relation_being_dropped = 10 [deprecated = true]; } message ColumnFamily { @@ -243,7 +243,7 @@ message SecondaryIndexPartial { // // TODO(postamar): remove this when we can have more expressive rule defs // See the dep rules for how this is used, and why it's not ideal. - bool is_relation_being_dropped = 10; + bool is_relation_being_dropped = 10 [deprecated = true]; } // SchemaParent models the schema to parent database relationship. diff --git a/pkg/sql/schemachanger/scplan/internal/rules/dep_drop_index_and_column.go b/pkg/sql/schemachanger/scplan/internal/rules/dep_drop_index_and_column.go index 17767c21f35a..db7a442a4f11 100644 --- a/pkg/sql/schemachanger/scplan/internal/rules/dep_drop_index_and_column.go +++ b/pkg/sql/schemachanger/scplan/internal/rules/dep_drop_index_and_column.go @@ -28,20 +28,14 @@ func init() { "index", "column", scpb.Status_ABSENT, scpb.Status_ABSENT, func(from, to nodeVars) rel.Clauses { - ic, ct := mkNodeVars("index-column"), mkNodeVars("column-type") + ic := mkNodeVars("index-column") relationID, columnID := rel.Var("table-id"), rel.Var("column-id") return rel.Clauses{ from.Type((*scpb.PrimaryIndex)(nil), (*scpb.SecondaryIndex)(nil)), to.Type((*scpb.Column)(nil)), - ct.Type((*scpb.ColumnType)(nil)), columnInIndex(ic, from, relationID, columnID, "index-id"), joinOnColumnID(ic, to, relationID, columnID), - joinOnColumnID(ic, ct, relationID, columnID), - rel.Filter("relationIsNotBeingDropped", ct.el)( - func(ct *scpb.ColumnType) bool { - return !ct.IsRelationBeingDropped - }, - ), + ic.descriptorIsNotBeingDropped(), } }) @@ -49,7 +43,7 @@ func init() { scgraph.Precedence, "index", "column", func(from, to nodeVars) rel.Clauses { - ic, ct := mkNodeVars("index-column"), mkNodeVars("column-type") + ic := mkNodeVars("index-column") relationID, columnID := rel.Var("table-id"), rel.Var("column-id") return rel.Clauses{ from.Type((*scpb.SecondaryIndex)(nil)), @@ -57,13 +51,7 @@ func init() { columnInIndex(ic, from, relationID, columnID, "index-id"), joinOnColumnID(ic, to, relationID, columnID), statusesToAbsent(from, scpb.Status_VALIDATED, to, scpb.Status_WRITE_ONLY), - ct.Type((*scpb.ColumnType)(nil)), - joinOnColumnID(ic, ct, relationID, columnID), - rel.Filter("relationIsNotBeingDropped", ct.el)( - func(ct *scpb.ColumnType) bool { - return !ct.IsRelationBeingDropped - }, - ), + ic.descriptorIsNotBeingDropped(), rel.Filter("isIndexKeyColumnKey", ic.el)( func(ic *scpb.IndexColumn) bool { return ic.Kind == scpb.IndexColumn_KEY diff --git a/pkg/sql/schemachanger/scplan/internal/rules/testdata/deprules b/pkg/sql/schemachanger/scplan/internal/rules/testdata/deprules index 743d0e274c3b..43cb2c98308a 100644 --- a/pkg/sql/schemachanger/scplan/internal/rules/testdata/deprules +++ b/pkg/sql/schemachanger/scplan/internal/rules/testdata/deprules @@ -1863,11 +1863,9 @@ deprules query: - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex'] - $column[Type] = '*scpb.Column' - - $column-type[Type] = '*scpb.ColumnType' - columnInIndex($index-column, $index, $table-id, $column-id, $index-id) - joinOnColumnID($index-column, $column, $table-id, $column-id) - - joinOnColumnID($index-column, $column-type, $table-id, $column-id) - - relationIsNotBeingDropped(*scpb.ColumnType)($column-type) + - descriptorIsNotBeingDropped($index-column) - $index-target[TargetStatus] = TRANSIENT_ABSENT - $index-node[CurrentStatus] = TRANSIENT_ABSENT - $column-target[TargetStatus] = ABSENT @@ -1881,11 +1879,9 @@ deprules query: - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex'] - $column[Type] = '*scpb.Column' - - $column-type[Type] = '*scpb.ColumnType' - columnInIndex($index-column, $index, $table-id, $column-id, $index-id) - joinOnColumnID($index-column, $column, $table-id, $column-id) - - joinOnColumnID($index-column, $column-type, $table-id, $column-id) - - relationIsNotBeingDropped(*scpb.ColumnType)($column-type) + - descriptorIsNotBeingDropped($index-column) - $index-target[TargetStatus] = ABSENT - $index-node[CurrentStatus] = ABSENT - $column-target[TargetStatus] = TRANSIENT_ABSENT @@ -1899,11 +1895,9 @@ deprules query: - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex'] - $column[Type] = '*scpb.Column' - - $column-type[Type] = '*scpb.ColumnType' - columnInIndex($index-column, $index, $table-id, $column-id, $index-id) - joinOnColumnID($index-column, $column, $table-id, $column-id) - - joinOnColumnID($index-column, $column-type, $table-id, $column-id) - - relationIsNotBeingDropped(*scpb.ColumnType)($column-type) + - descriptorIsNotBeingDropped($index-column) - transient($index-target, $column-target) - $index-node[CurrentStatus] = TRANSIENT_ABSENT - $column-node[CurrentStatus] = TRANSIENT_ABSENT @@ -1916,11 +1910,9 @@ deprules query: - $index[Type] IN ['*scpb.PrimaryIndex', '*scpb.SecondaryIndex'] - $column[Type] = '*scpb.Column' - - $column-type[Type] = '*scpb.ColumnType' - columnInIndex($index-column, $index, $table-id, $column-id, $index-id) - joinOnColumnID($index-column, $column, $table-id, $column-id) - - joinOnColumnID($index-column, $column-type, $table-id, $column-id) - - relationIsNotBeingDropped(*scpb.ColumnType)($column-type) + - descriptorIsNotBeingDropped($index-column) - toAbsent($index-target, $column-target) - $index-node[CurrentStatus] = ABSENT - $column-node[CurrentStatus] = ABSENT @@ -2148,9 +2140,7 @@ deprules - toAbsent($index-target, $column-target) - $index-node[CurrentStatus] = VALIDATED - $column-node[CurrentStatus] = WRITE_ONLY - - $column-type[Type] = '*scpb.ColumnType' - - joinOnColumnID($index-column, $column-type, $table-id, $column-id) - - relationIsNotBeingDropped(*scpb.ColumnType)($column-type) + - descriptorIsNotBeingDropped($index-column) - isIndexKeyColumnKey(*scpb.IndexColumn)($index-column) - joinTargetNode($index, $index-target, $index-node) - joinTargetNode($column, $column-target, $column-node)