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

Method RenameRootObject

core/sequences/root_object.go:324–340  ·  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

322
323// RenameRootObject implements the interface objinterface.Collection.
324func (pgs *Collection) RenameRootObject(ctx context.Context, oldName id.Id, newName id.Id) error {
325 if !oldName.IsValid() || !newName.IsValid() || oldName.Section() != newName.Section() || oldName.Section() != id.Section_Sequence {
326 return errors.New("cannot rename sequence due to invalid name")
327 }
328 oldSeqName := id.Sequence(oldName)
329 newSeqName := id.Sequence(newName)
330 seq, err := pgs.GetSequence(ctx, oldSeqName)
331 if err != nil {
332 return err
333 }
334 if err = pgs.DropSequence(ctx, oldSeqName); err != nil {
335 return err
336 }
337 newSeq := *seq
338 newSeq.Id = newSeqName
339 return pgs.CreateSequence(ctx, &newSeq)
340}
341
342// ResolveName implements the interface objinterface.Collection.
343func (pgs *Collection) ResolveName(ctx context.Context, name doltdb.TableName) (doltdb.TableName, id.Id, error) {

Callers

nothing calls this directly

Calls 6

GetSequenceMethod · 0.95
DropSequenceMethod · 0.95
CreateSequenceMethod · 0.95
SequenceTypeAlias · 0.92
SectionMethod · 0.80
IsValidMethod · 0.45

Tested by

no test coverage detected