mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-31 15:50:51 +03:00 
			
		
		
		
	
		
			
				
	
	
		
			278 lines
		
	
	
		
			6.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			278 lines
		
	
	
		
			6.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| # 
 | |
| # Test that user data is correctly "visualized" in
 | |
| # INFORMATION_SCHEMA.innodb_locks.lock_data
 | |
| #
 | |
| 
 | |
| -- source include/have_innodb.inc
 | |
| 
 | |
| # lock data that is part of result set for this testcase
 | |
| # is retreived using buf_page_try_get. i.e only show if page
 | |
| # happen to be in buffer pool, with key rotation threads
 | |
| # chances are substantial that pages have been evicted and lock_data
 | |
| # get NULL
 | |
| -- source include/not_encrypted.inc
 | |
| 
 | |
| -- disable_query_log
 | |
| -- disable_result_log
 | |
| 
 | |
| SET storage_engine=InnoDB;
 | |
| 
 | |
| -- disable_warnings
 | |
| DROP TABLE IF EXISTS t_min, t_max;
 | |
| -- enable_warnings
 | |
| 
 | |
| let $table_def =
 | |
| (
 | |
| 	c01 TINYINT,
 | |
| 	c02 TINYINT UNSIGNED,
 | |
| 	c03 SMALLINT,
 | |
| 	c04 SMALLINT UNSIGNED,
 | |
| 	c05 MEDIUMINT,
 | |
| 	c06 MEDIUMINT UNSIGNED,
 | |
| 	c07 INT,
 | |
| 	c08 INT UNSIGNED,
 | |
| 	c09 BIGINT,
 | |
| 	c10 BIGINT UNSIGNED,
 | |
| 	PRIMARY KEY(c01, c02, c03, c04, c05, c06, c07, c08, c09, c10)
 | |
| );
 | |
| 
 | |
| -- eval CREATE TABLE t_min $table_def;
 | |
| INSERT INTO t_min VALUES
 | |
| (-128, 0,
 | |
|  -32768, 0,
 | |
|  -8388608, 0,
 | |
|  -2147483648, 0,
 | |
|  -9223372036854775808, 0);
 | |
| 
 | |
| -- eval CREATE TABLE t_max $table_def;
 | |
| INSERT INTO t_max VALUES
 | |
| (127, 255,
 | |
|  32767, 65535,
 | |
|  8388607, 16777215,
 | |
|  2147483647, 4294967295,
 | |
|  9223372036854775807, 18446744073709551615);
 | |
| 
 | |
| CREATE TABLE ```t'\"_str` (
 | |
| 	c1 VARCHAR(32),
 | |
| 	c2 VARCHAR(32),
 | |
| 	c3 VARCHAR(32),
 | |
| 	c4 VARCHAR(32),
 | |
| 	c5 VARCHAR(32),
 | |
| 	c6 VARCHAR(32),
 | |
| 	c7 VARCHAR(32),
 | |
| 	PRIMARY KEY(c1, c2, c3, c4, c5, c6, c7)
 | |
| );
 | |
| INSERT INTO ```t'\"_str` VALUES
 | |
| ('1', 'abc', '''abc', 'abc''', 'a''bc', 'a''bc''', '''abc''''');
 | |
| INSERT INTO ```t'\"_str` VALUES
 | |
| ('2', 'abc', '"abc', 'abc"', 'a"bc', 'a"bc"', '"abc""');
 | |
| INSERT INTO ```t'\"_str` VALUES
 | |
| ('3', 'abc', '\\abc', 'abc\\', 'a\\bc', 'a\\bc\\', '\\abc\\\\');
 | |
| INSERT INTO ```t'\"_str` VALUES
 | |
| ('4', 'abc', 0x00616263, 0x61626300, 0x61006263, 0x6100626300, 0x610062630000);
 | |
| 
 | |
| --source include/count_sessions.inc
 | |
| 
 | |
| -- connect (con_lock,localhost,root,,)
 | |
| -- connect (con_min_trylock,localhost,root,,)
 | |
| -- connect (con_max_trylock,localhost,root,,)
 | |
| -- connect (con_str_insert_supremum,localhost,root,,)
 | |
| -- connect (con_str_lock_row1,localhost,root,,)
 | |
| -- connect (con_str_lock_row2,localhost,root,,)
 | |
| -- connect (con_str_lock_row3,localhost,root,,)
 | |
| -- connect (con_str_lock_row4,localhost,root,,)
 | |
