From: Dmitry Lenev Date: December 14 2010 3:32pm Subject: bzr commit into mysql-trunk-bugfixing branch (Dmitry.Lenev:3401) Bug#27480 List-Archive: http://lists.mysql.com/commits/126793 X-Bug: 27480 Message-Id: <20101214153217.9A68C1E5243@mockturtle> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1930495220==" --===============1930495220== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///home/dlenev/src/bzr/mysql-trunk-bugfixing-bug27480/ based on revid:dmitry.lenev@stripped 3401 Dmitry Lenev 2010-12-14 Prerequisite patch for Bug#27480 (Extend CREATE TEMPORARY TABLES privilege to allow temp table operations). Review fixes in progress. Polish handling of OT_TEMPORARY_ONLY flag and streamline process of table opening. modified: sql/sql_base.cc === modified file 'sql/sql_base.cc' --- a/sql/sql_base.cc 2010-12-14 09:15:37 +0000 +++ b/sql/sql_base.cc 2010-12-14 15:31:57 +0000 @@ -4290,35 +4290,47 @@ open_and_process_table(THD *thd, LEX *le error= TRUE; goto end; } - - /* - If this TABLE_LIST object has an associated open TABLE object - (TABLE_LIST::table is not NULL), that TABLE object must be a pre-opened - temporary table. - */ - if (tables->table) - { - DBUG_ASSERT(is_temporary_table(tables->table)); - goto process_table; - } - - /* - If we're in CREATE TEMPORARY TABLE statement, we should not proceed - to the actual opening. - */ - if (tables->open_type == OT_TEMPORARY_ONLY) - DBUG_RETURN(FALSE); - DBUG_PRINT("tcache", ("opening table: '%s'.'%s' item: %p", tables->db, tables->table_name, tables)); //psergey: invalid read of size 1 here (*counter)++; - /* Not a placeholder: must be a base table or a view. Let us open it. */ - DBUG_ASSERT(!tables->table); + /* Not a placeholder: must be a base/temporary table or a view. Let us open it. */ - if (tables->prelocking_placeholder) + if (tables->table) { /* + If this TABLE_LIST object has an associated open TABLE object + (TABLE_LIST::table is not NULL), that TABLE object must be a pre-opened + temporary table. + */ + DBUG_ASSERT(is_temporary_table(tables->table)); + } + else if (tables->open_type == OT_TEMPORARY_ONLY) + { + /* + OT_TEMPORARY_ONLY means that we are in CREATE TEMPORARY TABLE statement. + Also such table list element can't correspond to prelocking placeholder + or to underlying table of merge table. + So existing temporary table should have been preopened by this moment + and we can simply continue without trying to open temporary or base + table. + */ + DBUG_ASSERT(tables->open_strategy); + DBUG_ASSERT(!tables->prelocking_placeholder); + DBUG_ASSERT(!tables->parent_l); + } + else if (tables->prelocking_placeholder) + { + /* + For the tables added by the pre-locking code, attempt to open + the table but fail silently if the table does not exist. + The real failure will occur when/if a statement attempts to use + that table. + */ + No_such_table_error_handler no_such_table_handler; + thd->push_internal_handler(&no_such_table_handler); + + /* We're opening a table from the prelocking list. Since this table list element might have been added after pre-opening @@ -4343,42 +4355,26 @@ open_and_process_table(THD *thd, LEX *le */ error= open_temporary_table(thd, tables); - if (error) - goto end; - - if (tables->table) - goto process_table; + if (!error && !tables->table) + error= open_table(thd, tables, new_frm_mem, ot_ctx); - /* - For the tables added by the pre-locking code, attempt to open - the table but fail silently if the table does not exist. - The real failure will occur when/if a statement attempts to use - that table. - */ - No_such_table_error_handler no_such_table_handler; - thd->push_internal_handler(&no_such_table_handler); - error= open_table(thd, tables, new_frm_mem, ot_ctx); thd->pop_internal_handler(); safe_to_ignore_table= no_such_table_handler.safely_trapped_errors(); } else { - /* - Even if we are opening table not from the prelocking list we - still might need to look for a temporary table if this table - list element corresponds to underlying table of a merge table. - */ if (tables->parent_l) { + /* + Even if we are opening table not from the prelocking list we + still might need to look for a temporary table if this table + list element corresponds to underlying table of a merge table. + */ error= open_temporary_table(thd, tables); - - if (error) - goto end; - - if (tables->table) - goto process_table; } - error= open_table(thd, tables, new_frm_mem, ot_ctx); + + if (!error && !tables->table) + error= open_table(thd, tables, new_frm_mem, ot_ctx); } free_root(new_frm_mem, MYF(MY_KEEP_PREALLOC)); @@ -4427,7 +4423,6 @@ open_and_process_table(THD *thd, LEX *le goto process_view_routines; } -process_table: /* Special types of open can succeed but still don't set TABLE_LIST::table to anything. @@ -6016,6 +6011,12 @@ bool open_temporary_table(THD *thd, TABL if (!table) { + if (tl->open_type == OT_TEMPORARY_ONLY && + tl->open_strategy == TABLE_LIST::OPEN_NORMAL) + { + my_error(ER_NO_SUCH_TABLE, MYF(0), tl->db, tl->table_name); + DBUG_RETURN(TRUE); + } DBUG_RETURN(FALSE); } --===============1930495220== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/dmitry.lenev@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: dmitry.lenev@stripped # target_branch: file:///home/dlenev/src/bzr/mysql-trunk-bugfixing-\ # bug27480/ # testament_sha1: 78ffec1f643cf037d04855c6179d5112262ba2f6 # timestamp: 2010-12-14 18:32:17 +0300 # source_branch: file:///home/dlenev/src/bzr/mysql-trunk-bugfixing/ # base_revision_id: dmitry.lenev@stripped\ # lulafcax913ts2rk # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWbUNYbEAAwRfgFQQeff//3/n 3iC////6YAdL7e43U1005O2rV2dKHIQ7MJJAkMgAEnkTTamnlNHpkTNRsU9TRk0aaPKDQkyYaCES eU0DT2qHpMgGhkaeoBoGmQcZMmhiMTRgEYCYQBgJpo0yNAMJIUyNAU9KbRMDSPSZNAGgAaABoaBx kyaGIxNGARgJhAGAmmjTI0AwkiJkBGjJlMJoTRpoNGpoaMj0npM1AGRABGIu2rV/kqEJcIeC1cWK ouCpFNUTyhfbzpVmfhTiESP63bj/D0G+ugUiUxwCrM285jQYabjaYLJ2bGuZffJ977QEk6AVxXrO 88lzhnTz98mZhGXyL9O6VmBRqmZmfKTJOaD3Bmi5muQmf6cRvuY7D7nvs8d/ORmjh9I9hVpTd8Cf ab6yLcLK+RyRsDPXsOQxwjXN+aur8dJZOGtmUalLkqbDVcqYVfyT2HkMmhdHQcKXBtLIm8LgMZCU 7oWQzfj0MQ3A5sdSj6XielS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