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

Function GetExtensionFunction

core/extensions/extensions.go:88–120  ·  view source on GitHub ↗

GetExtensionFunction returns the function inside the extension matching the given names. Returns an error if the extension or function cannot be found.

(identifier LibraryIdentifier, funcName string)

Source from the content-addressed store, hash-verified

86// GetExtensionFunction returns the function inside the extension matching the given names. Returns an error if the
87// extension or function cannot be found.
88func GetExtensionFunction(identifier LibraryIdentifier, funcName string) (_ pg_extension.Function, err error) {
89 libMutex.Lock()
90 defer libMutex.Unlock()
91
92 extName := identifier.ExtensionName()
93 if identifier.Platform() != pg_extension.PLATFORM {
94 return pg_extension.Function{}, errors.Errorf(
95 `function "%s" was initialized through "%s" on a different platform, which is not supported`, funcName, extName)
96 }
97 lib, ok := allLibraries[extName]
98 if !ok {
99 ext, err := GetExtension(extName)
100 if err != nil {
101 return pg_extension.Function{}, err
102 }
103 lib, err = ext.LoadLibrary()
104 if err != nil {
105 return pg_extension.Function{}, err
106 }
107 lib.Version = ext.Control.DefaultVersion
108 allLibraries[extName] = lib
109 }
110 if lib.Version != identifier.Version() {
111 return pg_extension.Function{}, errors.Errorf(
112 `function "%s" was initialized through "%s" v%s, the current platform only supports v%s"`,
113 funcName, extName, identifier.Version().String(), lib.Version.String())
114 }
115 libFunc, ok := lib.Funcs[funcName]
116 if !ok {
117 return pg_extension.Function{}, errors.Errorf(`extension "%s" does not declare the function "%s"`, extName, funcName)
118 }
119 return libFunc, nil
120}
121
122// FindInvalidIdentifiers returns all identifiers that are not valid for the current environment. If the return is
123// empty, then that means all of the given identifiers are valid.

Callers 3

EvalMethod · 0.92
RowIterMethod · 0.92
RowIterMethod · 0.92

Calls 9

GetExtensionFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
ExtensionNameMethod · 0.80
PlatformMethod · 0.80
LoadLibraryMethod · 0.80
ErrorfMethod · 0.65
StringMethod · 0.65
VersionMethod · 0.45

Tested by

no test coverage detected