Skip to content

Commit 1598748

Browse files
committed
sql/schemachanger: fix incorrect filter for pk index swaps
Previously, we adjusted the schema changer rules to ensure that old secondary indexes are only dropped when the new secondary index is usable. Unfortunately, one of the rules had an incorrect filter. To address this, this patch fixes the filter to expect the new secondary index, which will have the new flag. Fixes: #154751 Release note: None
1 parent 7635297 commit 1598748

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/sql/schemachanger/scplan/internal/rules/current/dep_swap_index.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ func init() {
152152
func(from, to NodeVars) rel.Clauses {
153153
newIndex := MkNodeVars("new-index")
154154
return append(rel.Clauses{
155-
to.Type((*scpb.PrimaryIndex)(nil)),
156155
from.Type((*scpb.SecondaryIndex)(nil)),
156+
to.Type((*scpb.PrimaryIndex)(nil)),
157157
JoinOnDescID(from, to, "table-id"),
158158
from.TargetStatus(scpb.ToAbsent),
159159
from.CurrentStatus(scpb.Status_VALIDATED),
@@ -163,9 +163,9 @@ func init() {
163163
to.El.AttrEqVar(screl.IndexID, "new-primary-index-id"),
164164
// Only active this rule on secondary indexes created after 25.4
165165
FilterElements("only apply to secondary indexes created after 25.4",
166-
from, to,
167-
func(from *scpb.PrimaryIndex, to *scpb.SecondaryIndex) bool {
168-
return to.HideForPrimaryKeyRecreated
166+
newIndex, to,
167+
func(newIndex *scpb.SecondaryIndex, to *scpb.PrimaryIndex) bool {
168+
return newIndex.HideForPrimaryKeyRecreated
169169
}),
170170
},
171171
IsPotentialSecondaryIndexSwapWithNodeVars(from, newIndex, "index-id", "table-id")...)

0 commit comments

Comments
 (0)