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

Function loadFunction

server/node/create_trigger.go:169–199  ·  view source on GitHub ↗

loadFunction loads the function with the given ID from the given collection. If the collection is nil, then this also loads the collection from the context.

(ctx *sql.Context, funcCollection *functions.Collection, funcID id.Function)

Source from the content-addressed store, hash-verified

167// loadFunction loads the function with the given ID from the given collection. If the collection is nil, then this also
168// loads the collection from the context.
169func loadFunction(ctx *sql.Context, funcCollection *functions.Collection, funcID id.Function) (functions.Function, error) {
170 var err error
171 if funcCollection == nil {
172 funcCollection, err = core.GetFunctionsCollectionFromContext(ctx, "")
173 if err != nil {
174 return functions.Function{}, err
175 }
176 }
177 var function functions.Function
178 if len(funcID.SchemaName()) > 0 {
179 function, err = funcCollection.GetFunction(ctx, funcID)
180 if err != nil {
181 return functions.Function{}, err
182 }
183 } else {
184 searchPaths, err := core.SearchPath(ctx)
185 if err != nil {
186 return functions.Function{}, err
187 }
188 for _, searchPath := range searchPaths {
189 function, err = funcCollection.GetFunction(ctx, id.NewFunction(searchPath, funcID.FunctionName()))
190 if err != nil {
191 return functions.Function{}, err
192 }
193 if function.ID.IsValid() {
194 break
195 }
196 }
197 }
198 return function, nil
199}

Callers 2

loadTriggerFunctionMethod · 0.85
RowIterMethod · 0.85

Calls 7

SearchPathFunction · 0.92
NewFunctionFunction · 0.92
SchemaNameMethod · 0.45
GetFunctionMethod · 0.45
FunctionNameMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected