Commit 5eb0b481 authored by Matthias Leich's avatar Matthias Leich

Fix for Bug#43015 and Bug#43065

   Details for Bug#43015 main.lock_multi: Weak code (sleeps etc.)
   -------------------------------------------------------------
   - The fix for bug 42003 already removed a lot of the weaknesses mentioned.
   - Tests showed that there are unfortunately no improvements of this tests
     in MySQL 5.1 which could be ported back to 5.0.
   - Remove a superfluous "--sleep 1" around line 195

   Details for Bug#43065 main.lock_multi: This test is too big if the disk is slow
   -------------------------------------------------------------------------------
   - move the subtests for the bugs 38499 and 36691 into separate scripts
   - runtime under excessive parallel I/O load after applying the fix
     lock_multi           [ pass ]          22887
     lock_multi_bug38499  [ pass ]         536926
     lock_multi_bug38691  [ pass ]         258498
parent 45681525
...@@ -51,10 +51,10 @@ ERROR HY000: Can't execute the query because you have a conflicting read lock ...@@ -51,10 +51,10 @@ ERROR HY000: Can't execute the query because you have a conflicting read lock
UNLOCK TABLES; UNLOCK TABLES;
DROP DATABASE mysqltest_1; DROP DATABASE mysqltest_1;
ERROR HY000: Can't drop database 'mysqltest_1'; database doesn't exist ERROR HY000: Can't drop database 'mysqltest_1'; database doesn't exist
use mysql; USE mysql;
LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE; LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE;
FLUSH TABLES; FLUSH TABLES;
use mysql; USE mysql;
SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1; SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1;
OPTIMIZE TABLES columns_priv, db, host, user; OPTIMIZE TABLES columns_priv, db, host, user;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
...@@ -65,7 +65,7 @@ mysql.user optimize status OK ...@@ -65,7 +65,7 @@ mysql.user optimize status OK
UNLOCK TABLES; UNLOCK TABLES;
Select_priv Select_priv
N N
use test; USE test;
use test; use test;
CREATE TABLE t1 (c1 int); CREATE TABLE t1 (c1 int);
LOCK TABLE t1 WRITE; LOCK TABLE t1 WRITE;
...@@ -93,43 +93,9 @@ create table t1 (a int); ...@@ -93,43 +93,9 @@ create table t1 (a int);
connection: locker connection: locker
lock tables t1 read; lock tables t1 read;
connection: writer connection: writer
create table t2 like t1;; create table t2 like t1;
connection: default connection: default
kill query kill query
ERROR 70100: Query execution was interrupted ERROR 70100: Query execution was interrupted
unlock tables; unlock tables;
drop table t1; drop table t1;
CREATE TABLE t1 (
a int(11) unsigned default NULL,
b varchar(255) default NULL,
UNIQUE KEY a (a),
KEY b (b)
);
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
CREATE TABLE t2 SELECT * FROM t1;
CREATE TABLE t3 SELECT * FROM t1;
# test altering of columns that multiupdate doesn't use
# normal mode
# PS mode
# test altering of columns that multiupdate uses
# normal mode
# PS mode
DROP TABLE t1, t2, t3;
CREATE TABLE t1( a INT, b INT );
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4);
# 1. test regular tables
# 1.1. test altering of columns that multiupdate doesn't use
# 1.1.1. normal mode
# 1.1.2. PS mode
# 1.2. test altering of columns that multiupdate uses
# 1.2.1. normal mode
# 1.2.2. PS mode
ALTER TABLE t1 ADD COLUMN a INT;
# 2. test UNIONs
# 2.1. test altering of columns that multiupdate doesn't use
# 2.1.1. normal mode
# 2.1.2. PS mode
# 2.2. test altering of columns that multiupdate uses
# 2.2.1. normal mode
# 2.2.2. PS mode
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1( a INT, b INT );
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4);
# 1. test regular tables
# 1.1. test altering of columns that multiupdate doesn't use
# 1.1.1. normal mode
# 1.1.2. PS mode
# 1.2. test altering of columns that multiupdate uses
# 1.2.1. normal mode
# 1.2.2. PS mode
ALTER TABLE t1 ADD COLUMN a INT;
# 2. test UNIONs
# 2.1. test altering of columns that multiupdate doesn't use
# 2.1.1. normal mode
# 2.1.2. PS mode
# 2.2. test altering of columns that multiupdate uses
# 2.2.1. normal mode
# 2.2.2. PS mode
DROP TABLE t1;
DROP TABLE IF EXISTS t1,t2,t3;
CREATE TABLE t1 (
a int(11) unsigned default NULL,
b varchar(255) default NULL,
UNIQUE KEY a (a),
KEY b (b)
);
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
CREATE TABLE t2 SELECT * FROM t1;
CREATE TABLE t3 SELECT * FROM t1;
# test altering of columns that multiupdate doesn't use
# normal mode
# PS mode
# test altering of columns that multiupdate uses
# normal mode
# PS mode
DROP TABLE t1, t2, t3;
-- source include/not_embedded.inc -- source include/not_embedded.inc
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
--disable_warnings --disable_warnings
drop table if exists t1,t2; drop table if exists t1,t2;
--enable_warnings --enable_warnings
...@@ -14,12 +18,23 @@ create table t1(n int); ...@@ -14,12 +18,23 @@ create table t1(n int);
insert into t1 values (1); insert into t1 values (1);
lock tables t1 write; lock tables t1 write;
connection writer; connection writer;
send update low_priority t1 set n = 4; send
update low_priority t1 set n = 4;
connection reader; connection reader;
--sleep 2 # Sleep a bit till the update of connection writer is in work and hangs
send select n from t1; let $wait_timeout= 5;
let $show_statement= SHOW PROCESSLIST;
let $field= State;
let $condition= = 'Locked';
--source include/wait_show_condition.inc
send
select n from t1;
connection locker; connection locker;
--sleep 2 # Sleep a bit till the select of connection reader is in work and hangs
# Here we cannot use include/wait_show_condition.inc because this routine
# cannot count the number of 'Locked' sessions or access two columns within
# the same query_get_value call.
--sleep 3
unlock tables; unlock tables;
connection writer; connection writer;
reap; reap;
...@@ -32,12 +47,23 @@ create table t1(n int); ...@@ -32,12 +47,23 @@ create table t1(n int);
insert into t1 values (1); insert into t1 values (1);
lock tables t1 read; lock tables t1 read;
connection writer; connection writer;
send update low_priority t1 set n = 4; send
update low_priority t1 set n = 4;
connection reader; connection reader;
--sleep 2 # Sleep a bit till the update of connection writer is in work and hangs
send select n from t1; let $wait_timeout= 5;
let $show_statement= SHOW PROCESSLIST;
let $field= State;
let $condition= = 'Locked';
--source include/wait_show_condition.inc
#
send
select n from t1;
connection locker; connection locker;
--sleep 2 # Sleep a bit till the select of connection reader is in work and hangs
# Here we cannot use include/wait_show_condition.inc.
--sleep 3
#
unlock tables; unlock tables;
connection writer; connection writer;
reap; reap;
...@@ -58,10 +84,13 @@ insert into t1 values(2,2); ...@@ -58,10 +84,13 @@ insert into t1 values(2,2);
insert into t2 values(1,2); insert into t2 values(1,2);
lock table t1 read; lock table t1 read;
connection writer; connection writer;
--sleep 2 send
send update t1,t2 set c=a where b=d; update t1,t2 set c=a where b=d;
connection reader; connection reader;
--sleep 2 # Sleep a bit till the update of connection writer is finished
# Here we cannot use include/wait_show_condition.inc.
--sleep 3
#
select c from t2; select c from t2;
connection writer; connection writer;
reap; reap;
...@@ -70,7 +99,7 @@ drop table t1; ...@@ -70,7 +99,7 @@ drop table t1;
drop table t2; drop table t2;
# #
# Test problem when using locks on many tables and droping a table that # Test problem when using locks on many tables and dropping a table that
# is to-be-locked by another thread # is to-be-locked by another thread
# #
...@@ -79,11 +108,18 @@ create table t1 (a int); ...@@ -79,11 +108,18 @@ create table t1 (a int);
create table t2 (a int); create table t2 (a int);
lock table t1 write, t2 write; lock table t1 write, t2 write;
connection reader; connection reader;
send insert t1 select * from t2; send
insert t1 select * from t2;
connection locker; connection locker;
# Sleep a bit till the insert of connection reader is in work and hangs
let $wait_timeout= 5;
let $show_statement= SHOW PROCESSLIST;
let $field= State;
let $condition= = 'Locked';
--source include/wait_show_condition.inc
drop table t2; drop table t2;
connection reader; connection reader;
--error 1146 --error ER_NO_SUCH_TABLE
reap; reap;
connection locker; connection locker;
drop table t1; drop table t1;
...@@ -91,7 +127,7 @@ drop table t1; ...@@ -91,7 +127,7 @@ drop table t1;
# End of 4.1 tests # End of 4.1 tests
# #
# BUG#9998 - MySQL client hangs on USE "database" # Bug#9998 MySQL client hangs on USE "database"
# #
create table t1(a int); create table t1(a int);
lock tables t1 write; lock tables t1 write;
...@@ -102,7 +138,7 @@ unlock tables; ...@@ -102,7 +138,7 @@ unlock tables;
drop table t1; drop table t1;
# #
# Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock # Bug#19815 CREATE/RENAME/DROP DATABASE can deadlock on a global read lock
# #
connect (con1,localhost,root,,); connect (con1,localhost,root,,);
connect (con2,localhost,root,,); connect (con2,localhost,root,,);
...@@ -114,12 +150,18 @@ FLUSH TABLES WITH READ LOCK; ...@@ -114,12 +150,18 @@ FLUSH TABLES WITH READ LOCK;
# With bug in place: acquire LOCK_mysql_create_table and # With bug in place: acquire LOCK_mysql_create_table and
# wait in wait_if_global_read_lock(). # wait in wait_if_global_read_lock().
connection con2; connection con2;
send DROP DATABASE mysqltest_1; send
--sleep 1 DROP DATABASE mysqltest_1;
# #
# With bug in place: try to acquire LOCK_mysql_create_table... # With bug in place: try to acquire LOCK_mysql_create_table...
# When fixed: Reject dropping db because of the read lock. # When fixed: Reject dropping db because of the read lock.
connection con1; connection con1;
# Wait a bit so that the session con2 is in state "Waiting for release of readlock"
let $wait_timeout= 5;
let $show_statement= SHOW PROCESSLIST;
let $field= State;
let $condition= = 'Waiting for release of readlock';
--source include/wait_show_condition.inc
--error ER_CANT_UPDATE_WITH_READLOCK --error ER_CANT_UPDATE_WITH_READLOCK
DROP DATABASE mysqltest_1; DROP DATABASE mysqltest_1;
UNLOCK TABLES; UNLOCK TABLES;
...@@ -135,26 +177,33 @@ disconnect con2; ...@@ -135,26 +177,33 @@ disconnect con2;
--error ER_DB_DROP_EXISTS --error ER_DB_DROP_EXISTS
DROP DATABASE mysqltest_1; DROP DATABASE mysqltest_1;
# #
# Bug#16986 - Deadlock condition with MyISAM tables # Bug#16986 Deadlock condition with MyISAM tables
# #
# Need a matching user in mysql.user for multi-table select # Need a matching user in mysql.user for multi-table select
--source include/add_anonymous_users.inc --source include/add_anonymous_users.inc
connection locker; connection locker;
use mysql; USE mysql;
LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE; LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE;
FLUSH TABLES; FLUSH TABLES;
--sleep 1
#
connection reader; connection reader;
use mysql; USE mysql;
#NOTE: This must be a multi-table select, otherwise the deadlock will not occur # Note: This must be a multi-table select, otherwise the deadlock will not occur
send SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1; send
--sleep 1 SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1;
# #
connection locker; connection locker;
# Sleep a bit till the select of connection reader is in work and hangs
let $wait_timeout= 5;
let $show_statement= SHOW PROCESSLIST;
let $field= State;
let $condition= = 'Locked';
--source include/wait_show_condition.inc
# Make test case independent from earlier grants. # Make test case independent from earlier grants.
--replace_result "Table is already up to date" "OK" --replace_result "Table is already up to date" "OK"
OPTIMIZE TABLES columns_priv, db, host, user; OPTIMIZE TABLES columns_priv, db, host, user;
...@@ -162,7 +211,7 @@ UNLOCK TABLES; ...@@ -162,7 +211,7 @@ UNLOCK TABLES;
# #
connection reader; connection reader;
reap; reap;
use test; USE test;
# #
connection locker; connection locker;
use test; use test;
...@@ -177,11 +226,17 @@ LOCK TABLE t1 WRITE; ...@@ -177,11 +226,17 @@ LOCK TABLE t1 WRITE;
# #
# This waits until t1 is unlocked. # This waits until t1 is unlocked.
connection locker; connection locker;
send FLUSH TABLES WITH READ LOCK; send
--sleep 1 FLUSH TABLES WITH READ LOCK;
# #
# This must not block. # This must not block.
connection writer; connection writer;
# Sleep a bit till the flush of connection locker is in work and hangs
let $wait_timeout= 5;
let $show_statement= SHOW PROCESSLIST;
let $field= State;
let $condition= = 'Flushing tables';
--source include/wait_show_condition.inc
CREATE TABLE t2 (c1 int); CREATE TABLE t2 (c1 int);
UNLOCK TABLES; UNLOCK TABLES;
# #
...@@ -201,12 +256,18 @@ LOCK TABLE t1 WRITE; ...@@ -201,12 +256,18 @@ LOCK TABLE t1 WRITE;
# #
# This waits until t1 is unlocked. # This waits until t1 is unlocked.
connection locker; connection locker;
send FLUSH TABLES WITH READ LOCK; send
--sleep 1 FLUSH TABLES WITH READ LOCK;
# #
# This must not block. # This must not block.
connection writer; connection writer;
--error 1100 # Sleep a bit till the flush of connection locker is in work and hangs
let $wait_timeout= 5;
let $show_statement= SHOW PROCESSLIST;
let $field= State;
let $condition= = 'Flushing tables';
--source include/wait_show_condition.inc
--error ER_TABLE_NOT_LOCKED
CREATE TABLE t2 AS SELECT * FROM t1; CREATE TABLE t2 AS SELECT * FROM t1;
UNLOCK TABLES; UNLOCK TABLES;
# #
...@@ -220,8 +281,9 @@ DROP TABLE t1; ...@@ -220,8 +281,9 @@ DROP TABLE t1;
--source include/delete_anonymous_users.inc --source include/delete_anonymous_users.inc
# #
# Bug #17264: MySQL Server freeze # Bug#17264 MySQL Server freeze
# #
connection locker; connection locker;
# Disable warnings to allow test to run also without InnoDB # Disable warnings to allow test to run also without InnoDB
...@@ -230,17 +292,29 @@ create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) e ...@@ -230,17 +292,29 @@ create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) e
--enable_warnings --enable_warnings
lock tables t1 write; lock tables t1 write;
connection writer; connection writer;
--sleep 2 # mleich: I have doubts if the next sleep is really necessary
# Therefore I set it to comment but don't remove it
# in case it hat to be enabled again.
# --sleep 2
delimiter //; delimiter //;
send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // send
alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
delimiter ;// delimiter ;//
connection reader; connection reader;
--sleep 2 # Wait till connection writer is blocked
let $wait_timeout= 5;
let $show_statement= SHOW PROCESSLIST;
let $field= State;
let $condition= = 'Locked';
--source include/wait_show_condition.inc
delimiter //; delimiter //;
send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // send
alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
delimiter ;// delimiter ;//
connection locker; connection locker;
--sleep 2 # Wait till connection reader is blocked
# Here we cannot use include/wait_show_condition.inc.
--sleep 3
unlock tables; unlock tables;
connection writer; connection writer;
reap; reap;
...@@ -263,7 +337,7 @@ lock tables t1 read; ...@@ -263,7 +337,7 @@ lock tables t1 read;
--echo connection: writer --echo connection: writer
connection writer; connection writer;
let $ID= `select connection_id()`; let $ID= `select connection_id()`;
--send create table t2 like t1; send create table t2 like t1;
--echo connection: default --echo connection: default
connection default; connection default;
let $show_type= open tables where in_use=2 and name_locked=1; let $show_type= open tables where in_use=2 and name_locked=1;
...@@ -281,325 +355,14 @@ unlock tables; ...@@ -281,325 +355,14 @@ unlock tables;
connection default; connection default;
drop table t1; drop table t1;
#
# Bug #38691: segfault/abort in ``UPDATE ...JOIN'' while
# ``FLUSH TABLES WITH READ LOCK''
#
--connection default
CREATE TABLE t1 (
a int(11) unsigned default NULL,
b varchar(255) default NULL,
UNIQUE KEY a (a),
KEY b (b)
);
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
CREATE TABLE t2 SELECT * FROM t1;
CREATE TABLE t3 SELECT * FROM t1;
--echo # test altering of columns that multiupdate doesn't use
--echo # normal mode
--disable_query_log
let $i = 100;
while ($i) {
--dec $i
--connection writer
send UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a)
SET a = NULL WHERE t1.b <> t2.b;
--connection locker
ALTER TABLE t2 ADD COLUMN (c INT);
ALTER TABLE t2 DROP COLUMN c;
--connection writer
--reap
}
--echo # PS mode
--connection writer
PREPARE stmt FROM 'UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a)
SET a = NULL WHERE t1.b <> t2.b';
let $i = 100;
while ($i) {
--dec $i
--connection writer
--send EXECUTE stmt
--connection locker
ALTER TABLE t2 ADD COLUMN (c INT);
ALTER TABLE t2 DROP COLUMN c;
--connection writer
--reap
}
--enable_query_log
--echo # test altering of columns that multiupdate uses
--echo # normal mode
--connection default
--disable_query_log
let $i = 100;
while ($i) {
dec $i;
--connection locker
--error 0,1060
ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL;
UPDATE t2 SET a=b;
--connection writer
--send UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) SET a = NULL WHERE t1.b <> t2.b
--connection locker
--error 0,1091
ALTER TABLE t2 DROP COLUMN a;
--connection writer
--error 0,1054
--reap
}
--enable_query_log
--echo # PS mode
--disable_query_log
let $i = 100;
while ($i) {
dec $i;
--connection locker
--error 0,1060
ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL;
UPDATE t2 SET a=b;
--connection writer
PREPARE stmt FROM 'UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) SET a = NULL WHERE t1.b <> t2.b';
--send EXECUTE stmt
--connection locker
--error 0,1091
ALTER TABLE t2 DROP COLUMN a;
--connection writer
--error 0,1054
--reap
}
--enable_query_log
--connection default
DROP TABLE t1, t2, t3;
#
# Bug#38499: flush tables and multitable table update with derived table cause
# crash
#
CREATE TABLE t1( a INT, b INT );
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4);
--echo # 1. test regular tables
--echo # 1.1. test altering of columns that multiupdate doesn't use
--echo # 1.1.1. normal mode
--disable_query_log
let $i = 100;
while ($i) {
--dec $i
--connection writer # Close connections used in many subtests
send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0; --disconnect reader
--disconnect locker
--disconnect writer
--connection locker # End of 5.0 tests
ALTER TABLE t1 ADD COLUMN (c INT);
ALTER TABLE t1 DROP COLUMN c;
--connection writer
--reap
}
--echo # 1.1.2. PS mode
--connection writer
PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0';
let $i = 100;
while ($i) {
--dec $i
--connection writer
--send EXECUTE stmt
--connection locker
ALTER TABLE t1 ADD COLUMN (c INT);
ALTER TABLE t1 DROP COLUMN c;
--connection writer
--reap
}
--enable_query_log
--echo # 1.2. test altering of columns that multiupdate uses
--echo # 1.2.1. normal mode
--connection default
--disable_query_log
let $i = 100;
while ($i) {
dec $i;
--connection locker
--error 0,1060
ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL;
UPDATE t1 SET a=b;
--connection writer
--send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0;
--connection locker
--error 0,1091
ALTER TABLE t1 DROP COLUMN a;
--connection writer
--error 0,1054 # unknown column error
--reap
}
--enable_query_log
--echo # 1.2.2. PS mode
--disable_query_log
let $i = 100;
while ($i) {
dec $i;
--connection locker
--error 0,1060
ALTER TABLE t1 ADD COLUMN a INT;
UPDATE t1 SET a=b;
--connection writer
PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0';
--send EXECUTE stmt
--connection locker
--error 0,1091
ALTER TABLE t1 DROP COLUMN a;
--connection writer
--error 0,1054 # Unknown column 'a' in 'field list'
--reap
}
--enable_query_log
--connection default
ALTER TABLE t1 ADD COLUMN a INT;
--echo # 2. test UNIONs
--echo # 2.1. test altering of columns that multiupdate doesn't use
--echo # 2.1.1. normal mode
--disable_query_log
let $i = 100;
while ($i) {
--dec $i
--connection writer
send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0;
--connection locker
ALTER TABLE t1 ADD COLUMN (c INT);
ALTER TABLE t1 DROP COLUMN c;
--connection writer
--reap
}
--echo # 2.1.2. PS mode
--connection writer
PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0';
let $i = 100;
while ($i) {
--dec $i
--connection writer
--send EXECUTE stmt
--connection locker
ALTER TABLE t1 ADD COLUMN (c INT);
ALTER TABLE t1 DROP COLUMN c;
--connection writer
--reap
}
--enable_query_log
--echo # 2.2. test altering of columns that multiupdate uses
--echo # 2.2.1. normal mode
--connection default
--disable_query_log
let $i = 100;
while ($i) {
dec $i;
--connection locker
--error 0,1060
ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL;
UPDATE t1 SET a=b;
--connection writer
--send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0;
--connection locker
--error 0,1091
ALTER TABLE t1 DROP COLUMN a;
--connection writer
--error 0,1054 # Unknown column 'a' in 'field list'
--reap
}
--enable_query_log
--echo # 2.2.2. PS mode
--disable_query_log
let $i = 100;
while ($i) {
dec $i;
--connection locker
--error 0,1060
ALTER TABLE t1 ADD COLUMN a INT;
UPDATE t1 SET a=b;
--connection writer
PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0';
--send EXECUTE stmt
--connection locker
--error 0,1091
ALTER TABLE t1 DROP COLUMN a;
--connection writer # Wait till all disconnects are completed
--error 0,1054 # Unknown column 'a' in 'field list' --source include/wait_until_count_sessions.inc
--reap
}
--enable_query_log
--connection default
DROP TABLE t1;
# End of 5.0 tests
# Bug38499 flush tables and multitable table update with derived table cause crash
# MySQL >= 5.0
#
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
connect (locker,localhost,root,,);
connect (writer,localhost,root,,);
--connection default
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1( a INT, b INT );
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4);
--echo # 1. test regular tables
--echo # 1.1. test altering of columns that multiupdate doesn't use
--echo # 1.1.1. normal mode
--disable_query_log
let $i = 100;
while ($i) {
--dec $i
--connection writer
send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0;
--connection locker
ALTER TABLE t1 ADD COLUMN (c INT);
ALTER TABLE t1 DROP COLUMN c;
--connection writer
--reap
}
--echo # 1.1.2. PS mode
--connection writer
PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0';
let $i = 100;
while ($i) {
--dec $i
--connection writer
--send EXECUTE stmt
--connection locker
ALTER TABLE t1 ADD COLUMN (c INT);
ALTER TABLE t1 DROP COLUMN c;
--connection writer
--reap
}
--enable_query_log
--echo # 1.2. test altering of columns that multiupdate uses
--echo # 1.2.1. normal mode
--connection default
--disable_query_log
let $i = 100;
while ($i) {
dec $i;
--connection locker
--error 0,ER_DUP_FIELDNAME
ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL;
UPDATE t1 SET a=b;
--connection writer
--send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0;
--connection locker
--error 0,ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1 DROP COLUMN a;
--connection writer
--error 0,ER_BAD_FIELD_ERROR # unknown column error
--reap
}
--enable_query_log
--echo # 1.2.2. PS mode
--disable_query_log
let $i = 100;
while ($i) {
dec $i;
--connection locker
--error 0,ER_DUP_FIELDNAME
ALTER TABLE t1 ADD COLUMN a INT;
UPDATE t1 SET a=b;
--connection writer
PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0';
--send EXECUTE stmt
--connection locker
--error 0,ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1 DROP COLUMN a;
--connection writer
--error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list'
--reap
}
--enable_query_log
--connection default
ALTER TABLE t1 ADD COLUMN a INT;
--echo # 2. test UNIONs
--echo # 2.1. test altering of columns that multiupdate doesn't use
--echo # 2.1.1. normal mode
--disable_query_log
let $i = 100;
while ($i) {
--dec $i
--connection writer
send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0;
--connection locker
ALTER TABLE t1 ADD COLUMN (c INT);
ALTER TABLE t1 DROP COLUMN c;
--connection writer
--reap
}
--echo # 2.1.2. PS mode
--connection writer
PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0';
let $i = 100;
while ($i) {
--dec $i
--connection writer
--send EXECUTE stmt
--connection locker
ALTER TABLE t1 ADD COLUMN (c INT);
ALTER TABLE t1 DROP COLUMN c;
--connection writer
--reap
}
--enable_query_log
--echo # 2.2. test altering of columns that multiupdate uses
--echo # 2.2.1. normal mode
--connection default
--disable_query_log
let $i = 100;
while ($i) {
dec $i;
--connection locker
--error 0,ER_DUP_FIELDNAME
ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL;
UPDATE t1 SET a=b;
--connection writer
--send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0;
--connection locker
--error 0,ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1 DROP COLUMN a;
--connection writer
--error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list'
--reap
}
--enable_query_log
--echo # 2.2.2. PS mode
--disable_query_log
let $i = 100;
while ($i) {
dec $i;
--connection locker
--error 0,ER_DUP_FIELDNAME
ALTER TABLE t1 ADD COLUMN a INT;
UPDATE t1 SET a=b;
--connection writer
PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0';
--send EXECUTE stmt
--connection locker
--error 0,ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1 DROP COLUMN a;
--connection writer
--error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list'
--reap
}
--enable_query_log
--connection default
DROP TABLE t1;
# Close connections
--disconnect locker
--disconnect writer
# End of 5.0 tests
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
#
# Bug#38691 segfault/abort in ``UPDATE ...JOIN'' while
# ``FLUSH TABLES WITH READ LOCK''
# MySQL >= 5.0
#
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
# Test to see if select will get the lock ahead of low priority update
connect (locker,localhost,root,,);
connect (writer,localhost,root,,);
--connection default
--disable_warnings
DROP TABLE IF EXISTS t1,t2,t3;
--enable_warnings
CREATE TABLE t1 (
a int(11) unsigned default NULL,
b varchar(255) default NULL,
UNIQUE KEY a (a),
KEY b (b)
);
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
CREATE TABLE t2 SELECT * FROM t1;
CREATE TABLE t3 SELECT * FROM t1;
--echo # test altering of columns that multiupdate doesn't use
--echo # normal mode
--disable_query_log
let $i = 100;
while ($i) {
--dec $i
--connection writer
send UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a)
SET a = NULL WHERE t1.b <> t2.b;
--connection locker
ALTER TABLE t2 ADD COLUMN (c INT);
ALTER TABLE t2 DROP COLUMN c;
--connection writer
--reap
}
--echo # PS mode
--connection writer
PREPARE stmt FROM 'UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a)
SET a = NULL WHERE t1.b <> t2.b';
let $i = 100;
while ($i) {
--dec $i
--connection writer
--send EXECUTE stmt
--connection locker
ALTER TABLE t2 ADD COLUMN (c INT);
ALTER TABLE t2 DROP COLUMN c;
--connection writer
--reap
}
--enable_query_log
--echo # test altering of columns that multiupdate uses
--echo # normal mode
--connection default
--disable_query_log
let $i = 100;
while ($i) {
dec $i;
--connection locker
--error 0,ER_DUP_FIELDNAME
ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL;
UPDATE t2 SET a=b;
--connection writer
--send UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) SET a = NULL WHERE t1.b <> t2.b
--connection locker
--error 0,ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t2 DROP COLUMN a;
--connection writer
--error 0,ER_BAD_FIELD_ERROR
--reap
}
--enable_query_log
--echo # PS mode
--disable_query_log
let $i = 100;
while ($i) {
dec $i;
--connection locker
--error 0,ER_DUP_FIELDNAME
ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL;
UPDATE t2 SET a=b;
--connection writer
PREPARE stmt FROM 'UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) SET a = NULL WHERE t1.b <> t2.b';
--send EXECUTE stmt
--connection locker
--error 0,ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t2 DROP COLUMN a;
--connection writer
--error 0,ER_BAD_FIELD_ERROR
--reap
}
--enable_query_log
--connection default
DROP TABLE t1, t2, t3;
# Close connections
--disconnect locker
--disconnect writer
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment