summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorHartmut Holzgraefe <hartmut@mariadb.com>2017-02-07 22:56:28 +0100
committerSergei Golubchik <serg@mariadb.org>2017-03-10 18:21:24 +0100
commitc372388e4862938037f98b6e4936bc61872354dd (patch)
treec465cf4cd98449ab4fcefc701a02f06977f24a64 /client
parent8f1ca5e311bda92d4e901aae8ec5c47597d0f934 (diff)
downloadmariadb-git-c372388e4862938037f98b6e4936bc61872354dd.tar.gz
make mysql_upgrade try to install missing storage engine plugins (MDEV-11942)
Diffstat (limited to 'client')
-rw-r--r--client/mysql_upgrade.c50
1 files changed, 48 insertions, 2 deletions
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index 0594af39451..a1dcba91aa2 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -756,7 +756,6 @@ static void print_conn_args(const char *tool_name)
verbose("Running '%s with default connection arguments", tool_name);
}
-
/*
Check and upgrade(if necessary) all tables
in the server using "mysqlcheck --check-upgrade .."
@@ -927,6 +926,52 @@ static void print_line(char* line)
/*
+ Check for entries with "Unknown storage engine" in I_S.TABLES,
+ try to load plugins for these tables if available (MDEV-11942)
+*/
+static int run_mysqlcheck_engines(void)
+{
+ DYNAMIC_STRING ds_query;
+ DYNAMIC_STRING ds_result;
+
+ /* Trying to identify existing tables with unknown storage engine
+ Does not work with all engine types yet, and doesn't produce
+ results for BLACKHOLE without the dummy "WHERE row_format IS NULL"
+ condition yet. See MDEV-11943 */
+ const char *query = "SELECT DISTINCT LOWER(REPLACE(REPLACE(table_comment, 'Unknown storage engine ', ''), '\\'', '')) AS engine FROM information_schema.tables WHERE row_format IS NULL AND table_comment LIKE 'Unknown storage engine%'";
+
+ if (init_dynamic_string(&ds_query, "", 512, 512))
+ die("Out of memory");
+
+ if (init_dynamic_string(&ds_result, "", 512, 512))
+ die("Out of memory");
+
+ verbose("Checking for tables with unknown storage engine");
+
+ run_query(query, &ds_result, TRUE);
+
+ {
+ char *line= ds_result.str;
+ if (line && *line) {
+ do
+ {
+ line[strlen(line)-1]='\0';
+ verbose("installing missing plugin for '%s' storage engine", line);
+
+ dynstr_set(&ds_query, "INSTALL SONAME 'ha_");
+ dynstr_append(&ds_query, line); // we simply assume SONAME=ha_ENGINENAME
+ dynstr_append(&ds_query, "'");
+
+ if (run_query(ds_query.str, NULL, TRUE)) {
+ fprintf(stderr, "... can't install plugin 'ha_%s'\n", line);
+ }
+ } while ((line= get_line(line)) && *line);
+ }
+ }
+}
+
+
+/*
Update all system tables in MySQL Server to current
version using "mysql" to execute all the SQL commands
compiled into the mysql_fix_privilege_tables array
@@ -1131,7 +1176,8 @@ int main(int argc, char **argv)
/*
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
*/
- if (run_mysqlcheck_upgrade(TRUE) ||
+ if (run_mysqlcheck_engines() ||
+ run_mysqlcheck_upgrade(TRUE) ||
run_mysqlcheck_views() ||
run_sql_fix_privilege_tables() ||
run_mysqlcheck_fixnames() ||