CREATE LIBRARY
Loads a library containing user defined extensions (UDxs) into the Vertica catalog. Vertica automatically distributes copies of the library file and any supporting libraries to all cluster nodes. UDxs defined in the catalog that reference the updated library automatically start using the new library file. Nodes that are down or added to the cluster also receive a copy of the updated library file as soon as they join the cluster.
Because libraries are added to the database catalog, they persist across database restarts.
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 [[database.]schema.]library 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. |
[database.]schema
|
Specifies a schema, by default myschema.thisDbObject If you specify a database, it must be the current database. |
library
|
A name to assign to this library, where library conforms to conventions described in Identifiers. Use this name in a Tip: While not required, it is good practice to match library to the library file name. |
library‑path
|
The absolute path and file name of the library to load. This file must be located in the initiator node file system. |
DEPENDS 'support‑path'
|
Indicates that the UDx library depends on one or more support libraries, where support‑path specifies one or more absolute paths to the support libraries files, located in the initiator node's file system. You can specify multiple support paths as follows:
If your Java library depends on native libraries (SO files), use |
LANGUAGE 'language'
|
The programming language used to develop the function, where language is one of the following:
|
Privileges
Superuser
Requirements
- Vertica makes its own copies of the library files. Later modification or deletion of the original files specified in the statement does not affect the library defined in the catalog. To update the library, use ALTER LIBRARY.
- Loading a 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,CREATE LIBRARY
cannot detect many other issues in shared libraries. - You can choose to run UDxs developed in C++ in unfenced mode. Unfenced UDxs run directly in the Vertica process. If the UDx you run in unfenced mode has bugs, it can negatively impact the database, causing instability or even crashes. To avoid these issues, run your UDx only in fenced mode. A few UDx types can only be run in unfenced mode.
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';