LOAD PLUGIN
Enterprise—
Learn morePlugins are developed against the open-source questdb library
and run only on QuestDB Enterprise.
Loads a plugin JAR from the plugin directory, making its SQL functions available
immediately. Requires PLUGIN ADMIN permission.
Syntax
LOAD PLUGIN [IF NOT LOADED] plugin_name;
plugin_name— the JAR filename, with or without the.jarextension. May be quoted or unquoted.IF NOT LOADED— optional clause that makes the command idempotent: no error is raised if the plugin is already loaded.
Description
LOAD PLUGIN performs the following steps:
- Looks up
plugin_namein the set of discovered plugins (populated bySCAN PLUGINSor at startup). - Checks that all declared plugin dependencies are already loaded.
- Creates an isolated
URLClassLoaderfor the plugin JAR. - Scans the JAR for
FunctionFactoryimplementations and registers them under the plugin namespace. - Invokes the
PluginLifecycle.onLoad()callback if the plugin declares one. - If any step fails, the load is fully rolled back and the plugin remains unloaded.
After a successful load, the compiled query cache is flushed and plugin
functions are immediately available using qualified names:
plugin_name.function_name(args). Quote the plugin name in SQL when it
contains hyphens or dots (e.g. "my-plugin-1.0.0".my_func()).
Examples
Load a plugin
LOAD PLUGIN 'questdb-plugin-example-1.0.0';
Idempotent load
LOAD PLUGIN IF NOT LOADED 'questdb-plugin-example-1.0.0';
Error conditions
| Error | Cause |
|---|---|
Plugin not found | The plugin name was not discovered by SCAN PLUGINS. Run SCAN PLUGINS first. |
Plugin already loaded | The plugin is already loaded and IF NOT LOADED was not specified. |
Plugin X requires plugin Y to be loaded first | A declared dependency is not loaded. Load the dependency first. |