Hello, AFAIK, mroonga also requires some CREATE FUNCTION (and of course to be loaded either in MariaDB configuration or through INSTALL PLUGIN). I'm not sure how other plugins do, but what is the general stance about such things? Shall we do it automatically or leave it to the user?
I'm asking because I recently had to automatically install mroonga for a customer. I have attached to this email a (very rough) patch to automatically load the plugin and issue CREATE FUNCTION (if necessary of course) on startup. Cheers, -- Arnaud Fontaine
--- a/debian/additions/debian-start +++ b/debian/additions/debian-start @@ -30,6 +30,7 @@ trap "" SIGHUP upgrade_system_tables_if_necessary; check_root_accounts; check_for_crashed_tables; + upgrade_mroonga_if_necessary; ) >&2 & exit 0 --- a/debian/additions/debian-start.inc.sh +++ b/debian/additions/debian-start.inc.sh @@ -70,3 +70,30 @@ function check_root_accounts() { logger -p daemon.warn -i -t$0 "WARNING: mysql.user contains $ret root accounts without password!" fi } + +function upgrade_mroonga_if_necessary() { + set -e + set -u + + if [ -e "/var/lib/mysql/upgraded-debian.flag" ]; then + logger -p daemon.info -i -t$0 "Upgrading mroonga." + + # From storage/mroonga/data/install.sql.in + echo -e \ + "DROP FUNCTION IF EXISTS last_insert_grn_id;\n" \ + "CREATE FUNCTION last_insert_grn_id RETURNS INTEGER SONAME 'ha_mroonga.so';\n" \ + "DROP FUNCTION IF EXISTS mroonga_snippet;\n" \ + "CREATE FUNCTION mroonga_snippet RETURNS STRING SONAME 'ha_mroonga.so';\n" \ + "DROP FUNCTION IF EXISTS mroonga_command;\n" \ + "CREATE FUNCTION mroonga_command RETURNS STRING SONAME 'ha_mroonga.so';\n" \ + "DROP FUNCTION IF EXISTS mroonga_escape;\n" \ + "CREATE FUNCTION mroonga_escape RETURNS STRING SONAME 'ha_mroonga.so';\n" | \ + $MYSQL --skip-column-names + + if [ "$?" -ne "0" ]; then + logger -p daemon.warn -i -t$0 "WARNING: Could not upgrade mroonga!" + else + rm -f /var/lib/mysql/upgraded-debian.flag + fi + fi +} --- a/debian/additions/mariadb.cnf +++ b/debian/additions/mariadb.cnf @@ -15,3 +15,4 @@ #collation-server = utf8_general_ci #character_set_server = utf8 #collation_server = utf8_general_ci +plugin-load=Mroonga=ha_mroonga.so --- a/debian/mariadb-server-10.0.postinst +++ b/debian/mariadb-server-10.0.postinst @@ -229,6 +229,8 @@ EOF echo "$replace_query" | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER echo "$install_plugins" | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER set -e + + touch /var/lib/mysql/upgraded-debian.flag ;; abort-upgrade|abort-remove|abort-configure)