Skip to content

Installing mysqlv8udfs

rpbouman edited this page Sep 26, 2014 · 7 revisions

Once you managed to build the software, you should have a mysqlv8udfs.so file. First, you should place this file in MySQL's plugin dir. You can find out where that is by running this query:

SHOW VARIABLES LIKE 'plugin_dir'

After moving the mysqlv8udfs.so to the plugin dir, you can install the daemon plugin and the udfs into MySQL by running the install.sql script. You should run the script under MySQL's root account.

If you ran the install.sql script successfully you should now have 4 new UDFs. You can check it by running this query:

mysql> SELECT * FROM mysql.func WHERE name LIKE 'js%';
+-------+-----+----------------+-----------+
| name  | ret | dl             | type      |
+-------+-----+----------------+-----------+
| js    |   0 | mysqlv8udfs.so | function  |
| jsagg |   0 | mysqlv8udfs.so | aggregate |
| jsudf |   0 | mysqlv8udfs.so | function  |
| jserr |   0 | mysqlv8udfs.so | function  |
+-------+-----+----------------+-----------+
3 rows in set (0.00 sec)

(More rows may be returned if you have other UDFs installed)

You should also have a new daemon plugin:

mysql> SELECT *  FROM   information_schema.plugins WHERE  plugin_name = 'JS_DAEMON'\G
*************************** 1. row ***************************
           PLUGIN_NAME: JS_DAEMON
        PLUGIN_VERSION: 1.0
         PLUGIN_STATUS: ACTIVE
           PLUGIN_TYPE: DAEMON
   PLUGIN_TYPE_VERSION: 50610.0
        PLUGIN_LIBRARY: mysqlv8udfs.so
PLUGIN_LIBRARY_VERSION: 1.4
         PLUGIN_AUTHOR: Roland Bouman
    PLUGIN_DESCRIPTION: Javascript Daemon - Manages resources for the js* UDFs - https://github.com/rpbouman/mysqlv8udfs
        PLUGIN_LICENSE: GPL
           LOAD_OPTION: ON
1 row in set (0.00 sec)

Troubleshooting installation

my.cnf used by the libmysqlclient

If you get a message like this when you install the daemon plugin:

ERROR 1126 (HY000): Can't open shared library '/home/roland/mysql/mysql-5.1.73-linux-x86_64-glibc23/lib/plugin/mysqlv8udfs.so' (errno: 2 libmysqlclient.so.16: cannot open shared object file: No such file or directory)

...then check the server's error log. If you see a message pair like this:

Could not open required defaults file: my.cnf
Fatal error in defaults handling. Program aborted

It probably means the libmysqlclient that is loaded when the plugin is loaded can't locate a my.cnf file. I have been able to silence this message by adding a my.cnf to the data directory. It is possible that the proper location for this my.cnf file is dependent upon the system.

location of libmysqlclient

If you get a message like this when you install the daemon plugin:

ERROR 1126 (HY000): Can't open shared library '/home/roland/mysql/mysql-5.1.73-linux-x86_64-glibc23/lib/plugin/mysqlv8udfs.so' (errno: 22 libmysqlclient.so.16: cannot open shared object file: No such file or directory)

...then the mysqlv8udfs plugin cannot locate the appropriate libmysqlclient lib on your system. You may be able to solve this by adding the location of the libmysqlclient lib to the $LD_LIBRARY_PATH. Or you may simply copy the lib to the default dynamic library path. For example, on my Ubuntu 13 this is /usr/lib/x86_64-linux-gnu