summaryrefslogtreecommitdiff
path: root/mysql-test/t/flush.test
diff options
context:
space:
mode:
authorKonstantin Osipov <kostja@sun.com>2010-02-27 20:05:14 +0300
committerKonstantin Osipov <kostja@sun.com>2010-02-27 20:05:14 +0300
commit093106f552ae890a0c6b4b183899a5d0affa1629 (patch)
tree471fa62f6c3a91f1be012911d4f2ba03f73e9d5f /mysql-test/t/flush.test
parent88f4990c3333a720b09e43c095bb4257332177c4 (diff)
downloadmariadb-git-093106f552ae890a0c6b4b183899a5d0affa1629.tar.gz
WL#5000 FLUSH TABLES|TABLE table_list WITH READ LOCK.
Extend and implement the grammar that allows to FLUSH WITH READ LOCK a list of tables, rather than all of them. Incompatible grammar change: Previously one could perform FLUSH TABLES, HOSTS, PRIVILEGES in a single statement. After this change, FLUSH TABLES must always be alone on the list. Judging by the test suite, however, the old extended syntax was never or very rarely used. The new statement requires RELOAD ACL global privilege and LOCK_TABLES_ACL | SELECT_ACL on individual tables. In other words, it's an atomic combination of LOCK TALBES <list> READ and FLUSH TABLES <list>, and requires respective privileges. For additional information about the semantics, please see WL#5000 and the comment for flush_tables_with_read_lock() function in sql_parse.cc mysql-test/r/flush.result: Update test results (WL#5000). mysql-test/t/flush.test: Add test coverage for WL#5000. sql/sql_yacc.yy: Allow FLUSH TABLES <table_list> WITH READ LOCK. Disallow FLUSH TABLES <table_list>, flush_options.
Diffstat (limited to 'mysql-test/t/flush.test')
-rw-r--r--mysql-test/t/flush.test100
1 files changed, 100 insertions, 0 deletions
diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test
index d41ac3100b0..582d2562fc6 100644
--- a/mysql-test/t/flush.test
+++ b/mysql-test/t/flush.test
@@ -224,3 +224,103 @@ commit;
--echo # which was already released by commit.
unlock tables;
drop tables t1, t2;
+
+
+
+--echo #
+--echo # Tests for WL#5000 FLUSH TABLES|TABLE table_list WITH READ LOCK
+--echo #
+--echo # I. Check the incompatible changes in the grammar.
+--echo #
+--error ER_PARSE_ERROR
+flush tables with read lock, hosts;
+--error ER_PARSE_ERROR
+flush privileges, tables;
+--error ER_PARSE_ERROR
+flush privileges, tables with read lock;
+--error ER_PARSE_ERROR
+flush privileges, tables;
+--error ER_PARSE_ERROR
+flush tables with read lock, tables;
+show tables;
+--echo #
+--echo # II. Check the allowed syntax.
+--echo #
+--disable_warnings
+drop table if exists t1, t2, t3;
+--enable_warnings
+create table t1 (a int);
+create table t2 (a int);
+create table t3 (a int);
+lock table t1 read, t2 read;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+flush tables with read lock;
+unlock tables;
+flush tables with read lock;
+flush tables t1, t2 with read lock;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+flush tables t1, t2 with read lock;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+flush tables with read lock;
+select * from t1;
+select * from t2;
+--error ER_TABLE_NOT_LOCKED
+select * from t3;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+insert into t1 (a) values (1);
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+insert into t2 (a) values (1);
+--error ER_TABLE_NOT_LOCKED
+insert into t3 (a) values (1);
+--error ER_NO_SUCH_TABLE
+lock table no_such_table read;
+--echo #
+--echo # We implicitly left the locked tables
+--echo # mode but still have the read lock.
+--echo #
+--error ER_CANT_UPDATE_WITH_READLOCK
+insert into t2 (a) values (1);
+unlock tables;
+insert into t1 (a) values (1);
+insert into t2 (a) values (1);
+flush table t1, t2 with read lock;
+select * from t1;
+select * from t2;
+--error ER_TABLE_NOT_LOCKED
+select * from t3;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+insert into t1 (a) values (2);
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+insert into t2 (a) values (2);
+--error ER_TABLE_NOT_LOCKED
+insert into t3 (a) values (2);
+--error ER_NO_SUCH_TABLE
+lock table no_such_table read;
+insert into t3 (a) values (2);
+
+
+--echo #
+--echo # III. Concurrent tests.
+--echo #
+connect (con1,localhost,root,,);
+--echo # --> connection default
+--echo #
+--echo # Check that flush tables <list> with read lock
+--echo # does not affect non-locked tables.
+connection default;
+--echo #
+flush tables t1 with read lock;
+--echo # --> connection con1;
+connection con1;
+select * from t1;
+select * from t2;
+insert into t2 (a) values (3);
+--echo # --> connection default;
+connection default;
+unlock tables;
+--echo # --> connection con1
+connection con1;
+disconnect con1;
+--source include/wait_until_disconnected.inc
+connection default;
+drop table t1, t2, t3;