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

Method AddProcedure

core/procedures/collection.go:115–141  ·  view source on GitHub ↗

AddProcedure adds a new procedure.

(ctx context.Context, proc Procedure)

Source from the content-addressed store, hash-verified

113
114// AddProcedure adds a new procedure.
115func (pgp *Collection) AddProcedure(ctx context.Context, proc Procedure) error {
116 // First we'll check to see if it exists
117 if _, ok := pgp.accessCache[proc.ID]; ok {
118 return errors.Errorf(`procedure "%s" already exists with same argument types`, proc.ID.ProcedureName())
119 }
120
121 // Now we'll add the procedure to our map
122 data, err := proc.Serialize(ctx)
123 if err != nil {
124 return err
125 }
126 h, err := pgp.ns.WriteBytes(ctx, data)
127 if err != nil {
128 return err
129 }
130 mapEditor := pgp.underlyingMap.Editor()
131 if err = mapEditor.Add(ctx, string(proc.ID), h); err != nil {
132 return err
133 }
134 newMap, err := mapEditor.Flush(ctx)
135 if err != nil {
136 return err
137 }
138 pgp.underlyingMap = newMap
139 pgp.mapHash = pgp.underlyingMap.HashOf()
140 return pgp.reloadCaches(ctx)
141}
142
143// DropProcedure drops an existing procedure.
144func (pgp *Collection) DropProcedure(ctx context.Context, procIDs ...id.Procedure) error {

Callers 3

PutRootObjectMethod · 0.95
RenameRootObjectMethod · 0.95
RowIterMethod · 0.80

Calls 8

reloadCachesMethod · 0.95
ProcedureNameMethod · 0.80
WriteBytesMethod · 0.80
FlushMethod · 0.80
ErrorfMethod · 0.65
SerializeMethod · 0.65
AddMethod · 0.45
HashOfMethod · 0.45

Tested by

no test coverage detected