Commit df09ddac authored by Patrick Crews's avatar Patrick Crews

Bug#40178: Test main.completion_type_func does not clean up / needs to be rewritten

Revised the test to include a test of completion_type = 1 as well as making the test more readable / worthwhile
Removed the master.opt file as it was redundant / unnecessary.

mysql-test/suite/sys_vars/t/completion_type_func-master.opt:
  Removed as redundant.  Test uses include/have_innodb.inc.
parent 87fcb23d
...@@ -2,76 +2,187 @@ DROP TABLE IF EXISTS t1; ...@@ -2,76 +2,187 @@ DROP TABLE IF EXISTS t1;
## Creating new table ## ## Creating new table ##
CREATE TABLE t1 CREATE TABLE t1
( (
id INT NOT NULL AUTO_INCREMENT, id INT NOT NULL,
PRIMARY KEY (id), PRIMARY KEY (id),
name VARCHAR(30) name VARCHAR(30)
) ENGINE = INNODB; ) ENGINE = INNODB;
'#--------------------FN_DYNVARS_017_01-------------------------#' ## Creating new connections test_con1, test_con2 ##
## Creating new connection ## #########################################################
INSERT INTO t1(name) VALUES('Record_1'); # Setting initial value of completion_type to zero #
SET @@autocommit = 0; #########################################################
INSERT INTO t1 VALUES(1,'Record_1');
SELECT * FROM t1; SELECT * FROM t1;
id name id name
1 Record_1 1 Record_1
## Setting value of variable to 0 ## ## Setting value of variable to 0 ##
SET @@session.completion_type = 0; SET @@session.completion_type = 0;
## Here commit & rollback should work normally ## ## Here commit & rollback should work normally ##
## test commit ##
START TRANSACTION; START TRANSACTION;
INSERT INTO t1 VALUES(2,'Record_2');
INSERT INTO t1 VALUES(3,'Record_3');
SELECT * FROM t1; SELECT * FROM t1;
id name id name
1 Record_1 1 Record_1
INSERT INTO t1(name) VALUES('Record_2'); 2 Record_2
INSERT INTO t1(name) VALUES('Record_3'); 3 Record_3
Switching to connection test_con1
## Don't expect to see id's 2 and 3 in the table w/o COMMIT ##
SELECT * FROM t1;
id name
1 Record_1
Switching to default connection
COMMIT;
## test rollback ##
START TRANSACTION;
INSERT INTO t1 VALUES(4,'Record_4');
INSERT INTO t1 VALUES(5,'Record_5');
SELECT * FROM t1;
id name
1 Record_1
2 Record_2
3 Record_3
4 Record_4
5 Record_5
Switching to connection test_con1
## Don't expect to see id's 4 and 5 here ##
## Expect to see 3, Record_3 ##
SELECT * FROM t1; SELECT * FROM t1;
id name id name
1 Record_1 1 Record_1
2 Record_2 2 Record_2
3 Record_3 3 Record_3
DELETE FROM t1 WHERE id = 2; Switching to connection default;
ROLLBACK;
## Don't expect to see id's 4 and 5 now ##
SELECT * FROM t1; SELECT * FROM t1;
id name id name
1 Record_1 1 Record_1
2 Record_2
3 Record_3 3 Record_3
#########################################################
# Setting initial value of completion_type to one #
#########################################################
Switching to connection test_con1;
SET @@session.completion_type = 1;
START TRANSACTION; START TRANSACTION;
SELECT * FROM t1; SELECT * FROM t1;
id name id name
1 Record_1 1 Record_1
2 Record_2
3 Record_3 3 Record_3
INSERT INTO t1(name) VALUES('Record_4'); INSERT INTO t1 VALUES(6,'Record_6');
INSERT INTO t1(name) VALUES('Record_5'); INSERT INTO t1 VALUES(7,'Record_7');
COMMIT; COMMIT;
'#--------------------FN_DYNVARS_017_02-------------------------#' ## Expect to immediately have a new transaction ##
INSERT INTO t1 VALUES(8,'Record_8');
SELECT * FROM t1;
id name
1 Record_1
2 Record_2
3 Record_3
6 Record_6
7 Record_7
8 Record_8
switching to test_con2
## Do not expect to see 8, Record_8 as no COMMIT has occurred ##
SELECT * FROM t1;
id name
1 Record_1
2 Record_2
3 Record_3
6 Record_6
7 Record_7
switch to connection test_con1
## Testing ROLLBACK behavior
START TRANSACTION;
INSERT INTO t1 VALUES(9, 'Record_9');
INSERT INTO t1 VALUES(10, 'Record_10');
## Expect to see id's 8, 9, 10 here ##
## 8, Record_8 COMMITted with the start of this transaction ##
SELECT * FROM t1;
id name
1 Record_1
2 Record_2
3 Record_3
6 Record_6
7 Record_7
8 Record_8
9 Record_9
10 Record_10
ROLLBACK;
## id's 9 and 10 are gone now due to ROLLBACK ##
SELECT * FROM t1;
id name
1 Record_1
2 Record_2
3 Record_3
6 Record_6
7 Record_7
8 Record_8
## Expect a new transaction ##
INSERT INTO t1 VALUES(9, 'Record_9');
Switching to connection test_con2
## Don't expect to see 9, Record_9 due to no COMMIT yet ##
SELECT * FROM t1;
id name
1 Record_1
2 Record_2
3 Record_3
6 Record_6
7 Record_7
8 Record_8
Switching to connection test_con1
ROLLBACK;
## Don't expect to see 9, Record_9
SELECT * FROM t1;
id name
1 Record_1
2 Record_2
3 Record_3
6 Record_6
7 Record_7
8 Record_8
#########################################################
# Setting initial value of completion_type to 2 #
#########################################################
SET @@session.completion_type = 2; SET @@session.completion_type = 2;
## Here commit should work as COMMIT RELEASE ## ## Here commit should work as COMMIT RELEASE ##
START TRANSACTION; START TRANSACTION;
SELECT * FROM t1; SELECT * FROM t1;
id name id name
1 Record_1 1 Record_1
2 Record_2
3 Record_3 3 Record_3
4 Record_4 6 Record_6
5 Record_5 7 Record_7
INSERT INTO t1(name) VALUES('Record_6'); 8 Record_8
INSERT INTO t1(name) VALUES('Record_7'); INSERT INTO t1 VALUES(9,'Record_9');
INSERT INTO t1 VALUES(10,'Record_10');
COMMIT; COMMIT;
## Inserting rows should give error here because connection should ## ## Inserting rows should give error here because connection should ##
## disconnect after using COMMIT ## ## disconnect after using COMMIT ##
INSERT INTO t1(name) VALUES('Record_4'); INSERT INTO t1 VALUES(4,'Record_4');
Got one of the listed errors Got one of the listed errors
## Creating new connection test_con2 ## switch to connection test_con2
SET @@session.completion_type = 2; SET @@session.completion_type = 2;
## Inserting rows and using Rollback which should Rollback & release ## ## Inserting rows and using Rollback which should Rollback & release ##
START TRANSACTION; START TRANSACTION;
SELECT * FROM t1; SELECT * FROM t1;
id name id name
1 Record_1 1 Record_1
2 Record_2
3 Record_3 3 Record_3
4 Record_4
5 Record_5
6 Record_6 6 Record_6
7 Record_7 7 Record_7
INSERT INTO t1(name) VALUES('Record_8'); 8 Record_8
INSERT INTO t1(name) VALUES('Record_9'); 9 Record_9
10 Record_10
INSERT INTO t1 VALUES(11,'Record_11');
INSERT INTO t1 VALUES(12,'Record_12');
ROLLBACK; ROLLBACK;
INSERT INTO t1(name) VALUES('Record_4'); ## Expect a failure due to COMMIT/ROLLBACK AND RELEASE behavior ##
INSERT INTO t1 VALUES(4,'Record_4');
Got one of the listed errors Got one of the listed errors
DROP TABLE t1; DROP TABLE t1;
############## mysql-test\t\completion_type_func.test ########################## ############## mysql-test/suite/sys_vars/t/completion_type_func.test ###########
# # # #
# Variable Name: completion_type # # Variable Name: completion_type #
# Scope: GLOBAL & SESSION # # Scope: GLOBAL & SESSION #
...@@ -25,84 +25,154 @@ ...@@ -25,84 +25,154 @@
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
--enable_warnings --enable_warnings
######################### ##############################
# Creating new table # # Setup: Table + connections #
######################### ##############################
--echo ## Creating new table ## --echo ## Creating new table ##
CREATE TABLE t1 CREATE TABLE t1
( (
id INT NOT NULL AUTO_INCREMENT, id INT NOT NULL,
PRIMARY KEY (id), PRIMARY KEY (id),
name VARCHAR(30) name VARCHAR(30)
) ENGINE = INNODB; ) ENGINE = INNODB;
--echo '#--------------------FN_DYNVARS_017_01-------------------------#' --echo ## Creating new connections test_con1, test_con2 ##
#########################################################
# Setting initial value of completion_type to zero #
#########################################################
--echo ## Creating new connection ##
connect (test_con1,localhost,root,,); connect (test_con1,localhost,root,,);
connection test_con1; connect (test_con2,localhost,root,,);
connection default;
--echo #########################################################
--echo # Setting initial value of completion_type to zero #
--echo #########################################################
INSERT INTO t1(name) VALUES('Record_1'); INSERT INTO t1 VALUES(1,'Record_1');
SET @@autocommit = 0;
SELECT * FROM t1; SELECT * FROM t1;
--echo ## Setting value of variable to 0 ## --echo ## Setting value of variable to 0 ##
SET @@session.completion_type = 0; SET @@session.completion_type = 0;
--echo ## Here commit & rollback should work normally ## --echo ## Here commit & rollback should work normally ##
--echo ## test commit ##
START TRANSACTION;
INSERT INTO t1 VALUES(2,'Record_2');
INSERT INTO t1 VALUES(3,'Record_3');
SELECT * FROM t1;
--echo Switching to connection test_con1
connection test_con1;
--echo ## Don't expect to see id's 2 and 3 in the table w/o COMMIT ##
SELECT * FROM t1;
--echo Switching to default connection
connection default;
COMMIT;
--echo ## test rollback ##
START TRANSACTION; START TRANSACTION;
INSERT INTO t1 VALUES(4,'Record_4');
INSERT INTO t1 VALUES(5,'Record_5');
SELECT * FROM t1; SELECT * FROM t1;
INSERT INTO t1(name) VALUES('Record_2');
INSERT INTO t1(name) VALUES('Record_3'); --echo Switching to connection test_con1
connection test_con1;
--echo ## Don't expect to see id's 4 and 5 here ##
--echo ## Expect to see 3, Record_3 ##
SELECT * FROM t1; SELECT * FROM t1;
DELETE FROM t1 WHERE id = 2;
--echo Switching to connection default;
connection default;
ROLLBACK;
--echo ## Don't expect to see id's 4 and 5 now ##
SELECT * FROM t1; SELECT * FROM t1;
--echo
--echo #########################################################
--echo # Setting initial value of completion_type to one #
--echo #########################################################
--echo Switching to connection test_con1;
connection test_con1;
SET @@session.completion_type = 1;
START TRANSACTION; START TRANSACTION;
SELECT * FROM t1; SELECT * FROM t1;
INSERT INTO t1(name) VALUES('Record_4'); INSERT INTO t1 VALUES(6,'Record_6');
INSERT INTO t1(name) VALUES('Record_5'); INSERT INTO t1 VALUES(7,'Record_7');
COMMIT; COMMIT;
--echo ## Expect to immediately have a new transaction ##
INSERT INTO t1 VALUES(8,'Record_8');
SELECT * FROM t1;
connection test_con2;
--echo switching to test_con2
--echo ## Do not expect to see 8, Record_8 as no COMMIT has occurred ##
SELECT * FROM t1;
--echo switch to connection test_con1
connection test_con1;
--echo ## Testing ROLLBACK behavior
START TRANSACTION;
INSERT INTO t1 VALUES(9, 'Record_9');
INSERT INTO t1 VALUES(10, 'Record_10');
--echo ## Expect to see id's 8, 9, 10 here ##
--echo ## 8, Record_8 COMMITted with the start of this transaction ##
SELECT * FROM t1;
ROLLBACK;
--echo ## id's 9 and 10 are gone now due to ROLLBACK ##
SELECT * FROM t1;
--echo ## Expect a new transaction ##
INSERT INTO t1 VALUES(9, 'Record_9');
--echo '#--------------------FN_DYNVARS_017_02-------------------------#' --echo Switching to connection test_con2
######################################################### connection test_con2;
# Setting initial value of completion_type to 2 # --echo ## Don't expect to see 9, Record_9 due to no COMMIT yet ##
######################################################### SELECT * FROM t1;
--echo Switching to connection test_con1
connection test_con1;
ROLLBACK;
--echo ## Don't expect to see 9, Record_9
SELECT * FROM t1;
--echo #########################################################
--echo # Setting initial value of completion_type to 2 #
--echo #########################################################
SET @@session.completion_type = 2; SET @@session.completion_type = 2;
--echo ## Here commit should work as COMMIT RELEASE ## --echo ## Here commit should work as COMMIT RELEASE ##
START TRANSACTION; START TRANSACTION;
SELECT * FROM t1; SELECT * FROM t1;
INSERT INTO t1(name) VALUES('Record_6'); INSERT INTO t1 VALUES(9,'Record_9');
INSERT INTO t1(name) VALUES('Record_7'); INSERT INTO t1 VALUES(10,'Record_10');
COMMIT; COMMIT;
--echo ## Inserting rows should give error here because connection should ## --echo ## Inserting rows should give error here because connection should ##
--echo ## disconnect after using COMMIT ## --echo ## disconnect after using COMMIT ##
--Error 2006,2013,1053 --Error 2006,2013,ER_SERVER_SHUTDOWN
INSERT INTO t1(name) VALUES('Record_4'); INSERT INTO t1 VALUES(4,'Record_4');
--echo ## Creating new connection test_con2 ## --echo switch to connection test_con2
connect (test_con2,localhost,root,,);
connection test_con2; connection test_con2;
SET @@session.completion_type = 2; SET @@session.completion_type = 2;
--echo ## Inserting rows and using Rollback which should Rollback & release ## --echo ## Inserting rows and using Rollback which should Rollback & release ##
START TRANSACTION; START TRANSACTION;
SELECT * FROM t1; SELECT * FROM t1;
INSERT INTO t1(name) VALUES('Record_8'); INSERT INTO t1 VALUES(11,'Record_11');
INSERT INTO t1(name) VALUES('Record_9'); INSERT INTO t1 VALUES(12,'Record_12');
ROLLBACK; ROLLBACK;
--Error 2006,2013,1053 --echo ## Expect a failure due to COMMIT/ROLLBACK AND RELEASE behavior ##
INSERT INTO t1(name) VALUES('Record_4'); --Error 2006,2013,ER_SERVER_SHUTDOWN,
INSERT INTO t1 VALUES(4,'Record_4');
connection default; connection default;
disconnect test_con1; disconnect test_con1;
......
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