| -- connect (con_verify_innodb_locks,localhost,root,,)
 | |
| 
 | |
| -- connection con_lock
 | |
| SET autocommit=0;
 | |
| SELECT * FROM t_min FOR UPDATE;
 | |
| SELECT * FROM t_max FOR UPDATE;
 | |
| SELECT * FROM ```t'\"_str` FOR UPDATE;
 | |
| 
 | |
| -- connection con_min_trylock
 | |
| -- send
 | |
| SELECT * FROM t_min FOR UPDATE;
 | |
| 
 | |
| -- connection con_max_trylock
 | |
| -- send
 | |
| SELECT * FROM t_max FOR UPDATE;
 | |
| 
 | |
| -- connection con_str_insert_supremum
 | |
| -- send
 | |
| INSERT INTO ```t'\"_str` VALUES
 | |
| ('z', 'z', 'z', 'z', 'z', 'z', 'z');
 | |
| 
 | |
| -- connection con_str_lock_row1
 | |
| -- send
 | |
| SELECT * FROM ```t'\"_str` WHERE c1 = '1' FOR UPDATE;
 | |
| 
 | |
| -- connection con_str_lock_row2
 | |
| -- send
 | |
| SELECT * FROM ```t'\"_str` WHERE c1 = '2' FOR UPDATE;
 | |
| 
 | |
| -- connection con_str_lock_row3
 | |
| -- send
 | |
| SELECT * FROM ```t'\"_str` WHERE c1 = '3' FOR UPDATE;
 | |
| 
 | |
| -- connection con_str_lock_row4
 | |
| -- send
 | |
| SELECT * FROM ```t'\"_str` WHERE c1 = '4' FOR UPDATE;
 | |
| 
 | |
| -- enable_result_log
 | |
| -- connection con_verify_innodb_locks
 | |
| # Wait for the above queries to execute before continuing.
 | |
| # Without this, it sometimes happens that the SELECT from innodb_locks
 | |
| # executes before some of them, resulting in less than expected number
 | |
| # of rows being selected from innodb_locks. If there is a bug and there
 | |
| # are no 14 rows in innodb_locks then this test will fail with timeout.
 | |
| # Notice that if we query INNODB_LOCKS more often than once per 0.1 sec
 | |
| # then its contents will never change because the cache from which it is
 | |
| # filled is updated only if it has not been read for 0.1 seconds. See
 | |
| # CACHE_MIN_IDLE_TIME_US in trx/trx0i_s.c.
 | |
| let $cnt=200;
 | |
| while ($cnt)
 | |
| {
 | |
|     let $success=`SELECT COUNT(*) = 14 FROM INFORMATION_SCHEMA.INNODB_LOCKS`;
 | |
|     if ($success)
 | |
|     {
 | |
|         let $cnt=0;
 | |
|     }
 | |
|     if (!$success)
 | |
|     {
 | |
|         real_sleep 0.2;
 | |
|         dec $cnt;
 | |
|     }
 | |
| }
 | |
| if (!$success)
 | |
| {
 | |
|     -- echo Timeout waiting for rows in INNODB_LOCKS to appear
 | |
| }
 | |
| 
 | |
| SELECT lock_mode, lock_type, lock_table, lock_index, lock_rec, lock_data
 | |
| FROM INFORMATION_SCHEMA.INNODB_LOCKS ORDER BY lock_data;
 | |
| 
 | |
| SELECT lock_table,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS
 | |
| GROUP BY lock_table;
 | |
| 
 | |
| set @save_sql_mode = @@sql_mode;
 | |
| SET SQL_MODE='ANSI_QUOTES';
 | |
| SELECT lock_table,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS
 | |
| GROUP BY lock_table;
 | |
| SET @@sql_mode=@save_sql_mode;
 | |
| -- disable_result_log
 | |
| 
 | |
| -- connection default
 | |
| 
 | |
| -- disconnect con_lock
 | |
| -- disconnect con_min_trylock
 | |
| -- disconnect con_max_trylock
 | |
| -- disconnect con_str_insert_supremum
 | |
| -- disconnect con_str_lock_row1
 | |
| -- disconnect con_str_lock_row2
 | |
| -- disconnect con_str_lock_row3
 | |
| -- disconnect con_str_lock_row4
 | |
| -- disconnect con_verify_innodb_locks
 | |
| 
 | |
| DROP TABLE t_min, t_max, ```t'\"_str`;
 | |
| 
 | |
| --source include/wait_until_count_sessions.inc
 | |
