CREATE LIBRARY
Loads a library containing User Defined Extensions (UDxs) into the Vertica catalog. After loading a library in the catalog, you can use statements such as CREATE FUNCTION to define the extensions contained in the library. See Developing User-Defined Extensions (UDxs) in Extending Vertica for details.
Syntax
CREATE [OR REPLACE] LIBRARY [schema.]library-name AS 'library-path' [ DEPENDS 'support-path' ] [ LANGUAGE 'language' ]
Parameters
OR REPLACE
|
Replaces the old library with the new one. If you do not supply this parameter, the CREATE LIBRARY statement fails when an existing library matches the name the library you are trying to define. |
schema |
Specifies a schema. If multiple schemas are defined in the database, include the schema name. For example: myschema.thisDbObject |
library‑name
|
A name to assign to this library, where library-name.conforms to conventions described in Identifiers. Use this name in a CREATE FUNCTION statement to enable user defined functions stored in the library. Best practice: This name does not have to match the library file name. However, consider using the same name to avoid confusion. |
library‑path
|
The absolute path and file name of the library to load. This file must be located in the initiator node's filesystem. |
DEPENDS 'support‑path'
|
Indicates that the UDx library depends on one or more support libraries. Valid values: One or more absolute paths to the support libraries files, located in the initiator node's filesystem. Separate multiple paths with colons (:). Specify a directory containing multiple libraries using an asterisk wildcard (*). For example: |
LANGUAGE 'language'
|
The programming language used to develop the function, where language is one of the following:
|
Privileges
Usage Considerations
- As part of the loading process, Vertica distributes the library file and any supporting libraries to all nodes in the database. cluster. Any nodes that are down or that are added to the cluster later automatically receive a copy of the files when they join the cluster.
- Vertica makes its own copies of the library files. Later modification or deletion of the original files specified in the statement does not effect the library defined in the catalog. To update the library, use the ALTER LIBRARY statement.
- Simply loading the library is no guarantee that it functions correctly. CREATE LIBRARY performs some basic checks on the library file to verify it is compatible with Vertica. The statement fails if it detects that the library was not correctly compiled or it finds other basic incompatibilities. However, there are many issues in shared libraries that CREATE LIBRARY cannot detect.
- Libraries are added to the database catalog, and therefore persist across database restarts.
- If your Java library depends on native libraries (SO files), use DEPENDS to specify the path and call System.loadLibrary() in your UDx to load the native libraries from that path.
Examples
To load a library in the home directory of the dbadmin account with the name MyFunctions:
=> CREATE LIBRARY MyFunctions AS 'home/dbadmin/my_functions.so';
To load a library located in the directory where you started vsql:
=> \set libfile '\''`pwd`'/MyOtherFunctions.so\''; => CREATE LIBRARY MyOtherFunctions AS :libfile;
To load a Java library named JavaLib.jar
that depends on multiple support JAR files in the /home/dbamin/mylibs
subdirectory:
=> CREATE LIBRARY DeleteVowelsLib AS '/home/dbadmin/JavaLib.jar' DEPENDS '/home/dbadmin/mylibs/*' LANGUAGE 'JAVA';