From add2913a40046857723d48f205f25e34eff0d269 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov Date: Thu, 12 Aug 2010 19:29:41 +0400 Subject: [PATCH] A follow up patch for WL#5000: add a test case and a comment for the case when a connection issuing FLUSH TABLES WITH READ LOCK has an open handler. --- mysql-test/r/flush.result | 25 +++++++++++++++++++++++++ mysql-test/t/flush.test | 23 +++++++++++++++++++++++ sql/sql_parse.cc | 11 +++++++++++ 3 files changed, 59 insertions(+) diff --git a/mysql-test/r/flush.result b/mysql-test/r/flush.result index be6562f8ab6..f2b562db478 100644 --- a/mysql-test/r/flush.result +++ b/mysql-test/r/flush.result @@ -279,3 +279,28 @@ drop temporary table v1; unlock tables; drop view v2, v3; drop table t1, v1; +# +# FLUSH TABLES WITH READ LOCK and HANDLER +# +drop table if exists t1; +create table t1 (a int, key a (a)); +insert into t1 (a) values (1), (2), (3); +handler t1 open; +handler t1 read a next; +a +1 +handler t1 read a next; +a +2 +flush tables t1 with read lock; +handler t1 read a next; +ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction +unlock tables; +# +# Sic: lost handler position. +# +handler t1 read a next; +a +1 +handler t1 close; +drop table t1; diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test index cd3df229f10..9996c98de9a 100644 --- a/mysql-test/t/flush.test +++ b/mysql-test/t/flush.test @@ -407,3 +407,26 @@ drop temporary table v1; unlock tables; drop view v2, v3; drop table t1, v1; + + +--echo # +--echo # FLUSH TABLES WITH READ LOCK and HANDLER +--echo # +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int, key a (a)); +insert into t1 (a) values (1), (2), (3); +handler t1 open; +handler t1 read a next; +handler t1 read a next; +flush tables t1 with read lock; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +handler t1 read a next; +unlock tables; +--echo # +--echo # Sic: lost handler position. +--echo # +handler t1 read a next; +handler t1 close; +drop table t1; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6305d2b4140..b526db2b5b2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1750,6 +1750,17 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, If a temporary table with such name exists, it's ignored: if there is a base table, it's used, otherwise ER_NO_SUCH_TABLE is returned. + + Implicit commit + --------------- + This statement causes an implicit commit before and + after it. + + HANDLER SQL + ----------- + If this connection has HANDLERs open against + some of the tables being FLUSHed, these handlers + are implicitly flushed (lose their position). */ static bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)