Skip to content

Commit

Permalink
funcdesc: make ToFuncObj return an object on the heap directly
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
knz committed Feb 6, 2023
1 parent 5b19c6c commit abd3600
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pkg/sql/alter_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ 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
}

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(),
)
}

Expand Down Expand Up @@ -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(),
)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/catalog/funcdesc/func_desc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
}
Expand Down

0 comments on commit abd3600

Please sign in to comment.