Navigation Menu

Skip to content

Commit

Permalink
make mysql_upgrade try to install missing storage engine plugins (MDE…
Browse files Browse the repository at this point in the history
…V-11942)
  • Loading branch information
hartmut-mariadb authored and vuvova committed Mar 10, 2017
1 parent 8f1ca5e commit c372388
Showing 1 changed file with 48 additions and 2 deletions.
50 changes: 48 additions & 2 deletions client/mysql_upgrade.c
Expand Up @@ -756,7 +756,6 @@ static void print_conn_args(const char *tool_name)
verbose("Running '%s with default connection arguments", tool_name); verbose("Running '%s with default connection arguments", tool_name);
} }



/* /*
Check and upgrade(if necessary) all tables Check and upgrade(if necessary) all tables
in the server using "mysqlcheck --check-upgrade .." in the server using "mysqlcheck --check-upgrade .."
Expand Down Expand Up @@ -926,6 +925,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 Update all system tables in MySQL Server to current
version using "mysql" to execute all the SQL commands version using "mysql" to execute all the SQL commands
Expand Down Expand Up @@ -1131,7 +1176,8 @@ int main(int argc, char **argv)
/* /*
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql" 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_mysqlcheck_views() ||
run_sql_fix_privilege_tables() || run_sql_fix_privilege_tables() ||
run_mysqlcheck_fixnames() || run_mysqlcheck_fixnames() ||
Expand Down

0 comments on commit c372388

Please sign in to comment.