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

Method DropFunction

core/functions/collection.go:138–164  ·  view source on GitHub ↗

DropFunction drops an existing function.

(ctx context.Context, funcIDs ...id.Function)

Source from the content-addressed store, hash-verified

136
137// DropFunction drops an existing function.
138func (pgf *Collection) DropFunction(ctx context.Context, funcIDs ...id.Function) error {
139 if len(funcIDs) == 0 {
140 return nil
141 }
142 // Check that each name exists before performing any deletions
143 for _, funcID := range funcIDs {
144 if _, ok := pgf.accessCache[funcID]; !ok {
145 return errors.Errorf(`function %s does not exist`, funcID.FunctionName())
146 }
147 }
148
149 // Now we'll remove the functions from the map
150 mapEditor := pgf.underlyingMap.Editor()
151 for _, funcID := range funcIDs {
152 err := mapEditor.Delete(ctx, string(funcID))
153 if err != nil {
154 return err
155 }
156 }
157 newMap, err := mapEditor.Flush(ctx)
158 if err != nil {
159 return err
160 }
161 pgf.underlyingMap = newMap
162 pgf.mapHash = pgf.underlyingMap.HashOf()
163 return pgf.reloadCaches(ctx)
164}
165
166// resolveName returns the fully resolved name of the given function. Returns an error if the name is ambiguous.
167//

Callers 4

DropRootObjectMethod · 0.95
RenameRootObjectMethod · 0.95
RowIterMethod · 0.80
dropFunctionFunction · 0.80

Calls 5

reloadCachesMethod · 0.95
FlushMethod · 0.80
ErrorfMethod · 0.65
FunctionNameMethod · 0.45
HashOfMethod · 0.45

Tested by

no test coverage detected