diff --git a/include/thr_alarm.h b/include/thr_alarm.h index 99812ed808c..806735b2d38 100644 --- a/include/thr_alarm.h +++ b/include/thr_alarm.h @@ -88,6 +88,7 @@ typedef struct st_alarm { extern uint thr_client_alarm; extern pthread_t alarm_thread; +extern my_bool my_disable_thr_alarm; #define thr_alarm_init(A) (*(A))=0 #define thr_alarm_in_use(A) (*(A)!= 0) diff --git a/include/thr_lock.h b/include/thr_lock.h index 08cc8bd5408..ec24bbabddd 100644 --- a/include/thr_lock.h +++ b/include/thr_lock.h @@ -123,8 +123,10 @@ typedef struct st_thr_lock_data { struct st_thr_lock *lock; pthread_cond_t *cond; void *status_param; /* Param to status functions */ - void *debug_print_param; enum thr_lock_type type; + + enum thr_lock_type org_type; /* Cache for MariaDB */ + void *debug_print_param; /* For error messages */ uint priority; } THR_LOCK_DATA; diff --git a/mysql-test/include/check_no_concurrent_insert.inc b/mysql-test/include/check_no_concurrent_insert.inc index 6938c53fd16..f6a3d2052f5 100644 --- a/mysql-test/include/check_no_concurrent_insert.inc +++ b/mysql-test/include/check_no_concurrent_insert.inc @@ -43,7 +43,7 @@ connection default; # of our statement. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Locked" and info = "insert into $table (i) values (0)"; + where state = "Table lock" and info = "insert into $table (i) values (0)"; --source include/wait_condition.inc --disable_result_log diff --git a/mysql-test/include/handler.inc b/mysql-test/include/handler.inc index 6e7f53ba9b2..e8aeeeefcb2 100644 --- a/mysql-test/include/handler.inc +++ b/mysql-test/include/handler.inc @@ -77,8 +77,9 @@ handler t2 read a prev limit 10; handler t2 read a>=(16) limit 4; handler t2 read a>=(16) limit 2,2; +select * from t1 where a>=16 limit 2,2; handler t2 read a last limit 3; - +handler t2 read a=(16) limit 1,3; handler t2 read a=(19); handler t2 read a=(19) where b="yyy"; @@ -105,6 +106,79 @@ eval alter table t1 engine = $engine_type; --error 1109 handler t2 read first; +handler t1 open; +handler t1 read a=(16) limit 1,3; +flush tables; +handler t1 read a=(16) limit 1,3; +handler t1 close; + +# +# Test with prepared statements +# + +handler t1 open; +prepare stmt from 'handler t1 read a=(?) limit ?,?'; +set @a=16,@b=1,@c=100; +execute stmt using @a,@b,@c; +set @a=16,@b=2,@c=1; +execute stmt using @a,@b,@c; +set @a=16,@b=0,@c=2; +execute stmt using @a,@b,@c; +deallocate prepare stmt; + +prepare stmt from 'handler t1 read a next limit ?'; +handler t1 read a>=(11); +set @a=3; +execute stmt using @a; +execute stmt using @a; +execute stmt using @a; +deallocate prepare stmt; + +prepare stmt from 'handler t1 read b prev limit ?'; +execute stmt using @a; +execute stmt using @a; +execute stmt using @a; +execute stmt using @a; +deallocate prepare stmt; + +prepare stmt from 'handler t1 read b=(?,?)'; +set @a=14, @b='aaa'; +execute stmt using @a,@b; +set @a=14, @b='not found'; +execute stmt using @a,@b; +deallocate prepare stmt; + +prepare stmt from 'handler t1 read b=(1+?) limit 10'; +set @a=15; +execute stmt using @a; +execute stmt using @a; +deallocate prepare stmt; + +prepare stmt from 'handler t1 read a>=(?) where a < ? limit 5'; +set @a=15, @b=20; +execute stmt using @a,@b; +execute stmt using @a,@b; +deallocate prepare stmt; + +prepare stmt from 'handler t1 read a=(?)'; +set @a=16; +execute stmt using @a; +alter table t1 add c int; +--error 1109 +execute stmt using @a; +deallocate prepare stmt; +--error 1109 +handler t1 close; + +handler t1 open; +prepare stmt from 'handler t1 read a=(?)'; +flush tables; +set @a=16; +--error ER_NEED_REPREPARE +execute stmt using @a; +deallocate prepare stmt; +handler t1 close; + # # DROP TABLE / ALTER TABLE # diff --git a/mysql-test/r/handler_innodb.result b/mysql-test/r/handler_innodb.result index 957fc30acef..c13bea72cf1 100644 --- a/mysql-test/r/handler_innodb.result +++ b/mysql-test/r/handler_innodb.result @@ -115,11 +115,18 @@ handler t2 read a>=(16) limit 2,2; a b 17 ddd 18 eee +select * from t1 where a>=16 limit 2,2; +a b +17 ddd +18 eee handler t2 read a last limit 3; a b 22 iii 21 hhh 20 ggg +handler t2 read a=(16) limit 1,3; +a b +16 xxx handler t2 read a=(19); a b 19 fff @@ -161,6 +168,128 @@ a b alter table t1 engine = InnoDB; handler t2 read first; ERROR 42S02: Unknown table 't2' in HANDLER +handler t1 open; +handler t1 read a=(16) limit 1,3; +a b +16 xxx +flush tables; +handler t1 read a=(16) limit 1,3; +a b +16 xxx +handler t1 close; +handler t1 open; +prepare stmt from 'handler t1 read a=(?) limit ?,?'; +set @a=16,@b=1,@c=100; +execute stmt using @a,@b,@c; +a b +16 xxx +set @a=16,@b=2,@c=1; +execute stmt using @a,@b,@c; +a b +set @a=16,@b=0,@c=2; +execute stmt using @a,@b,@c; +a b +16 ccc +16 xxx +deallocate prepare stmt; +prepare stmt from 'handler t1 read a next limit ?'; +handler t1 read a>=(11); +a b +14 aaa +set @a=3; +execute stmt using @a; +a b +15 bbb +16 ccc +16 xxx +execute stmt using @a; +a b +17 ddd +18 eee +19 fff +execute stmt using @a; +a b +19 yyy +20 ggg +21 hhh +deallocate prepare stmt; +prepare stmt from 'handler t1 read b prev limit ?'; +execute stmt using @a; +a b +22 iii +21 hhh +20 ggg +execute stmt using @a; +a b +19 yyy +19 fff +18 eee +execute stmt using @a; +a b +17 ddd +16 xxx +16 ccc +execute stmt using @a; +a b +15 bbb +14 aaa +deallocate prepare stmt; +prepare stmt from 'handler t1 read b=(?,?)'; +set @a=14, @b='aaa'; +execute stmt using @a,@b; +a b +14 aaa +set @a=14, @b='not found'; +execute stmt using @a,@b; +a b +deallocate prepare stmt; +prepare stmt from 'handler t1 read b=(1+?) limit 10'; +set @a=15; +execute stmt using @a; +a b +16 ccc +16 xxx +execute stmt using @a; +a b +16 ccc +16 xxx +deallocate prepare stmt; +prepare stmt from 'handler t1 read a>=(?) where a < ? limit 5'; +set @a=15, @b=20; +execute stmt using @a,@b; +a b +15 bbb +16 ccc +16 xxx +17 ddd +18 eee +execute stmt using @a,@b; +a b +15 bbb +16 ccc +16 xxx +17 ddd +18 eee +deallocate prepare stmt; +prepare stmt from 'handler t1 read a=(?)'; +set @a=16; +execute stmt using @a; +a b +16 ccc +alter table t1 add c int; +execute stmt using @a; +ERROR 42S02: Unknown table 't1' in HANDLER +deallocate prepare stmt; +handler t1 close; +ERROR 42S02: Unknown table 't1' in HANDLER +handler t1 open; +prepare stmt from 'handler t1 read a=(?)'; +flush tables; +set @a=16; +execute stmt using @a; +ERROR HY000: Prepared statement needs to be re-prepared +deallocate prepare stmt; +handler t1 close; handler t1 open as t2; drop table t1; create table t1 (a int); diff --git a/mysql-test/r/handler_myisam.result b/mysql-test/r/handler_myisam.result index b20b8dbb138..420cb956d37 100644 --- a/mysql-test/r/handler_myisam.result +++ b/mysql-test/r/handler_myisam.result @@ -115,11 +115,18 @@ handler t2 read a>=(16) limit 2,2; a b 17 ddd 18 eee +select * from t1 where a>=16 limit 2,2; +a b +17 ddd +18 eee handler t2 read a last limit 3; a b 22 iii 21 hhh 20 ggg +handler t2 read a=(16) limit 1,3; +a b +16 xxx handler t2 read a=(19); a b 19 fff @@ -161,6 +168,128 @@ a b alter table t1 engine = MyISAM; handler t2 read first; ERROR 42S02: Unknown table 't2' in HANDLER +handler t1 open; +handler t1 read a=(16) limit 1,3; +a b +16 xxx +flush tables; +handler t1 read a=(16) limit 1,3; +a b +16 xxx +handler t1 close; +handler t1 open; +prepare stmt from 'handler t1 read a=(?) limit ?,?'; +set @a=16,@b=1,@c=100; +execute stmt using @a,@b,@c; +a b +16 xxx +set @a=16,@b=2,@c=1; +execute stmt using @a,@b,@c; +a b +set @a=16,@b=0,@c=2; +execute stmt using @a,@b,@c; +a b +16 ccc +16 xxx +deallocate prepare stmt; +prepare stmt from 'handler t1 read a next limit ?'; +handler t1 read a>=(11); +a b +14 aaa +set @a=3; +execute stmt using @a; +a b +15 bbb +16 ccc +16 xxx +execute stmt using @a; +a b +17 ddd +18 eee +19 fff +execute stmt using @a; +a b +19 yyy +20 ggg +21 hhh +deallocate prepare stmt; +prepare stmt from 'handler t1 read b prev limit ?'; +execute stmt using @a; +a b +22 iii +21 hhh +20 ggg +execute stmt using @a; +a b +19 yyy +19 fff +18 eee +execute stmt using @a; +a b +17 ddd +16 xxx +16 ccc +execute stmt using @a; +a b +15 bbb +14 aaa +deallocate prepare stmt; +prepare stmt from 'handler t1 read b=(?,?)'; +set @a=14, @b='aaa'; +execute stmt using @a,@b; +a b +14 aaa +set @a=14, @b='not found'; +execute stmt using @a,@b; +a b +deallocate prepare stmt; +prepare stmt from 'handler t1 read b=(1+?) limit 10'; +set @a=15; +execute stmt using @a; +a b +16 ccc +16 xxx +execute stmt using @a; +a b +16 ccc +16 xxx +deallocate prepare stmt; +prepare stmt from 'handler t1 read a>=(?) where a < ? limit 5'; +set @a=15, @b=20; +execute stmt using @a,@b; +a b +15 bbb +16 ccc +16 xxx +17 ddd +18 eee +execute stmt using @a,@b; +a b +15 bbb +16 ccc +16 xxx +17 ddd +18 eee +deallocate prepare stmt; +prepare stmt from 'handler t1 read a=(?)'; +set @a=16; +execute stmt using @a; +a b +16 ccc +alter table t1 add c int; +execute stmt using @a; +ERROR 42S02: Unknown table 't1' in HANDLER +deallocate prepare stmt; +handler t1 close; +ERROR 42S02: Unknown table 't1' in HANDLER +handler t1 open; +prepare stmt from 'handler t1 read a=(?)'; +flush tables; +set @a=16; +execute stmt using @a; +ERROR HY000: Prepared statement needs to be re-prepared +deallocate prepare stmt; +handler t1 close; handler t1 open as t2; drop table t1; create table t1 (a int); diff --git a/mysql-test/r/sp-threads.result b/mysql-test/r/sp-threads.result index 953830ecc87..d974cfb9605 100644 --- a/mysql-test/r/sp-threads.result +++ b/mysql-test/r/sp-threads.result @@ -35,7 +35,7 @@ call bug9486(); show processlist; Id User Host db Command Time State Info # root localhost test Sleep # NULL -# root localhost test Query # Locked update t1, t2 set val= 1 where id1=id2 +# root localhost test Query # Table lock update t1, t2 set val= 1 where id1=id2 # root localhost test Query # NULL show processlist # root localhost test Sleep # NULL unlock tables; diff --git a/mysql-test/suite/binlog/t/binlog_stm_row.test b/mysql-test/suite/binlog/t/binlog_stm_row.test index 29b0a69330d..47d9cbbbfb6 100644 --- a/mysql-test/suite/binlog/t/binlog_stm_row.test +++ b/mysql-test/suite/binlog/t/binlog_stm_row.test @@ -60,7 +60,7 @@ let $wait_condition= --echo # con1 let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE - state = "Locked" and info = "INSERT INTO t2 VALUES (3)"; + state = "Table Lock" and info = "INSERT INTO t2 VALUES (3)"; --source include/wait_condition.inc SELECT RELEASE_LOCK('Bug#34306'); --connection con2 diff --git a/mysql-test/suite/funcs_1/datadict/processlist_val.inc b/mysql-test/suite/funcs_1/datadict/processlist_val.inc index b1c1130cbdf..e06c5f081f5 100644 --- a/mysql-test/suite/funcs_1/datadict/processlist_val.inc +++ b/mysql-test/suite/funcs_1/datadict/processlist_val.inc @@ -368,13 +368,13 @@ echo ; connection default; echo -# Poll till INFO is no more NULL and State = 'Locked'. +# Poll till INFO is no more NULL and State = "Table Lock". ; let $wait_condition= SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST - WHERE INFO IS NOT NULL AND STATE = 'Locked'; + WHERE INFO IS NOT NULL AND STATE = "Table Lock"; --source include/wait_condition.inc # -# Expect to see the state 'Locked' for the third connection because the SELECT +# Expect to see the state "Table Lock" for the third connection because the SELECT # collides with the WRITE TABLE LOCK. --replace_column 1 3 6