To simplify the control of Buddy plugins, especially when developing a new one or modifying an existing one, the enable and disable Buddy plugin commands are provided. These commands act temporarily during runtime and will reset to their defaults after restarting the daemon or performing a Buddy reset. To permanently disable a plugin, it must be removed.
You need the fully qualified package name of the plugin to enable or disable it. To find it, you can run the SHOW BUDDY PLUGINS
query and look for the full qualified name in the package
field. For example, the SHOW
plugin has the fully qualified name manticoresoftware/buddy-plugin-show
.
ENABLE BUDDY PLUGIN <username/package name on https://packagist.org/>
This command reactivates a previously disabled Buddy plugin, allowing it to process your requests again.
- SQL
ENABLE BUDDY PLUGIN manticoresoftware/buddy-plugin-show
DISABLE BUDDY PLUGIN <username/package name on https://packagist.org/>
This command deactivates an active Buddy plugin, preventing it from processing any further requests.
- SQL
DISABLE BUDDY PLUGIN manticoresoftware/buddy-plugin-show
After disabling, if you try the SHOW QUERIES
command, you'll encounter an error because the plugin is disabled.
RELOAD PLUGINS FROM SONAME 'plugin_library'
Reloads all plugins (UDFs, rankers, etc.) from a given library. In a sense, the reload process is transactional, ensuring that:
- all plugins are successfully updated to their new versions;
- the update is atomic, meaning all plugins are replaced simultaneously. This atomicity ensures that queries using multiple functions from a reloaded library will never mix old and new versions.
During the RELOAD
, the set of plugins is guaranteed to be consistent; they will either be all old or all new.
The reload process is also seamless, as some version of a reloaded plugin will always be available for concurrent queries, without any temporary disruptions. This is an improvement over using a pair of DROP
and CREATE
statements for reloading. With those, there is a brief window between the DROP
and the subsequent CREATE
during which queries technically refer to an unknown plugin and will therefore fail.
If there's any failure, RELOAD PLUGINS
does nothing, retains the old plugins, and reports an error.
On Windows, overwriting or deleting a DLL library currently in use can be problematic. However, you can still rename it, place a new version under the old name, and then RELOAD
will work. After a successful reload, you'll also be able to delete the renamed old library.
mysql> RELOAD PLUGINS FROM SONAME 'udfexample.dll';
Query OK, 0 rows affected (0.00 sec)
Ranker plugins let you implement a custom ranker that receives all the occurrences of the keywords matched in the document, and computes a WEIGHT()
value. They can be called as follows:
SELECT id, attr1 FROM test WHERE match('hello') OPTION ranker=myranker('option1=1');
The call workflow proceeds as follows:
XXX_init()
is invoked once per query per table, at the very beginning. Several query-wide options are passed to it via aSPH_RANKER_INIT
structure, including the user options strings (for instance, "option1=1" in the example above).XXX_update()
is called multiple times for each matched document, with every matched keyword occurrence provided as its parameter, aSPH_RANKER_HIT
structure. The occurrences within each document are guaranteed to be passed in ascending order ofhit->hit_pos
values.XXX_finalize()
is called once for each matched document when there are no more keyword occurrences. It must return theWEIGHT()
value. This function is the only mandatory one.XXX_deinit()
is invoked once per query, at the very end.