mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-31 15:50:51 +03:00 
			
		
		
		
	Bug#46527 COMMIT AND CHAIN RELEASE does not make sense
Bug#53343 completion_type=1, COMMIT/ROLLBACK AND CHAIN don't 
          preserve the isolation level
Bug#53346 completion_type has strange effect in a stored 
          procedure/prepared statement
Added test cases to verify the expected behaviour of :
 SET SESSION TRANSACTION ISOLATION LEVEL, 
 SET TRANSACTION ISOLATION LEVEL,
 @@completion_type,
 COMMIT AND CHAIN,
 ROLLBACK AND CHAIN
 ..and some combinations of the above
		
	
		
			
				
	
	
		
			133 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			133 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| drop table if exists t1;
 | |
| set binlog_format=mixed;
 | |
| set session transaction isolation level repeatable read;
 | |
| create table t1(a int not null)
 | |
| engine=innodb
 | |
| DEFAULT CHARSET=latin1
 | |
| PARTITION BY RANGE(a)
 | |
| (PARTITION p0 VALUES LESS THAN (20),
 | |
| PARTITION p1 VALUES LESS THAN MAXVALUE);
 | |
| insert into t1 values (1),(2),(3),(4),(5),(6),(7);
 | |
| set autocommit=0;
 | |
| select * from t1 where a=3 lock in share mode;
 | |
| a
 | |
| 3
 | |
| set binlog_format=mixed;
 | |
| set session transaction isolation level repeatable read;
 | |
| set autocommit=0;
 | |
| update t1 set a=10 where a=5;
 | |
| ERROR HY000: Lock wait timeout exceeded; try restarting transaction
 | |
| commit;
 | |
| commit;
 | |
| set session transaction isolation level read committed;
 | |
| update t1 set a=10 where a=5;
 | |
| select * from t1 where a=2 for update;
 | |
| ERROR HY000: Lock wait timeout exceeded; try restarting transaction
 | |
| select * from t1 where a=2 limit 1 for update;
 | |
| a
 | |
| 2
 | |
| update t1 set a=11 where a=6;
 | |
| update t1 set a=12 where a=2;
 | |
| ERROR HY000: Lock wait timeout exceeded; try restarting transaction
 | |
| update t1 set a=13 where a=1;
 | |
| ERROR HY000: Lock wait timeout exceeded; try restarting transaction
 | |
| commit;
 | |
| update t1 set a=14 where a=1;
 | |
| commit;
 | |
| select * from t1;
 | |
| a
 | |
| 10
 | |
| 11
 | |
| 14
 | |
| 2
 | |
| 3
 | |
| 4
 | |
| 7
 | |
| drop table t1;
 | |
| SET SESSION AUTOCOMMIT = 0;
 | |
| SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 | |
| set binlog_format=mixed;
 | |
| # Switch to connection con1
 | |
| CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256))
 | |
| ENGINE = InnoDB
 | |
| PARTITION BY RANGE (a)
 | |
| (PARTITION p0 VALUES LESS THAN (300),
 | |
| PARTITION p1 VALUES LESS THAN MAXVALUE);
 | |
| INSERT INTO t1 VALUES (1,2);
 | |
| # 1. test for locking:
 | |
| BEGIN;
 | |
| UPDATE t1 SET b = 12 WHERE a = 1;
 | |
| affected rows: 1
 | |
| info: Rows matched: 1  Changed: 1  Warnings: 0
 | |
| SELECT * FROM t1;
 | |
| a	b
 | |
| 1	12
 | |
| # Switch to connection con2
 | |
| UPDATE t1 SET b = 21 WHERE a = 1;
 | |
| ERROR HY000: Lock wait timeout exceeded; try restarting transaction
 | |
| ROLLBACK;
 | |
| # Switch to connection con1
 | |
| SELECT * FROM t1;
 | |
| a	b
 | |
| 1	12
 | |
| ROLLBACK;
 | |
| # 2. test for serialized update:
 | |
| CREATE TABLE t2 (a INT);
 | |
| TRUNCATE t1;
 | |
| INSERT INTO t1 VALUES (1,'init');
 | |
| CREATE PROCEDURE p1()
 | |
| BEGIN
 | |
| UPDATE t1 SET b = CONCAT(b, '+con2')  WHERE a = 1;
 | |
| INSERT INTO t2 VALUES ();
 | |
| END|
 | |
| BEGIN;
 | |
| UPDATE t1 SET b = CONCAT(b, '+con1') WHERE a = 1;
 | |
| affected rows: 1
 | |
| info: Rows matched: 1  Changed: 1  Warnings: 0
 | |
| SELECT * FROM t1;
 | |
| a	b
 | |
| 1	init+con1
 | |
| # Switch to connection con2
 | |
| CALL p1;;
 | |
| # Switch to connection con1
 | |
| SELECT * FROM t1;
 | |
| a	b
 | |
| 1	init+con1
 | |
| COMMIT;
 | |
| SELECT * FROM t1;
 | |
| a	b
 | |
| 1	init+con1
 | |
| # Switch to connection con2
 | |
| SELECT * FROM t1;
 | |
| a	b
 | |
| 1	init+con1+con2
 | |
| COMMIT;
 | |
| # Switch to connection con1
 | |
| # 3. test for updated key column:
 | |
| TRUNCATE t1;
 | |
| DELETE FROM t2;
 | |
| INSERT INTO t1 VALUES (1,'init');
 | |
| BEGIN;
 | |
| UPDATE t1 SET a = 2, b = CONCAT(b, '+con1') WHERE a = 1;
 | |
| affected rows: 1
 | |
| info: Rows matched: 1  Changed: 1  Warnings: 0
 | |
| SELECT * FROM t1;
 | |
| a	b
 | |
| 2	init+con1
 | |
| # Switch to connection con2
 | |
| CALL p1;;
 | |
| # Switch to connection con1
 | |
| SELECT * FROM t1;
 | |
| a	b
 | |
| 2	init+con1
 | |
| COMMIT;
 | |
| SELECT * FROM t1;
 | |
| a	b
 | |
| 2	init+con1
 | |
| # Switch to connection con2
 | |
| SELECT * FROM t1;
 | |
| a	b
 | |
| 2	init+con1
 | |
| DROP PROCEDURE p1;
 | |
| DROP TABLE t1, t2;
 |