summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-02-20 22:26:48 +0100
committerSergei Golubchik <serg@mariadb.org>2016-02-23 10:54:34 +0100
commit9214d043fd864f8ee96e34551e49a011e20ddef0 (patch)
treed4f2e0e757d5eb4920947a79e7cf14b227346d1f
parent57905d18d650004ca84d7f9b01f0cf72e100d6bc (diff)
downloadmariadb-git-9214d043fd864f8ee96e34551e49a011e20ddef0.tar.gz
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
-rw-r--r--mysql-test/r/show.result12
-rw-r--r--mysql-test/t/show.test15
-rw-r--r--sql/sql_show.cc5
-rw-r--r--sql/sql_show.h5
-rw-r--r--sql/sql_yacc.yy5
5 files changed, 38 insertions, 4 deletions
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;