MCPcopy Create free account
hub / github.com/dolthub/doltgresql / RenameRootObject

Method RenameRootObject

core/functions/root_object.go:258–277  ·  view source on GitHub ↗

RenameRootObject implements the interface objinterface.Collection.

(ctx context.Context, oldName id.Id, newName id.Id)

Source from the content-addressed store, hash-verified

256
257// RenameRootObject implements the interface objinterface.Collection.
258func (pgf *Collection) RenameRootObject(ctx context.Context, oldName id.Id, newName id.Id) error {
259 if !oldName.IsValid() || !newName.IsValid() || oldName.Section() != newName.Section() || oldName.Section() != id.Section_Function {
260 return errors.New("cannot rename function due to invalid name")
261 }
262 oldFuncName := id.Function(oldName)
263 newFuncName := id.Function(newName)
264 if oldFuncName.ParameterCount() != newFuncName.ParameterCount() {
265 return errors.Newf(`old function id had "%d" parameters, new function id has "%d" parameters`,
266 oldFuncName.ParameterCount(), newFuncName.ParameterCount())
267 }
268 f, err := pgf.GetFunction(ctx, oldFuncName)
269 if err != nil {
270 return err
271 }
272 if err = pgf.DropFunction(ctx, oldFuncName); err != nil {
273 return err
274 }
275 f.ID = newFuncName
276 return pgf.AddFunction(ctx, f)
277}
278
279// ResolveName implements the interface objinterface.Collection.
280func (pgf *Collection) ResolveName(ctx context.Context, name doltdb.TableName) (doltdb.TableName, id.Id, error) {

Callers

nothing calls this directly

Calls 7

GetFunctionMethod · 0.95
DropFunctionMethod · 0.95
AddFunctionMethod · 0.95
FunctionTypeAlias · 0.92
SectionMethod · 0.80
IsValidMethod · 0.45
ParameterCountMethod · 0.45

Tested by

no test coverage detected