Commit 79a90dad authored by joerg@trift2's avatar joerg@trift2

Merge trift2.:/MySQL/M50/mysql-5.0

into  trift2.:/MySQL/M50/push-5.0
parents 81905ee1 88ef9a42
......@@ -20,6 +20,7 @@ AUTOMAKE_OPTIONS = foreign
# These are built from source in the Docs directory
EXTRA_DIST = INSTALL-SOURCE INSTALL-WIN-SOURCE \
README COPYING EXCEPTIONS-CLIENT CMakeLists.txt
SUBDIRS = . include @docs_dirs@ @zlib_dir@ @yassl_dir@ \
@readline_topdir@ sql-common scripts \
@thread_dirs@ pstack \
......@@ -157,8 +158,6 @@ test-bt:
@PERL@ ./mysql-test-run.pl --force --comment=funcs1_ps --ps-protocol --suite=funcs_1
-cd mysql-test ; MTR_BUILD_THREAD=auto \
@PERL@ ./mysql-test-run.pl --force --comment=funcs2 --suite=funcs_2
-cd mysql-test ; MTR_BUILD_THREAD=auto \
@PERL@ ./mysql-test-run.pl --force --comment=rowlock --suite=row_lock
-if [ -d mysql-test/suite/nist ] ; then \
cd mysql-test ; MTR_BUILD_THREAD=auto \
@PERL@ ./mysql-test-run.pl --comment=NIST+normal --force --suite=nist ; \
......
......@@ -437,19 +437,23 @@ eval SELECT *
# check also with a 'simple' user
CREATE USER user_3212@localhost;
GRANT ALL ON db_datadict.* TO user_3212@localhost;
# OBN: The following line was added following the fix to bug 28181
# where queries to information_schema will fail if exporting to
# a file without having the FILE attribute
GRANT FILE ON *.* TO user_3212@localhost;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (u3212,localhost,user_3212,,db_datadict);
--source suite/funcs_1/include/show_connection.inc
# no db given --> db_datadict.schema does not exist
--error 1045
--error 1146
eval SELECT *
INTO OUTFILE '../tmp/out.$ENGINE_TYPE.user.file'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM schemata LIMIT 0, 5;
# FIXME 3.2.1.2: why do we get different error numbers with and without OUTFILE ?
--error 1146
eval SELECT *
FROM schemata LIMIT 0, 5;
......@@ -460,8 +464,6 @@ eval SELECT *
LINES TERMINATED BY '\n'
FROM information_schema.schemata
WHERE schema_name LIKE 'db_%';
# The above will fail with access error as long as
# BUBG#28181 - a regression introduced in 5.0.42 is not fixed
eval SELECT *
FROM information_schema.schemata
......@@ -469,14 +471,11 @@ eval SELECT *
USE information_schema;
# no db given --> db_datadict.schema does not exist
eval SELECT *
INTO OUTFILE '../tmp/out.$ENGINE_TYPE.user_2.file'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM schemata LIMIT 0, 5;
# The above will fail with access error as long as
# BUBG#28181 - a regression introduced in 5.0.42 is not fixed
eval SELECT *
FROM schemata LIMIT 0, 5;
......@@ -487,8 +486,6 @@ eval SELECT *
LINES TERMINATED BY '\n'
FROM information_schema.schemata
WHERE schema_name LIKE 'db_%';
# The above will fail with access error as long as
# BUBG#28181 - a regression introduced in 5.0.42 is not fixed
eval SELECT *
FROM information_schema.schemata
......
......@@ -4859,6 +4859,7 @@ INTO OUTFILE '../tmp/out.innodb.db.file'
WHERE schema_name LIKE 'db_%';
CREATE USER user_3212@localhost;
GRANT ALL ON db_datadict.* TO user_3212@localhost;
GRANT FILE ON *.* TO user_3212@localhost;
connect(localhost,user_3212,,db_datadict,MYSQL_PORT,MYSQL_SOCK);
user_3212@localhost db_datadict
......@@ -4867,7 +4868,7 @@ INTO OUTFILE '../tmp/out.innodb.user.file'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM schemata LIMIT 0, 5;
ERROR 28000: Access denied for user 'user_3212'@'localhost' (using password: NO)
ERROR 42S02: Table 'db_datadict.schemata' doesn't exist
SELECT *
FROM schemata LIMIT 0, 5;
ERROR 42S02: Table 'db_datadict.schemata' doesn't exist
......
......@@ -237,7 +237,7 @@ create table t1 (f1 integer) engine = innodb;
use test;
CREATE TRIGGER trig_db.trg6_2 AFTER INSERT on tb3
for each row set @ret_trg6_2 = 5;
ERROR HY000: Trigger in wrong schema
ERROR 42S02: Table 'trig_db.tb3' doesn't exist
use trig_db;
CREATE TRIGGER trg6_3 AFTER INSERT on test.tb3
for each row set @ret_trg6_3 = 18;
......
......@@ -484,9 +484,8 @@ BEGIN
WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END//
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END' at line 3
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET @counter1 = @counter1 + 1;
END' at line 4
delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7;
......
......@@ -194,7 +194,7 @@ a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000
Update tb3 Set f122='Test 3.5.9.4-trig', f136=NULL, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4';
Warnings:
Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'f136' at row 11
Warning 1048 Column 'f136' cannot be null
select f118, f121, f122, f136, f151, f163 from tb3
where f122 like 'Test 3.5.9.4-trig';
f118 f121 f122 f136 f151 f163
......
......@@ -10202,7 +10202,8 @@ SHOW FIELDS FROM v1;
ERROR 42S02: Table 'test.v1' doesn't exist
CHECK TABLE v1;
Table Op Msg_type Msg_text
test.v1 check error Table 'test.v1' doesn't exist
test.v1 check Error Table 'test.v1' doesn't exist
test.v1 check error Corrupt
DESCRIBE v1;
ERROR 42S02: Table 'test.v1' doesn't exist
EXPLAIN SELECT * FROM v1;
......
......@@ -4842,6 +4842,7 @@ INTO OUTFILE '../tmp/out.memory.db.file'
WHERE schema_name LIKE 'db_%';
CREATE USER user_3212@localhost;
GRANT ALL ON db_datadict.* TO user_3212@localhost;
GRANT FILE ON *.* TO user_3212@localhost;
connect(localhost,user_3212,,db_datadict,MYSQL_PORT,MYSQL_SOCK);
user_3212@localhost db_datadict
......@@ -4850,7 +4851,7 @@ INTO OUTFILE '../tmp/out.memory.user.file'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM schemata LIMIT 0, 5;
ERROR 28000: Access denied for user 'user_3212'@'localhost' (using password: NO)
ERROR 42S02: Table 'db_datadict.schemata' doesn't exist
SELECT *
FROM schemata LIMIT 0, 5;
ERROR 42S02: Table 'db_datadict.schemata' doesn't exist
......
......@@ -233,7 +233,7 @@ create table t1 (f1 integer) engine = memory;
use test;
CREATE TRIGGER trig_db.trg6_2 AFTER INSERT on tb3
for each row set @ret_trg6_2 = 5;
ERROR HY000: Trigger in wrong schema
ERROR 42S02: Table 'trig_db.tb3' doesn't exist
use trig_db;
CREATE TRIGGER trg6_3 AFTER INSERT on test.tb3
for each row set @ret_trg6_3 = 18;
......
......@@ -480,9 +480,8 @@ BEGIN
WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END//
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END' at line 3
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET @counter1 = @counter1 + 1;
END' at line 4
delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7;
......
......@@ -190,7 +190,7 @@ a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000
Update tb3 Set f122='Test 3.5.9.4-trig', f136=NULL, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4';
Warnings:
Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'f136' at row 11
Warning 1048 Column 'f136' cannot be null
select f118, f121, f122, f136, f151, f163 from tb3
where f122 like 'Test 3.5.9.4-trig';
f118 f121 f122 f136 f151 f163
......
......@@ -10207,7 +10207,8 @@ SHOW FIELDS FROM v1;
ERROR 42S02: Table 'test.v1' doesn't exist
CHECK TABLE v1;
Table Op Msg_type Msg_text
test.v1 check error Table 'test.v1' doesn't exist
test.v1 check Error Table 'test.v1' doesn't exist
test.v1 check error Corrupt
DESCRIBE v1;
ERROR 42S02: Table 'test.v1' doesn't exist
EXPLAIN SELECT * FROM v1;
......
......@@ -4912,6 +4912,7 @@ INTO OUTFILE '../tmp/out.myisam.db.file'
WHERE schema_name LIKE 'db_%';
CREATE USER user_3212@localhost;
GRANT ALL ON db_datadict.* TO user_3212@localhost;
GRANT FILE ON *.* TO user_3212@localhost;
connect(localhost,user_3212,,db_datadict,MYSQL_PORT,MYSQL_SOCK);
user_3212@localhost db_datadict
......@@ -4920,7 +4921,7 @@ INTO OUTFILE '../tmp/out.myisam.user.file'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM schemata LIMIT 0, 5;
ERROR 28000: Access denied for user 'user_3212'@'localhost' (using password: NO)
ERROR 42S02: Table 'db_datadict.schemata' doesn't exist
SELECT *
FROM schemata LIMIT 0, 5;
ERROR 42S02: Table 'db_datadict.schemata' doesn't exist
......
......@@ -237,7 +237,7 @@ create table t1 (f1 integer) engine = myisam;
use test;
CREATE TRIGGER trig_db.trg6_2 AFTER INSERT on tb3
for each row set @ret_trg6_2 = 5;
ERROR HY000: Trigger in wrong schema
ERROR 42S02: Table 'trig_db.tb3' doesn't exist
use trig_db;
CREATE TRIGGER trg6_3 AFTER INSERT on test.tb3
for each row set @ret_trg6_3 = 18;
......
......@@ -484,9 +484,8 @@ BEGIN
WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END//
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1;
END' at line 3
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET @counter1 = @counter1 + 1;
END' at line 4
delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7;
......
......@@ -194,7 +194,7 @@ a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000
Update tb3 Set f122='Test 3.5.9.4-trig', f136=NULL, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4';
Warnings:
Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'f136' at row 11
Warning 1048 Column 'f136' cannot be null
select f118, f121, f122, f136, f151, f163 from tb3
where f122 like 'Test 3.5.9.4-trig';
f118 f121 f122 f136 f151 f163
......
......@@ -265,7 +265,7 @@ let $message= Testcase 3.5.1.8:;
# Can't create a trigger in a different database
use test;
--error 1435
--error 1146
CREATE TRIGGER trig_db.trg6_2 AFTER INSERT on tb3
for each row set @ret_trg6_2 = 5;
......
......@@ -609,7 +609,8 @@ let $col_type= my_year;
# 1.1.6. CAST --> DECIMAL
let $target_type= DECIMAL;
# Set the following to (37,2) since the default was changed to (10,0) - OBN
let $target_type= DECIMAL(37,2);
#
let $col_type= my_char_30;
--source suite/funcs_1/views/fv_cast.inc
......
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
SET autocommit=0;
# Create additional connections used through test
CONNECT (root1, localhost, root,,);
SET autocommit=0;
--echo connection default;
CONNECTION default;
eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
eval $indext1;
eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
eval $indext2;
COMMIT;
SELECT @@global.tx_isolation;
# Both transaction are able to update the tables
eval EXPLAIN $select;
eval $select;
--echo connection root1;
CONNECTION root1;
UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
UPDATE t1,t2 SET t1.i=223,t2.i=223 WHERE t1.i=123 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection root1;
CONNECTION root1;
UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
UPDATE t1,t2 SET t1.i=224,t2.i=224 WHERE t1.i=124 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection root1;
CONNECTION root1;
DELETE FROM t1 WHERE t1.i=226;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
DELETE FROM t1 WHERE t1.i=224;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
COMMIT;
--echo connection root1;
CONNECTION root1;
ROLLBACK;
--echo connection default;
CONNECTION default;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection root1;
CONNECTION root1;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
DISCONNECT root1;
--echo connection default;
CONNECTION default;
DROP TABLE t1, t2;
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
--enable_warnings
SET autocommit=0;
# Create additional connections used through test
CONNECT (root1, localhost, root,,);
SET autocommit=0;
--echo connection default;
CONNECTION default;
eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
eval $indext1;
eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
eval $indext2;
DELIMITER |;
CREATE PROCEDURE fill_t1 (IN upb int)
BEGIN
DECLARE cnt int DEFAULT 0;
WHILE cnt < upb DO
INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100);
SET cnt= cnt+1;
END WHILE;
END;
|
CREATE FUNCTION half_t1() RETURNS int
BEGIN
DECLARE res int DEFAULT 0;
SELECT count(*)/2 INTO res FROM t1;
RETURN res;
END;
|
CREATE PROCEDURE fill_t2 (IN upb int)
BEGIN
DECLARE cnt int DEFAULT 0;
WHILE cnt < upb DO
INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100);
SET cnt= cnt+1;
END WHILE;
END;
|
CREATE FUNCTION half_t2() RETURNS int
BEGIN
DECLARE res int DEFAULT 0;
SELECT count(*)/2 INTO res FROM t2;
RETURN res;
END;
|
DELIMITER ;|
CALL fill_t1 (10);
CALL fill_t2 (10);
COMMIT;
SELECT @@global.tx_isolation;
# With the two separate selects (without join) the differs from
# that select with join.
# Both transaction are able to update the tables
eval EXPLAIN $select;
eval $select;
--echo connection root1;
CONNECTION root1;
SELECT k from t1 WHERE k < half_t1();
SELECT k from t1 WHERE k >= half_t1();
UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k < half_t1() AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k >= half_t1() AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
COMMIT;
--echo connection root1;
CONNECTION root1;
ROLLBACK;
--echo connection default;
CONNECTION default;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection root1;
CONNECTION root1;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
DISCONNECT root1;
--echo connection default;
CONNECTION default;
DROP VIEW IF EXISTS v1;
DROP TABLE t1, t2;
#DROP VIEW v1;
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
--enable_warnings
SET autocommit=0;
# Create additional connections used through test
CONNECT (root1, localhost, root,,);
SET autocommit=0;
--echo connection default;
CONNECTION default;
eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
eval $indext1;
eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
eval $indext2;
DELIMITER |;
CREATE PROCEDURE fill_t1 (IN upb int)
BEGIN
DECLARE cnt int DEFAULT 0;
WHILE cnt < upb DO
INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100);
SET cnt= cnt+1;
END WHILE;
END;
|
CREATE FUNCTION half_t1() RETURNS int
BEGIN
DECLARE res int DEFAULT 0;
SELECT MOD(k,2) INTO res FROM t1;
RETURN res;
END;
|
CREATE PROCEDURE fill_t2 (IN upb int)
BEGIN
DECLARE cnt int DEFAULT 0;
WHILE cnt < upb DO
INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100);
SET cnt= cnt+1;
END WHILE;
END;
|
CREATE FUNCTION half_t2() RETURNS int
BEGIN
DECLARE res int DEFAULT 0;
SELECT MOD(k,2) INTO res FROM t2;
RETURN res;
END;
|
DELIMITER ;|
eval CALL fill_t1 ($nbrows);
eval CALL fill_t2 ($nbrows);
COMMIT;
SELECT @@global.tx_isolation;
# With the two separate selects (without join) the differs from
# that select with join.
# Both transaction are able to update the tables
eval EXPLAIN $select;
eval $select;
--echo connection root1;
CONNECTION root1;
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 1 AND t1.k = t2.k LOCK IN SHARE MODE;
UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k % 2 = 1 AND t1.k = t2.k;
SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k;
SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k % 2 = 0 AND t1.k = t2.k;
SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k;
SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k;
COMMIT;
--echo connection root1;
CONNECTION root1;
ROLLBACK;
--echo connection default;
CONNECTION default;
SELECT * FROM t1 WHERE k < 40 ORDER BY t1.k;
SELECT * FROM t2 WHERE k < 40 ORDER BY t2.k;
--echo connection root1;
CONNECTION root1;
SELECT * FROM t1 WHERE k < 40 ORDER BY t1.k;
SELECT * FROM t2 WHERE k < 40 ORDER BY t2.k;
DISCONNECT root1;
--echo connection default;
CONNECTION default;
DROP TABLE t1, t2;
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
--enable_warnings
SET autocommit=0;
# Create additional connections used through test
CONNECT (root1, localhost, root,,);
SET autocommit=0;
--echo connection default;
CONNECTION default;
eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
eval $indext1;
eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
eval $indext2;
DELIMITER |;
CREATE PROCEDURE fill_t1 (IN upb int)
BEGIN
DECLARE cnt int DEFAULT 0;
WHILE cnt < upb DO
INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100);
SET cnt= cnt+1;
END WHILE;
END;
|
CREATE FUNCTION half_t1() RETURNS int
BEGIN
DECLARE res int DEFAULT 0;
SELECT MOD(k,2) INTO res FROM t1;
RETURN res;
END;
|
CREATE PROCEDURE fill_t2 (IN upb int)
BEGIN
DECLARE cnt int DEFAULT 0;
WHILE cnt < upb DO
INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100);
SET cnt= cnt+1;
END WHILE;
END;
|
CREATE FUNCTION half_t2() RETURNS int
BEGIN
DECLARE res int DEFAULT 0;
SELECT MOD(k,2) INTO res FROM t2;
RETURN res;
END;
|
DELIMITER ;|
eval CALL fill_t1 ($nbrows);
eval CALL fill_t2 ($nbrows);
COMMIT;
SELECT @@global.tx_isolation;
# With the two separate selects (without join) the differs from
# that select with join.
# Both transaction are able to update the tables
eval EXPLAIN $select;
eval $select;
--echo connection root1;
CONNECTION root1;
#SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 1 AND t1.k = t2.k FOR UPDATE;
DELETE FROM t1 WHERE t1.k % 2 = 1;
SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k;
SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k % 2 = 0 AND t1.k = t2.k;
SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k;
SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k;
COMMIT;
--echo connection root1;
CONNECTION root1;
ROLLBACK;
--echo connection default;
CONNECTION default;
SELECT * FROM t1 WHERE k < 40 ORDER BY t1.k;
SELECT * FROM t2 WHERE k < 40 ORDER BY t2.k;
--echo connection root1;
CONNECTION root1;
SELECT * FROM t1 WHERE k < 40 ORDER BY t1.k;
SELECT * FROM t2 WHERE k < 40 ORDER BY t2.k;
DISCONNECT root1;
--echo connection default;
CONNECTION default;
DROP TABLE t1, t2;
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
--enable_warnings
SET autocommit=0;
# Create additional connections used through test
CONNECT (root1, localhost, root,,);
SET autocommit=0;
--echo connection default;
CONNECTION default;
eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
eval $indext1;
eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
eval $indext2;
DELIMITER |;
CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
FOR EACH ROW BEGIN
UPDATE t1 SET l = NEW.i WHERE i = OLD.i;
END;
|
DELIMITER ;|
COMMIT;
SELECT @@global.tx_isolation;
# With the two separate selects (without join) the differs from
# that select with join.
# Both transaction are able to update the tables
eval EXPLAIN $select;
eval $select;
--echo connection root1;
CONNECTION root1;
UPDATE t2 SET t2.i=225 WHERE t2.i=125;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
UPDATE t2 SET t2.i=223 WHERE t2.i=123;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection root1;
CONNECTION root1;
UPDATE t2 SET t2.i=226 WHERE t2.i=126;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
UPDATE t2 SET t2.i=224 WHERE t2.i=124;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection root1;
CONNECTION root1;
DELETE FROM t1 WHERE t1.i=226;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
DELETE FROM t1 WHERE t1.i=224;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
COMMIT;
--echo connection root1;
CONNECTION root1;
ROLLBACK;
--echo connection default;
CONNECTION default;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection root1;
CONNECTION root1;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
DISCONNECT root1;
--echo connection default;
CONNECTION default;
DROP TABLE t1, t2;
#DROP VIEW v1;
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
--enable_warnings
SET autocommit=0;
# Create additional connections used through test
CONNECT (root1, localhost, root,,);
SET autocommit=0;
--echo connection default;
CONNECTION default;
eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
eval $indext1;
eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
eval $indext2;
CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
COMMIT;
SELECT @@global.tx_isolation;
# With the two separate selects (without join) the differs from
# that select with join.
# Both transaction are able to update the tables
eval EXPLAIN $select;
eval $select;
--echo connection root1;
CONNECTION root1;
UPDATE v1 SET i=325 where i=125;
SELECT * FROM v1 ORDER BY i,l;
SELECT * FROM t1 ORDER BY t1.k;
--echo connection default;
CONNECTION default;
UPDATE v1 SET i=323 where i=123;
SELECT * FROM v1 ORDER BY i,l;
SELECT * FROM t1 ORDER BY t1.k;
--echo connection root1;
CONNECTION root1;
UPDATE v1 SET i=326 where i=126;
SELECT * FROM v1 ORDER BY i,l;
SELECT * FROM t1 ORDER BY t1.k;
--echo connection default;
CONNECTION default;
UPDATE v1 SET i=324 where i=124;
SELECT * FROM v1 ORDER BY i,l;
SELECT * FROM t1 ORDER BY t1.k;
--echo connection root1;
CONNECTION root1;
DELETE FROM t1 WHERE t1.i=226;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
DELETE FROM t1 WHERE t1.i=224;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
COMMIT;
--echo connection root1;
CONNECTION root1;
ROLLBACK;
--echo connection default;
CONNECTION default;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection root1;
CONNECTION root1;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
DISCONNECT root1;
--echo connection default;
CONNECTION default;
DROP VIEW IF EXISTS v1;
DROP TABLE t1, t2;
#DROP VIEW v1;
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
--enable_warnings
SET autocommit=0;
# Create additional connections used through test
CONNECT (root1, localhost, root,,);
SET autocommit=0;
--echo connection default;
CONNECTION default;
eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
eval $indext1;
eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
eval $indext2;
CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
COMMIT;
SELECT @@global.tx_isolation;
# With the two separate selects (without join) the differs from
# that select with join.
# Both transaction are able to update the tables
eval EXPLAIN $select;
eval $select;
--echo connection root1;
CONNECTION root1;
UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
#UPDATE v1 SET i=325 where i=125;
#SELECT * FROM v1 ORDER BY i,l;
#SELECT * FROM t1 ORDER BY t1.k;
--echo connection default;
CONNECTION default;
UPDATE v1 SET i=323 where i=123;
SELECT * FROM v1 ORDER BY i,l;
SELECT * FROM t1 ORDER BY t1.k;
--echo connection root1;
CONNECTION root1;
UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
UPDATE v1 SET i=324 where i=124;
SELECT * FROM v1 ORDER BY i,l;
SELECT * FROM t1 ORDER BY t1.k;
--echo connection root1;
CONNECTION root1;
DELETE FROM t1 WHERE t1.i=226;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
DELETE FROM t1 WHERE t1.i=224;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
COMMIT;
--echo connection root1;
CONNECTION root1;
ROLLBACK;
--echo connection default;
CONNECTION default;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection root1;
CONNECTION root1;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
DISCONNECT root1;
--echo connection default;
CONNECTION default;
DROP VIEW IF EXISTS v1;
DROP TABLE t1, t2;
#DROP VIEW v1;
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
DROP PROCEDURE IF EXISTS stp_t;
--enable_warnings
SET autocommit=0;
# Create additional connections used through test
CONNECT (root1, localhost, root,,);
SET autocommit=0;
CONNECT (root2, localhost, root,,);
SET autocommit=0;
--echo connection default;
CONNECTION default;
eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
INSERT INTO t1 VALUES (5,127,5,127);
INSERT INTO t1 VALUES (6,128,6,128);
eval $indext1;
eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
INSERT INTO t2 VALUES (5,127,5,127);
INSERT INTO t2 VALUES (6,128,6,128);
eval $indext2;
CREATE VIEW v1 AS SELECT t1.i from t1;
DELIMITER |;
CREATE PROCEDURE stp_t (IN p1 int, IN p2 int) MODIFIES SQL DATA
BEGIN
UPDATE t2 SET i = p2 WHERE i = p1;
UPDATE v1 SET i = p2 WHERE i = p1;
SELECT * FROM v1 ORDER BY i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
END;
|
DELIMITER ;|
COMMIT;
SELECT @@global.tx_isolation;
eval EXPLAIN $select;
eval $select;
--echo connection root1;
CONNECTION root1;
CALL stp_t (125, 225);
--echo connection root2;
CONNECTION root2;
CALL stp_t (127, 227);
--echo connection default;
CONNECTION default;
CALL stp_t (123, 223);
--echo connection root1;
CONNECTION root1;
CALL stp_t (126, 226);
--echo connection root2;
CONNECTION root2;
CALL stp_t (128, 228);
--echo connection default;
CONNECTION default;
CALL stp_t (124, 224);
--echo connection root1;
CONNECTION root1;
DELETE FROM t1 WHERE t1.i=226;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection root2;
CONNECTION root2;
DELETE FROM t1 WHERE t1.i=228;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
DELETE FROM t1 WHERE t1.i=224;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
COMMIT;
--echo connection root1;
CONNECTION root1;
ROLLBACK;
--echo connection root1;
CONNECTION root1;
COMMIT;
--echo connection default;
CONNECTION default;
SELECT * FROM v1 ORDER BY i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection root1;
CONNECTION root1;
SELECT * FROM v1 ORDER BY i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
DISCONNECT root1;
--echo connection root2;
CONNECTION root2;
SELECT * FROM v1 ORDER BY i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
DISCONNECT root2;
--echo connection default;
CONNECTION default;
--disable_warnings
DROP VIEW v1;
DROP PROCEDURE stp_t;
DROP TABLE t1, t2;
--enable_warnings
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
--enable_warnings
SET autocommit=0;
# Create additional connections used through test
CONNECT (root1, localhost, root,,);
SET autocommit=0;
--echo connection default;
CONNECTION default;
eval CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
eval $indext1;
eval CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=$engine;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
eval $indext2;
CREATE VIEW v1 AS SELECT t1.i from t1;
DELIMITER |;
CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
FOR EACH ROW BEGIN
UPDATE v1 SET i = NEW.i WHERE i = OLD.i;
END;
|
DELIMITER ;|
COMMIT;
SELECT @@global.tx_isolation;
eval EXPLAIN $select;
eval $select;
--echo connection root1;
CONNECTION root1;
UPDATE t2 SET t2.i=225 WHERE t2.i=125;
SELECT * FROM v1 ORDER BY i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
UPDATE t2 SET t2.i=223 WHERE t2.i=123;
SELECT * FROM v1 ORDER BY i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection root1;
CONNECTION root1;
UPDATE t2 SET t2.i=226 WHERE t2.i=126;
SELECT * FROM v1 ORDER BY i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
UPDATE t2 SET t2.i=224 WHERE t2.i=124;
SELECT * FROM v1 ORDER BY i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection root1;
CONNECTION root1;
DELETE FROM t1 WHERE t1.i=226;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection default;
CONNECTION default;
DELETE FROM t1 WHERE t1.i=224;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
COMMIT;
--echo connection root1;
CONNECTION root1;
ROLLBACK;
--echo connection default;
CONNECTION default;
SELECT * FROM v1 ORDER BY i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
--echo connection root1;
CONNECTION root1;
SELECT * FROM v1 ORDER BY i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
DISCONNECT root1;
--echo connection default;
CONNECTION default;
DROP TABLE t1, t2;
DROP VIEW v1;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
CREATE INDEX ixi ON t2 (i);
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
1 SIMPLE t2 ref ixi ixi 5 test.t1.i 2 Using where; Using index
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
i i
123 123
124 124
connection root1;
UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 126 4 126
connection default;
UPDATE t1,t2 SET t1.i=223,t2.i=223 WHERE t1.i=123 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
2 124 2 124
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 124 2 124
3 125 3 125
4 126 4 126
connection root1;
UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
connection default;
UPDATE t1,t2 SET t1.i=224,t2.i=224 WHERE t1.i=124 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
connection root1;
DELETE FROM t1 WHERE t1.i=226;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
connection default;
DELETE FROM t1 WHERE t1.i=224;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
COMMIT;
connection root1;
ROLLBACK;
connection default;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
connection root1;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
connection default;
DROP TABLE t1, t2;
SET @@global.innodb_table_locks= @table_locks;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
#CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
#CREATE INDEX ixi ON t2 (i);
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
i i
123 123
124 124
connection root1;
UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
#CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
#CREATE INDEX ixi ON t2 (i);
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
i i
123 123
124 124
connection root1;
UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
CREATE INDEX ixi ON t2 (i);
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
1 SIMPLE t2 ref ixi ixi 5 test.t1.i 2 Using where; Using index
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
i i
123 123
124 124
connection root1;
UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 126 4 126
connection default;
UPDATE t1,t2 SET t1.i=223,t2.i=223 WHERE t1.i=123 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
2 124 2 124
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 124 2 124
3 125 3 125
4 126 4 126
connection root1;
UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
connection default;
UPDATE t1,t2 SET t1.i=224,t2.i=224 WHERE t1.i=124 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
connection root1;
DELETE FROM t1 WHERE t1.i=226;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
connection default;
DELETE FROM t1 WHERE t1.i=224;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
COMMIT;
connection root1;
ROLLBACK;
connection default;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
connection root1;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
connection default;
DROP TABLE t1, t2;
SET @@global.innodb_table_locks= @table_locks;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
CREATE INDEX ixi ON t2 (i);
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
i i
123 123
124 124
connection root1;
UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
CREATE INDEX ixi ON t2 (i);
CREATE PROCEDURE fill_t1 (IN upb int)
BEGIN
DECLARE cnt int DEFAULT 0;
WHILE cnt < upb DO
INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100);
SET cnt= cnt+1;
END WHILE;
END;
|
CREATE FUNCTION half_t1() RETURNS int
BEGIN
DECLARE res int DEFAULT 0;
SELECT count(*)/2 INTO res FROM t1;
RETURN res;
END;
|
CREATE PROCEDURE fill_t2 (IN upb int)
BEGIN
DECLARE cnt int DEFAULT 0;
WHILE cnt < upb DO
INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100);
SET cnt= cnt+1;
END WHILE;
END;
|
CREATE FUNCTION half_t2() RETURNS int
BEGIN
DECLARE res int DEFAULT 0;
SELECT count(*)/2 INTO res FROM t2;
RETURN res;
END;
|
CALL fill_t1 (10);
CALL fill_t2 (10);
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ixi ixi 5 NULL 10 Using where; Using index
1 SIMPLE t2 ref ixi ixi 5 test.t1.i 1 Using where; Using index
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE;
i i
connection root1;
SELECT k from t1 WHERE k < half_t1();
k
0
1
2
3
4
SELECT k from t1 WHERE k >= half_t1();
k
5
6
7
8
9
UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k < half_t1() AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
0 1111 0 100
1 1111 1 101
2 1111 2 102
3 1111 3 103
4 1111 4 104
5 105 5 105
6 106 6 106
7 107 7 107
8 108 8 108
9 109 9 109
SELECT * FROM t2 ORDER BY t2.k;
k i j l
0 2222 0 100
1 2222 1 101
2 2222 2 102
3 2222 3 103
4 2222 4 104
5 105 5 105
6 106 6 106
7 107 7 107
8 108 8 108
9 109 9 109
connection default;
UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k >= half_t1() AND t2.i=t1.i;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
CREATE INDEX ixi ON t2 (i);
CREATE PROCEDURE fill_t1 (IN upb int)
BEGIN
DECLARE cnt int DEFAULT 0;
WHILE cnt < upb DO
INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100);
SET cnt= cnt+1;
END WHILE;
END;
|
CREATE FUNCTION half_t1() RETURNS int
BEGIN
DECLARE res int DEFAULT 0;
SELECT MOD(k,2) INTO res FROM t1;
RETURN res;
END;
|
CREATE PROCEDURE fill_t2 (IN upb int)
BEGIN
DECLARE cnt int DEFAULT 0;
WHILE cnt < upb DO
INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100);
SET cnt= cnt+1;
END WHILE;
END;
|
CREATE FUNCTION half_t2() RETURNS int
BEGIN
DECLARE res int DEFAULT 0;
SELECT MOD(k,2) INTO res FROM t2;
RETURN res;
END;
|
CALL fill_t1 (40);
CALL fill_t2 (40);
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY ixi 5 NULL 40 Using where; Using index
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.k 1
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE;
i i
100 100
102 102
104 104
106 106
108 108
110 110
112 112
114 114
116 116
118 118
120 120
122 122
124 124
126 126
128 128
130 130
132 132
134 134
136 136
138 138
connection root1;
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 1 AND t1.k = t2.k LOCK IN SHARE MODE;
i i
101 101
103 103
105 105
107 107
109 109
111 111
113 113
115 115
117 117
119 119
121 121
123 123
125 125
127 127
129 129
131 131
133 133
135 135
137 137
139 139
UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k % 2 = 1 AND t1.k = t2.k;
SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k;
k i j l
0 100 0 100
1 1111 1 101
2 102 2 102
3 1111 3 103
4 104 4 104
5 1111 5 105
6 106 6 106
7 1111 7 107
8 108 8 108
9 1111 9 109
10 110 10 110
11 1111 11 111
12 112 12 112
13 1111 13 113
14 114 14 114
15 1111 15 115
16 116 16 116
17 1111 17 117
18 118 18 118
19 1111 19 119
SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k;
k i j l
0 100 0 100
1 2222 1 101
2 102 2 102
3 2222 3 103
4 104 4 104
5 2222 5 105
6 106 6 106
7 2222 7 107
8 108 8 108
9 2222 9 109
10 110 10 110
11 2222 11 111
12 112 12 112
13 2222 13 113
14 114 14 114
15 2222 15 115
16 116 16 116
17 2222 17 117
18 118 18 118
19 2222 19 119
connection default;
UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k % 2 = 0 AND t1.k = t2.k;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
CREATE INDEX ixi ON t2 (i);
CREATE PROCEDURE fill_t1 (IN upb int)
BEGIN
DECLARE cnt int DEFAULT 0;
WHILE cnt < upb DO
INSERT INTO t1 VALUES (cnt, cnt+100, cnt, cnt+100);
SET cnt= cnt+1;
END WHILE;
END;
|
CREATE FUNCTION half_t1() RETURNS int
BEGIN
DECLARE res int DEFAULT 0;
SELECT MOD(k,2) INTO res FROM t1;
RETURN res;
END;
|
CREATE PROCEDURE fill_t2 (IN upb int)
BEGIN
DECLARE cnt int DEFAULT 0;
WHILE cnt < upb DO
INSERT INTO t2 VALUES (cnt, cnt+100, cnt, cnt+100);
SET cnt= cnt+1;
END WHILE;
END;
|
CREATE FUNCTION half_t2() RETURNS int
BEGIN
DECLARE res int DEFAULT 0;
SELECT MOD(k,2) INTO res FROM t2;
RETURN res;
END;
|
CALL fill_t1 (40);
CALL fill_t2 (40);
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY ixi 5 NULL 40 Using where; Using index
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.k 1
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE;
i i
100 100
102 102
104 104
106 106
108 108
110 110
112 112
114 114
116 116
118 118
120 120
122 122
124 124
126 126
128 128
130 130
132 132
134 134
136 136
138 138
connection root1;
DELETE FROM t1 WHERE t1.k % 2 = 1;
SELECT * FROM t1 WHERE k < 20 ORDER BY t1.k;
k i j l
0 100 0 100
2 102 2 102
4 104 4 104
6 106 6 106
8 108 8 108
10 110 10 110
12 112 12 112
14 114 14 114
16 116 16 116
18 118 18 118
SELECT * FROM t2 WHERE k < 20 ORDER BY t2.k;
k i j l
0 100 0 100
1 101 1 101
2 102 2 102
3 103 3 103
4 104 4 104
5 105 5 105
6 106 6 106
7 107 7 107
8 108 8 108
9 109 9 109
10 110 10 110
11 111 11 111
12 112 12 112
13 113 13 113
14 114 14 114
15 115 15 115
16 116 16 116
17 117 17 117
18 118 18 118
19 119 19 119
connection default;
UPDATE t1,t2 SET t1.i=3333,t2.i=4444 WHERE t1.k % 2 = 0 AND t1.k = t2.k;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
CREATE INDEX ixi ON t2 (i);
CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
FOR EACH ROW BEGIN
UPDATE t1 SET l = NEW.i WHERE i = OLD.i;
END;
|
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
i
123
124
connection root1;
UPDATE t2 SET t2.i=225 WHERE t2.i=125;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 125 3 225
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 126 4 126
connection default;
UPDATE t2 SET t2.i=223 WHERE t2.i=123;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 223
2 124 2 124
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 124 2 124
3 125 3 125
4 126 4 126
connection root1;
UPDATE t2 SET t2.i=226 WHERE t2.i=126;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 125 3 225
4 126 4 226
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
connection default;
UPDATE t2 SET t2.i=224 WHERE t2.i=124;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 223
2 124 2 224
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
connection root1;
DELETE FROM t1 WHERE t1.i=226;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 125 3 225
4 126 4 226
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
connection default;
DELETE FROM t1 WHERE t1.i=224;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 223
2 124 2 224
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
COMMIT;
connection root1;
ROLLBACK;
connection default;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 223
2 124 2 224
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
connection root1;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 223
2 124 2 224
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
connection default;
DROP TABLE t1, t2;
SET @@global.innodb_table_locks= @table_locks;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
#CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
#CREATE INDEX ixi ON t2 (i);
CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
FOR EACH ROW BEGIN
UPDATE t1 SET l = NEW.i WHERE i = OLD.i;
END;
|
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
i
123
124
connection root1;
UPDATE t2 SET t2.i=225 WHERE t2.i=125;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
CREATE INDEX ixi ON t2 (i);
CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
1 SIMPLE t2 ref ixi ixi 5 test.t1.i 2 Using where; Using index
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
i i
123 123
124 124
connection root1;
UPDATE v1 SET i=325 where i=125;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
CREATE INDEX ixi ON t2 (i);
CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
1 SIMPLE t2 index NULL PRIMARY 4 NULL 4 Using index
SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
i
123
124
123
124
123
124
123
124
connection root1;
UPDATE v1 SET i=325 where i=125;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
CREATE INDEX ixi ON t2 (i);
CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
1 SIMPLE t2 ref ixi ixi 5 test.t1.i 2 Using where; Using index
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
i i
123 123
124 124
connection root1;
UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 126 4 126
connection default;
UPDATE v1 SET i=323 where i=123;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
CREATE INDEX ixi ON t2 (i);
CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
1 SIMPLE t2 index NULL PRIMARY 4 NULL 4 Using index
SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
i
123
124
123
124
123
124
123
124
connection root1;
UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
INSERT INTO t1 VALUES (5,127,5,127);
INSERT INTO t1 VALUES (6,128,6,128);
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
INSERT INTO t2 VALUES (5,127,5,127);
INSERT INTO t2 VALUES (6,128,6,128);
CREATE INDEX ixi ON t2 (i);
CREATE VIEW v1 AS SELECT t1.i from t1;
CREATE PROCEDURE stp_t (IN p1 int, IN p2 int) MODIFIES SQL DATA
BEGIN
UPDATE t2 SET i = p2 WHERE i = p1;
UPDATE v1 SET i = p2 WHERE i = p1;
SELECT * FROM v1 ORDER BY i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
END;
|
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ixi ixi 5 NULL 6 Using where; Using index
SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
i
123
124
connection root1;
CALL stp_t (125, 225);
i
123
124
126
127
128
225
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 126 4 126
5 127 5 127
6 128 6 128
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 126 4 126
5 127 5 127
6 128 6 128
connection root2;
CALL stp_t (127, 227);
i
123
124
125
126
128
227
k i j l
1 123 1 123
2 124 2 124
3 125 3 125
4 126 4 126
5 227 5 127
6 128 6 128
k i j l
1 123 1 123
2 124 2 124
3 125 3 125
4 126 4 126
5 227 5 127
6 128 6 128
connection default;
CALL stp_t (123, 223);
i
124
125
126
127
128
223
k i j l
1 223 1 123
2 124 2 124
3 125 3 125
4 126 4 126
5 127 5 127
6 128 6 128
k i j l
1 223 1 123
2 124 2 124
3 125 3 125
4 126 4 126
5 127 5 127
6 128 6 128
connection root1;
CALL stp_t (126, 226);
i
123
124
127
128
225
226
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
5 127 5 127
6 128 6 128
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
5 127 5 127
6 128 6 128
connection root2;
CALL stp_t (128, 228);
i
123
124
125
126
227
228
k i j l
1 123 1 123
2 124 2 124
3 125 3 125
4 126 4 126
5 227 5 127
6 228 6 128
k i j l
1 123 1 123
2 124 2 124
3 125 3 125
4 126 4 126
5 227 5 127
6 228 6 128
connection default;
CALL stp_t (124, 224);
i
125
126
127
128
223
224
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
5 127 5 127
6 128 6 128
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
5 127 5 127
6 128 6 128
connection root1;
DELETE FROM t1 WHERE t1.i=226;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
5 127 5 127
6 128 6 128
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
5 127 5 127
6 128 6 128
connection root2;
DELETE FROM t1 WHERE t1.i=228;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 125 3 125
4 126 4 126
5 227 5 127
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 125 3 125
4 126 4 126
5 227 5 127
6 228 6 128
connection default;
DELETE FROM t1 WHERE t1.i=224;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
5 127 5 127
6 128 6 128
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
5 127 5 127
6 128 6 128
COMMIT;
connection root1;
ROLLBACK;
connection root1;
COMMIT;
connection default;
SELECT * FROM v1 ORDER BY i;
i
125
126
127
128
223
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
5 127 5 127
6 128 6 128
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
5 127 5 127
6 128 6 128
connection root1;
SELECT * FROM v1 ORDER BY i;
i
125
126
127
128
223
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
5 127 5 127
6 128 6 128
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
5 127 5 127
6 128 6 128
connection root2;
SELECT * FROM v1 ORDER BY i;
i
123
124
125
126
227
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 125 3 125
4 126 4 126
5 227 5 127
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 125 3 125
4 126 4 126
5 227 5 127
6 228 6 128
connection default;
DROP TABLE t1, t2;
DROP VIEW v1;
SET @@global.innodb_table_locks= @table_locks;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
INSERT INTO t1 VALUES (5,127,5,127);
INSERT INTO t1 VALUES (6,128,6,128);
#CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
INSERT INTO t2 VALUES (5,127,5,127);
INSERT INTO t2 VALUES (6,128,6,128);
#CREATE INDEX ixi ON t2 (i);
CREATE VIEW v1 AS SELECT t1.i from t1;
CREATE PROCEDURE stp_t (IN p1 int, IN p2 int) MODIFIES SQL DATA
BEGIN
UPDATE t2 SET i = p2 WHERE i = p1;
UPDATE v1 SET i = p2 WHERE i = p1;
SELECT * FROM v1 ORDER BY i;
SELECT * FROM t1 ORDER BY t1.k;
SELECT * FROM t2 ORDER BY t2.k;
END;
|
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using where
SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
i
123
124
connection root1;
CALL stp_t (125, 225);
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
CREATE INDEX ixi ON t2 (i);
CREATE VIEW v1 AS SELECT t1.i from t1;
CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
FOR EACH ROW BEGIN
UPDATE v1 SET i = NEW.i WHERE i = OLD.i;
END;
|
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ixi ixi 5 NULL 4 Using where; Using index
SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
i
123
124
connection root1;
UPDATE t2 SET t2.i=225 WHERE t2.i=125;
SELECT * FROM v1 ORDER BY i;
i
123
124
126
225
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 126 4 126
connection default;
UPDATE t2 SET t2.i=223 WHERE t2.i=123;
SELECT * FROM v1 ORDER BY i;
i
124
125
126
223
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
2 124 2 124
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 124 2 124
3 125 3 125
4 126 4 126
connection root1;
UPDATE t2 SET t2.i=226 WHERE t2.i=126;
SELECT * FROM v1 ORDER BY i;
i
123
124
225
226
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
connection default;
UPDATE t2 SET t2.i=224 WHERE t2.i=124;
SELECT * FROM v1 ORDER BY i;
i
125
126
223
224
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
connection root1;
DELETE FROM t1 WHERE t1.i=226;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
connection default;
DELETE FROM t1 WHERE t1.i=224;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
COMMIT;
connection root1;
ROLLBACK;
connection default;
SELECT * FROM v1 ORDER BY i;
i
125
126
223
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
connection root1;
SELECT * FROM v1 ORDER BY i;
i
125
126
223
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
connection default;
DROP TABLE t1, t2;
DROP VIEW v1;
SET @@global.innodb_table_locks= @table_locks;
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
#CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
#CREATE INDEX ixi ON t2 (i);
CREATE VIEW v1 AS SELECT t1.i from t1;
CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
FOR EACH ROW BEGIN
UPDATE v1 SET i = NEW.i WHERE i = OLD.i;
END;
|
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
i
123
124
connection root1;
UPDATE t2 SET t2.i=225 WHERE t2.i=125;
DROP TABLE IF EXISTS t1, t2;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
CREATE INDEX ixi ON t2 (i);
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where
1 SIMPLE t2 ref ixi ixi 5 test.t1.i 1 Using where
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
i i
123 123
124 124
connection root1;
UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 126 4 126
connection default;
UPDATE t1,t2 SET t1.i=223,t2.i=223 WHERE t1.i=123 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
2 124 2 124
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 124 2 124
3 125 3 125
4 126 4 126
connection root1;
UPDATE t1,t2 SET t1.i=226,t2.i=226 WHERE t1.i=126 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
connection default;
UPDATE t1,t2 SET t1.i=224,t2.i=224 WHERE t1.i=124 AND t2.i=t1.i;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
connection root1;
DELETE FROM t1 WHERE t1.i=226;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 123 1 123
2 124 2 124
3 225 3 125
4 226 4 126
connection default;
DELETE FROM t1 WHERE t1.i=224;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
COMMIT;
connection root1;
ROLLBACK;
connection default;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
connection root1;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
SELECT * FROM t2 ORDER BY t2.k;
k i j l
1 223 1 123
2 224 2 124
3 125 3 125
4 126 4 126
connection default;
DROP TABLE t1, t2;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
#CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
#CREATE INDEX ixi ON t2 (i);
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
i i
123 123
124 124
connection root1;
UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
DROP TABLE IF EXISTS t1, t2;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
#CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
#CREATE INDEX ixi ON t2 (i);
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
i i
123 123
124 124
connection root1;
UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
This diff is collapsed.
DROP TABLE IF EXISTS t1, t2;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
CREATE INDEX ixi ON t2 (i);
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
SELECT t1.i,t2.i FROM t1 ignore index (ixi),t2 IGNORE INDEX (ixi) WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
i i
123 123
124 124
connection root1;
UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
This diff is collapsed.
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
#CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
#CREATE INDEX ixi ON t2 (i);
CREATE TRIGGER trig_t2 AFTER UPDATE ON t2
FOR EACH ROW BEGIN
UPDATE t1 SET l = NEW.i WHERE i = OLD.i;
END;
|
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
i
123
124
connection root1;
UPDATE t2 SET t2.i=225 WHERE t2.i=125;
This diff is collapsed.
This diff is collapsed.
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
SET autocommit=0;
SET autocommit=0;
connection default;
CREATE TABLE t1 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
INSERT INTO t1 VALUES (1,123,1,123);
INSERT INTO t1 VALUES (2,124,2,124);
INSERT INTO t1 VALUES (3,125,3,125);
INSERT INTO t1 VALUES (4,126,4,126);
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
INSERT INTO t2 VALUES (1,123,1,123);
INSERT INTO t2 VALUES (2,124,2,124);
INSERT INTO t2 VALUES (3,125,3,125);
INSERT INTO t2 VALUES (4,126,4,126);
CREATE INDEX ixi ON t2 (i);
CREATE VIEW v1 AS SELECT t1.i, t2.l from t1,t2;
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range ixi ixi 5 NULL 10 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 4
SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
i
123
124
123
124
123
124
123
124
connection root1;
UPDATE t1,t2 SET t1.i=225,t2.i=225 WHERE t1.i=125 AND t2.i=t1.i;
All row lock test with InnoDB have to be executed with the options
--innodb_lock_wait_timeout=1
--innodb_locks_unsafe_for_binlog
for example
perl mysql-test-run.pl --mysqld=--innodb_lock_wait_timeout=2 --mysqld=--innodb_locks_unsafe_for_binlog --suite=row_lock innodb_row_lock_2
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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