# Tests for WL#5000 FLUSH TABLES|TABLE table_list WITH READ LOCK
#
# I. Check the incompatible changes in the grammar.
#
flush tables with read lock, hosts;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' hosts' at line 1
flush privileges, tables;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tables' at line 1
flush privileges, tables with read lock;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tables with read lock' at line 1
flush privileges, tables;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tables' at line 1
flush tables with read lock, tables;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' tables' at line 1
show tables;
Tables_in_test
#
# II. Check the allowed syntax.
#
drop table if exists t1, t2, t3;
create table t1 (a int);
create table t2 (a int);
create table t3 (a int);
lock table t1 read, t2 read;
flush tables with read lock;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
unlock tables;
flush tables with read lock;
flush tables t1, t2 with read lock;
flush tables t1, t2 with read lock;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
flush tables with read lock;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
select * from t1;
a
select * from t2;
a
select * from t3;
ERROR HY000: Table 't3' was not locked with LOCK TABLES
insert into t1 (a) values (1);
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
insert into t2 (a) values (1);
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
insert into t3 (a) values (1);
ERROR HY000: Table 't3' was not locked with LOCK TABLES
select event_time from (select event_time from mysql.general_log as t_1 where command_type like 'Connect' order by event_time desc limit 2) as t_2 order by event_time desc limit 1 into @ts_last;
select event_time from (select event_time from mysql.general_log as t_1 where command_type like 'Connect' order by event_time desc limit 2) as t_2 order by event_time asc limit 1 into @ts_prev;
select @result as 'Must be 1';
Must be 1
1
set @@global.general_log = @save_general_log;
set @@global.log_output = @save_log_output;
set @@global.slave_net_timeout = @save_slave_net_timeout;