mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
414 lines
9.1 KiB
Text
414 lines
9.1 KiB
Text
############# mysql-test\t\tx_isolation_func.test #######################################
|
|
# #
|
|
# Variable Name: tx_isolation #
|
|
# Scope: GLOBAL & SESSION #
|
|
# Access Type: Dynamic #
|
|
# Data Type: ENUMERATION #
|
|
# Default Value: REPEATABLE-READ #
|
|
# Values: READ-UNCOMMITTED, READ-COMMITTED, REPEATABLE-READ, SERIALIZABLE #
|
|
# #
|
|
# #
|
|
# Creation Date: 2008-02-25 #
|
|
# Author: Sharique Abdullah #
|
|
# #
|
|
# Description: Test Cases of Dynamic System Variable "tx_isolation" #
|
|
# that checks behavior of this variable in the following ways #
|
|
# * Functionality based on different values #
|
|
# #
|
|
# Reference: http://dev.mysql.com/doc/refman/5.1/en/set-option.html #
|
|
# #
|
|
#########################################################################################
|
|
|
|
--source include/have_innodb.inc
|
|
|
|
--echo ** Setup **
|
|
#
|
|
# Setup
|
|
#
|
|
|
|
SET @session_tx_isolation = @@SESSION.tx_isolation;
|
|
SET @global_tx_isolation = @@GLOBAL.tx_isolation;
|
|
|
|
#
|
|
# Creating connections
|
|
#
|
|
|
|
--echo ** Connecting con0 using root **
|
|
connect (con0,localhost,root,,);
|
|
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
|
|
SET SESSION AUTOCOMMIT = OFF;
|
|
|
|
--echo ** Connecting con1 using root **
|
|
connect (con1, localhost, root,,);
|
|
|
|
--echo ** Connection con1 **
|
|
connection con1;
|
|
|
|
SET SESSION AUTOCOMMIT = OFF;
|
|
|
|
--echo ** Connection default **
|
|
connection default;
|
|
|
|
#
|
|
# Creating tables
|
|
#
|
|
|
|
CREATE TABLE t1 (a int PRIMARY KEY, b int) ENGINE=INNODB;
|
|
|
|
INSERT INTO t1 VALUES(2, 2);
|
|
INSERT INTO t1 VALUES(4, 4);
|
|
INSERT INTO t1 VALUES(6, 6);
|
|
INSERT INTO t1 VALUES(8, 8);
|
|
INSERT INTO t1 VALUES(16, 16);
|
|
INSERT INTO t1 VALUES(18, 18);
|
|
INSERT INTO t1 VALUES(20, 20);
|
|
INSERT INTO t1 VALUES(22, 22);
|
|
INSERT INTO t1 VALUES(24, 24);
|
|
|
|
--echo '#----------------------------FN_DYNVARS_184_01--------------------------------------#'
|
|
#
|
|
# Testing for value READ-UNCOMMITTED
|
|
#
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
SET SESSION tx_isolation = 'READ-UNCOMMITTED';
|
|
|
|
--echo ** Connection con1 **
|
|
connection con1;
|
|
SET SESSION tx_isolation = 'READ-UNCOMMITTED';
|
|
|
|
#
|
|
# Testing WHERE on keys using IN clause
|
|
#
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1 WHERE a IN (2,4,6,8) FOR UPDATE;
|
|
UPDATE t1 SET b = 10 WHERE a IN (2,4,6,8);
|
|
|
|
--echo ** Connection con1 **
|
|
connection con1;
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
INSERT INTO t1 VALUES(1, 1);
|
|
INSERT INTO t1 VALUES(3, 3);
|
|
|
|
SELECT * FROM t1;
|
|
|
|
COMMIT;
|
|
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
|
|
DELETE FROM t1 WHERE a = 1 OR a = 3;
|
|
|
|
COMMIT;
|
|
|
|
--echo '#----------------------------FN_DYNVARS_184_02--------------------------------------#'
|
|
#
|
|
# Testing WHERE on keys using # on even rows
|
|
#
|
|
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1 WHERE a % 2 = 0 FOR UPDATE;
|
|
UPDATE t1 SET b = 10 WHERE a % 2 = 0;
|
|
|
|
--echo ** Connection con1 **
|
|
connection con1;
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
INSERT INTO t1 VALUES(23, 23);
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
INSERT INTO t1 VALUES(25, 25);
|
|
--echo Bug: Only even rows are being locked, error 1205 should'nt have occured
|
|
|
|
SELECT * FROM t1;
|
|
|
|
COMMIT;
|
|
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
|
|
COMMIT;
|
|
|
|
--echo '#----------------------------FN_DYNVARS_184_03--------------------------------------#'
|
|
#
|
|
# Testing for value READ-COMMITTED
|
|
#
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
SET SESSION tx_isolation = 'READ-COMMITTED';
|
|
|
|
--echo ** Connection con1 **
|
|
connection con1;
|
|
SET SESSION tx_isolation = 'READ-COMMITTED';
|
|
|
|
#
|
|
# Testing WHERE on keys using % on even rows
|
|
#
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1 WHERE a % 2 = 0 FOR UPDATE;
|
|
UPDATE t1 SET b = 11 WHERE a % 2 = 0;
|
|
|
|
--echo ** Connection con1 **
|
|
connection con1;
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
INSERT INTO t1 VALUES(5, 5);
|
|
INSERT INTO t1 VALUES(7, 7);
|
|
|
|
SELECT * FROM t1;
|
|
|
|
COMMIT;
|
|
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
|
|
COMMIT;
|
|
|
|
|
|
--echo '#----------------------------FN_DYNVARS_184_04--------------------------------------#'
|
|
#
|
|
# Testing for value REPEATABLE-READ
|
|
#
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
SET SESSION tx_isolation = 'REPEATABLE-READ';
|
|
|
|
--echo ** Connection con1 **
|
|
connection con1;
|
|
SET SESSION tx_isolation = 'REPEATABLE-READ';
|
|
|
|
#
|
|
# Testing WHERE on keys using % on even rows
|
|
#
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1 WHERE a % 2 = 0 FOR UPDATE;
|
|
UPDATE t1 SET b = 12 WHERE a % 2 = 0;
|
|
|
|
--echo ** Connection con1 **
|
|
connection con1;
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
INSERT INTO t1 VALUES(9, 9);
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
INSERT INTO t1 VALUES(13, 13);
|
|
--echo Expected error "Lock wait timeout"
|
|
|
|
SELECT * FROM t1;
|
|
|
|
COMMIT;
|
|
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
|
|
COMMIT;
|
|
|
|
--echo '#----------------------------FN_DYNVARS_184_05--------------------------------------#'
|
|
#
|
|
# Testing WHERE on keys using IN clause
|
|
#
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1 WHERE a IN (2,4,6,8,10,12,14,16,18,20,22,24,26) = 0 FOR UPDATE;
|
|
UPDATE t1 SET b = 13 WHERE a IN (2,4,6,8,10,12,14,16,18,20,22,24,26) = 0;
|
|
|
|
--echo ** Connection con1 **
|
|
connection con1;
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
INSERT INTO t1 VALUES(9, 9);
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
INSERT INTO t1 VALUES(13, 13);
|
|
--echo Expected error "Lock wait timeout"
|
|
|
|
SELECT * FROM t1;
|
|
|
|
COMMIT;
|
|
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
|
|
COMMIT;
|
|
|
|
--echo '#----------------------------FN_DYNVARS_184_06--------------------------------------#'
|
|
#
|
|
# Testing WHERE on keys using IN clause
|
|
#
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1 WHERE a IN (2,4,6,8) = 0 FOR UPDATE;
|
|
UPDATE t1 SET b = 14 WHERE a IN (2,4,6,8) = 0;
|
|
|
|
--echo ** Connection con1 **
|
|
connection con1;
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
INSERT INTO t1 VALUES(9, 9);
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
INSERT INTO t1 VALUES(13, 13);
|
|
--echo Expected error "Lock wait timeout"
|
|
|
|
SELECT * FROM t1;
|
|
|
|
COMMIT;
|
|
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
|
|
COMMIT;
|
|
|
|
--echo '#----------------------------FN_DYNVARS_184_07--------------------------------------#'
|
|
#
|
|
# Testing for value SERIALIZABLE
|
|
#
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
SET SESSION tx_isolation = 'SERIALIZABLE';
|
|
|
|
--echo ** Connection con0 **
|
|
connection con1;
|
|
SET SESSION tx_isolation = 'SERIALIZABLE';
|
|
|
|
#
|
|
# Testing WHERE on keys using # on even rows
|
|
#
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
|
|
START TRANSACTION;
|
|
|
|
SELECT * FROM t1 WHERE a % 2 = 0 FOR UPDATE;
|
|
UPDATE t1 SET b = 15 WHERE a % 2 = 0;
|
|
|
|
--echo ** Connection con0 **
|
|
connection con1;
|
|
|
|
START TRANSACTION;
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
SELECT * FROM t1;
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
INSERT INTO t1 VALUES(15, 15);
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
INSERT INTO t1 VALUES(17, 17);
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
SELECT * FROM t1;
|
|
|
|
COMMIT;
|
|
|
|
--echo ** Connection con0 **
|
|
connection con0;
|
|
|
|
COMMIT;
|
|
|
|
|
|
--echo '#----------------------------FN_DYNVARS_184_08--------------------------------------#'
|
|
#
|
|
# Session data integrity check & GLOBAL Value check
|
|
#
|
|
|
|
SET GLOBAL tx_isolation = 'READ-UNCOMMITTED';
|
|
--echo ** Connecting con_int1 using root **
|
|
connect (con_int1,localhost,root,,);
|
|
|
|
--echo ** Connection con_int1 **
|
|
connection con_int1;
|
|
SELECT @@SESSION.tx_isolation;
|
|
--echo READ-UNCOMMITTED Expected
|
|
|
|
SET SESSION tx_isolation = 'SERIALIZABLE';
|
|
|
|
--echo ** Connecting con_int2 using root **
|
|
connect (con_int2,localhost,root,,);
|
|
|
|
--echo ** Connection con_int2 **
|
|
connection con_int2;
|
|
SELECT @@SESSION.tx_isolation;
|
|
--echo READ-UNCOMMITTED Expected
|
|
|
|
SET SESSION tx_isolation = 'REPEATABLE-READ';
|
|
|
|
--echo ** Connection con_int2 **
|
|
connection con_int2;
|
|
SELECT @@SESSION.tx_isolation;
|
|
--echo REPEATABLE-READ Expected
|
|
|
|
--echo ** Connection con_int1 **
|
|
connection con_int1;
|
|
SELECT @@SESSION.tx_isolation;
|
|
--echo SERIALIZABLE Expected
|
|
|
|
|
|
SELECT @@GLOBAL.tx_isolation;
|
|
--echo READ-UNCOMMITTED Expected
|
|
|
|
--echo ** Connection default **
|
|
connection default;
|
|
|
|
--echo Disconnecting Connections con_int1, con_int2
|
|
disconnect con_int1;
|
|
disconnect con_int2;
|
|
|
|
#
|
|
# Cleanup
|
|
#
|
|
|
|
SET @@SESSION.tx_isolation = @session_tx_isolation;
|
|
SET @@GLOBAL.tx_isolation = @global_tx_isolation;
|
|
|
|
--echo ** Connection default **
|
|
connection default;
|
|
--echo Disconnecting Connections con0, con1
|
|
disconnect con0;
|
|
disconnect con1;
|
|
|
|
DROP TABLE t1;
|