DropFunction drops an existing function.
(ctx context.Context, funcIDs ...id.Function)
| 136 | |
| 137 | // DropFunction drops an existing function. |
| 138 | func (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 | // |
no test coverage detected