diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index d421ac1d184..21aac20d392 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -590,6 +590,23 @@ TABLES TABLE_PRIVILEGES TABLE_CONSTRAINTS TABLE_NAMES +select table_name from tables where table_name='user'; +table_name +user +select column_name, privileges from columns +where table_name='user' and column_name like '%o%'; +column_name privileges +Host select,insert,update,references +Password select,insert,update,references +Drop_priv select,insert,update,references +Reload_priv select,insert,update,references +Shutdown_priv select,insert,update,references +Process_priv select,insert,update,references +Show_db_priv select,insert,update,references +Lock_tables_priv select,insert,update,references +Show_view_priv select,insert,update,references +max_questions select,insert,update,references +max_connections select,insert,update,references use test; create function sub1(i int) returns int return i+1; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 0fe7636e500..288aabdc797 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -293,6 +293,13 @@ show tables; use information_schema; show tables like "T%"; +# +# Bug#7210: information_schema: can't access when table-name = reserved word +# +select table_name from tables where table_name='user'; +select column_name, privileges from columns +where table_name='user' and column_name like '%o%'; + # # Bug#7212: information_schema: "Can't find file" errors if storage engine gone # Bug#7211: information_schema: crash if bad view diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 5720aac8dbd..3895102bf77 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1583,6 +1583,15 @@ bool dispatch_command(enum enum_server_command command, THD *thd, packet, (uint) (pend-packet), thd->charset()); table_list.alias= table_list.real_name= conv_name.str; packet= pend+1; + + if (!my_strcasecmp(system_charset_info, table_list.db, + information_schema_name.str)) + { + ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, table_list.alias); + if (schema_table) + table_list.schema_table= schema_table; + } + /* command not cachable => no gap for data base name */ if (!(thd->query=fields=thd->memdup(packet,thd->query_length+1))) break; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 55a0f6ff692..98966374f2a 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -6885,6 +6885,7 @@ keyword: | CLIENT_SYM {} | CLOSE_SYM {} | COLLATION_SYM {} + | COLUMNS {} | COMMENT_SYM {} | COMMITTED_SYM {} | COMMIT_SYM {} @@ -7006,6 +7007,7 @@ keyword: | POLYGON {} | PREPARE_SYM {} | PREV_SYM {} + | PRIVILEGES {} | PROCESS {} | PROCESSLIST_SYM {} | QUARTER_SYM {} @@ -7057,6 +7059,7 @@ keyword: | SUBDATE_SYM {} | SUBJECT_SYM {} | SUPER_SYM {} + | TABLES {} | TABLESPACE {} | TEMPORARY {} | TEMPTABLE_SYM {}