@@ -377,17 +377,17 @@ create view v1 as select 1;
377
377
create view v2 as select * from t1;
378
378
create view v3 as select * from v2;
379
379
380
- --error ER_WRONG_OBJECT
381
380
flush table v1, v2, v3 with read lock;
382
- --error ER_WRONG_OBJECT
381
+ unlock tables;
383
382
flush table v1 with read lock;
384
- --error ER_WRONG_OBJECT
383
+ unlock tables;
385
384
flush table v2 with read lock;
386
- --error ER_WRONG_OBJECT
385
+ unlock tables;
387
386
flush table v3 with read lock;
387
+ unlock tables;
388
388
create temporary table v1 (a int);
389
- --error ER_WRONG_OBJECT
390
389
flush table v1 with read lock;
390
+ unlock tables;
391
391
drop view v1;
392
392
create table v1 (a int);
393
393
flush table v1 with read lock;
@@ -669,6 +669,60 @@ UNLOCK TABLES;
669
669
DROP VIEW v1;
670
670
DROP TABLE t1;
671
671
672
+ --echo #
673
+ --echo # MDEV-15888 Implement FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK for views.
674
+ --echo #
675
+
676
+ create table t1 (a int);
677
+ insert into t1 values (1), (2), (3);
678
+ create view v1 as select * from t1;
679
+ create view v2 as select * from v1;
680
+
681
+ flush table v1 with read lock;
682
+ connect(con1, localhost, root);
683
+ --send insert into v1 values (4)
684
+ --sleep 1
685
+ connection default;
686
+ --echo # Wait until INSERT starts to wait for FTWRL to go away.
687
+ let $wait_condition=
688
+ select count(*) = 1 from information_schema.processlist
689
+ where state = "Waiting for table metadata lock"
690
+ and info = "insert into v1 values (4)";
691
+ --source include/wait_condition.inc
692
+ select * from t1;
693
+ unlock tables;
694
+
695
+ connection con1;
696
+ reap;
697
+
698
+ connection default;
699
+ select * from t1;
700
+
701
+ flush table v2 with read lock;
702
+ connection con1;
703
+ --send insert into t1 values (5)
704
+ --sleep 1
705
+ connection default;
706
+ --echo # Wait until INSERT starts to wait for FTWRL to go away.
707
+ let $wait_condition=
708
+ select count(*) = 1 from information_schema.processlist
709
+ where state = "Waiting for table metadata lock"
710
+ and info = "insert into t1 values (5)";
711
+ --source include/wait_condition.inc
712
+ select * from t1;
713
+ unlock tables;
714
+
715
+ connection con1;
716
+ reap;
717
+
718
+ connection default;
719
+ select * from t1;
720
+
721
+ drop view v1, v2;
722
+ drop table t1;
723
+ disconnect con1;
724
+
725
+
672
726
--echo #
673
727
--echo # Test FLUSH THREADS
674
728
--echo #
0 commit comments