From abd36000968093794aefe384d03aca278990071f Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Mon, 6 Feb 2023 20:20:03 +0100 Subject: [PATCH] funcdesc: make `ToFuncObj` return an object on the heap directly Release note: None --- pkg/sql/alter_function.go | 8 ++++---- pkg/sql/catalog/funcdesc/func_desc.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/sql/alter_function.go b/pkg/sql/alter_function.go index d7fb8a35e9ff..744fc60ae1c7 100644 --- a/pkg/sql/alter_function.go +++ b/pkg/sql/alter_function.go @@ -140,7 +140,7 @@ func (n *alterFunctionRenameNode) startExec(params runParams) error { maybeExistingFuncObj := fnDesc.ToFuncObj() maybeExistingFuncObj.FuncName.ObjectName = n.n.NewName - existing, err := params.p.matchUDF(params.ctx, &maybeExistingFuncObj, false /* required */) + existing, err := params.p.matchUDF(params.ctx, maybeExistingFuncObj, false /* required */) if err != nil { return err } @@ -148,7 +148,7 @@ func (n *alterFunctionRenameNode) startExec(params runParams) error { if existing != nil { return pgerror.Newf( pgcode.DuplicateFunction, "function %s already exists in schema %q", - tree.AsString(&maybeExistingFuncObj), scDesc.GetName(), + tree.AsString(maybeExistingFuncObj), scDesc.GetName(), ) } @@ -305,14 +305,14 @@ func (n *alterFunctionSetSchemaNode) startExec(params runParams) error { maybeExistingFuncObj := fnDesc.ToFuncObj() maybeExistingFuncObj.FuncName.SchemaName = tree.Name(targetSc.GetName()) maybeExistingFuncObj.FuncName.ExplicitSchema = true - existing, err := params.p.matchUDF(params.ctx, &maybeExistingFuncObj, false /* required */) + existing, err := params.p.matchUDF(params.ctx, maybeExistingFuncObj, false /* required */) if err != nil { return err } if existing != nil { return pgerror.Newf( pgcode.DuplicateFunction, "function %s already exists in schema %q", - tree.AsString(&maybeExistingFuncObj), targetSc.GetName(), + tree.AsString(maybeExistingFuncObj), targetSc.GetName(), ) } diff --git a/pkg/sql/catalog/funcdesc/func_desc.go b/pkg/sql/catalog/funcdesc/func_desc.go index e1ec17b1a63b..d20b79e51ded 100644 --- a/pkg/sql/catalog/funcdesc/func_desc.go +++ b/pkg/sql/catalog/funcdesc/func_desc.go @@ -504,8 +504,8 @@ func (desc *Mutable) SetParentSchemaID(id descpb.ID) { } // ToFuncObj converts the descriptor to a tree.FuncObj. -func (desc *immutable) ToFuncObj() tree.FuncObj { - ret := tree.FuncObj{ +func (desc *immutable) ToFuncObj() *tree.FuncObj { + ret := &tree.FuncObj{ FuncName: tree.MakeFunctionNameFromPrefix(tree.ObjectNamePrefix{}, tree.Name(desc.Name)), Params: make(tree.FuncParams, len(desc.Params)), }