File: innodb_i_s_innodb_trx.result

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (122 lines) | stat: -rw-r--r-- 3,449 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
SET GLOBAL innodb_lock_wait_timeout=600;
DESCRIBE INFORMATION_SCHEMA.INNODB_TRX;
Field	Type	Null	Key	Default	Extra
trx_id	bigint unsigned	NO			
trx_state	varchar(13)	NO			
trx_started	datetime	NO			
trx_requested_lock_id	varchar(126)	YES			
trx_wait_started	datetime	YES			
trx_weight	bigint unsigned	NO			
trx_mysql_thread_id	bigint unsigned	NO			
trx_query	varchar(1024)	YES			
trx_operation_state	varchar(64)	YES			
trx_tables_in_use	bigint unsigned	NO			
trx_tables_locked	bigint unsigned	NO			
trx_lock_structs	bigint unsigned	NO			
trx_lock_memory_bytes	bigint unsigned	NO			
trx_rows_locked	bigint unsigned	NO			
trx_rows_modified	bigint unsigned	NO			
trx_concurrency_tickets	bigint unsigned	NO			
trx_isolation_level	varchar(16)	NO			
trx_unique_checks	int	NO			
trx_foreign_key_checks	int	NO			
trx_last_foreign_key_error	varchar(256)	YES			
trx_adaptive_hash_latched	int	NO			
trx_adaptive_hash_timeout	bigint unsigned	NO			
trx_is_read_only	int	NO			
trx_autocommit_non_locking	int	NO			
trx_schedule_weight	bigint unsigned	YES			
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
c01 INT,
c02 INT,
PRIMARY KEY (c01)
) ENGINE=INNODB STATS_AUTO_RECALC=0;
INSERT INTO t1 VALUES
(1,2),(2,4),(3,6),(4,8);
CREATE TABLE t2 (
c01 INT,
c02 INT,
PRIMARY KEY (c01),
CONSTRAINT fk1 FOREIGN KEY (c02) REFERENCES t1 (c01)
) ENGINE=INNODB STATS_AUTO_RECALC=0;
INSERT INTO t2 VALUES
(1,1),(2,2),(3,3);
SET autocommit=0;
INSERT INTO t1 VALUES (5,10);
SELECT * FROM t1 FOR UPDATE;
c01	c02
1	2
2	4
3	6
4	8
5	10
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;
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
RUNNING	5	0	1	7	1	0	REPEATABLE READ	1	1
ROLLBACK;
SET FOREIGN_KEY_CHECKS = 0;
SET UNIQUE_CHECKS = 0;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN;
INSERT INTO t1 VALUES (6,12);
SELECT trx_isolation_level, trx_unique_checks, trx_foreign_key_checks
FROM INFORMATION_SCHEMA.INNODB_TRX;
trx_isolation_level	trx_unique_checks	trx_foreign_key_checks
SERIALIZABLE	0	0
ROLLBACK;
SET FOREIGN_KEY_CHECKS = 1;
SET UNIQUE_CHECKS = 1;
BEGIN;
INSERT INTO t2 VALUES (4,10);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk1` FOREIGN KEY (`c02`) REFERENCES `t1` (`c01`))
SELECT trx_state, trx_isolation_level, trx_last_foreign_key_error
FROM INFORMATION_SCHEMA.INNODB_TRX;
trx_state	trx_isolation_level	trx_last_foreign_key_error
RUNNING	REPEATABLE READ	`test`.`t2`, CONSTRAINT `fk1` FOREIGN KEY (`c02`) REFERENCES `t1` (`c01`)
CREATE TABLE t0 (
id INT PRIMARY KEY,
trx_mysql_thread_id BIGINT
) ENGINE=InnoDB;
INSERT INTO t0 VALUES (1, CONNECTION_ID());
BEGIN;
SELECT * FROM t1 FOR SHARE;
c01	c02
1	2
2	4
3	6
4	8
INSERT INTO t0 VALUES (2, CONNECTION_ID());
BEGIN;
SELECT * FROM t1 FOR UPDATE;
INSERT INTO t0 VALUES (3, CONNECTION_ID());
BEGIN;
SELECT * FROM t1 FOR SHARE;
SELECT t0.id, trx_schedule_weight
FROM INFORMATION_SCHEMA.INNODB_TRX
JOIN t0 USING(trx_mysql_thread_id)
ORDER BY t0.id;
id	trx_schedule_weight
1	NULL
2	2
3	1
ROLLBACK;
c01	c02
1	2
2	4
3	6
4	8
ROLLBACK;
c01	c02
1	2
2	4
3	6
4	8
ROLLBACK;
DROP TABLE t2;
DROP TABLE t1;
DROP TABLE t0;
SET GLOBAL innodb_lock_wait_timeout=default;