diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2016-03-25 20:51:22 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2016-03-31 10:11:16 +0400 |
commit | 282497dd6d1049b4fb963641504c2733752845a7 (patch) | |
tree | 7288d17c29fbbe9ac47ec51f6988fb954f59a361 /mysql-test/suite/handler | |
parent | 5052e2479e873461bebfcedbc674bbaf57d3c968 (diff) | |
download | mariadb-git-282497dd6d1049b4fb963641504c2733752845a7.tar.gz |
MDEV-6720 - enable connection log in mysqltest by default
Diffstat (limited to 'mysql-test/suite/handler')
-rw-r--r-- | mysql-test/suite/handler/aria.result | 185 | ||||
-rw-r--r-- | mysql-test/suite/handler/disconnect_4480.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/handler/handler.inc | 95 | ||||
-rw-r--r-- | mysql-test/suite/handler/heap.result | 196 | ||||
-rw-r--r-- | mysql-test/suite/handler/innodb.result | 185 | ||||
-rw-r--r-- | mysql-test/suite/handler/interface.result | 44 | ||||
-rw-r--r-- | mysql-test/suite/handler/interface.test | 10 | ||||
-rw-r--r-- | mysql-test/suite/handler/myisam.result | 185 |
8 files changed, 444 insertions, 458 deletions
diff --git a/mysql-test/suite/handler/aria.result b/mysql-test/suite/handler/aria.result index e0b98bd36a0..43720eaa4bb 100644 --- a/mysql-test/suite/handler/aria.result +++ b/mysql-test/suite/handler/aria.result @@ -538,17 +538,19 @@ handler t1 open; handler t1 read first; c1 1 +connect con2,localhost,root,,; +connection con2; send the below to another connection, do not wait for the result optimize table t1; -proceed with the normal connection +connection default; handler t1 read next; c1 1 handler t1 close; -read the result from the other connection +connection con2; Table Op Msg_type Msg_text test.t1 optimize status OK -proceed with the normal connection +connection default; drop table t1; CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY using btree (no1,no2)); INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2); @@ -569,26 +571,28 @@ insert into t1 values (14397); flush tables with read lock; drop table t1; ERROR HY000: Can't execute the query because you have a conflicting read lock -send the below to another connection, do not wait for the result +connection con2; drop table t1; -proceed with the normal connection +connection default; select * from t1; c1 14397 unlock tables; +connection con2; read the result from the other connection -proceed with the normal connection +connection default; select * from t1; ERROR 42S02: Table 'test.t1' doesn't exist drop table if exists t1; Warnings: Note 1051 Unknown table 'test.t1' create table t1 (a int not null) ENGINE=csv; ---> client 2 +connection con2; handler t1 open; ERROR HY000: Storage engine CSV of the table `test`.`t1` doesn't have this option ---> client 1 +connection default; drop table t1; +disconnect con2; create table t1 (a int); handler t1 open as t1_alias; handler t1_alias read a next; @@ -968,15 +972,17 @@ handler t1 close; # Explore the effect of HANDLER locks on concurrent DDL # handler t1 open; -# Establishing auxiliary connections con1, con2, con3 -# --> connection con1; +connect con1, localhost, root,,; +connect con2, localhost, root,,; +connect con3, localhost, root,,; +connection con1; # Sending: drop table t1 ; # We can't use connection 'default' as wait_condition will # autoclose handlers. -# --> connection con2 +connection con2; # Waitng for 'drop table t1' to get blocked... -# --> connection default +connection default; handler t1 read a prev; a b 5 NULL @@ -984,9 +990,9 @@ handler t1 read a prev; a b 4 NULL handler t1 close; -# --> connection con1 +connection con1; # Reaping 'drop table t1'... -# --> connection default +connection default; # # Explore the effect of HANDLER locks in parallel with SELECT # @@ -1008,12 +1014,12 @@ handler t1 read a prev; a 4 handler t1 close; -# --> connection con1; +connection con1; # Sending: drop table t1 ; -# --> connection con2 +connection con2; # Waiting for 'drop table t1' to get blocked... -# --> connection default +connection default; # We can still use the table, it's part of the transaction select * from t1; a @@ -1038,10 +1044,10 @@ handler t1 read a prev; a 3 handler t1 close; -# --> connection con1 +connection con1; # Now drop can proceed # Reaping 'drop table t1'... -# --> connection default +connection default; # # Demonstrate that HANDLER locks and transaction locks # reside in the same context. @@ -1058,12 +1064,12 @@ a 3 4 5 -# --> connection con2 +connection con2; # Sending: rename table t0 to t3, t1 to t0, t3 to t1; -# --> connection con1 +connection con1; # Waiting for 'rename table ...' to get blocked... -# --> connection default +connection default; # We back-off on hitting deadlock condition. handler t0 open; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction @@ -1077,9 +1083,9 @@ a handler t1 open; commit; handler t1 close; -# --> connection con2 +connection con2; # Reaping 'rename table ...'... -# --> connection default +connection default; handler t1 open; handler t1 read a prev; a @@ -1095,22 +1101,22 @@ drop table t0; # create table t2 (a int, key a (a)); handler t1 open; -# --> connection con1 +connection con1; lock tables t2 read; -# --> connection con2 +connection con2; # Sending 'drop table t2'... drop table t2; -# --> connection con1 +connection con1; # Waiting for 'drop table t2' to get blocked... -# --> connection default +connection default; # Sending 'select * from t2' select * from t2; -# --> connection con1 +connection con1; # Waiting for 'select * from t2' to get blocked... unlock tables; -# --> connection con2 +connection con2; # Reaping 'drop table t2'... -# --> connection default +connection default; # Reaping 'select * from t2' ERROR 42S02: Table 'test.t2' doesn't exist handler t1 close; @@ -1134,29 +1140,29 @@ a 2 select * from t2; a -# --> connection con1 +connection con1; # Sending: drop table t1; -# --> connection con2 +connection con2; # Sending: drop table t2; -# --> connection default +connection default; # Let DROP TABLE statements sync in. We must use # a separate connection for that, because otherwise SELECT # will auto-close the HANDLERs, becaues there are pending # exclusive locks against them. -# --> connection con3 +connection con3; # Waiting for 'drop table t1' to get blocked... # Waiting for 'drop table t2' to get blocked... # Demonstrate that t2 lock was released and t2 was dropped # after ROLLBACK TO SAVEPOINT -# --> connection default +connection default; rollback to savepoint sv; -# --> connection con2 +connection con2; # Reaping 'drop table t2'... # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler # lock. -# --> connection default +connection default; handler t1 read a next; a 3 @@ -1166,9 +1172,9 @@ a # Demonstrate that the drop will go through as soon as we close the # HANDLER handler t1 close; -# connection con1 +connection con1; # Reaping 'drop table t1'... -# --> connection default +connection default; commit; drop table t3; # @@ -1193,29 +1199,29 @@ a 2 select * from t2; a -# --> connection con1 +connection con1; # Sending: drop table t1; -# --> connection con2 +connection con2; # Sending: drop table t2; -# --> connection default +connection default; # Let DROP TABLE statements sync in. We must use # a separate connection for that, because otherwise SELECT # will auto-close the HANDLERs, becaues there are pending # exclusive locks against them. -# --> connection con3 +connection con3; # Waiting for 'drop table t1' to get blocked... # Waiting for 'drop table t2' to get blocked... # Demonstrate that t2 lock was released and t2 was dropped # after ROLLBACK TO SAVEPOINT -# --> connection default +connection default; rollback to savepoint sv; -# --> connection con2 +connection con2; # Reaping 'drop table t2'... # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler # lock. -# --> connection default +connection default; handler t1 read a next; a 3 @@ -1225,9 +1231,9 @@ a # Demonstrate that the drop will go through as soon as we close the # HANDLER handler t1 close; -# connection con1 +connection con1; # Reaping 'drop table t1'... -# --> connection default +connection default; commit; # # Show that rollback to the savepoint taken in the beginning @@ -1254,25 +1260,25 @@ handler t3 read a first; a 1 rollback to savepoint sv; -# --> connection con1 +connection con1; drop table t1, t2; # Sending: drop table t3; # Let DROP TABLE statement sync in. -# --> connection con2 +connection con2; # Waiting for 'drop table t3' to get blocked... # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler # lock. -# --> connection default +connection default; handler t3 read a next; a 2 # Demonstrate that the drop will go through as soon as we close the # HANDLER handler t3 close; -# connection con1 +connection con1; # Reaping 'drop table t3'... -# --> connection default +connection default; commit; # # If we have to wait on an exclusive locks while having @@ -1281,27 +1287,27 @@ commit; create table t1 (a int, key a(a)); create table t2 like t1; handler t1 open; -# --> connection con1 +connection con1; lock table t1 write, t2 write; -# --> connection default +connection default; drop table t2; -# --> connection con2 +connection con2; # Waiting for 'drop table t2' to get blocked... -# --> connection con1 +connection con1; drop table t1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction unlock tables; -# --> connection default +connection default; # Demonstrate that there is no deadlock with FLUSH TABLE, # even though it is waiting for the other table to go away create table t2 like t1; # Sending: flush table t2; -# --> connection con2 +connection con2; drop table t1; -# --> connection con1 +connection con1; unlock tables; -# --> connection default +connection default; # Reaping 'flush table t2'... drop table t2; # @@ -1310,20 +1316,20 @@ drop table t2; # create table t1 (a int, key using btree (a)); insert into t1 values (1), (2); -# --> connection default +connection default; begin; select * from t1; a 1 2 handler t1 open; -# --> connection con1 +connection con1; # Sending: lock tables t1 write; -# --> connection con2 +connection con2; # Check that 'lock tables t1 write' waits until transaction which # has read from the table commits. -# --> connection default +connection default; # The below 'handler t1 read ...' should not be blocked as # 'lock tables t1 write' has not succeeded yet. handler t1 read a next; @@ -1331,24 +1337,28 @@ a 1 # Unblock 'lock tables t1 write'. commit; -# --> connection con1 +connection con1; # Reap 'lock tables t1 write'. -# --> connection default +connection default; # Sending: handler t1 read a next; -# --> connection con1 +connection con1; # Waiting for 'handler t1 read a next' to get blocked... # The below 'drop table t1' should be able to proceed without # waiting as it will force HANDLER to be closed. drop table t1; unlock tables; -# --> connection default +connection default; # Reaping 'handler t1 read a next'... ERROR 42S02: Table 'test.t1' doesn't exist handler t1 close; -# --> connection con1 -# --> connection con2 -# --> connection con3 +connection con1; +disconnect con1; +connection con2; +disconnect con2; +connection con3; +disconnect con3; +connection default; # # A temporary table test. # Check that we don't loose positions of HANDLER opened @@ -1475,8 +1485,8 @@ drop table t2, t3; # Check that when we clone a ticket for HANDLER we downrade # the lock. # -# Establish an auxiliary connection con1. -# -> connection default +connect con1,localhost,root,,; +connection default; create table t1 (a int, b int, key using btree (a)); insert into t1 (a, b) values (1, 1), (2, 1), (3, 2), (4, 2), (5, 5); begin; @@ -1490,19 +1500,20 @@ handler t1 read a last; a b 7 7 commit; -# -> connection con1 +connection con1; # Demonstrate that the HANDLER doesn't hold MDL_SHARED_WRITE. lock table t1 write; unlock tables; -# -> connection default +connection default; handler t1 read a prev; a b 6 6 handler t1 close; # Cleanup. drop table t1; -# -> connection con1 -# -> connection default +connection con1; +disconnect con1; +connection default; # # A test for Bug#50555 "handler commands crash server in # my_hash_first()". @@ -1631,26 +1642,28 @@ drop tables t1, t2; # bool MDL_context::try_acquire_lock(MDL_request*) # DROP TABLE IF EXISTS t1; -# Connection default +connect con51355, localhost, root; +connection default; CREATE TABLE t1(id INT, KEY id(id)); HANDLER t1 OPEN; -# Connection con51355 +connection con51355; # Sending: DROP TABLE t1; -# Connection default +connection default; # This I_S query will cause the handler table to be closed and # the metadata lock to be released. This will allow DROP TABLE # to proceed. Waiting for the table to be removed. -# Connection con51355 +connection con51355; # Reaping: DROP TABLE t1 -# Connection default +connection default; HANDLER t1 READ id NEXT; ERROR 42S02: Table 'test.t1' doesn't exist HANDLER t1 READ id NEXT; ERROR 42S02: Table 'test.t1' doesn't exist HANDLER t1 CLOSE; -# Connection con51355 -# Connection default +connection con51355; +disconnect con51355; +connection default; # # Bug#54401 assert in Diagnostics_area::set_eof_status , HANDLER # diff --git a/mysql-test/suite/handler/disconnect_4480.result b/mysql-test/suite/handler/disconnect_4480.result index d0a67c72c05..3e21a9ac1a7 100644 --- a/mysql-test/suite/handler/disconnect_4480.result +++ b/mysql-test/suite/handler/disconnect_4480.result @@ -1,5 +1,7 @@ +connect con1,localhost,root,,; create temporary table t1 as select 1; handler t1 open; handler t1 read next; 1 1 +disconnect con1; diff --git a/mysql-test/suite/handler/handler.inc b/mysql-test/suite/handler/handler.inc index c71dc53e5ac..b1e881f1bd8 100644 --- a/mysql-test/suite/handler/handler.inc +++ b/mysql-test/suite/handler/handler.inc @@ -365,26 +365,18 @@ drop table t5; # create table t1 (c1 int); insert into t1 values (1); -# client 1 handler t1 open; handler t1 read first; -# client 2 connect (con2,localhost,root,,); connection con2; --echo send the below to another connection, do not wait for the result send optimize table t1; --sleep 1 -# client 1 ---echo proceed with the normal connection connection default; handler t1 read next; handler t1 close; -# client 2 ---echo read the result from the other connection connection con2; reap; -# client 1 ---echo proceed with the normal connection connection default; drop table t1; @@ -411,34 +403,27 @@ flush tables with read lock; --error 1223 drop table t1; # -# client 2 # We need a second connection to try the drop. # The drop waits for the global read lock to go away. # Without the addendum fix it locked LOCK_open before entering the wait loop. connection con2; ---echo send the below to another connection, do not wait for the result send drop table t1; --sleep 1 # -# client 1 # Now we need something that wants LOCK_open. A simple table access which # opens the table does the trick. ---echo proceed with the normal connection connection default; # This would hang on LOCK_open without the 5.0 addendum fix. select * from t1; # Release the read lock. This should make the DROP go through. unlock tables; # -# client 2 # Read the result of the drop command. connection con2; --echo read the result from the other connection reap; # -# client 1 # Now back to normal operation. The table should not exist any more. ---echo proceed with the normal connection connection default; --error 1146 select * from t1; @@ -449,11 +434,9 @@ drop table if exists t1; # Bug#25856 - HANDLER table OPEN in one connection lock DROP TABLE in another one # create table t1 (a int not null) ENGINE=csv; ---echo --> client 2 connection con2; --error 1031 handler t1 open; ---echo --> client 1 connection default; drop table t1; disconnect con2; @@ -777,33 +760,27 @@ handler t1 close; --echo # Explore the effect of HANDLER locks on concurrent DDL --echo # handler t1 open; ---echo # Establishing auxiliary connections con1, con2, con3 connect(con1, localhost, root,,); connect(con2, localhost, root,,); connect(con3, localhost, root,,); ---echo # --> connection con1; connection con1; --echo # Sending: --send drop table t1 --echo # We can't use connection 'default' as wait_condition will --echo # autoclose handlers. ---echo # --> connection con2 connection con2; --echo # Waitng for 'drop table t1' to get blocked... let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table metadata lock' and info='drop table t1'; --source include/wait_condition.inc ---echo # --> connection default connection default; handler t1 read a prev; handler t1 read a prev; handler t1 close; ---echo # --> connection con1 connection con1; --echo # Reaping 'drop table t1'... --reap ---echo # --> connection default connection default; --echo # --echo # Explore the effect of HANDLER locks in parallel with SELECT @@ -816,18 +793,15 @@ handler t1 open; handler t1 read a prev; handler t1 read a prev; handler t1 close; ---echo # --> connection con1; connection con1; --echo # Sending: --send drop table t1 ---echo # --> connection con2 connection con2; --echo # Waiting for 'drop table t1' to get blocked... let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table metadata lock' and info='drop table t1'; --source include/wait_condition.inc ---echo # --> connection default connection default; --echo # We can still use the table, it's part of the transaction select * from t1; @@ -841,12 +815,10 @@ handler t1 read a prev; handler t1 read a prev; handler t1 read a prev; handler t1 close; ---echo # --> connection con1 connection con1; --echo # Now drop can proceed --echo # Reaping 'drop table t1'... --reap ---echo # --> connection default connection default; --echo # --echo # Demonstrate that HANDLER locks and transaction locks @@ -858,18 +830,15 @@ create table t0 (a int, key a using btree (a)); insert into t0 (a) values (1), (2), (3), (4), (5); begin; select * from t1; ---echo # --> connection con2 connection con2; --echo # Sending: send rename table t0 to t3, t1 to t0, t3 to t1; ---echo # --> connection con1 connection con1; --echo # Waiting for 'rename table ...' to get blocked... let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table metadata lock' and info='rename table t0 to t3, t1 to t0, t3 to t1'; --source include/wait_condition.inc ---echo # --> connection default connection default; --echo # We back-off on hitting deadlock condition. --error ER_LOCK_DEADLOCK @@ -878,11 +847,9 @@ select * from t0; handler t1 open; commit; handler t1 close; ---echo # --> connection con2 connection con2; --echo # Reaping 'rename table ...'... --reap ---echo # --> connection default connection default; handler t1 open; handler t1 read a prev; @@ -897,36 +864,29 @@ drop table t0; --echo # create table t2 (a int, key a (a)); handler t1 open; ---echo # --> connection con1 connection con1; lock tables t2 read; ---echo # --> connection con2 connection con2; --echo # Sending 'drop table t2'... --send drop table t2 ---echo # --> connection con1 connection con1; --echo # Waiting for 'drop table t2' to get blocked... let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table metadata lock' and info='drop table t2'; --source include/wait_condition.inc ---echo # --> connection default connection default; --echo # Sending 'select * from t2' send select * from t2; ---echo # --> connection con1 connection con1; --echo # Waiting for 'select * from t2' to get blocked... let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table metadata lock' and info='select * from t2'; unlock tables; ---echo # --> connection con2 connection con2; --echo # Reaping 'drop table t2'... --reap ---echo # --> connection default connection default; --echo # Reaping 'select * from t2' --error ER_NO_SUCH_TABLE @@ -947,21 +907,17 @@ handler t1 open; handler t1 read a first; handler t1 read a next; select * from t2; ---echo # --> connection con1 connection con1; --echo # Sending: --send drop table t1 ---echo # --> connection con2 connection con2; --echo # Sending: --send drop table t2 ---echo # --> connection default connection default; --echo # Let DROP TABLE statements sync in. We must use --echo # a separate connection for that, because otherwise SELECT --echo # will auto-close the HANDLERs, becaues there are pending --echo # exclusive locks against them. ---echo # --> connection con3 connection con3; --echo # Waiting for 'drop table t1' to get blocked... let $wait_condition=select count(*)=1 from information_schema.processlist @@ -975,27 +931,22 @@ let $wait_condition=select count(*)=1 from information_schema.processlist --source include/wait_condition.inc --echo # Demonstrate that t2 lock was released and t2 was dropped --echo # after ROLLBACK TO SAVEPOINT ---echo # --> connection default connection default; rollback to savepoint sv; ---echo # --> connection con2 connection con2; --echo # Reaping 'drop table t2'... --reap --echo # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler --echo # lock. ---echo # --> connection default connection default; handler t1 read a next; handler t1 read a next; --echo # Demonstrate that the drop will go through as soon as we close the --echo # HANDLER handler t1 close; ---echo # connection con1 connection con1; --echo # Reaping 'drop table t1'... --reap ---echo # --> connection default connection default; commit; drop table t3; @@ -1016,21 +967,17 @@ handler t1 open; handler t1 read a first; handler t1 read a next; select * from t2; ---echo # --> connection con1 connection con1; --echo # Sending: --send drop table t1 ---echo # --> connection con2 connection con2; --echo # Sending: --send drop table t2 ---echo # --> connection default connection default; --echo # Let DROP TABLE statements sync in. We must use --echo # a separate connection for that, because otherwise SELECT --echo # will auto-close the HANDLERs, becaues there are pending --echo # exclusive locks against them. ---echo # --> connection con3 connection con3; --echo # Waiting for 'drop table t1' to get blocked... let $wait_condition=select count(*)=1 from information_schema.processlist @@ -1044,27 +991,22 @@ let $wait_condition=select count(*)=1 from information_schema.processlist --source include/wait_condition.inc --echo # Demonstrate that t2 lock was released and t2 was dropped --echo # after ROLLBACK TO SAVEPOINT ---echo # --> connection default connection default; rollback to savepoint sv; ---echo # --> connection con2 connection con2; --echo # Reaping 'drop table t2'... --reap --echo # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler --echo # lock. ---echo # --> connection default connection default; handler t1 read a next; handler t1 read a next; --echo # Demonstrate that the drop will go through as soon as we close the --echo # HANDLER handler t1 close; ---echo # connection con1 connection con1; --echo # Reaping 'drop table t1'... --reap ---echo # --> connection default connection default; commit; --echo # @@ -1087,13 +1029,11 @@ handler t1 close; handler t3 open; handler t3 read a first; rollback to savepoint sv; ---echo # --> connection con1 connection con1; drop table t1, t2; --echo # Sending: --send drop table t3 --echo # Let DROP TABLE statement sync in. ---echo # --> connection con2 connection con2; --echo # Waiting for 'drop table t3' to get blocked... let $wait_condition=select count(*)=1 from information_schema.processlist @@ -1102,17 +1042,14 @@ let $wait_condition=select count(*)=1 from information_schema.processlist --source include/wait_condition.inc --echo # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler --echo # lock. ---echo # --> connection default connection default; handler t3 read a next; --echo # Demonstrate that the drop will go through as soon as we close the --echo # HANDLER handler t3 close; ---echo # connection con1 connection con1; --echo # Reaping 'drop table t3'... --reap ---echo # --> connection default connection default; commit; @@ -1123,25 +1060,20 @@ commit; create table t1 (a int, key a(a)); create table t2 like t1; handler t1 open; ---echo # --> connection con1 connection con1; lock table t1 write, t2 write; ---echo # --> connection default connection default; send drop table t2; ---echo # --> connection con2 connection con2; --echo # Waiting for 'drop table t2' to get blocked... let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table metadata lock' and info='drop table t2'; --source include/wait_condition.inc ---echo # --> connection con1 connection con1; --error ER_LOCK_DEADLOCK drop table t1; unlock tables; ---echo # --> connection default connection default; reap; @@ -1150,13 +1082,10 @@ reap; create table t2 like t1; --echo # Sending: --send flush table t2 ---echo # --> connection con2 connection con2; drop table t1; ---echo # --> connection con1 connection con1; unlock tables; ---echo # --> connection default connection default; --echo # Reaping 'flush table t2'... --reap @@ -1169,18 +1098,15 @@ drop table t2; create table t1 (a int, key using btree (a)); insert into t1 values (1), (2); ---echo # --> connection default connection default; begin; select * from t1; handler t1 open; ---echo # --> connection con1 connection con1; --echo # Sending: --send lock tables t1 write ---echo # --> connection con2 connection con2; --echo # Check that 'lock tables t1 write' waits until transaction which --echo # has read from the table commits. @@ -1190,7 +1116,6 @@ let $wait_condition= info = "lock tables t1 write"; --source include/wait_condition.inc ---echo # --> connection default connection default; --echo # The below 'handler t1 read ...' should not be blocked as --echo # 'lock tables t1 write' has not succeeded yet. @@ -1199,17 +1124,14 @@ handler t1 read a next; --echo # Unblock 'lock tables t1 write'. commit; ---echo # --> connection con1 connection con1; --echo # Reap 'lock tables t1 write'. --reap ---echo # --> connection default connection default; --echo # Sending: --send handler t1 read a next ---echo # --> connection con1 connection con1; --echo # Waiting for 'handler t1 read a next' to get blocked... let $wait_condition= @@ -1223,22 +1145,18 @@ let $wait_condition= drop table t1; unlock tables; ---echo # --> connection default connection default; --echo # Reaping 'handler t1 read a next'... --error ER_NO_SUCH_TABLE --reap handler t1 close; ---echo # --> connection con1 connection con1; disconnect con1; --source include/wait_until_disconnected.inc ---echo # --> connection con2 connection con2; disconnect con2; --source include/wait_until_disconnected.inc ---echo # --> connection con3 connection con3; disconnect con3; --source include/wait_until_disconnected.inc @@ -1335,9 +1253,7 @@ drop table t2, t3; --echo # Check that when we clone a ticket for HANDLER we downrade --echo # the lock. --echo # ---echo # Establish an auxiliary connection con1. connect (con1,localhost,root,,); ---echo # -> connection default connection default; create table t1 (a int, b int, key using btree (a)); insert into t1 (a, b) values (1, 1), (2, 1), (3, 2), (4, 2), (5, 5); @@ -1348,22 +1264,18 @@ handler t1 read a last; insert into t1 (a, b) values (7, 7); handler t1 read a last; commit; ---echo # -> connection con1 connection con1; --echo # Demonstrate that the HANDLER doesn't hold MDL_SHARED_WRITE. lock table t1 write; unlock tables; ---echo # -> connection default connection default; handler t1 read a prev; handler t1 close; --echo # Cleanup. drop table t1; ---echo # -> connection con1 connection con1; disconnect con1; --source include/wait_until_disconnected.inc ---echo # -> connection default connection default; --echo # @@ -1503,17 +1415,14 @@ DROP TABLE IF EXISTS t1; connect(con51355, localhost, root); ---echo # Connection default connection default; CREATE TABLE t1(id INT, KEY id(id)); HANDLER t1 OPEN; ---echo # Connection con51355 connection con51355; --echo # Sending: --send DROP TABLE t1 ---echo # Connection default connection default; --echo # This I_S query will cause the handler table to be closed and --echo # the metadata lock to be released. This will allow DROP TABLE @@ -1522,12 +1431,10 @@ let $wait_condition= SELECT COUNT(*) = 0 FROM information_schema.tables WHERE table_name = "t1"; --source include/wait_condition.inc ---echo # Connection con51355 connection con51355; --echo # Reaping: DROP TABLE t1 --reap ---echo # Connection default connection default; --error ER_NO_SUCH_TABLE HANDLER t1 READ id NEXT; @@ -1536,11 +1443,9 @@ HANDLER t1 READ id NEXT; HANDLER t1 READ id NEXT; HANDLER t1 CLOSE; ---echo # Connection con51355 connection con51355; disconnect con51355; --source include/wait_until_disconnected.inc ---echo # Connection default connection default; diff --git a/mysql-test/suite/handler/heap.result b/mysql-test/suite/handler/heap.result index 527986edb5c..e558911e2e1 100644 --- a/mysql-test/suite/handler/heap.result +++ b/mysql-test/suite/handler/heap.result @@ -538,17 +538,19 @@ handler t1 open; handler t1 read first; c1 1 +connect con2,localhost,root,,; +connection con2; send the below to another connection, do not wait for the result optimize table t1; -proceed with the normal connection +connection default; handler t1 read next; c1 1 handler t1 close; -read the result from the other connection +connection con2; Table Op Msg_type Msg_text test.t1 optimize note The storage engine for the table doesn't support optimize -proceed with the normal connection +connection default; drop table t1; CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY using btree (no1,no2)); INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2); @@ -569,26 +571,28 @@ insert into t1 values (14397); flush tables with read lock; drop table t1; ERROR HY000: Can't execute the query because you have a conflicting read lock -send the below to another connection, do not wait for the result +connection con2; drop table t1; -proceed with the normal connection +connection default; select * from t1; c1 14397 unlock tables; +connection con2; read the result from the other connection -proceed with the normal connection +connection default; select * from t1; ERROR 42S02: Table 'test.t1' doesn't exist drop table if exists t1; Warnings: Note 1051 Unknown table 'test.t1' create table t1 (a int not null) ENGINE=csv; ---> client 2 +connection con2; handler t1 open; ERROR HY000: Storage engine CSV of the table `test`.`t1` doesn't have this option ---> client 1 +connection default; drop table t1; +disconnect con2; create table t1 (a int); handler t1 open as t1_alias; handler t1_alias read a next; @@ -968,15 +972,17 @@ handler t1 close; # Explore the effect of HANDLER locks on concurrent DDL # handler t1 open; -# Establishing auxiliary connections con1, con2, con3 -# --> connection con1; +connect con1, localhost, root,,; +connect con2, localhost, root,,; +connect con3, localhost, root,,; +connection con1; # Sending: drop table t1 ; # We can't use connection 'default' as wait_condition will # autoclose handlers. -# --> connection con2 +connection con2; # Waitng for 'drop table t1' to get blocked... -# --> connection default +connection default; handler t1 read a prev; a b 5 NULL @@ -984,9 +990,9 @@ handler t1 read a prev; a b 4 NULL handler t1 close; -# --> connection con1 +connection con1; # Reaping 'drop table t1'... -# --> connection default +connection default; # # Explore the effect of HANDLER locks in parallel with SELECT # @@ -1008,12 +1014,12 @@ handler t1 read a prev; a 4 handler t1 close; -# --> connection con1; +connection con1; # Sending: drop table t1 ; -# --> connection con2 +connection con2; # Waiting for 'drop table t1' to get blocked... -# --> connection default +connection default; # We can still use the table, it's part of the transaction select * from t1; a @@ -1038,10 +1044,10 @@ handler t1 read a prev; a 3 handler t1 close; -# --> connection con1 +connection con1; # Now drop can proceed # Reaping 'drop table t1'... -# --> connection default +connection default; # # Demonstrate that HANDLER locks and transaction locks # reside in the same context. @@ -1058,12 +1064,12 @@ a 3 4 5 -# --> connection con2 +connection con2; # Sending: rename table t0 to t3, t1 to t0, t3 to t1; -# --> connection con1 +connection con1; # Waiting for 'rename table ...' to get blocked... -# --> connection default +connection default; # We back-off on hitting deadlock condition. handler t0 open; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction @@ -1077,9 +1083,9 @@ a handler t1 open; commit; handler t1 close; -# --> connection con2 +connection con2; # Reaping 'rename table ...'... -# --> connection default +connection default; handler t1 open; handler t1 read a prev; a @@ -1095,22 +1101,22 @@ drop table t0; # create table t2 (a int, key a (a)); handler t1 open; -# --> connection con1 +connection con1; lock tables t2 read; -# --> connection con2 +connection con2; # Sending 'drop table t2'... drop table t2; -# --> connection con1 +connection con1; # Waiting for 'drop table t2' to get blocked... -# --> connection default +connection default; # Sending 'select * from t2' select * from t2; -# --> connection con1 +connection con1; # Waiting for 'select * from t2' to get blocked... unlock tables; -# --> connection con2 +connection con2; # Reaping 'drop table t2'... -# --> connection default +connection default; # Reaping 'select * from t2' ERROR 42S02: Table 'test.t2' doesn't exist handler t1 close; @@ -1134,29 +1140,29 @@ a 2 select * from t2; a -# --> connection con1 +connection con1; # Sending: drop table t1; -# --> connection con2 +connection con2; # Sending: drop table t2; -# --> connection default +connection default; # Let DROP TABLE statements sync in. We must use # a separate connection for that, because otherwise SELECT # will auto-close the HANDLERs, becaues there are pending # exclusive locks against them. -# --> connection con3 +connection con3; # Waiting for 'drop table t1' to get blocked... # Waiting for 'drop table t2' to get blocked... # Demonstrate that t2 lock was released and t2 was dropped # after ROLLBACK TO SAVEPOINT -# --> connection default +connection default; rollback to savepoint sv; -# --> connection con2 +connection con2; # Reaping 'drop table t2'... # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler # lock. -# --> connection default +connection default; handler t1 read a next; a 3 @@ -1166,9 +1172,9 @@ a # Demonstrate that the drop will go through as soon as we close the # HANDLER handler t1 close; -# connection con1 +connection con1; # Reaping 'drop table t1'... -# --> connection default +connection default; commit; drop table t3; # @@ -1193,29 +1199,29 @@ a 2 select * from t2; a -# --> connection con1 +connection con1; # Sending: drop table t1; -# --> connection con2 +connection con2; # Sending: drop table t2; -# --> connection default +connection default; # Let DROP TABLE statements sync in. We must use # a separate connection for that, because otherwise SELECT # will auto-close the HANDLERs, becaues there are pending # exclusive locks against them. -# --> connection con3 +connection con3; # Waiting for 'drop table t1' to get blocked... # Waiting for 'drop table t2' to get blocked... # Demonstrate that t2 lock was released and t2 was dropped # after ROLLBACK TO SAVEPOINT -# --> connection default +connection default; rollback to savepoint sv; -# --> connection con2 +connection con2; # Reaping 'drop table t2'... # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler # lock. -# --> connection default +connection default; handler t1 read a next; a 3 @@ -1225,9 +1231,9 @@ a # Demonstrate that the drop will go through as soon as we close the # HANDLER handler t1 close; -# connection con1 +connection con1; # Reaping 'drop table t1'... -# --> connection default +connection default; commit; # # Show that rollback to the savepoint taken in the beginning @@ -1254,25 +1260,25 @@ handler t3 read a first; a 1 rollback to savepoint sv; -# --> connection con1 +connection con1; drop table t1, t2; # Sending: drop table t3; # Let DROP TABLE statement sync in. -# --> connection con2 +connection con2; # Waiting for 'drop table t3' to get blocked... # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler # lock. -# --> connection default +connection default; handler t3 read a next; a 2 # Demonstrate that the drop will go through as soon as we close the # HANDLER handler t3 close; -# connection con1 +connection con1; # Reaping 'drop table t3'... -# --> connection default +connection default; commit; # # If we have to wait on an exclusive locks while having @@ -1281,27 +1287,27 @@ commit; create table t1 (a int, key a(a)); create table t2 like t1; handler t1 open; -# --> connection con1 +connection con1; lock table t1 write, t2 write; -# --> connection default +connection default; drop table t2; -# --> connection con2 +connection con2; # Waiting for 'drop table t2' to get blocked... -# --> connection con1 +connection con1; drop table t1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction unlock tables; -# --> connection default +connection default; # Demonstrate that there is no deadlock with FLUSH TABLE, # even though it is waiting for the other table to go away create table t2 like t1; # Sending: flush table t2; -# --> connection con2 +connection con2; drop table t1; -# --> connection con1 +connection con1; unlock tables; -# --> connection default +connection default; # Reaping 'flush table t2'... drop table t2; # @@ -1310,20 +1316,20 @@ drop table t2; # create table t1 (a int, key using btree (a)); insert into t1 values (1), (2); -# --> connection default +connection default; begin; select * from t1; a 1 2 handler t1 open; -# --> connection con1 +connection con1; # Sending: lock tables t1 write; -# --> connection con2 +connection con2; # Check that 'lock tables t1 write' waits until transaction which # has read from the table commits. -# --> connection default +connection default; # The below 'handler t1 read ...' should not be blocked as # 'lock tables t1 write' has not succeeded yet. handler t1 read a next; @@ -1331,24 +1337,28 @@ a 1 # Unblock 'lock tables t1 write'. commit; -# --> connection con1 +connection con1; # Reap 'lock tables t1 write'. -# --> connection default +connection default; # Sending: handler t1 read a next; -# --> connection con1 +connection con1; # Waiting for 'handler t1 read a next' to get blocked... # The below 'drop table t1' should be able to proceed without # waiting as it will force HANDLER to be closed. drop table t1; unlock tables; -# --> connection default +connection default; # Reaping 'handler t1 read a next'... ERROR 42S02: Table 'test.t1' doesn't exist handler t1 close; -# --> connection con1 -# --> connection con2 -# --> connection con3 +connection con1; +disconnect con1; +connection con2; +disconnect con2; +connection con3; +disconnect con3; +connection default; # # A temporary table test. # Check that we don't loose positions of HANDLER opened @@ -1475,8 +1485,8 @@ drop table t2, t3; # Check that when we clone a ticket for HANDLER we downrade # the lock. # -# Establish an auxiliary connection con1. -# -> connection default +connect con1,localhost,root,,; +connection default; create table t1 (a int, b int, key using btree (a)); insert into t1 (a, b) values (1, 1), (2, 1), (3, 2), (4, 2), (5, 5); begin; @@ -1490,19 +1500,20 @@ handler t1 read a last; a b 7 7 commit; -# -> connection con1 +connection con1; # Demonstrate that the HANDLER doesn't hold MDL_SHARED_WRITE. lock table t1 write; unlock tables; -# -> connection default +connection default; handler t1 read a prev; a b 6 6 handler t1 close; # Cleanup. drop table t1; -# -> connection con1 -# -> connection default +connection con1; +disconnect con1; +connection default; # # A test for Bug#50555 "handler commands crash server in # my_hash_first()". @@ -1631,26 +1642,28 @@ drop tables t1, t2; # bool MDL_context::try_acquire_lock(MDL_request*) # DROP TABLE IF EXISTS t1; -# Connection default +connect con51355, localhost, root; +connection default; CREATE TABLE t1(id INT, KEY id(id)); HANDLER t1 OPEN; -# Connection con51355 +connection con51355; # Sending: DROP TABLE t1; -# Connection default +connection default; # This I_S query will cause the handler table to be closed and # the metadata lock to be released. This will allow DROP TABLE # to proceed. Waiting for the table to be removed. -# Connection con51355 +connection con51355; # Reaping: DROP TABLE t1 -# Connection default +connection default; HANDLER t1 READ id NEXT; ERROR 42S02: Table 'test.t1' doesn't exist HANDLER t1 READ id NEXT; ERROR 42S02: Table 'test.t1' doesn't exist HANDLER t1 CLOSE; -# Connection con51355 -# Connection default +connection con51355; +disconnect con51355; +connection default; # # Bug#54401 assert in Diagnostics_area::set_eof_status , HANDLER # @@ -1697,6 +1710,8 @@ INSERT INTO t1 VALUES(1); HANDLER t1 READ a NEXT; HANDLER t1 CLOSE; DROP TABLE t1; +connect con1,localhost,root,,; +connection default; CREATE TABLE t1(a INT, b INT, KEY(a), KEY b using btree (b), KEY ab using btree(a, b)) engine=memory; INSERT INTO t1 VALUES (2, 20), (2,20), (1, 10), (4, 40), (3, 30), (5,50), (6,50); HANDLER t1 OPEN; @@ -1762,26 +1777,35 @@ ERROR HY000: Record has changed since last read in table 't1' HANDLER t1 READ b FIRST; a b 1 10 +connection con1; insert into t1 values (7,50); +connection default; HANDLER t1 READ b NEXT; ERROR HY000: Record has changed since last read in table 't1' HANDLER t1 READ FIRST; a b 2 20 +connection con1; insert into t1 values (8,50); +connection default; HANDLER t1 READ NEXT; a b 2 20 +connection con1; delete from t1 where a=3; +connection default; HANDLER t1 READ NEXT LIMIT 2; a b 1 10 4 40 +connection con1; delete from t1; +connection default; HANDLER t1 READ NEXT LIMIT 2; ERROR HY000: Record has changed since last read in table 't1' HANDLER t1 CLOSE; DROP TABLE t1; +disconnect con1; create table t1 (f1 integer not null, key (f1)) engine=Memory; insert into t1 values (1); HANDLER t1 OPEN; diff --git a/mysql-test/suite/handler/innodb.result b/mysql-test/suite/handler/innodb.result index 78660b0ef9c..fc1089ee445 100644 --- a/mysql-test/suite/handler/innodb.result +++ b/mysql-test/suite/handler/innodb.result @@ -538,18 +538,20 @@ handler t1 open; handler t1 read first; c1 1 +connect con2,localhost,root,,; +connection con2; send the below to another connection, do not wait for the result optimize table t1; -proceed with the normal connection +connection default; handler t1 read next; c1 1 handler t1 close; -read the result from the other connection +connection con2; Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK -proceed with the normal connection +connection default; drop table t1; CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY using btree (no1,no2)); INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2); @@ -570,26 +572,28 @@ insert into t1 values (14397); flush tables with read lock; drop table t1; ERROR HY000: Can't execute the query because you have a conflicting read lock -send the below to another connection, do not wait for the result +connection con2; drop table t1; -proceed with the normal connection +connection default; select * from t1; c1 14397 unlock tables; +connection con2; read the result from the other connection -proceed with the normal connection +connection default; select * from t1; ERROR 42S02: Table 'test.t1' doesn't exist drop table if exists t1; Warnings: Note 1051 Unknown table 'test.t1' create table t1 (a int not null) ENGINE=csv; ---> client 2 +connection con2; handler t1 open; ERROR HY000: Storage engine CSV of the table `test`.`t1` doesn't have this option ---> client 1 +connection default; drop table t1; +disconnect con2; create table t1 (a int); handler t1 open as t1_alias; handler t1_alias read a next; @@ -972,15 +976,17 @@ handler t1 close; # Explore the effect of HANDLER locks on concurrent DDL # handler t1 open; -# Establishing auxiliary connections con1, con2, con3 -# --> connection con1; +connect con1, localhost, root,,; +connect con2, localhost, root,,; +connect con3, localhost, root,,; +connection con1; # Sending: drop table t1 ; # We can't use connection 'default' as wait_condition will # autoclose handlers. -# --> connection con2 +connection con2; # Waitng for 'drop table t1' to get blocked... -# --> connection default +connection default; handler t1 read a prev; a b 5 NULL @@ -988,9 +994,9 @@ handler t1 read a prev; a b 4 NULL handler t1 close; -# --> connection con1 +connection con1; # Reaping 'drop table t1'... -# --> connection default +connection default; # # Explore the effect of HANDLER locks in parallel with SELECT # @@ -1012,12 +1018,12 @@ handler t1 read a prev; a 4 handler t1 close; -# --> connection con1; +connection con1; # Sending: drop table t1 ; -# --> connection con2 +connection con2; # Waiting for 'drop table t1' to get blocked... -# --> connection default +connection default; # We can still use the table, it's part of the transaction select * from t1; a @@ -1042,10 +1048,10 @@ handler t1 read a prev; a 3 handler t1 close; -# --> connection con1 +connection con1; # Now drop can proceed # Reaping 'drop table t1'... -# --> connection default +connection default; # # Demonstrate that HANDLER locks and transaction locks # reside in the same context. @@ -1062,12 +1068,12 @@ a 3 4 5 -# --> connection con2 +connection con2; # Sending: rename table t0 to t3, t1 to t0, t3 to t1; -# --> connection con1 +connection con1; # Waiting for 'rename table ...' to get blocked... -# --> connection default +connection default; # We back-off on hitting deadlock condition. handler t0 open; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction @@ -1081,9 +1087,9 @@ a handler t1 open; commit; handler t1 close; -# --> connection con2 +connection con2; # Reaping 'rename table ...'... -# --> connection default +connection default; handler t1 open; handler t1 read a prev; a @@ -1099,22 +1105,22 @@ drop table t0; # create table t2 (a int, key a (a)); handler t1 open; -# --> connection con1 +connection con1; lock tables t2 read; -# --> connection con2 +connection con2; # Sending 'drop table t2'... drop table t2; -# --> connection con1 +connection con1; # Waiting for 'drop table t2' to get blocked... -# --> connection default +connection default; # Sending 'select * from t2' select * from t2; -# --> connection con1 +connection con1; # Waiting for 'select * from t2' to get blocked... unlock tables; -# --> connection con2 +connection con2; # Reaping 'drop table t2'... -# --> connection default +connection default; # Reaping 'select * from t2' ERROR 42S02: Table 'test.t2' doesn't exist handler t1 close; @@ -1138,29 +1144,29 @@ a 2 select * from t2; a -# --> connection con1 +connection con1; # Sending: drop table t1; -# --> connection con2 +connection con2; # Sending: drop table t2; -# --> connection default +connection default; # Let DROP TABLE statements sync in. We must use # a separate connection for that, because otherwise SELECT # will auto-close the HANDLERs, becaues there are pending # exclusive locks against them. -# --> connection con3 +connection con3; # Waiting for 'drop table t1' to get blocked... # Waiting for 'drop table t2' to get blocked... # Demonstrate that t2 lock was released and t2 was dropped # after ROLLBACK TO SAVEPOINT -# --> connection default +connection default; rollback to savepoint sv; -# --> connection con2 +connection con2; # Reaping 'drop table t2'... # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler # lock. -# --> connection default +connection default; handler t1 read a next; a 3 @@ -1170,9 +1176,9 @@ a # Demonstrate that the drop will go through as soon as we close the # HANDLER handler t1 close; -# connection con1 +connection con1; # Reaping 'drop table t1'... -# --> connection default +connection default; commit; drop table t3; # @@ -1197,29 +1203,29 @@ a 2 select * from t2; a -# --> connection con1 +connection con1; # Sending: drop table t1; -# --> connection con2 +connection con2; # Sending: drop table t2; -# --> connection default +connection default; # Let DROP TABLE statements sync in. We must use # a separate connection for that, because otherwise SELECT # will auto-close the HANDLERs, becaues there are pending # exclusive locks against them. -# --> connection con3 +connection con3; # Waiting for 'drop table t1' to get blocked... # Waiting for 'drop table t2' to get blocked... # Demonstrate that t2 lock was released and t2 was dropped # after ROLLBACK TO SAVEPOINT -# --> connection default +connection default; rollback to savepoint sv; -# --> connection con2 +connection con2; # Reaping 'drop table t2'... # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler # lock. -# --> connection default +connection default; handler t1 read a next; a 3 @@ -1229,9 +1235,9 @@ a # Demonstrate that the drop will go through as soon as we close the # HANDLER handler t1 close; -# connection con1 +connection con1; # Reaping 'drop table t1'... -# --> connection default +connection default; commit; # # Show that rollback to the savepoint taken in the beginning @@ -1258,25 +1264,25 @@ handler t3 read a first; a 1 rollback to savepoint sv; -# --> connection con1 +connection con1; drop table t1, t2; # Sending: drop table t3; # Let DROP TABLE statement sync in. -# --> connection con2 +connection con2; # Waiting for 'drop table t3' to get blocked... # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler # lock. -# --> connection default +connection default; handler t3 read a next; a 2 # Demonstrate that the drop will go through as soon as we close the # HANDLER handler t3 close; -# connection con1 +connection con1; # Reaping 'drop table t3'... -# --> connection default +connection default; commit; # # If we have to wait on an exclusive locks while having @@ -1285,27 +1291,27 @@ commit; create table t1 (a int, key a(a)); create table t2 like t1; handler t1 open; -# --> connection con1 +connection con1; lock table t1 write, t2 write; -# --> connection default +connection default; drop table t2; -# --> connection con2 +connection con2; # Waiting for 'drop table t2' to get blocked... -# --> connection con1 +connection con1; drop table t1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction unlock tables; -# --> connection default +connection default; # Demonstrate that there is no deadlock with FLUSH TABLE, # even though it is waiting for the other table to go away create table t2 like t1; # Sending: flush table t2; -# --> connection con2 +connection con2; drop table t1; -# --> connection con1 +connection con1; unlock tables; -# --> connection default +connection default; # Reaping 'flush table t2'... drop table t2; # @@ -1314,20 +1320,20 @@ drop table t2; # create table t1 (a int, key using btree (a)); insert into t1 values (1), (2); -# --> connection default +connection default; begin; select * from t1; a 1 2 handler t1 open; -# --> connection con1 +connection con1; # Sending: lock tables t1 write; -# --> connection con2 +connection con2; # Check that 'lock tables t1 write' waits until transaction which # has read from the table commits. -# --> connection default +connection default; # The below 'handler t1 read ...' should not be blocked as # 'lock tables t1 write' has not succeeded yet. handler t1 read a next; @@ -1335,24 +1341,28 @@ a 1 # Unblock 'lock tables t1 write'. commit; -# --> connection con1 +connection con1; # Reap 'lock tables t1 write'. -# --> connection default +connection default; # Sending: handler t1 read a next; -# --> connection con1 +connection con1; # Waiting for 'handler t1 read a next' to get blocked... # The below 'drop table t1' should be able to proceed without # waiting as it will force HANDLER to be closed. drop table t1; unlock tables; -# --> connection default +connection default; # Reaping 'handler t1 read a next'... ERROR 42S02: Table 'test.t1' doesn't exist handler t1 close; -# --> connection con1 -# --> connection con2 -# --> connection con3 +connection con1; +disconnect con1; +connection con2; +disconnect con2; +connection con3; +disconnect con3; +connection default; # # A temporary table test. # Check that we don't loose positions of HANDLER opened @@ -1479,8 +1489,8 @@ drop table t2, t3; # Check that when we clone a ticket for HANDLER we downrade # the lock. # -# Establish an auxiliary connection con1. -# -> connection default +connect con1,localhost,root,,; +connection default; create table t1 (a int, b int, key using btree (a)); insert into t1 (a, b) values (1, 1), (2, 1), (3, 2), (4, 2), (5, 5); begin; @@ -1494,19 +1504,20 @@ handler t1 read a last; a b 7 7 commit; -# -> connection con1 +connection con1; # Demonstrate that the HANDLER doesn't hold MDL_SHARED_WRITE. lock table t1 write; unlock tables; -# -> connection default +connection default; handler t1 read a prev; a b 6 6 handler t1 close; # Cleanup. drop table t1; -# -> connection con1 -# -> connection default +connection con1; +disconnect con1; +connection default; # # A test for Bug#50555 "handler commands crash server in # my_hash_first()". @@ -1635,26 +1646,28 @@ drop tables t1, t2; # bool MDL_context::try_acquire_lock(MDL_request*) # DROP TABLE IF EXISTS t1; -# Connection default +connect con51355, localhost, root; +connection default; CREATE TABLE t1(id INT, KEY id(id)); HANDLER t1 OPEN; -# Connection con51355 +connection con51355; # Sending: DROP TABLE t1; -# Connection default +connection default; # This I_S query will cause the handler table to be closed and # the metadata lock to be released. This will allow DROP TABLE # to proceed. Waiting for the table to be removed. -# Connection con51355 +connection con51355; # Reaping: DROP TABLE t1 -# Connection default +connection default; HANDLER t1 READ id NEXT; ERROR 42S02: Table 'test.t1' doesn't exist HANDLER t1 READ id NEXT; ERROR 42S02: Table 'test.t1' doesn't exist HANDLER t1 CLOSE; -# Connection con51355 -# Connection default +connection con51355; +disconnect con51355; +connection default; # # Bug#54401 assert in Diagnostics_area::set_eof_status , HANDLER # diff --git a/mysql-test/suite/handler/interface.result b/mysql-test/suite/handler/interface.result index 89dec29f412..4d5a385df0f 100644 --- a/mysql-test/suite/handler/interface.result +++ b/mysql-test/suite/handler/interface.result @@ -168,15 +168,16 @@ create table t1 (c1 int); create table t2 (c1 int); insert into t1 values (1); insert into t2 values (2); -connection: default handler t1 open; handler t1 read first; c1 1 -connection: flush +connect flush,localhost,root,,; +connection flush; flush tables; -connection: waiter -connection: default +connect waiter,localhost,root,,; +connection waiter; +connection default; handler t2 open; handler t2 read first; c1 @@ -186,17 +187,20 @@ c1 1 handler t1 close; handler t2 close; +connection flush; +connection default; drop table t1,t2; +disconnect flush; drop table if exists t1, t0; create table t1 (c1 int); -connection: default handler t1 open; handler t1 read first; c1 -connection: flush +connect flush,localhost,root,,; +connection flush; rename table t1 to t0; -connection: waiter -connection: default +connection waiter; +connection default; # # RENAME placed two pending locks and waits. # When HANDLER t0 OPEN does open_tables(), it calls @@ -211,12 +215,18 @@ connection: default # handler t0 open; handler t0 close; -connection: flush +connection flush; handler t1 read next; ERROR 42S02: Unknown table 't1' in HANDLER handler t1 close; ERROR 42S02: Unknown table 't1' in HANDLER +connection default; drop table t0; +connection flush; +disconnect flush; +connection waiter; +disconnect waiter; +connection default; create table t1 (a int); handler t1 open as t1_alias; drop table t1; @@ -260,25 +270,36 @@ unlock tables; drop table t1; handler t1 read a next; ERROR 42S02: Unknown table 't1' in HANDLER +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection default; drop table if exists t1; # First test case which is supposed trigger the execution # path on which problem was discovered. create table t1 (a int not null); insert into t1 values (1); handler t1 open; +connection con1; lock table t1 write; alter table t1 engine=csv; +connection con2; +connection default; handler t1 read a next; ERROR HY000: Storage engine CSV of the table `test`.`t1` doesn't have this option handler t1 close; +connection con1; unlock tables; drop table t1; # Now test case which was reported originally but which no longer # triggers execution path which has caused the problem. +connection default; create table t1 (a int not null); insert into t1 values (1); handler t1 open; +connection con1; alter table t1 engine=csv; +connection con2; +connection default; # Since S metadata lock was already acquired at HANDLER OPEN time # and TL_READ lock requested by HANDLER READ is compatible with # ALTER's TL_WRITE_ALLOW_READ the below statement should succeed @@ -287,7 +308,12 @@ handler t1 read next; a 1 handler t1 close; +connection con1; drop table t1; +disconnect con1; +connection con2; +disconnect con2; +connection default; USE information_schema; HANDLER COLUMNS OPEN; ERROR HY000: Incorrect usage of HANDLER OPEN and information_schema diff --git a/mysql-test/suite/handler/interface.test b/mysql-test/suite/handler/interface.test index 2ef617c3ce7..a82412799eb 100644 --- a/mysql-test/suite/handler/interface.test +++ b/mysql-test/suite/handler/interface.test @@ -175,22 +175,18 @@ create table t1 (c1 int); create table t2 (c1 int); insert into t1 values (1); insert into t2 values (2); ---echo connection: default handler t1 open; handler t1 read first; connect (flush,localhost,root,,); connection flush; ---echo connection: flush send flush tables; connect (waiter,localhost,root,,); connection waiter; ---echo connection: waiter let $wait_condition= select count(*) = 1 from information_schema.processlist where state = "Waiting for table flush"; --source include/wait_condition.inc connection default; ---echo connection: default handler t2 open; handler t2 read first; handler t1 read next; @@ -210,22 +206,18 @@ disconnect flush; drop table if exists t1, t0; --enable_warnings create table t1 (c1 int); ---echo connection: default handler t1 open; handler t1 read first; connect (flush,localhost,root,,); connection flush; ---echo connection: flush send rename table t1 to t0; connection waiter; ---echo connection: waiter let $wait_condition= select count(*) = 1 from information_schema.processlist where state = "Waiting for table metadata lock" and info = "rename table t1 to t0"; --source include/wait_condition.inc connection default; ---echo connection: default --echo # --echo # RENAME placed two pending locks and waits. --echo # When HANDLER t0 OPEN does open_tables(), it calls @@ -242,7 +234,6 @@ connection default; handler t0 open; --error 0, ER_UNKNOWN_TABLE handler t0 close; ---echo connection: flush connection flush; reap; --error ER_UNKNOWN_TABLE @@ -389,4 +380,3 @@ execute stmt; --error ER_UNKNOWN_TABLE handler v read next; drop view v; - diff --git a/mysql-test/suite/handler/myisam.result b/mysql-test/suite/handler/myisam.result index 9081722d866..84cd8bbd5d2 100644 --- a/mysql-test/suite/handler/myisam.result +++ b/mysql-test/suite/handler/myisam.result @@ -538,17 +538,19 @@ handler t1 open; handler t1 read first; c1 1 +connect con2,localhost,root,,; +connection con2; send the below to another connection, do not wait for the result optimize table t1; -proceed with the normal connection +connection default; handler t1 read next; c1 1 handler t1 close; -read the result from the other connection +connection con2; Table Op Msg_type Msg_text test.t1 optimize status OK -proceed with the normal connection +connection default; drop table t1; CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY using btree (no1,no2)); INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2); @@ -569,26 +571,28 @@ insert into t1 values (14397); flush tables with read lock; drop table t1; ERROR HY000: Can't execute the query because you have a conflicting read lock -send the below to another connection, do not wait for the result +connection con2; drop table t1; -proceed with the normal connection +connection default; select * from t1; c1 14397 unlock tables; +connection con2; read the result from the other connection -proceed with the normal connection +connection default; select * from t1; ERROR 42S02: Table 'test.t1' doesn't exist drop table if exists t1; Warnings: Note 1051 Unknown table 'test.t1' create table t1 (a int not null) ENGINE=csv; ---> client 2 +connection con2; handler t1 open; ERROR HY000: Storage engine CSV of the table `test`.`t1` doesn't have this option ---> client 1 +connection default; drop table t1; +disconnect con2; create table t1 (a int); handler t1 open as t1_alias; handler t1_alias read a next; @@ -968,15 +972,17 @@ handler t1 close; # Explore the effect of HANDLER locks on concurrent DDL # handler t1 open; -# Establishing auxiliary connections con1, con2, con3 -# --> connection con1; +connect con1, localhost, root,,; +connect con2, localhost, root,,; +connect con3, localhost, root,,; +connection con1; # Sending: drop table t1 ; # We can't use connection 'default' as wait_condition will # autoclose handlers. -# --> connection con2 +connection con2; # Waitng for 'drop table t1' to get blocked... -# --> connection default +connection default; handler t1 read a prev; a b 5 NULL @@ -984,9 +990,9 @@ handler t1 read a prev; a b 4 NULL handler t1 close; -# --> connection con1 +connection con1; # Reaping 'drop table t1'... -# --> connection default +connection default; # # Explore the effect of HANDLER locks in parallel with SELECT # @@ -1008,12 +1014,12 @@ handler t1 read a prev; a 4 handler t1 close; -# --> connection con1; +connection con1; # Sending: drop table t1 ; -# --> connection con2 +connection con2; # Waiting for 'drop table t1' to get blocked... -# --> connection default +connection default; # We can still use the table, it's part of the transaction select * from t1; a @@ -1038,10 +1044,10 @@ handler t1 read a prev; a 3 handler t1 close; -# --> connection con1 +connection con1; # Now drop can proceed # Reaping 'drop table t1'... -# --> connection default +connection default; # # Demonstrate that HANDLER locks and transaction locks # reside in the same context. @@ -1058,12 +1064,12 @@ a 3 4 5 -# --> connection con2 +connection con2; # Sending: rename table t0 to t3, t1 to t0, t3 to t1; -# --> connection con1 +connection con1; # Waiting for 'rename table ...' to get blocked... -# --> connection default +connection default; # We back-off on hitting deadlock condition. handler t0 open; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction @@ -1077,9 +1083,9 @@ a handler t1 open; commit; handler t1 close; -# --> connection con2 +connection con2; # Reaping 'rename table ...'... -# --> connection default +connection default; handler t1 open; handler t1 read a prev; a @@ -1095,22 +1101,22 @@ drop table t0; # create table t2 (a int, key a (a)); handler t1 open; -# --> connection con1 +connection con1; lock tables t2 read; -# --> connection con2 +connection con2; # Sending 'drop table t2'... drop table t2; -# --> connection con1 +connection con1; # Waiting for 'drop table t2' to get blocked... -# --> connection default +connection default; # Sending 'select * from t2' select * from t2; -# --> connection con1 +connection con1; # Waiting for 'select * from t2' to get blocked... unlock tables; -# --> connection con2 +connection con2; # Reaping 'drop table t2'... -# --> connection default +connection default; # Reaping 'select * from t2' ERROR 42S02: Table 'test.t2' doesn't exist handler t1 close; @@ -1134,29 +1140,29 @@ a 2 select * from t2; a -# --> connection con1 +connection con1; # Sending: drop table t1; -# --> connection con2 +connection con2; # Sending: drop table t2; -# --> connection default +connection default; # Let DROP TABLE statements sync in. We must use # a separate connection for that, because otherwise SELECT # will auto-close the HANDLERs, becaues there are pending # exclusive locks against them. -# --> connection con3 +connection con3; # Waiting for 'drop table t1' to get blocked... # Waiting for 'drop table t2' to get blocked... # Demonstrate that t2 lock was released and t2 was dropped # after ROLLBACK TO SAVEPOINT -# --> connection default +connection default; rollback to savepoint sv; -# --> connection con2 +connection con2; # Reaping 'drop table t2'... # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler # lock. -# --> connection default +connection default; handler t1 read a next; a 3 @@ -1166,9 +1172,9 @@ a # Demonstrate that the drop will go through as soon as we close the # HANDLER handler t1 close; -# connection con1 +connection con1; # Reaping 'drop table t1'... -# --> connection default +connection default; commit; drop table t3; # @@ -1193,29 +1199,29 @@ a 2 select * from t2; a -# --> connection con1 +connection con1; # Sending: drop table t1; -# --> connection con2 +connection con2; # Sending: drop table t2; -# --> connection default +connection default; # Let DROP TABLE statements sync in. We must use # a separate connection for that, because otherwise SELECT # will auto-close the HANDLERs, becaues there are pending # exclusive locks against them. -# --> connection con3 +connection con3; # Waiting for 'drop table t1' to get blocked... # Waiting for 'drop table t2' to get blocked... # Demonstrate that t2 lock was released and t2 was dropped # after ROLLBACK TO SAVEPOINT -# --> connection default +connection default; rollback to savepoint sv; -# --> connection con2 +connection con2; # Reaping 'drop table t2'... # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler # lock. -# --> connection default +connection default; handler t1 read a next; a 3 @@ -1225,9 +1231,9 @@ a # Demonstrate that the drop will go through as soon as we close the # HANDLER handler t1 close; -# connection con1 +connection con1; # Reaping 'drop table t1'... -# --> connection default +connection default; commit; # # Show that rollback to the savepoint taken in the beginning @@ -1254,25 +1260,25 @@ handler t3 read a first; a 1 rollback to savepoint sv; -# --> connection con1 +connection con1; drop table t1, t2; # Sending: drop table t3; # Let DROP TABLE statement sync in. -# --> connection con2 +connection con2; # Waiting for 'drop table t3' to get blocked... # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler # lock. -# --> connection default +connection default; handler t3 read a next; a 2 # Demonstrate that the drop will go through as soon as we close the # HANDLER handler t3 close; -# connection con1 +connection con1; # Reaping 'drop table t3'... -# --> connection default +connection default; commit; # # If we have to wait on an exclusive locks while having @@ -1281,27 +1287,27 @@ commit; create table t1 (a int, key a(a)); create table t2 like t1; handler t1 open; -# --> connection con1 +connection con1; lock table t1 write, t2 write; -# --> connection default +connection default; drop table t2; -# --> connection con2 +connection con2; # Waiting for 'drop table t2' to get blocked... -# --> connection con1 +connection con1; drop table t1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction unlock tables; -# --> connection default +connection default; # Demonstrate that there is no deadlock with FLUSH TABLE, # even though it is waiting for the other table to go away create table t2 like t1; # Sending: flush table t2; -# --> connection con2 +connection con2; drop table t1; -# --> connection con1 +connection con1; unlock tables; -# --> connection default +connection default; # Reaping 'flush table t2'... drop table t2; # @@ -1310,20 +1316,20 @@ drop table t2; # create table t1 (a int, key using btree (a)); insert into t1 values (1), (2); -# --> connection default +connection default; begin; select * from t1; a 1 2 handler t1 open; -# --> connection con1 +connection con1; # Sending: lock tables t1 write; -# --> connection con2 +connection con2; # Check that 'lock tables t1 write' waits until transaction which # has read from the table commits. -# --> connection default +connection default; # The below 'handler t1 read ...' should not be blocked as # 'lock tables t1 write' has not succeeded yet. handler t1 read a next; @@ -1331,24 +1337,28 @@ a 1 # Unblock 'lock tables t1 write'. commit; -# --> connection con1 +connection con1; # Reap 'lock tables t1 write'. -# --> connection default +connection default; # Sending: handler t1 read a next; -# --> connection con1 +connection con1; # Waiting for 'handler t1 read a next' to get blocked... # The below 'drop table t1' should be able to proceed without # waiting as it will force HANDLER to be closed. drop table t1; unlock tables; -# --> connection default +connection default; # Reaping 'handler t1 read a next'... ERROR 42S02: Table 'test.t1' doesn't exist handler t1 close; -# --> connection con1 -# --> connection con2 -# --> connection con3 +connection con1; +disconnect con1; +connection con2; +disconnect con2; +connection con3; +disconnect con3; +connection default; # # A temporary table test. # Check that we don't loose positions of HANDLER opened @@ -1475,8 +1485,8 @@ drop table t2, t3; # Check that when we clone a ticket for HANDLER we downrade # the lock. # -# Establish an auxiliary connection con1. -# -> connection default +connect con1,localhost,root,,; +connection default; create table t1 (a int, b int, key using btree (a)); insert into t1 (a, b) values (1, 1), (2, 1), (3, 2), (4, 2), (5, 5); begin; @@ -1490,19 +1500,20 @@ handler t1 read a last; a b 7 7 commit; -# -> connection con1 +connection con1; # Demonstrate that the HANDLER doesn't hold MDL_SHARED_WRITE. lock table t1 write; unlock tables; -# -> connection default +connection default; handler t1 read a prev; a b 6 6 handler t1 close; # Cleanup. drop table t1; -# -> connection con1 -# -> connection default +connection con1; +disconnect con1; +connection default; # # A test for Bug#50555 "handler commands crash server in # my_hash_first()". @@ -1631,26 +1642,28 @@ drop tables t1, t2; # bool MDL_context::try_acquire_lock(MDL_request*) # DROP TABLE IF EXISTS t1; -# Connection default +connect con51355, localhost, root; +connection default; CREATE TABLE t1(id INT, KEY id(id)); HANDLER t1 OPEN; -# Connection con51355 +connection con51355; # Sending: DROP TABLE t1; -# Connection default +connection default; # This I_S query will cause the handler table to be closed and # the metadata lock to be released. This will allow DROP TABLE # to proceed. Waiting for the table to be removed. -# Connection con51355 +connection con51355; # Reaping: DROP TABLE t1 -# Connection default +connection default; HANDLER t1 READ id NEXT; ERROR 42S02: Table 'test.t1' doesn't exist HANDLER t1 READ id NEXT; ERROR 42S02: Table 'test.t1' doesn't exist HANDLER t1 CLOSE; -# Connection con51355 -# Connection default +connection con51355; +disconnect con51355; +connection default; # # Bug#54401 assert in Diagnostics_area::set_eof_status , HANDLER # |