| 
 | |
| #
 | |
| # Test that transaction data is correctly "visualized" in
 | |
| # INFORMATION_SCHEMA.INNODB_TRX
 | |
| #
 | |
| 
 | |
| -- enable_result_log
 | |
| DESCRIBE INFORMATION_SCHEMA.INNODB_TRX;
 | |
| -- disable_result_log
 | |
| 
 | |
| -- disable_warnings
 | |
| DROP TABLE IF EXISTS t1;
 | |
| -- enable_warnings
 | |
| 
 | |
| CREATE TABLE t1 (
 | |
| 	c01 INT,
 | |
| 	c02 INT,
 | |
| 	PRIMARY KEY (c01)
 | |
| ) ENGINE = InnoDB;
 | |
| 
 | |
| INSERT INTO t1 VALUES
 | |
| (1,2),(2,4),(3,6),(4,8);
 | |
| 
 | |
| CREATE TABLE t2 (
 | |
| 	c01 INT,
 | |
| 	c02 INT,
 | |
| 	PRIMARY KEY (c01),
 | |
| 	FOREIGN KEY fk1 (c02) REFERENCES t1 (c01)
 | |
| ) ENGINE = InnoDB;
 | |
| 
 | |
| INSERT INTO t2 VALUES
 | |
| (1,1),(2,2),(3,3);
 | |
| 
 | |
| -- connect (con_trx,localhost,root,,)
 | |
| -- connect (con_verify_innodb_trx,localhost,root,,)
 | |
| 
 | |
| -- connection con_trx
 | |
| SET autocommit=0;
 | |
| INSERT INTO t1 VALUES (5,10);
 | |
| SELECT * FROM t1 FOR UPDATE;
 | |
| 
 | |
| let $wait_condition=
 | |
|   SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_TRX;
 | |
| --source include/wait_condition.inc
 | |
| -- disable_query_log
 | |
| 
 | |
| -- connection con_verify_innodb_trx
 | |
| -- enable_result_log
 | |
| SELECT trx_state, trx_weight, trx_tables_in_use, trx_tables_locked,
 | |
| trx_rows_locked, trx_rows_modified, trx_concurrency_tickets,
 | |
| trx_isolation_level, trx_unique_checks, trx_foreign_key_checks
 | |
| FROM INFORMATION_SCHEMA.INNODB_TRX;
 | |
| 
 | |
| -- connection con_trx
 | |
| -- disable_result_log
 | |
| ROLLBACK;
 | |
| SET FOREIGN_KEY_CHECKS = 0;
 | |
| SET UNIQUE_CHECKS = 0;
 | |
| SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
 | |
| BEGIN;
 | |
| INSERT INTO t1 VALUES (6,12);
 | |
| 
 | |
| let $wait_condition=
 | |
|   SELECT trx_unique_checks = 0 FROM INFORMATION_SCHEMA.INNODB_TRX;
 | |
| --source include/wait_condition.inc
 | |
| -- disable_query_log
 | |
| 
 | |
| -- connection con_verify_innodb_trx
 | |
| -- enable_result_log
 | |
| SELECT trx_isolation_level, trx_unique_checks, trx_foreign_key_checks
 | |
| FROM INFORMATION_SCHEMA.INNODB_TRX;
 | |
| 
 | |
| -- disable_result_log
 | |
| -- connection con_trx
 | |
| ROLLBACK;
 | |
| SET FOREIGN_KEY_CHECKS = 1;
 | |
| SET UNIQUE_CHECKS = 1;
 | |
| BEGIN;
 | |
| -- error 1452
 | |
| INSERT INTO t2 VALUES (4,10);
 | |
| 
 | |
| let $wait_condition=
 | |
|   SELECT trx_unique_checks  = 1 FROM INFORMATION_SCHEMA.INNODB_TRX;
 | |
| --source include/wait_condition.inc
 | |
| -- disable_query_log
 | |
| 
 | |
| -- enable_result_log
 | |
| -- connection con_verify_innodb_trx
 | |
| SELECT trx_state, trx_isolation_level, trx_last_foreign_key_error
 | |
| FROM INFORMATION_SCHEMA.INNODB_TRX;
 | |
| -- disable_result_log
 | |
| 
 | |
| -- connection default
 | |
| 
 | |
| -- disconnect con_trx
 | |
| -- disconnect con_verify_innodb_trx
 | |
| 
 | |
| DROP TABLE t2;
 | |
| DROP TABLE t1;
 |