From: Dmitry Lenev Date: November 30 2010 8:33am Subject: bzr push into mysql-trunk-bugfixing branch (Dmitry.Lenev:3391 to 3392) Bug#27480 List-Archive: http://lists.mysql.com/commits/125455 X-Bug: 27480 Message-Id: <20101130083316.27C2F1E520D@mockturtle> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3392 Dmitry Lenev 2010-11-30 Prerequisite patch for Bug#27480 (Extend CREATE TEMPORARY TABLES privilege to allow temp table operations). Review fixes in progress. modified: sql/sp_head.cc sql/sql_view.cc 3391 Alexander Nozdrin 2010-11-29 Prerequisite patch for Bug#27480 (Extend CREATE TEMPORARY TABLES privilege to allow temp table operations): - move opening of temporary tables out of open_table(); - make open_table() to work with base tables and views only. It will be renamed to open_base_table_or_view() in a follow-up patch. - introduce open_temporary_table() to open temporary tables (similar to open_table()); - introduce open_and_process_temporary_table() to fully prepare temporary tables for use (similar to open_and_process_table()); - introduce a new "command flag" (CF_PREOPEN_TMP_TABLES) to mark statements that work with temporary tables, thus temporary tables should be opened for those statements; - open temporary tables in a unified way in the beginning of the statements marked with CF_PREOPEN_TMP_TABLES flag; - introduce a new "command flag" (CF_HA_CLOSE) to mark statements for which open handlers (by HANDLER OPEN) should be closed; - close open handlers in a unified way in the beginning of the statements marked with CF_HA_CLOSE flag. modified: mysql-test/r/handler_myisam.result mysql-test/r/merge.result mysql-test/r/temp_table.result mysql-test/t/handler_myisam.test mysql-test/t/merge.test mysql-test/t/temp_table.test sql/sp_head.cc sql/sql_admin.cc sql/sql_base.cc sql/sql_base.h sql/sql_class.h sql/sql_db.cc sql/sql_handler.cc sql/sql_insert.cc sql/sql_parse.cc sql/sql_prepare.cc sql/sql_rename.cc sql/sql_show.cc sql/sql_table.cc sql/sql_truncate.cc sql/sql_view.cc === modified file 'sql/sp_head.cc' --- a/sql/sp_head.cc 2010-11-29 14:13:07 +0000 +++ b/sql/sp_head.cc 2010-11-30 08:30:48 +0000 @@ -2952,9 +2952,6 @@ sp_lex_keeper::reset_lex_and_exec_core(T reinit_stmt_before_use(thd, m_lex); if (open_tables) - res= open_and_process_temporary_table_list(thd, m_lex->query_tables); - - if (!res && open_tables) res= instr->exec_open_and_lock_tables(thd, m_lex->query_tables); if (!res) @@ -3044,8 +3041,9 @@ 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 (check_table_access(thd, SELECT_ACL, tables, FALSE, UINT_MAX, FALSE) - || open_and_lock_tables(thd, tables, TRUE, 0)) + if (open_and_process_temporary_table_list(thd, tables) || + check_table_access(thd, SELECT_ACL, tables, FALSE, UINT_MAX, FALSE) || + open_and_lock_tables(thd, tables, TRUE, 0)) result= -1; else result= 0; === modified file 'sql/sql_view.cc' --- a/sql/sql_view.cc 2010-11-29 14:13:07 +0000 +++ b/sql/sql_view.cc 2010-11-30 08:30:48 +0000 @@ -441,6 +441,12 @@ bool mysql_create_view(THD *thd, TABLE_L goto err; } + /* + Open matching temporary tables for table list elements added by + prelocking algorithm. We need this in order to catch cases when + view uses functions that use temporary tables (note that this + check is not robust). + */ if (open_and_process_temporary_table_list(thd, lex->query_tables)) { res= TRUE; No bundle (reason: useless for push emails).