@@ -4056,6 +4056,22 @@ make_table_name_list(THD *thd, Dynamic_array<LEX_STRING*> *table_names,
4056
4056
}
4057
4057
4058
4058
4059
+ static void get_table_engine_for_i_s (THD *thd, char *buf, TABLE_LIST *tl,
4060
+ LEX_STRING *db, LEX_STRING *table)
4061
+ {
4062
+ LEX_STRING engine_name= { buf, 0 };
4063
+
4064
+ if (thd->get_stmt_da ()->sql_errno () == ER_UNKNOWN_STORAGE_ENGINE)
4065
+ {
4066
+ char path[FN_REFLEN];
4067
+ build_table_filename (path, sizeof (path) - 1 ,
4068
+ db->str , table->str , reg_ext, 0 );
4069
+ if (dd_frm_type (thd, path, &engine_name) == FRMTYPE_TABLE)
4070
+ tl->option = engine_name.str ;
4071
+ }
4072
+ }
4073
+
4074
+
4059
4075
/* *
4060
4076
Fill I_S table with data obtained by performing full-blown table open.
4061
4077
@@ -4126,9 +4142,9 @@ fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys,
4126
4142
4127
4143
/*
4128
4144
Since make_table_list() might change database and table name passed
4129
- to it we create copies of orig_db_name and orig_table_name here.
4130
- These copies are used for make_table_list() while unaltered values
4131
- are passed to process_table() functions.
4145
+ to it (if lower_case_table_names) we create copies of orig_db_name and
4146
+ orig_table_name here. These copies are used for make_table_list()
4147
+ while unaltered values are passed to process_table() functions.
4132
4148
*/
4133
4149
if (!thd->make_lex_string (&db_name,
4134
4150
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,
4215
4231
}
4216
4232
else
4217
4233
{
4234
+ char buf[NAME_CHAR_LEN + 1 ];
4235
+ if (thd->is_error ())
4236
+ get_table_engine_for_i_s (thd, buf, table_list, &db_name, &table_name);
4237
+
4218
4238
result= schema_table->process_table (thd, table_list,
4219
4239
table, result,
4220
4240
orig_db_name,
@@ -4525,7 +4545,9 @@ static int fill_schema_table_from_frm(THD *thd, TABLE *table,
4525
4545
}
4526
4546
else
4527
4547
{
4528
- table_list.table = &tbl;
4548
+ char buf[NAME_CHAR_LEN + 1 ];
4549
+ get_table_engine_for_i_s (thd, buf, &table_list, db_name, table_name);
4550
+
4529
4551
res= schema_table->process_table (thd, &table_list, table,
4530
4552
true , db_name, table_name);
4531
4553
}
@@ -4939,6 +4961,11 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
4939
4961
else
4940
4962
table->field [3 ]->store (STRING_WITH_LEN (" BASE TABLE" ), cs);
4941
4963
4964
+ if (tables->option )
4965
+ {
4966
+ table->field [4 ]->store (tables->option , strlen (tables->option ), cs);
4967
+ table->field [4 ]->set_notnull ();
4968
+ }
4942
4969
goto err;
4943
4970
}
4944
4971
0 commit comments