Skip to content

Commit

Permalink
Merge #137304
Browse files Browse the repository at this point in the history
137304: catalog/rewrite: remove unused error return value in RewriteIDsInTypesT r=yuzefovich a=yuzefovich

Epic: None

Release note: None

Co-authored-by: Yahor Yuzefovich <[email protected]>
  • Loading branch information
craig[bot] and yuzefovich committed Dec 19, 2024
2 parents 5d3823e + 78c1f2b commit 3b6f3c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 32 deletions.
4 changes: 1 addition & 3 deletions pkg/backup/restore_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,9 +734,7 @@ func remapAndFilterRelevantStatistics(
if _, ok := descriptorRewrites[typDescID]; !ok {
continue
}
if err := rewrite.RewriteIDsInTypesT(typ, descriptorRewrites); err != nil {
continue
}
rewrite.RewriteIDsInTypesT(typ, descriptorRewrites)
}
}
relevantTableStatistics = append(relevantTableStatistics, stat)
Expand Down
41 changes: 12 additions & 29 deletions pkg/sql/catalog/rewrite/rewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,7 @@ func TableDescs(
// rewriteCol is a closure that performs the ID rewrite logic on a column.
rewriteCol := func(col *descpb.ColumnDescriptor) error {
// Rewrite the types.T's IDs present in the column.
if err := RewriteIDsInTypesT(col.Type, descriptorRewrites); err != nil {
return err
}
RewriteIDsInTypesT(col.Type, descriptorRewrites)
var newUsedSeqRefs []descpb.ID
for _, seqID := range col.UsesSequenceIds {
if rewrite, ok := descriptorRewrites[seqID]; ok {
Expand Down Expand Up @@ -636,9 +634,9 @@ func rewriteSequencesInFunction(

// RewriteIDsInTypesT rewrites all ID's in the input types.T using the input
// ID rewrite mapping.
func RewriteIDsInTypesT(typ *types.T, descriptorRewrites jobspb.DescRewriteMap) error {
func RewriteIDsInTypesT(typ *types.T, descriptorRewrites jobspb.DescRewriteMap) {
if !typ.UserDefined() {
return nil
return
}
tid := typedesc.GetUserDefinedTypeDescID(typ)
// Collect potential new OID values.
Expand All @@ -655,12 +653,8 @@ func RewriteIDsInTypesT(typ *types.T, descriptorRewrites jobspb.DescRewriteMap)
types.RemapUserDefinedTypeOIDs(typ, newOID, newArrayOID)
// If the type is an array, then we need to rewrite the element type as well.
if typ.Family() == types.ArrayFamily {
if err := RewriteIDsInTypesT(typ.ArrayContents(), descriptorRewrites); err != nil {
return err
}
RewriteIDsInTypesT(typ.ArrayContents(), descriptorRewrites)
}

return nil
}

// rewriteRoutineBody rewrites a set of SQL or PL/pgSQL statements.
Expand Down Expand Up @@ -748,9 +742,7 @@ func TypeDescs(types []*typedesc.Mutable, descriptorRewrites jobspb.DescRewriteM
}
case descpb.TypeDescriptor_ALIAS:
// We need to rewrite any ID's present in the aliased types.T.
if err := RewriteIDsInTypesT(typ.Alias, descriptorRewrites); err != nil {
return err
}
RewriteIDsInTypesT(typ.Alias, descriptorRewrites)
default:
return errors.AssertionFailedf("unknown type kind %s", t.String())
}
Expand Down Expand Up @@ -788,17 +780,11 @@ func SchemaDescs(schemas []*schemadesc.Mutable, descriptorRewrites jobspb.DescRe
}
sig.ID = fnDesc.ID
for _, typ := range sig.ArgTypes {
if err := RewriteIDsInTypesT(typ, descriptorRewrites); err != nil {
return err
}
}
if err := RewriteIDsInTypesT(sig.ReturnType, descriptorRewrites); err != nil {
return err
RewriteIDsInTypesT(typ, descriptorRewrites)
}
RewriteIDsInTypesT(sig.ReturnType, descriptorRewrites)
for _, typ := range sig.OutParamTypes {
if err := RewriteIDsInTypesT(typ, descriptorRewrites); err != nil {
return err
}
RewriteIDsInTypesT(typ, descriptorRewrites)
}
newSigs = append(newSigs, *sig)
}
Expand Down Expand Up @@ -933,7 +919,8 @@ func rewriteSchemaChangerState(
return err
}
if err := screl.WalkTypes(t.Element(), func(t *types.T) error {
return RewriteIDsInTypesT(t, descriptorRewrites)
RewriteIDsInTypesT(t, descriptorRewrites)
return nil
}); err != nil {
return errors.Wrap(err, "rewriting user-defined type references")
}
Expand Down Expand Up @@ -1145,13 +1132,9 @@ func FunctionDescs(

// Rewrite type IDs.
for _, param := range fnDesc.Params {
if err := RewriteIDsInTypesT(param.Type, descriptorRewrites); err != nil {
return err
}
}
if err := RewriteIDsInTypesT(fnDesc.ReturnType.Type, descriptorRewrites); err != nil {
return err
RewriteIDsInTypesT(param.Type, descriptorRewrites)
}
RewriteIDsInTypesT(fnDesc.ReturnType.Type, descriptorRewrites)

// Rewrite Dependency IDs.
for i, depID := range fnDesc.DependsOn {
Expand Down

0 comments on commit 3b6f3c6

Please sign in to comment.