Skip to content

Commit

Permalink
disable SHOW I_S_table for built-in I_S tables
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vuvova committed Feb 23, 2016
1 parent 57905d1 commit 9214d04
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
12 changes: 12 additions & 0 deletions mysql-test/r/show.result
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions mysql-test/t/show.test
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 4 additions & 1 deletion sql/sql_show.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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))
Expand Down
5 changes: 4 additions & 1 deletion sql/sql_show.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions sql/sql_yacc.yy
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9214d04

Please sign in to comment.