Skip to content

Commit c372388

Browse files
hartmut-mariadbvuvova
authored andcommitted
make mysql_upgrade try to install missing storage engine plugins (MDEV-11942)
1 parent 8f1ca5e commit c372388

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

client/mysql_upgrade.c

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,6 @@ static void print_conn_args(const char *tool_name)
756756
verbose("Running '%s with default connection arguments", tool_name);
757757
}
758758

759-
760759
/*
761760
Check and upgrade(if necessary) all tables
762761
in the server using "mysqlcheck --check-upgrade .."
@@ -926,6 +925,52 @@ static void print_line(char* line)
926925
}
927926

928927

928+
/*
929+
Check for entries with "Unknown storage engine" in I_S.TABLES,
930+
try to load plugins for these tables if available (MDEV-11942)
931+
*/
932+
static int run_mysqlcheck_engines(void)
933+
{
934+
DYNAMIC_STRING ds_query;
935+
DYNAMIC_STRING ds_result;
936+
937+
/* Trying to identify existing tables with unknown storage engine
938+
Does not work with all engine types yet, and doesn't produce
939+
results for BLACKHOLE without the dummy "WHERE row_format IS NULL"
940+
condition yet. See MDEV-11943 */
941+
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%'";
942+
943+
if (init_dynamic_string(&ds_query, "", 512, 512))
944+
die("Out of memory");
945+
946+
if (init_dynamic_string(&ds_result, "", 512, 512))
947+
die("Out of memory");
948+
949+
verbose("Checking for tables with unknown storage engine");
950+
951+
run_query(query, &ds_result, TRUE);
952+
953+
{
954+
char *line= ds_result.str;
955+
if (line && *line) {
956+
do
957+
{
958+
line[strlen(line)-1]='\0';
959+
verbose("installing missing plugin for '%s' storage engine", line);
960+
961+
dynstr_set(&ds_query, "INSTALL SONAME 'ha_");
962+
dynstr_append(&ds_query, line); // we simply assume SONAME=ha_ENGINENAME
963+
dynstr_append(&ds_query, "'");
964+
965+
if (run_query(ds_query.str, NULL, TRUE)) {
966+
fprintf(stderr, "... can't install plugin 'ha_%s'\n", line);
967+
}
968+
} while ((line= get_line(line)) && *line);
969+
}
970+
}
971+
}
972+
973+
929974
/*
930975
Update all system tables in MySQL Server to current
931976
version using "mysql" to execute all the SQL commands
@@ -1131,7 +1176,8 @@ int main(int argc, char **argv)
11311176
/*
11321177
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
11331178
*/
1134-
if (run_mysqlcheck_upgrade(TRUE) ||
1179+
if (run_mysqlcheck_engines() ||
1180+
run_mysqlcheck_upgrade(TRUE) ||
11351181
run_mysqlcheck_views() ||
11361182
run_sql_fix_privilege_tables() ||
11371183
run_mysqlcheck_fixnames() ||

0 commit comments

Comments
 (0)