Skip to content

Commit 8a49c18

Browse files
committed
catalog/rewrite: rewrite declarative schema changer state for functions
The declarative schema changer state rewrite logic previously skipped function descriptors. This was an oversight stemming from the fact that function creation was limited to a single stage. However, with schema_locked support, function creation involving table references can now span multiple stages. This patch corrects the oversight by enabling schema changer state rewriting for functions. Release note: None
1 parent c5944b3 commit 8a49c18

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pkg/sql/catalog/rewrite/rewrite.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,20 @@ func rewriteSchemaChangerState(
892892
removeElementAtCurrentIdx()
893893
continue
894894
}
895+
case *scpb.TriggerFunctionCall:
896+
// If there is a missing function, then this was in middle of creating
897+
// a trigger when the back-up was taken.
898+
if el.FuncID == missingID {
899+
removeElementAtCurrentIdx()
900+
continue
901+
}
902+
case *scpb.TriggerDeps:
903+
// If there is a missing function, then this was in middle of creating
904+
// a trigger when the back-up was taken.
905+
if catalog.MakeDescriptorIDSet(el.UsesRoutineIDs...).Contains(missingID) {
906+
removeElementAtCurrentIdx()
907+
continue
908+
}
895909
}
896910
return errors.Wrap(err, "rewriting descriptor ids")
897911
}
@@ -1176,6 +1190,9 @@ func FunctionDescs(
11761190
fnDesc.Name, dep.ID)
11771191
}
11781192
}
1193+
if err := rewriteSchemaChangerState(fnDesc, descriptorRewrites); err != nil {
1194+
return err
1195+
}
11791196
}
11801197
return nil
11811198
}

0 commit comments

Comments
 (0)