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 ...@@ -20,6 +20,7 @@ AUTOMAKE_OPTIONS = foreign
# These are built from source in the Docs directory # These are built from source in the Docs directory
EXTRA_DIST = INSTALL-SOURCE INSTALL-WIN-SOURCE \ EXTRA_DIST = INSTALL-SOURCE INSTALL-WIN-SOURCE \
README COPYING EXCEPTIONS-CLIENT CMakeLists.txt README COPYING EXCEPTIONS-CLIENT CMakeLists.txt
SUBDIRS = . include @docs_dirs@ @zlib_dir@ @yassl_dir@ \ SUBDIRS = . include @docs_dirs@ @zlib_dir@ @yassl_dir@ \
@readline_topdir@ sql-common scripts \ @readline_topdir@ sql-common scripts \
@thread_dirs@ pstack \ @thread_dirs@ pstack \
...@@ -157,8 +158,6 @@ test-bt: ...@@ -157,8 +158,6 @@ test-bt:
@PERL@ ./mysql-test-run.pl --force --comment=funcs1_ps --ps-protocol --suite=funcs_1 @PERL@ ./mysql-test-run.pl --force --comment=funcs1_ps --ps-protocol --suite=funcs_1
-cd mysql-test ; MTR_BUILD_THREAD=auto \ -cd mysql-test ; MTR_BUILD_THREAD=auto \
@PERL@ ./mysql-test-run.pl --force --comment=funcs2 --suite=funcs_2 @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 \ -if [ -d mysql-test/suite/nist ] ; then \
cd mysql-test ; MTR_BUILD_THREAD=auto \ cd mysql-test ; MTR_BUILD_THREAD=auto \
@PERL@ ./mysql-test-run.pl --comment=NIST+normal --force --suite=nist ; \ @PERL@ ./mysql-test-run.pl --comment=NIST+normal --force --suite=nist ; \
......
...@@ -437,19 +437,23 @@ eval SELECT * ...@@ -437,19 +437,23 @@ eval SELECT *
# check also with a 'simple' user # check also with a 'simple' user
CREATE USER user_3212@localhost; CREATE USER user_3212@localhost;
GRANT ALL ON db_datadict.* TO 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 --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (u3212,localhost,user_3212,,db_datadict); connect (u3212,localhost,user_3212,,db_datadict);
--source suite/funcs_1/include/show_connection.inc --source suite/funcs_1/include/show_connection.inc
# no db given --> db_datadict.schema does not exist # no db given --> db_datadict.schema does not exist
--error 1045 --error 1146
eval SELECT * eval SELECT *
INTO OUTFILE '../tmp/out.$ENGINE_TYPE.user.file' INTO OUTFILE '../tmp/out.$ENGINE_TYPE.user.file'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n' LINES TERMINATED BY '\n'
FROM schemata LIMIT 0, 5; FROM schemata LIMIT 0, 5;
# FIXME 3.2.1.2: why do we get different error numbers with and without OUTFILE ?
--error 1146 --error 1146
eval SELECT * eval SELECT *
FROM schemata LIMIT 0, 5; FROM schemata LIMIT 0, 5;
...@@ -460,8 +464,6 @@ eval SELECT * ...@@ -460,8 +464,6 @@ eval SELECT *
LINES TERMINATED BY '\n' LINES TERMINATED BY '\n'
FROM information_schema.schemata FROM information_schema.schemata
WHERE schema_name LIKE 'db_%'; 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 * eval SELECT *
FROM information_schema.schemata FROM information_schema.schemata
...@@ -469,14 +471,11 @@ eval SELECT * ...@@ -469,14 +471,11 @@ eval SELECT *
USE information_schema; USE information_schema;
# no db given --> db_datadict.schema does not exist
eval SELECT * eval SELECT *
INTO OUTFILE '../tmp/out.$ENGINE_TYPE.user_2.file' INTO OUTFILE '../tmp/out.$ENGINE_TYPE.user_2.file'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n' LINES TERMINATED BY '\n'
FROM schemata LIMIT 0, 5; 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 * eval SELECT *
FROM schemata LIMIT 0, 5; FROM schemata LIMIT 0, 5;
...@@ -487,8 +486,6 @@ eval SELECT * ...@@ -487,8 +486,6 @@ eval SELECT *
LINES TERMINATED BY '\n' LINES TERMINATED BY '\n'
FROM information_schema.schemata FROM information_schema.schemata
WHERE schema_name LIKE 'db_%'; 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 * eval SELECT *
FROM information_schema.schemata FROM information_schema.schemata
......
...@@ -4859,6 +4859,7 @@ INTO OUTFILE '../tmp/out.innodb.db.file' ...@@ -4859,6 +4859,7 @@ INTO OUTFILE '../tmp/out.innodb.db.file'
WHERE schema_name LIKE 'db_%'; WHERE schema_name LIKE 'db_%';
CREATE USER user_3212@localhost; CREATE USER user_3212@localhost;
GRANT ALL ON db_datadict.* TO 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); connect(localhost,user_3212,,db_datadict,MYSQL_PORT,MYSQL_SOCK);
user_3212@localhost db_datadict user_3212@localhost db_datadict
...@@ -4867,7 +4868,7 @@ INTO OUTFILE '../tmp/out.innodb.user.file' ...@@ -4867,7 +4868,7 @@ INTO OUTFILE '../tmp/out.innodb.user.file'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n' LINES TERMINATED BY '\n'
FROM schemata LIMIT 0, 5; 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 * SELECT *
FROM schemata LIMIT 0, 5; FROM schemata LIMIT 0, 5;
ERROR 42S02: Table 'db_datadict.schemata' doesn't exist ERROR 42S02: Table 'db_datadict.schemata' doesn't exist
......
...@@ -237,7 +237,7 @@ create table t1 (f1 integer) engine = innodb; ...@@ -237,7 +237,7 @@ create table t1 (f1 integer) engine = innodb;
use test; use test;
CREATE TRIGGER trig_db.trg6_2 AFTER INSERT on tb3 CREATE TRIGGER trig_db.trg6_2 AFTER INSERT on tb3
for each row set @ret_trg6_2 = 5; 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; use trig_db;
CREATE TRIGGER trg6_3 AFTER INSERT on test.tb3 CREATE TRIGGER trg6_3 AFTER INSERT on test.tb3
for each row set @ret_trg6_3 = 18; for each row set @ret_trg6_3 = 18;
......
...@@ -484,9 +484,8 @@ BEGIN ...@@ -484,9 +484,8 @@ BEGIN
WHILE @counter1 < new.f136 WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1; SET @counter1 = @counter1 + 1;
END// 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 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;
SET @counter1 = @counter1 + 1; END' at line 4
END' at line 3
delete from tb3 where f122='Test 3.5.8.5-while'; delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7; drop trigger trg7;
......
...@@ -194,7 +194,7 @@ a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000 ...@@ -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 Update tb3 Set f122='Test 3.5.9.4-trig', f136=NULL, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4'; where f122='Test 3.5.9.4';
Warnings: 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 select f118, f121, f122, f136, f151, f163 from tb3
where f122 like 'Test 3.5.9.4-trig'; where f122 like 'Test 3.5.9.4-trig';
f118 f121 f122 f136 f151 f163 f118 f121 f122 f136 f151 f163
......
...@@ -10202,7 +10202,8 @@ SHOW FIELDS FROM v1; ...@@ -10202,7 +10202,8 @@ SHOW FIELDS FROM v1;
ERROR 42S02: Table 'test.v1' doesn't exist ERROR 42S02: Table 'test.v1' doesn't exist
CHECK TABLE v1; CHECK TABLE v1;
Table Op Msg_type Msg_text 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; DESCRIBE v1;
ERROR 42S02: Table 'test.v1' doesn't exist ERROR 42S02: Table 'test.v1' doesn't exist
EXPLAIN SELECT * FROM v1; EXPLAIN SELECT * FROM v1;
......
...@@ -4842,6 +4842,7 @@ INTO OUTFILE '../tmp/out.memory.db.file' ...@@ -4842,6 +4842,7 @@ INTO OUTFILE '../tmp/out.memory.db.file'
WHERE schema_name LIKE 'db_%'; WHERE schema_name LIKE 'db_%';
CREATE USER user_3212@localhost; CREATE USER user_3212@localhost;
GRANT ALL ON db_datadict.* TO 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); connect(localhost,user_3212,,db_datadict,MYSQL_PORT,MYSQL_SOCK);
user_3212@localhost db_datadict user_3212@localhost db_datadict
...@@ -4850,7 +4851,7 @@ INTO OUTFILE '../tmp/out.memory.user.file' ...@@ -4850,7 +4851,7 @@ INTO OUTFILE '../tmp/out.memory.user.file'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n' LINES TERMINATED BY '\n'
FROM schemata LIMIT 0, 5; 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 * SELECT *
FROM schemata LIMIT 0, 5; FROM schemata LIMIT 0, 5;
ERROR 42S02: Table 'db_datadict.schemata' doesn't exist ERROR 42S02: Table 'db_datadict.schemata' doesn't exist
......
...@@ -233,7 +233,7 @@ create table t1 (f1 integer) engine = memory; ...@@ -233,7 +233,7 @@ create table t1 (f1 integer) engine = memory;
use test; use test;
CREATE TRIGGER trig_db.trg6_2 AFTER INSERT on tb3 CREATE TRIGGER trig_db.trg6_2 AFTER INSERT on tb3
for each row set @ret_trg6_2 = 5; 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; use trig_db;
CREATE TRIGGER trg6_3 AFTER INSERT on test.tb3 CREATE TRIGGER trg6_3 AFTER INSERT on test.tb3
for each row set @ret_trg6_3 = 18; for each row set @ret_trg6_3 = 18;
......
...@@ -480,9 +480,8 @@ BEGIN ...@@ -480,9 +480,8 @@ BEGIN
WHILE @counter1 < new.f136 WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1; SET @counter1 = @counter1 + 1;
END// 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 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;
SET @counter1 = @counter1 + 1; END' at line 4
END' at line 3
delete from tb3 where f122='Test 3.5.8.5-while'; delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7; drop trigger trg7;
......
...@@ -190,7 +190,7 @@ a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000 ...@@ -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 Update tb3 Set f122='Test 3.5.9.4-trig', f136=NULL, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4'; where f122='Test 3.5.9.4';
Warnings: 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 select f118, f121, f122, f136, f151, f163 from tb3
where f122 like 'Test 3.5.9.4-trig'; where f122 like 'Test 3.5.9.4-trig';
f118 f121 f122 f136 f151 f163 f118 f121 f122 f136 f151 f163
......
...@@ -10207,7 +10207,8 @@ SHOW FIELDS FROM v1; ...@@ -10207,7 +10207,8 @@ SHOW FIELDS FROM v1;
ERROR 42S02: Table 'test.v1' doesn't exist ERROR 42S02: Table 'test.v1' doesn't exist
CHECK TABLE v1; CHECK TABLE v1;
Table Op Msg_type Msg_text 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; DESCRIBE v1;
ERROR 42S02: Table 'test.v1' doesn't exist ERROR 42S02: Table 'test.v1' doesn't exist
EXPLAIN SELECT * FROM v1; EXPLAIN SELECT * FROM v1;
......
...@@ -4912,6 +4912,7 @@ INTO OUTFILE '../tmp/out.myisam.db.file' ...@@ -4912,6 +4912,7 @@ INTO OUTFILE '../tmp/out.myisam.db.file'
WHERE schema_name LIKE 'db_%'; WHERE schema_name LIKE 'db_%';
CREATE USER user_3212@localhost; CREATE USER user_3212@localhost;
GRANT ALL ON db_datadict.* TO 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); connect(localhost,user_3212,,db_datadict,MYSQL_PORT,MYSQL_SOCK);
user_3212@localhost db_datadict user_3212@localhost db_datadict
...@@ -4920,7 +4921,7 @@ INTO OUTFILE '../tmp/out.myisam.user.file' ...@@ -4920,7 +4921,7 @@ INTO OUTFILE '../tmp/out.myisam.user.file'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n' LINES TERMINATED BY '\n'
FROM schemata LIMIT 0, 5; 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 * SELECT *
FROM schemata LIMIT 0, 5; FROM schemata LIMIT 0, 5;
ERROR 42S02: Table 'db_datadict.schemata' doesn't exist ERROR 42S02: Table 'db_datadict.schemata' doesn't exist
......
...@@ -237,7 +237,7 @@ create table t1 (f1 integer) engine = myisam; ...@@ -237,7 +237,7 @@ create table t1 (f1 integer) engine = myisam;
use test; use test;
CREATE TRIGGER trig_db.trg6_2 AFTER INSERT on tb3 CREATE TRIGGER trig_db.trg6_2 AFTER INSERT on tb3
for each row set @ret_trg6_2 = 5; 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; use trig_db;
CREATE TRIGGER trg6_3 AFTER INSERT on test.tb3 CREATE TRIGGER trg6_3 AFTER INSERT on test.tb3
for each row set @ret_trg6_3 = 18; for each row set @ret_trg6_3 = 18;
......
...@@ -484,9 +484,8 @@ BEGIN ...@@ -484,9 +484,8 @@ BEGIN
WHILE @counter1 < new.f136 WHILE @counter1 < new.f136
SET @counter1 = @counter1 + 1; SET @counter1 = @counter1 + 1;
END// 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 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;
SET @counter1 = @counter1 + 1; END' at line 4
END' at line 3
delete from tb3 where f122='Test 3.5.8.5-while'; delete from tb3 where f122='Test 3.5.8.5-while';
drop trigger trg7; drop trigger trg7;
......
...@@ -194,7 +194,7 @@ a NULL Test 3.5.9.4 7 999 995.240000000000000000000000000000 ...@@ -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 Update tb3 Set f122='Test 3.5.9.4-trig', f136=NULL, f151=DEFAULT, f163=NULL
where f122='Test 3.5.9.4'; where f122='Test 3.5.9.4';
Warnings: 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 select f118, f121, f122, f136, f151, f163 from tb3
where f122 like 'Test 3.5.9.4-trig'; where f122 like 'Test 3.5.9.4-trig';
f118 f121 f122 f136 f151 f163 f118 f121 f122 f136 f151 f163
......
...@@ -265,7 +265,7 @@ let $message= Testcase 3.5.1.8:; ...@@ -265,7 +265,7 @@ let $message= Testcase 3.5.1.8:;
# Can't create a trigger in a different database # Can't create a trigger in a different database
use test; use test;
--error 1435 --error 1146
CREATE TRIGGER trig_db.trg6_2 AFTER INSERT on tb3 CREATE TRIGGER trig_db.trg6_2 AFTER INSERT on tb3
for each row set @ret_trg6_2 = 5; for each row set @ret_trg6_2 = 5;
......
...@@ -609,7 +609,8 @@ let $col_type= my_year; ...@@ -609,7 +609,8 @@ let $col_type= my_year;
# 1.1.6. CAST --> DECIMAL # 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; let $col_type= my_char_30;
--source suite/funcs_1/views/fv_cast.inc --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;
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 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 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;
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;
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;
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
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 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 < 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
3
1
2
4
SELECT k from t1 WHERE k >= half_t1();
k
6
7
9
5
8
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 * FROM t1 ORDER BY t1.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 3333 5 105
6 3333 6 106
7 3333 7 107
8 3333 8 108
9 3333 9 109
SELECT * FROM t2 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 4444 5 105
6 4444 6 106
7 4444 7 107
8 4444 8 108
9 4444 9 109
COMMIT;
connection root1;
ROLLBACK;
connection default;
SELECT * FROM t1 ORDER BY t1.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 3333 5 105
6 3333 6 106
7 3333 7 107
8 3333 8 108
9 3333 9 109
SELECT * FROM t2 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 4444 5 105
6 4444 6 106
7 4444 7 107
8 4444 8 108
9 4444 9 109
connection root1;
SELECT * FROM t1 ORDER BY t1.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 3333 5 105
6 3333 6 106
7 3333 7 107
8 3333 8 108
9 3333 9 109
SELECT * FROM t2 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 4444 5 105
6 4444 6 106
7 4444 7 107
8 4444 8 108
9 4444 9 109
connection default;
DROP VIEW IF EXISTS v1;
Warnings:
Note 1051 Unknown table 'test.v1'
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;
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
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 (200);
CALL fill_t2 (200);
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 200 Using where
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.k 1
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE;
i i
135 135
119 119
211 211
184 184
232 232
105 105
188 188
216 216
255 255
154 154
197 197
279 279
218 218
127 127
203 203
281 281
194 194
161 161
276 276
122 122
139 139
183 183
114 114
247 247
144 144
148 148
174 174
267 267
142 142
168 168
226 226
258 258
231 231
146 146
253 253
189 189
230 230
290 290
178 178
158 158
130 130
214 214
133 133
229 229
294 294
295 295
108 108
112 112
297 297
151 151
251 251
270 270
291 291
159 159
132 132
121 121
244 244
272 272
293 293
186 186
111 111
166 166
201 201
175 175
180 180
209 209
192 192
246 246
195 195
107 107
233 233
239 239
103 103
109 109
128 128
266 266
143 143
160 160
187 187
243 243
273 273
259 259
110 110
176 176
141 141
170 170
215 215
191 191
200 200
271 271
162 162
260 260
106 106
150 150
126 126
147 147
155 155
193 193
207 207
287 287
235 235
252 252
129 129
205 205
268 268
278 278
116 116
137 137
199 199
217 217
234 234
190 190
236 236
257 257
100 100
210 210
212 212
264 264
221 221
241 241
256 256
262 262
265 265
269 269
277 277
173 173
177 177
208 208
219 219
285 285
101 101
164 164
113 113
125 125
202 202
140 140
156 156
282 282
181 181
206 206
299 299
102 102
145 145
227 227
196 196
138 138
198 198
204 204
237 237
171 171
284 284
263 263
292 292
104 104
149 149
250 250
296 296
228 228
280 280
242 242
248 248
185 185
220 220
245 245
275 275
118 118
120 120
152 152
153 153
157 157
182 182
179 179
254 254
288 288
172 172
283 283
286 286
115 115
238 238
289 289
131 131
223 223
134 134
136 136
222 222
225 225
261 261
274 274
123 123
163 163
224 224
117 117
298 298
169 169
124 124
167 167
240 240
249 249
165 165
213 213
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
209 209
195 195
107 107
233 233
239 239
103 103
109 109
143 143
187 187
243 243
273 273
259 259
141 141
215 215
191 191
271 271
147 147
155 155
193 193
207 207
287 287
235 235
129 129
205 205
137 137
199 199
217 217
257 257
221 221
241 241
265 265
269 269
277 277
173 173
177 177
135 135
119 119
211 211
105 105
255 255
197 197
279 279
127 127
203 203
281 281
161 161
139 139
183 183
247 247
267 267
231 231
253 253
189 189
133 133
229 229
295 295
297 297
151 151
251 251
291 291
159 159
121 121
293 293
111 111
201 201
175 175
185 185
245 245
275 275
153 153
157 157
179 179
283 283
115 115
289 289
131 131
223 223
225 225
261 261
123 123
163 163
117 117
169 169
167 167
249 249
165 165
213 213
219 219
285 285
101 101
113 113
125 125
181 181
299 299
145 145
227 227
237 237
171 171
263 263
149 149
UPDATE t1,t2 SET t1.i=1111,t2.i=2222 WHERE t1.k % 2 = 1 AND t1.k = t2.k;
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;
CREATE INDEX ixi ON t1 (i);
CREATE TABLE t2 (k INT NOT NULL PRIMARY KEY, i INT, j INT, l INT) ENGINE=NDB;
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 (200);
CALL fill_t2 (200);
COMMIT;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
EXPLAIN SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 200 Using where
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.k 1
SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE;
i i
135 135
119 119
211 211
184 184
232 232
105 105
188 188
216 216
255 255
154 154
197 197
279 279
218 218
127 127
203 203
281 281
194 194
161 161
276 276
122 122
139 139
183 183
114 114
247 247
144 144
148 148
174 174
267 267
142 142
168 168
226 226
258 258
231 231
146 146
253 253
189 189
230 230
290 290
178 178
158 158
130 130
214 214
133 133
229 229
294 294
295 295
108 108
112 112
297 297
151 151
251 251
270 270
291 291
159 159
132 132
121 121
244 244
272 272
293 293
186 186
111 111
166 166
201 201
175 175
180 180
209 209
192 192
246 246
195 195
107 107
233 233
239 239
103 103
109 109
128 128
266 266
143 143
160 160
187 187
243 243
273 273
259 259
110 110
176 176
141 141
170 170
215 215
191 191
200 200
271 271
162 162
260 260
106 106
150 150
126 126
147 147
155 155
193 193
207 207
287 287
235 235
252 252
129 129
205 205
268 268
278 278
116 116
137 137
199 199
217 217
234 234
190 190
236 236
257 257
100 100
210 210
212 212
264 264
221 221
241 241
256 256
262 262
265 265
269 269
277 277
173 173
177 177
208 208
219 219
285 285
101 101
164 164
113 113
125 125
202 202
140 140
156 156
282 282
181 181
206 206
299 299
102 102
145 145
227 227
196 196
138 138
198 198
204 204
237 237
171 171
284 284
263 263
292 292
104 104
149 149
250 250
296 296
228 228
280 280
242 242
248 248
185 185
220 220
245 245
275 275
118 118
120 120
152 152
153 153
157 157
182 182
179 179
254 254
288 288
172 172
283 283
286 286
115 115
238 238
289 289
131 131
223 223
134 134
136 136
222 222
225 225
261 261
274 274
123 123
163 163
224 224
117 117
298 298
169 169
124 124
167 167
240 240
249 249
165 165
213 213
connection root1;
DELETE FROM t1 WHERE t1.k % 2 = 1;
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 range ixi ixi 5 NULL 10 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 * 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;
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;
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 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 v1 SET i=325 where i=125;
SELECT * FROM v1 ORDER BY i,l;
i l
123 123
123 124
123 125
123 126
124 123
124 124
124 125
124 126
126 123
126 124
126 125
126 126
325 123
325 124
325 125
325 126
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 325 3 125
4 126 4 126
connection default;
UPDATE v1 SET i=323 where i=123;
SELECT * FROM v1 ORDER BY i,l;
i l
124 123
124 124
124 125
124 126
125 123
125 124
125 125
125 126
126 123
126 124
126 125
126 126
323 123
323 124
323 125
323 126
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 323 1 123
2 124 2 124
3 125 3 125
4 126 4 126
connection root1;
UPDATE v1 SET i=326 where i=126;
SELECT * FROM v1 ORDER BY i,l;
i l
123 123
123 124
123 125
123 126
124 123
124 124
124 125
124 126
325 123
325 124
325 125
325 126
326 123
326 124
326 125
326 126
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 325 3 125
4 326 4 126
connection default;
UPDATE v1 SET i=324 where i=124;
SELECT * FROM v1 ORDER BY i,l;
i l
125 123
125 124
125 125
125 126
126 123
126 124
126 125
126 126
323 123
323 124
323 125
323 126
324 123
324 124
324 125
324 126
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 323 1 123
2 324 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 325 3 125
4 326 4 126
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
connection default;
DELETE FROM t1 WHERE t1.i=224;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 323 1 123
2 324 2 124
3 125 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 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 323 1 123
2 324 2 124
3 125 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 125 3 125
4 126 4 126
connection root1;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 323 1 123
2 324 2 124
3 125 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 125 3 125
4 126 4 126
connection default;
DROP VIEW IF EXISTS v1;
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);
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 v1 SET i=325 where i=125;
SELECT * FROM v1 ORDER BY i,l;
i l
123 123
123 124
123 125
123 126
124 123
124 124
124 125
124 126
126 123
126 124
126 125
126 126
325 123
325 124
325 125
325 126
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 325 3 125
4 126 4 126
connection default;
UPDATE v1 SET i=323 where i=123;
SELECT * FROM v1 ORDER BY i,l;
i l
124 123
124 124
124 125
124 126
125 123
125 124
125 125
125 126
126 123
126 124
126 125
126 126
323 123
323 124
323 125
323 126
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 323 1 123
2 124 2 124
3 125 3 125
4 126 4 126
connection root1;
UPDATE v1 SET i=326 where i=126;
SELECT * FROM v1 ORDER BY i,l;
i l
123 123
123 124
123 125
123 126
124 123
124 124
124 125
124 126
325 123
325 124
325 125
325 126
326 123
326 124
326 125
326 126
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 123 1 123
2 124 2 124
3 325 3 125
4 326 4 126
connection default;
UPDATE v1 SET i=324 where i=124;
SELECT * FROM v1 ORDER BY i,l;
i l
125 123
125 124
125 125
125 126
126 123
126 124
126 125
126 126
323 123
323 124
323 125
323 126
324 123
324 124
324 125
324 126
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 323 1 123
2 324 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 325 3 125
4 326 4 126
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
connection default;
DELETE FROM t1 WHERE t1.i=224;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 323 1 123
2 324 2 124
3 125 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 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 323 1 123
2 324 2 124
3 125 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 125 3 125
4 126 4 126
connection root1;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 323 1 123
2 324 2 124
3 125 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 125 3 125
4 126 4 126
connection default;
DROP VIEW IF EXISTS v1;
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);
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 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 v1 SET i=323 where i=123;
SELECT * FROM v1 ORDER BY i,l;
i l
124 123
124 124
124 125
124 126
125 123
125 124
125 125
125 126
126 123
126 124
126 125
126 126
323 123
323 124
323 125
323 126
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 323 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 v1 SET i=324 where i=124;
SELECT * FROM v1 ORDER BY i,l;
i l
125 123
125 124
125 125
125 126
126 123
126 124
126 125
126 126
323 123
323 124
323 125
323 126
324 123
324 124
324 125
324 126
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 323 1 123
2 324 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 323 1 123
2 324 2 124
3 125 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 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 323 1 123
2 324 2 124
3 125 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 125 3 125
4 126 4 126
connection root1;
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 323 1 123
2 324 2 124
3 125 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 125 3 125
4 126 4 126
connection default;
DROP VIEW IF EXISTS v1;
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);
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;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
DROP PROCEDURE IF EXISTS stp_t;
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=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);
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=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);
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 range ixi ixi 5 NULL 10 Using where
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
125
126
223
227
SELECT * FROM t1 ORDER BY t1.k;
k i j l
1 223 1 123
3 125 3 125
4 126 4 126
5 227 5 127
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 227 5 127
6 228 6 128
connection default;
DROP VIEW v1;
DROP PROCEDURE stp_t;
DROP TABLE t1, t2;
DROP TABLE IF EXISTS t1, t2;
DROP VIEW IF EXISTS v1;
DROP PROCEDURE IF EXISTS stp_t;
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=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);
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=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);
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);
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 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 range ixi ixi 5 NULL 10 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 * 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;
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 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;
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
Test plan:
Create 2 tables with a primary key and 3 integer columns. Both get the same rows (1,123,1,123),(2,124,2,124),(3,125,3,125),(4,126,4,126). The second and third column may get an index to have cases with, without and mutilple index. Create views on the tables. Create an update trigger. Create a stored procedure updating the table. Create a stored function updating the table and deliver the key as result.
The test isself consists of 2 sessions (transactions) running in "parallel" (same user "root") accessing and locking the same tables on basis of a row lock. Expected is that both sessions(transactions) can update the table successfully.
First session
execute an explain to every select and one of the following selects on the first half of table t1:
- select <non index columns> ... where ... for update;
- select <non index columns> ... where ... lock in share mode;
- select <indexed columns> ... where ... for update;
- select <indexed columns> ... where ... lock in share mode;
- select <indexed columns> ... ignore index ... where ... for update;
- select <indexed columns> ... ignore index ... where ... lock in share mode;
- select ... where (select...) ... for update;
- select ... where (select...) ... lock in share mode;
- (select ... where) union (select ... where) for update;
- (select ... where) union (select ... where) lock in...;
- select <view> ... where ... for update;
- select <view> ... where ... lock in ...;
- select <join> ... where ... for update;
- select <join> ... where ... lock in ...;
Then executes
- update
- delete
- trigger accessing table t1
- stored procedure accessing table t1
- stored function accessing table t1
Second session
executes the same on the last half of table t1
call of mysqld with option
--innodb_locks_unsafe_for_binlog
As the tests above work with small tables (<10 rows) there must be at least one test with a big table (>1000 rows) doing a table scan.
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
let $indext1= #CREATE INDEX ixi ON t1 (i);
let $indext2= #CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
let $indext1= #CREATE INDEX ixi ON t1 (i);
let $indext2= #CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $select= 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;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_big_tab.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $nbrows= 40;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_big_tab_1.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $nbrows= 40;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.k % 2= 0 AND t1.k = t2.k LOCK IN SHARE MODE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_big_tab_2.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_trig.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
let $indext1= #CREATE INDEX ixi ON t1 (i);
let $indext2= #CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_trig.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $select= SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view_mix.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
#let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
let $select= SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view_mix.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view_storedp.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
let $indext1= #CREATE INDEX ixi ON t1 (i);
let $indext2= #CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view_storedp.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view_trig.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_innodb.inc
SELECT @@global.innodb_table_locks into @table_locks;
SET @@global.innodb_table_locks= OFF;
let $engine= InnoDB;
let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
let $indext1= #CREATE INDEX ixi ON t1 (i);
let $indext2= #CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view_trig.inc
SET @@global.innodb_table_locks= @table_locks;
--source include/have_ndb.inc
let $engine= NDB;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock.inc
--source include/have_ndb.inc
let $engine= NDB;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
let $indext1= #CREATE INDEX ixi ON t1 (i);
let $indext2= #CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock.inc
--source include/have_ndb.inc
let $engine= NDB;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
let $indext1= #CREATE INDEX ixi ON t1 (i);
let $indext2= #CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock.inc
--source include/have_ndb.inc
let $engine= NDB;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i LOCK IN SHARE MODE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock.inc
--source include/have_ndb.inc
let $engine= NDB;
let $select= 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;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock.inc
--source include/have_ndb.inc
let $engine= NDB;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < half_t1() AND t2.i=t1.i LOCK IN SHARE MODE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_big_tab.inc
--source include/have_ndb.inc
let $engine= NDB;
let $nbrows= 200;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_big_tab_1.inc
--source include/have_ndb.inc
let $engine= NDB;
let $nbrows= 200;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i < t1.k % 2 = 0 AND t2.k=t1.k LOCK IN SHARE MODE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_big_tab_2.inc
--source include/have_ndb.inc
let $engine= NDB;
let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_trig.inc
--source include/have_ndb.inc
let $engine= NDB;
let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
let $indext1= #CREATE INDEX ixi ON t1 (i);
let $indext2= #CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_trig.inc
--source include/have_ndb.inc
let $engine= NDB;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view.inc
--source include/have_ndb.inc
let $engine= NDB;
let $select= SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view.inc
--source include/have_ndb.inc
let $engine= NDB;
let $select= SELECT t1.i,t2.i FROM t1,t2 WHERE t1.i<125 AND t2.i=t1.i FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view_mix.inc
--source include/have_ndb.inc
let $engine= NDB;
let $select= SELECT v1.i FROM v1 WHERE v1.i<125 FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view_mix.inc
--source include/have_ndb.inc
let $engine= NDB;
let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view_storedp.inc
--source include/have_ndb.inc
let $engine= NDB;
let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
let $indext1= #CREATE INDEX ixi ON t1 (i);
let $indext2= #CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view_storedp.inc
--source include/have_ndb.inc
let $engine= NDB;
let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
let $indext1= CREATE INDEX ixi ON t1 (i);
let $indext2= CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view_trig.inc
--source include/have_ndb.inc
let $engine= NDB;
let $select= SELECT t1.i FROM t1 WHERE t1.i< 125 FOR UPDATE;
let $indext1= #CREATE INDEX ixi ON t1 (i);
let $indext2= #CREATE INDEX ixi ON t2 (i);
--source suite/row_lock/include/row_lock_view_trig.inc
...@@ -318,7 +318,7 @@ if [ $BASE_SYSTEM != "netware" ] ; then ...@@ -318,7 +318,7 @@ if [ $BASE_SYSTEM != "netware" ] ; then
copyfileto $BASE/bin scripts/* copyfileto $BASE/bin scripts/*
$BASE/bin/replace \@localstatedir\@ ./data \@bindir\@ ./bin \@scriptdir\@ \ $BASE/bin/replace \@localstatedir\@ ./data \@bindir\@ ./bin \@scriptdir\@ \
./bin \@libexecdir\@ ./bin \@sbindir\@ ./bin \@prefix\@ . \@HOSTNAME\@ \ ./bin \@libexecdir\@ ./bin \@sbindir\@ ./bin \@prefix\@ . \@HOSTNAME\@ \
@HOSTNAME@ \@pkgdatadir\@ ./support-files \ @HOSTNAME@ \@pkgdatadir\@ ./share \
< scripts/mysql_install_db.sh > $BASE/scripts/mysql_install_db < scripts/mysql_install_db.sh > $BASE/scripts/mysql_install_db
$BASE/bin/replace \@prefix\@ /usr/local/mysql \@bindir\@ ./bin \ $BASE/bin/replace \@prefix\@ /usr/local/mysql \@bindir\@ ./bin \
\@sbindir\@ ./bin \@libexecdir\@ ./bin \ \@sbindir\@ ./bin \@libexecdir\@ ./bin \
......
...@@ -18,26 +18,68 @@ ...@@ -18,26 +18,68 @@
# #
# All unrecognized arguments to this script are passed to mysqld. # All unrecognized arguments to this script are passed to mysqld.
in_rpm=0 basedir=""
windows=0 ldata=""
srcdir=""
args=""
defaults="" defaults=""
mysqld_opt=""
user="" user=""
case "$1" in force=0
--no-defaults|--defaults-file=*|--defaults-extra-file=*) in_rpm=0
defaults="$1"; shift ip_only=0
;; windows=0
esac
usage()
{
cat <<EOF
Usage: $0 [OPTIONS]
--basedir=path The path to the MySQL installation directory.
--datadir=path The path to the MySQL data directory.
--force Causes mysql_install_db to run even if DNS does not
work. In that case, grant table entries that normally
use hostnames will use IP addresses.
--ldata=path The path to the MySQL data directory.
--rpm For internal use. This option is used by RPM files
during the MySQL installation process.
--skip-name-resolve Use IP addresses rather than hostnames when creating
grant table entries. This option can be useful if
your DNS does not work.
--srcdir=path For internal use. The directory under which
mysql_install_db looks for support files such as the
error message file and the file for popoulating the
help tables.
--user=user_name The login username to use for running mysqld. Files
and directories created by mysqld will be owned by this
user. You must be root to use this option. By default
mysqld runs using your current login name and files and
directories that it creates will be owned by you.
--windows For internal use. This option is used for creating
Windows distributions.
All other options are passed to the mysqld program
EOF
exit 1
}
s_echo() s_echo()
{ {
if test "$in_rpm" -eq 0 -a "$windows" -eq 0 if test "$in_rpm" -eq 0 -a "$windows" -eq 0
then then
echo $1 echo "$1"
fi fi
} }
parse_arguments() { parse_arg()
{
echo "$1" | sed -e 's/^[^=]*=//'
}
parse_arguments()
{
# We only need to pass arguments through to the server if we don't # We only need to pass arguments through to the server if we don't
# handle them here. So, we collect unrecognized options (passed on # handle them here. So, we collect unrecognized options (passed on
# the command line) into the args variable. # the command line) into the args variable.
...@@ -48,20 +90,24 @@ parse_arguments() { ...@@ -48,20 +90,24 @@ parse_arguments() {
shift shift
fi fi
for arg do for arg
do
case "$arg" in case "$arg" in
--force) force=1 ;; --force) force=1 ;;
--basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --basedir=*) basedir=`parse_arg "$arg"` ;;
--srcdir=*) srcdir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --srcdir=*) srcdir=`parse_arg "$arg"` ;;
--ldata=*|--datadir=*) ldata=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --ldata=*|--datadir=*) ldata=`parse_arg "$arg"` ;;
--user=*) --user=*)
# Note that the user will be passed to mysqld so that it runs # Note that the user will be passed to mysqld so that it runs
# as 'user' (crucial e.g. if log-bin=/some_other_path/ # as 'user' (crucial e.g. if log-bin=/some_other_path/
# where a chown of datadir won't help) # where a chown of datadir won't help)
user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; user=`parse_arg "$arg"` ;;
--skip-name-resolve) ip_only=1 ;; --skip-name-resolve) ip_only=1 ;;
--verbose) verbose=1 ;; # Obsolete --verbose) verbose=1 ;; # Obsolete
--rpm) in_rpm=1 ;; --rpm) in_rpm=1 ;;
--help) usage ;;
--no-defaults|--defaults-file=*|--defaults-extra-file=*)
defaults="$arg" ;;
--windows) --windows)
# This is actually a "cross bootstrap" argument used when # This is actually a "cross bootstrap" argument used when
...@@ -89,137 +135,152 @@ parse_arguments() { ...@@ -89,137 +135,152 @@ parse_arguments() {
done done
} }
# Get first arguments from the my.cfg file, groups [mysqld] and # Try to find a specific file within --basedir which can either be a binary
# [mysql_install_db], and then merge with the command line arguments # release or installed source directory and return the path.
if test -x ./bin/my_print_defaults find_in_basedir()
then {
print_defaults="./bin/my_print_defaults" case "$1" in
elif test -x ./extra/my_print_defaults --dir)
then return_dir=1; shift
print_defaults="./extra/my_print_defaults" ;;
elif test -x @bindir@/my_print_defaults esac
then
print_defaults="@bindir@/my_print_defaults"
elif test -x @bindir@/mysql_print_defaults
then
print_defaults="@bindir@/mysql_print_defaults"
else
print_defaults="my_print_defaults"
fi
args= file=$1; shift
ldata=
execdir=
bindir=
basedir=
srcdir=
force=0
parse_arguments `$print_defaults $defaults mysqld mysql_install_db` for dir in "$@"
do
if test -f "$basedir/$dir/$file"
then
if test -n "$return_dir"
then
echo "$basedir/$dir"
else
echo "$basedir/$dir/$file"
fi
break
fi
done
}
missing_in_basedir()
{
echo "FATAL ERROR: Could not find $* inside --basedir"
echo
echo "When using --basedir you must point either into a MySQL binary"
echo "distribution directory or a compiled tree previously populated"
echo "by 'make install'"
}
# Ok, let's go. We first need to parse arguments which are required by
# my_print_defaults so that we can execute it first, then later re-parse
# the command line to add any extra bits that we need.
parse_arguments PICK-ARGS-FROM-ARGV "$@" parse_arguments PICK-ARGS-FROM-ARGV "$@"
test -z "$ldata" && ldata=@localstatedir@ # We can now find my_print_defaults, either in the supplied --basedir
if test -z "$basedir" # location or in the installed area.
if test -n "$basedir"
then then
basedir=@prefix@ print_defaults=`find_in_basedir my_print_defaults bin extra`
bindir=@bindir@ if ! test -x "$print_defaults"
execdir=@libexecdir@
pkgdatadir=@pkgdatadir@
else
bindir="$basedir/bin"
if test -x "$basedir/libexec/mysqld"
then then
execdir="$basedir/libexec" missing_in_basedir my_print_defaults
elif test -x "$basedir/sbin/mysqld" exit 1
fi
else
print_defaults="@bindir@/my_print_defaults"
if ! test -x "$print_defaults"
then then
execdir="$basedir/sbin" echo "FATAL ERROR: Could not find $print_defaults"
else echo
execdir="$basedir/bin" echo "If you are using a binary release, you must run this script from"
echo "within the directory the archive extracted into. If you compiled"
echo "MySQL yourself you must run 'make install' first."
exit 1
fi fi
fi fi
# Find SQL scripts needed for bootstrap # Now we can get arguments from the groups [mysqld] and [mysql_install_db]
fill_help_tables="fill_help_tables.sql" # in the my.cfg file, then re-run to merge with command line arguments.
create_system_tables="mysql_system_tables.sql" parse_arguments `$print_defaults $defaults mysqld mysql_install_db`
fill_system_tables="mysql_system_tables_data.sql" parse_arguments PICK-ARGS-FROM-ARGV "$@"
if test -n "$srcdir"
# Path to MySQL installation directory
if test -z "$basedir"
then then
fill_help_tables=$srcdir/scripts/$fill_help_tables basedir="@prefix@"
create_system_tables=$srcdir/scripts/$create_system_tables bindir="@bindir@"
fill_system_tables=$srcdir/scripts/$fill_system_tables mysqld="@libexecdir@/mysqld"
pkgdatadir="@pkgdatadir@"
else else
for i in $basedir/support-files $basedir/share $basedir/share/mysql \ bindir="$basedir/bin"
$basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@ # We set up bootstrap-specific paths later, so skip this for --windows
do if test "$windows" -eq 0
if test -f $i/$fill_help_tables then
pkgdatadir=`find_in_basedir --dir fill_help_tables.sql share share/mysql`
if test -z "$pkgdatadir"
then then
pkgdatadir=$i missing_in_basedir fill_help_tables.sql
break exit 1
fi fi
done mysqld=`find_in_basedir mysqld libexec sbin bin`
if ! test -x "$mysqld"
fill_help_tables=$pkgdatadir/$fill_help_tables then
create_system_tables=$pkgdatadir/$create_system_tables missing_in_basedir mysqld
fill_system_tables=$pkgdatadir/$fill_system_tables exit 1
fi
fi
fi fi
if test ! -f $create_system_tables # Path to data directory
if test -z "$ldata"
then then
echo "FATAL ERROR: Could not find SQL file '$create_system_tables' in" ldata="@localstatedir@"
echo "@pkgdatadir@ or inside $basedir"
exit 1;
fi fi
if test ! -f $fill_help_tables # Set up paths to SQL scripts required for bootstrap and ensure they exist.
if test -n "$srcdir"
then then
echo "FATAL ERROR: Could not find help file '$fill_help_tables' in" pkgdatadir="$srcdir/scripts"
echo "@pkgdatadir@ or inside $basedir"
exit 1;
fi fi
if test ! -f $fill_system_tables fill_help_tables="$pkgdatadir/fill_help_tables.sql"
then create_system_tables="$pkgdatadir/mysql_system_tables.sql"
echo "FATAL ERROR: Could not find help file '$fill_system_tables' in" fill_system_tables="$pkgdatadir/mysql_system_tables_data.sql"
echo "@pkgdatadir@ or inside $basedir"
exit 1;
fi
# Find executables and paths for f in $fill_help_tables $create_system_tables $fill_system_tables
mysqld=$execdir/mysqld do
mysqld_opt="" if test ! -f "$f"
scriptdir=$bindir then
echo "FATAL ERROR: Could not find SQL file '$f'"
exit 1
fi
done
if test "$windows" = 1 # Set up Windows-specific paths
if test "$windows" -eq 1
then then
mysqld="./sql/mysqld" mysqld="./sql/mysqld"
if test -n "$srcdir" -a -f $srcdir/sql/share/english/errmsg.sys if test -n "$srcdir" -a -f "$srcdir/sql/share/english/errmsg.sys"
then then
langdir=$srcdir/sql/share/english mysqld_opt="--language=$srcdir/sql/share/english"
else else
langdir=./sql/share/english mysqld_opt="--language=./sql/share/english"
fi fi
mysqld_opt="--language=$langdir"
scriptdir="./scripts"
fi fi
if test ! -x $mysqld # Make sure mysqld is available in default location (--basedir option is
# already tested above).
if test ! -x "$mysqld"
then then
if test "$in_rpm" = 1 echo "FATAL ERROR: $mysqld not found!"
then exit 1
echo "FATAL ERROR $mysqld not found!"
exit 1
else
echo "FATAL ERROR Didn't find $mysqld"
echo "You should do a 'make install' before executing this script"
exit 1
fi
fi fi
# Try to determine the hostname # Try to determine the hostname
hostname=`@HOSTNAME@` hostname=`@HOSTNAME@`
# Check if hostname is valid # Check if hostname is valid
if test "$windows" = 0 -a "$in_rpm" = 0 -a $force = 0 if test "$windows" -eq 0 -a "$in_rpm" -eq 0 -a "$force" -eq 0
then then
resolved=`$bindir/resolveip $hostname 2>&1` resolved=`$bindir/resolveip $hostname 2>&1`
if [ $? -ne 0 ] if [ $? -ne 0 ]
...@@ -244,39 +305,35 @@ then ...@@ -244,39 +305,35 @@ then
fi fi
fi fi
if test "$ip_only" = "1" if test "$ip_only" -eq 1
then then
ip=`echo "$resolved" | awk '/ /{print $6}'` hostname=`echo "$resolved" | awk '/ /{print $6}'`
hostname=$ip
fi fi
# Create database directories mysql & test # Create database directories mysql & test
if test ! -d $ldata; then for dir in $ldata $ldata/mysql $ldata/test
mkdir $ldata; do
chmod 700 $ldata ; if test ! -d $dir
fi then
if test ! -d $ldata/mysql; then mkdir -p $dir
mkdir $ldata/mysql; chmod 700 $dir
chmod 700 $ldata/mysql ; fi
fi if test -w / -a ! -z "$user"
if test ! -d $ldata/test; then then
mkdir $ldata/test; chown $user $dir
chmod 700 $ldata/test ; fi
fi done
if test -w / -a ! -z "$user"; then
chown $user $ldata $ldata/mysql $ldata/test;
fi
if test -n "$user"; then if test -n "$user"
then
args="$args --user=$user" args="$args --user=$user"
fi fi
# Peform the install of system tables # Peform the install of system tables
mysqld_bootstrap="${MYSQLD_BOOTSTRAP-$mysqld}" mysqld_bootstrap="${MYSQLD_BOOTSTRAP-$mysqld}"
mysqld_install_cmd_line="$mysqld_bootstrap $defaults $mysqld_opt --bootstrap \ mysqld_install_cmd_line="$mysqld_bootstrap $defaults $mysqld_opt --bootstrap \
--basedir=$basedir --datadir=$ldata --skip-innodb \ --basedir=$basedir --datadir=$ldata --skip-innodb --skip-bdb \
--skip-bdb --skip-ndbcluster $args --max_allowed_packet=8M \ --skip-ndbcluster $args --max_allowed_packet=8M --net_buffer_length=16K"
--net_buffer_length=16K"
# Pipe mysql_system_tables.sql to "mysqld --bootstrap" # Pipe mysql_system_tables.sql to "mysqld --bootstrap"
s_echo "Installing MySQL system tables..." s_echo "Installing MySQL system tables..."
...@@ -284,23 +341,20 @@ if `(echo "use mysql;"; cat $create_system_tables $fill_system_tables) | $mysqld ...@@ -284,23 +341,20 @@ if `(echo "use mysql;"; cat $create_system_tables $fill_system_tables) | $mysqld
then then
s_echo "OK" s_echo "OK"
if test -n "$fill_help_tables" s_echo "Filling help tables..."
# Pipe fill_help_tables.sql to "mysqld --bootstrap"
if `(echo "use mysql;"; cat $fill_help_tables) | $mysqld_install_cmd_line`
then then
s_echo "Filling help tables..." # Fill suceeded
# Pipe fill_help_tables.sql to "mysqld --bootstrap" s_echo "OK"
if `(echo "use mysql;"; cat $fill_help_tables) | $mysqld_install_cmd_line` else
then echo
# Fill suceeded echo "WARNING: HELP FILES ARE NOT COMPLETELY INSTALLED!"
s_echo "OK" echo "The \"HELP\" command might not work properly"
else echo
echo ""
echo "WARNING: HELP FILES ARE NOT COMPLETELY INSTALLED!"
echo "The \"HELP\" command might not work properly"
echo ""
fi
fi fi
s_echo "" s_echo
s_echo "To start mysqld at boot time you have to copy" s_echo "To start mysqld at boot time you have to copy"
s_echo "support-files/mysql.server to the right place for your system" s_echo "support-files/mysql.server to the right place for your system"
s_echo s_echo
...@@ -319,7 +373,7 @@ then ...@@ -319,7 +373,7 @@ then
echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'" echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'"
echo "See the manual for more instructions." echo "See the manual for more instructions."
if test "$in_rpm" = "0" if test "$in_rpm" -eq 0
then then
echo "You can start the MySQL daemon with:" echo "You can start the MySQL daemon with:"
echo "cd @prefix@ ; $bindir/mysqld_safe &" echo "cd @prefix@ ; $bindir/mysqld_safe &"
......
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