GetFunctionsCollectionFromContext returns the functions collection from the given context. Will always return a collection if no error is returned.
(ctx *sql.Context, database string)
| 313 | // GetFunctionsCollectionFromContext returns the functions collection from the given context. Will always return a |
| 314 | // collection if no error is returned. |
| 315 | func GetFunctionsCollectionFromContext(ctx *sql.Context, database string) (*functions.Collection, error) { |
| 316 | cv, err := getContextValues(ctx) |
| 317 | if err != nil { |
| 318 | return nil, err |
| 319 | } |
| 320 | if cv.funcs == nil { |
| 321 | cv.funcs = make(map[string]*functions.Collection) |
| 322 | } |
| 323 | if len(database) == 0 { |
| 324 | database = ctx.GetCurrentDatabase() |
| 325 | } |
| 326 | if cv.funcs[database] == nil { |
| 327 | _, root, err := getRootFromContextForDatabase(ctx, database) |
| 328 | if err != nil { |
| 329 | return nil, err |
| 330 | } |
| 331 | cv.funcs[database], err = functions.LoadFunctions(ctx, root) |
| 332 | if err != nil { |
| 333 | return nil, err |
| 334 | } |
| 335 | } |
| 336 | return cv.funcs[database], nil |
| 337 | } |
| 338 | |
| 339 | // GetProceduresCollectionFromContext returns the procedures collection from the given context. Will always return a |
| 340 | // collection if no error is returned. |
no test coverage detected