From 9214d043fd864f8ee96e34551e49a011e20ddef0 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 20 Feb 2016 22:26:48 +0100 Subject: disable SHOW I_S_table for built-in I_S tables This fixes MDEV-9538 Server crashes in check_show_access on SHOW STATISTICS MDEV-9539 Server crashes in make_columns_old_format on SHOW GEOMETRY_COLUMNS MDEV-9540 SHOW SPATIAL_REF_SYS and SHOW SYSTEM_VARIABLES return empty results with numerous warnings --- mysql-test/r/show.result | 12 ++++++++++++ mysql-test/t/show.test | 15 +++++++++++++++ sql/sql_show.cc | 5 ++++- sql/sql_show.h | 5 ++++- sql/sql_yacc.yy | 5 +++-- 5 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 mysql-test/r/show.result create mode 100644 mysql-test/t/show.test diff --git a/mysql-test/r/show.result b/mysql-test/r/show.result new file mode 100644 index 00000000000..3dd7af5de05 --- /dev/null +++ b/mysql-test/r/show.result @@ -0,0 +1,12 @@ +show statistics; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'statistics' at line 1 +show spatial_ref_sys +--error ER_PARSE_ERROR +show system_variables; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'spatial_ref_sys +--error ER_PARSE_ERROR +show system_variables' at line 2 +show geometry_columns; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'geometry_columns' at line 1 +show nonexistent; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'nonexistent' at line 1 diff --git a/mysql-test/t/show.test b/mysql-test/t/show.test new file mode 100644 index 00000000000..3101f443264 --- /dev/null +++ b/mysql-test/t/show.test @@ -0,0 +1,15 @@ +# +# MDEV-9538 Server crashes in check_show_access on SHOW STATISTICS +# MDEV-9539 Server crashes in make_columns_old_format on SHOW GEOMETRY_COLUMNS +# MDEV-9540 SHOW SPATIAL_REF_SYS and SHOW SYSTEM_VARIABLES return empty results with numerous warnings +# +--error ER_PARSE_ERROR +show statistics; +--error ER_PARSE_ERROR +show spatial_ref_sys +--error ER_PARSE_ERROR +show system_variables; +--error ER_PARSE_ERROR +show geometry_columns; +--error ER_PARSE_ERROR +show nonexistent; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 6aeea4b0316..1f41b6a1e60 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -7374,12 +7374,14 @@ static my_bool find_schema_table_in_plugin(THD *thd, plugin_ref plugin, # pointer to 'schema_tables' element */ -ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name) +ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name, + bool *in_plugin) { schema_table_ref schema_table_a; ST_SCHEMA_TABLE *schema_table= schema_tables; DBUG_ENTER("find_schema_table"); + *in_plugin= false; for (; schema_table->table_name; schema_table++) { if (!my_strcasecmp(system_charset_info, @@ -7388,6 +7390,7 @@ ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name) DBUG_RETURN(schema_table); } + *in_plugin= true; schema_table_a.table_name= table_name; if (plugin_foreach(thd, find_schema_table_in_plugin, MYSQL_INFORMATION_SCHEMA_PLUGIN, &schema_table_a)) diff --git a/sql/sql_show.h b/sql/sql_show.h index ecb7e9468ea..d92479971cd 100644 --- a/sql/sql_show.h +++ b/sql/sql_show.h @@ -117,7 +117,10 @@ bool schema_table_store_record(THD *thd, TABLE *table); void initialize_information_schema_acl(); COND *make_cond_for_info_schema(THD *thd, COND *cond, TABLE_LIST *table); -ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name); +ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name, bool *in_plugin); +static inline ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name) +{ bool unused; return find_schema_table(thd, table_name, &unused); } + ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx); int make_schema_select(THD *thd, SELECT_LEX *sel, ST_SCHEMA_TABLE *schema_table); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index e857a3b633a..44387b27406 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -12865,9 +12865,10 @@ show_param: | IDENT_sys remember_tok_start wild_and_where { LEX *lex= Lex; + bool in_plugin; lex->sql_command= SQLCOM_SHOW_GENERIC; - ST_SCHEMA_TABLE *table= find_schema_table(thd, $1.str); - if (!table || !table->old_format) + ST_SCHEMA_TABLE *table= find_schema_table(thd, $1.str, &in_plugin); + if (!table || !table->old_format || !in_plugin) { my_parse_error(thd, ER_SYNTAX_ERROR, $2); MYSQL_YYABORT; -- cgit v1.2.1