summaryrefslogtreecommitdiff
path: root/sql/sql_show.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-03-03 15:27:19 +0100
committerSergei Golubchik <serg@mariadb.org>2017-03-10 18:21:24 +0100
commit8f1ca5e311bda92d4e901aae8ec5c47597d0f934 (patch)
treeaaee0a93556cad47699e9e2c76aa90bd97b40f8c /sql/sql_show.cc
parent48b1d175345caa3c644597044751906a04106b91 (diff)
downloadmariadb-git-8f1ca5e311bda92d4e901aae8ec5c47597d0f934.tar.gz
MDEV-11943 I_S.TABLES inconsistencies with tables with unknown storage engine
Try harder to show the table's engine. If the table's engine is not loaded, the table won't open. But we can still read the engine name from frm as a string.
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r--sql/sql_show.cc35
1 files changed, 31 insertions, 4 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 0ef70997089..e915a78d54a 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -4056,6 +4056,22 @@ make_table_name_list(THD *thd, Dynamic_array<LEX_STRING*> *table_names,
}
+static void get_table_engine_for_i_s(THD *thd, char *buf, TABLE_LIST *tl,
+ LEX_STRING *db, LEX_STRING *table)
+{
+ LEX_STRING engine_name= { buf, 0 };
+
+ if (thd->get_stmt_da()->sql_errno() == ER_UNKNOWN_STORAGE_ENGINE)
+ {
+ char path[FN_REFLEN];
+ build_table_filename(path, sizeof(path) - 1,
+ db->str, table->str, reg_ext, 0);
+ if (dd_frm_type(thd, path, &engine_name) == FRMTYPE_TABLE)
+ tl->option= engine_name.str;
+ }
+}
+
+
/**
Fill I_S table with data obtained by performing full-blown table open.
@@ -4126,9 +4142,9 @@ fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys,
/*
Since make_table_list() might change database and table name passed
- to it we create copies of orig_db_name and orig_table_name here.
- These copies are used for make_table_list() while unaltered values
- are passed to process_table() functions.
+ to it (if lower_case_table_names) we create copies of orig_db_name and
+ orig_table_name here. These copies are used for make_table_list()
+ while unaltered values are passed to process_table() functions.
*/
if (!thd->make_lex_string(&db_name,
orig_db_name->str, orig_db_name->length) ||
@@ -4215,6 +4231,10 @@ fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys,
}
else
{
+ char buf[NAME_CHAR_LEN + 1];
+ if (thd->is_error())
+ get_table_engine_for_i_s(thd, buf, table_list, &db_name, &table_name);
+
result= schema_table->process_table(thd, table_list,
table, result,
orig_db_name,
@@ -4525,7 +4545,9 @@ static int fill_schema_table_from_frm(THD *thd, TABLE *table,
}
else
{
- table_list.table= &tbl;
+ char buf[NAME_CHAR_LEN + 1];
+ get_table_engine_for_i_s(thd, buf, &table_list, db_name, table_name);
+
res= schema_table->process_table(thd, &table_list, table,
true, db_name, table_name);
}
@@ -4939,6 +4961,11 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
else
table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs);
+ if (tables->option)
+ {
+ table->field[4]->store(tables->option, strlen(tables->option), cs);
+ table->field[4]->set_notnull();
+ }
goto err;
}