From 7e08016a91dc8d24110a73b5286f947718a9379e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Apr 2007 15:11:34 +0400 Subject: Fix for BUG#27337: Privileges are not properly restored. The problem was that THD::db_access variable was not restored after database switch in stored-routine-execution code. The fix is to restore THD::db_access in this case. Unfortunately, this fix requires additional changes, because in prepare_schema_table(), called on the parsing stage, we checked privileges. That was wrong according to our design, but this flaw haven't struck so far, because it was masked. All privilege checkings must be done on the execution stage in order to be compatible with prepared statements and stored routines. So, this patch also contains patch for prepare_schema_table(), which moves the checkings to the execution phase. mysql-test/r/grant.result: Updated result file. mysql-test/t/grant.test: Added test case for BUG#27337. sql/mysql_priv.h: Added function declaration. sql/sql_db.cc: Fix for BUG#27337 -- set THD::db_access even if we're called from stored-routine-execution code. sql/sql_parse.cc: Split prepare_schema_table() into two functions: - prepare_schema_table(), which is called from the parser (parsing stage); - check_show_access(), which is called on the execution stage. sql/sql_show.cc: Ignore schema_select_lex member if its table is NULL. --- sql/sql_show.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_show.cc') diff --git a/sql/sql_show.cc b/sql/sql_show.cc index cf0cb9ba8d2..fa78db50532 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2148,7 +2148,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) */ thd->reset_n_backup_open_tables_state(&open_tables_state_backup); - if (lsel) + if (lsel && lsel->table_list.first) { TABLE_LIST *show_table_list= (TABLE_LIST*) lsel->table_list.first; bool res; -- cgit v1.2.1