From: Dmitry Lenev Date: December 22 2010 4:15pm Subject: bzr push into mysql-trunk-bugfixing branch (Dmitry.Lenev:3402 to 3403) Bug#27480 List-Archive: http://lists.mysql.com/commits/127518 X-Bug: 27480 Message-Id: <20101222161521.1C73AE58F0@mockturtle> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3403 Dmitry Lenev 2010-12-22 Prerequisite patch for Bug#27480 (Extend CREATE TEMPORARY TABLES privilege to allow temp table operations). Review fixes in progress. modified: sql/log_event.cc sql/sp_head.cc sql/sql_admin.cc sql/sql_base.cc sql/sql_base.h sql/sql_handler.cc sql/sql_parse.cc sql/sql_prepare.cc sql/sql_show.cc sql/sql_table.cc 3402 Dmitry Lenev 2010-12-22 Prerequisite patch for Bug#27480 (Extend CREATE TEMPORARY TABLES privilege to allow temp table operations). Review fixes in progress. Final (almost) batch of fixes. modified: mysql-test/r/alter_table.result mysql-test/r/handler_myisam.result mysql-test/r/temp_table.result mysql-test/suite/innodb/r/innodb_mysql.result mysql-test/suite/innodb/t/innodb_mysql.test mysql-test/suite/rpl/r/rpl_create_if_not_exists.result mysql-test/suite/rpl/t/rpl_create_if_not_exists.test mysql-test/t/alter_table.test mysql-test/t/handler_myisam.test mysql-test/t/temp_table.test sql/log_event.cc sql/sql_admin.cc sql/sql_base.cc sql/sql_base.h sql/sql_class.h sql/sql_handler.cc sql/sql_parse.cc sql/sql_partition_admin.cc sql/sql_show.cc sql/sql_table.cc sql/sql_truncate.cc === modified file 'sql/log_event.cc' --- a/sql/log_event.cc 2010-12-22 15:23:28 +0000 +++ b/sql/log_event.cc 2010-12-22 16:13:34 +0000 @@ -5302,7 +5302,7 @@ int Load_log_event::do_apply_event(NET* update it inside mysql_load(). */ List tmp_list; - if (open_temporary_table_list(thd, &tables) || + if (open_temporary_tables(thd, &tables) || mysql_load(thd, &ex, &tables, field_list, tmp_list, tmp_list, handle_dup, ignore, net != 0)) thd->is_slave_error= 1; === modified file 'sql/sp_head.cc' --- a/sql/sp_head.cc 2010-12-14 09:15:37 +0000 +++ b/sql/sp_head.cc 2010-12-22 16:13:34 +0000 @@ -3041,7 +3041,7 @@ int sp_instr::exec_open_and_lock_tables( Check whenever we have access to tables for this statement and open and lock them before executing instructions core function. */ - if (open_temporary_table_list(thd, tables) || + if (open_temporary_tables(thd, tables) || check_table_access(thd, SELECT_ACL, tables, FALSE, UINT_MAX, FALSE) || open_and_lock_tables(thd, tables, TRUE, 0)) result= -1; === modified file 'sql/sql_admin.cc' --- a/sql/sql_admin.cc 2010-12-22 15:23:28 +0000 +++ b/sql/sql_admin.cc 2010-12-22 16:13:34 +0000 @@ -345,7 +345,7 @@ static bool mysql_admin_table(THD* thd, if (view_operator_func == NULL) table->required_type=FRMTYPE_TABLE; - open_error= open_temporary_table_list(thd, table); + open_error= open_temporary_tables(thd, table); if (! open_error) open_error= open_and_lock_tables(thd, table, TRUE, 0); @@ -730,7 +730,7 @@ send_result_message: table->next_local= table->next_global= 0; tmp_disable_binlog(thd); // binlogging is done by caller if wanted /* Don't forget to pre-open temporary tables. */ - result_code= (open_temporary_table_list(thd, table) || + result_code= (open_temporary_tables(thd, table) || mysql_recreate_table(thd, table)); reenable_binlog(thd); /* @@ -752,7 +752,7 @@ send_result_message: { DEBUG_SYNC(thd, "ha_admin_open_ltable"); table->mdl_request.set_type(MDL_SHARED_WRITE); - if (!open_temporary_table_list(thd, table) && + if (!open_temporary_tables(thd, table) && (table->table= open_n_lock_single_table(thd, table, lock_type, 0))) { result_code= table->table->file->ha_analyze(thd, check_opt); === modified file 'sql/sql_base.cc' --- a/sql/sql_base.cc 2010-12-22 15:23:28 +0000 +++ b/sql/sql_base.cc 2010-12-22 16:13:34 +0000 @@ -4847,7 +4847,7 @@ restart: goto err; /* Re-open temporary tables after close_tables_for_reopen(). */ - if (open_temporary_table_list(thd, *start)) + if (open_temporary_tables(thd, *start)) goto err; error= FALSE; @@ -4897,7 +4897,7 @@ restart: goto err; /* Re-open temporary tables after close_tables_for_reopen(). */ - if (open_temporary_table_list(thd, *start)) + if (open_temporary_tables(thd, *start)) goto err; error= FALSE; @@ -6004,7 +6004,7 @@ bool open_temporary_table(THD *thd, TABL This function should not be called for cases when derived or I_S tables can be met since table list elements for such tables can have invalid db or table name. - Instead open_temporary_table_list() should be used. + Instead open_temporary_tables() should be used. */ DBUG_ASSERT(!tl->derived && !tl->schema_table); @@ -6070,9 +6070,9 @@ bool open_temporary_table(THD *thd, TABL @retval TRUE On error. my_error() has been called. */ -bool open_temporary_table_list(THD *thd, TABLE_LIST *tl_list) +bool open_temporary_tables(THD *thd, TABLE_LIST *tl_list) { - DBUG_ENTER("open_temporary_table_list"); + DBUG_ENTER("open_temporary_tables"); for (TABLE_LIST *tl= tl_list; tl; tl= tl->next_global) { === modified file 'sql/sql_base.h' --- a/sql/sql_base.h 2010-12-22 15:23:28 +0000 +++ b/sql/sql_base.h 2010-12-22 16:13:34 +0000 @@ -267,7 +267,7 @@ void close_temporary_table(THD *thd, TAB void close_temporary(TABLE *table, bool free_share, bool delete_table); bool rename_temporary_table(THD* thd, TABLE *table, const char *new_db, const char *table_name); -bool open_temporary_table_list(THD *thd, TABLE_LIST *tl_list); +bool open_temporary_tables(THD *thd, TABLE_LIST *tl_list); bool open_temporary_table(THD *thd, TABLE_LIST *tl); bool is_equal(const LEX_STRING *a, const LEX_STRING *b); === modified file 'sql/sql_handler.cc' --- a/sql/sql_handler.cc 2010-12-22 15:23:28 +0000 +++ b/sql/sql_handler.cc 2010-12-22 16:13:34 +0000 @@ -291,7 +291,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST TODO/FIXME: In the upcoming patch we somehow should handle situation with privilege check for temporary table. */ - error= open_temporary_table_list(thd, hash_tables); + error= open_temporary_tables(thd, hash_tables); if (!error) error= open_tables(thd, &hash_tables, &counter, 0); === modified file 'sql/sql_parse.cc' --- a/sql/sql_parse.cc 2010-12-22 15:23:28 +0000 +++ b/sql/sql_parse.cc 2010-12-22 16:13:34 +0000 @@ -1253,7 +1253,7 @@ bool dispatch_command(enum enum_server_c thd->set_query(fields, query_length); general_log_print(thd, command, "%s %s", table_list.table_name, fields); - if (open_temporary_table_list(thd, &table_list)) + if (open_temporary_tables(thd, &table_list)) break; if (check_table_access(thd, SELECT_ACL, &table_list, @@ -2094,7 +2094,7 @@ mysql_execute_command(THD *thd) */ if (sql_command_flags[lex->sql_command] & CF_PREOPEN_TMP_TABLES) { - if (open_temporary_table_list(thd, all_tables)) + if (open_temporary_tables(thd, all_tables)) goto error; } @@ -2405,8 +2405,7 @@ case SQLCOM_PREPARE: */ if (lex->create_info.merge_list.elements) { - if (open_temporary_table_list( - thd, lex->create_info.merge_list.first)) + if (open_temporary_tables(thd, lex->create_info.merge_list.first)) { res= 1; goto end_with_restore_list; @@ -2757,7 +2756,7 @@ end_with_restore_list: Temporary tables should be opened for SHOW CREATE TABLE, but not for SHOW CREATE VIEW. */ - if (open_temporary_table_list(thd, all_tables)) + if (open_temporary_tables(thd, all_tables)) goto error; /* @@ -3245,7 +3244,7 @@ end_with_restore_list: in a usual way, they would have been closed. */ - if (open_temporary_table_list(thd, all_tables)) + if (open_temporary_tables(thd, all_tables)) goto error; if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, all_tables, === modified file 'sql/sql_prepare.cc' --- a/sql/sql_prepare.cc 2010-12-14 09:15:37 +0000 +++ b/sql/sql_prepare.cc 2010-12-22 16:13:34 +0000 @@ -1718,7 +1718,7 @@ static bool mysql_test_create_table(Prep if (lex->create_info.merge_list.elements) { - if (open_temporary_table_list(thd, lex->create_info.merge_list.first)) + if (open_temporary_tables(thd, lex->create_info.merge_list.first)) { DBUG_RETURN(TRUE); } @@ -1982,7 +1982,7 @@ static bool check_prepared_statement(Pre */ if (sql_command_flags[sql_command] & CF_PREOPEN_TMP_TABLES) { - if (open_temporary_table_list(thd, tables)) + if (open_temporary_tables(thd, tables)) goto error; } === modified file 'sql/sql_show.cc' --- a/sql/sql_show.cc 2010-12-22 15:23:28 +0000 +++ b/sql/sql_show.cc 2010-12-22 16:13:34 +0000 @@ -3020,7 +3020,7 @@ fill_schema_show_cols_or_idxs(THD *thd, */ lex->sql_command= SQLCOM_SHOW_FIELDS; - res= open_temporary_table_list(thd, show_table_list); + res= open_temporary_tables(thd, show_table_list); if (!res) { === modified file 'sql/sql_table.cc' --- a/sql/sql_table.cc 2010-12-22 15:23:28 +0000 +++ b/sql/sql_table.cc 2010-12-22 16:13:34 +0000 @@ -7347,7 +7347,7 @@ bool mysql_checksum_table(THD *thd, TABL /* Allow to open real tables only. */ table->required_type= FRMTYPE_TABLE; - if (open_temporary_table_list(thd, table) || + if (open_temporary_tables(thd, table) || open_and_lock_tables(thd, table, FALSE, 0)) { t= NULL; No bundle (reason: useless for push emails).