diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index cd0f9a7a172..2d8ff8d433f 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1470,6 +1470,10 @@ f7 datetime NO NULL f8 datetime YES 2006-01-01 00:00:00 drop table t1; End of 5.0 tests. +show fields from information_schema.TABLE_NAMES; +ERROR 42S02: Unknown table 'TABLE_NAMES' in information_schema +show keys from information_schema.TABLE_NAMES; +ERROR 42S02: Unknown table 'TABLE_NAMES' in information_schema select * from information_schema.engines WHERE ENGINE="MyISAM"; ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS MyISAM DEFAULT Default engine as of MySQL 3.23 with great performance NO NO NO diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index c2c0f79d66b..6edc2353fc0 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1090,6 +1090,15 @@ show columns from t1; drop table t1; --echo End of 5.0 tests. + +# +# Bug#30079 A check for "hidden" I_S tables is flawed +# +--error 1109 +show fields from information_schema.TABLE_NAMES; +--error 1109 +show keys from information_schema.TABLE_NAMES; + # # Show engines # diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ae347bebb47..011ba463b5b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5766,7 +5766,12 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, ptr->table_name); if (!schema_table || (schema_table->hidden && - (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0)) + ((sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0 || + /* + this check is used for show columns|keys from I_S hidden table + */ + lex->orig_sql_command == SQLCOM_SHOW_FIELDS || + lex->orig_sql_command == SQLCOM_SHOW_KEYS))) { my_error(ER_UNKNOWN_TABLE, MYF(0), ptr->table_name, INFORMATION_SCHEMA_NAME.str);