summaryrefslogtreecommitdiff
path: root/mysql-test/suite/innodb/t/insert_into_empty.test
blob: 8b885cb5b4f3e7c49b6831e7587397e7604ebc6e (plain)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
--source include/have_innodb.inc
--source include/have_sequence.inc
--source include/maybe_debug.inc
--source include/have_partition.inc

# Enable MDEV-515 table-level undo logging for insert into empty table
SET foreign_key_checks=0, unique_checks=0;

--echo #
--echo # MDEV-24715 Assertion !node->table->skip_alter_undo
--echo #
CREATE TABLE t (a INT UNIQUE) ENGINE=InnoDB
REPLACE SELECT 1 AS a, 2 AS b UNION SELECT 1 AS a, 3 AS c;
SELECT * FROM t;
DROP TABLE t;

CREATE TEMPORARY TABLE t (a INT UNIQUE) ENGINE=InnoDB
REPLACE SELECT 1 AS a, 2 AS b UNION SELECT 1 AS a, 3 AS c;
SELECT * FROM t;
DROP TEMPORARY TABLE t;

--echo #
--echo # MDEV-24720 AHI removal during bulk index rollback
--echo #
SET @save_ahi = @@global.innodb_adaptive_hash_index;
SET GLOBAL innodb_adaptive_hash_index = 1;
CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB;
BEGIN;
INSERT INTO t1 SELECT * FROM seq_1_to_65536;
ROLLBACK;
CHECK TABLE t1;
--echo #
--echo # MDEV-24832 Root page AHI Removal fails fails during
--echo #		bulk index rollback
--echo #
BEGIN;
INSERT INTO t1 SELECT * FROM seq_1_to_500;
ROLLBACK;
DROP TABLE t1;
SET GLOBAL innodb_adaptive_hash_index = @save_ahi;

--echo #
--echo # MDEV-24951 Assertion m.first->second.valid(trx->undo_no) failed
--echo # in trx_undo_report_row_operation
--echo #

CREATE TEMPORARY TABLE t (c INT) ENGINE=InnoDB;
CREATE TEMPORARY TABLE t2 (c INT) ENGINE=InnoDB;
SET tx_read_only=1;
BEGIN;
INSERT INTO t2 VALUES(0);
INSERT INTO t VALUES(0);
COMMIT;
INSERT INTO t VALUES(0);

--error ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION
DROP TEMPORARY TABLE t,t2;
SET tx_read_only=0;
DROP TEMPORARY TABLE t,t2;

--echo #
--echo # MDEV-24818 Optimize multiple INSERT into empty table
--echo #

CREATE TABLE t1(f1 INT PRIMARY KEY) ENGINE=InnoDB;
BEGIN;
INSERT INTO t1 VALUES (5),(6),(7);
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES (4),(5),(6);
COMMIT;
SELECT * FROM t1;
BEGIN;
INSERT INTO t1 VALUES (5),(6),(7);
SAVEPOINT a;
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES (4),(5),(6);
ROLLBACK TO SAVEPOINT a;
COMMIT;
SELECT * FROM t1;
DROP TABLE t1;

# Repeat the same with the MDEV-515 test disabled
SET foreign_key_checks=1;

CREATE TABLE t1(f1 INT PRIMARY KEY) ENGINE=InnoDB;
BEGIN;
INSERT INTO t1 VALUES (5),(6),(7);
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES (4),(5),(6);
COMMIT;
SELECT * FROM t1;
BEGIN;
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES (5),(6),(7);
SAVEPOINT a;
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES (4),(5),(6);
ROLLBACK TO SAVEPOINT a;
COMMIT;
SELECT * FROM t1;
DROP TABLE t1;

SET foreign_key_checks=0;

--echo #
--echo # MDEV-25315 Crash in SHOW ENGINE INNODB STATUS
--echo #

CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;

INSERT INTO t1 VALUES(1);
BEGIN;
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES(1);
INSERT INTO t2 VALUES(0);
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES(2), (2);
--disable_result_log
SHOW ENGINE InnoDB STATUS;
--enable_result_log
COMMIT;
DROP TABLE t1,t2;

--echo #
--echo # MDEV-25297 Assertion: trx->roll_limit <= trx->undo_no
--echo # in ROLLBACK TO SAVEPOINT
--echo #

CREATE TABLE t1 (c INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (c INT PRIMARY KEY) ENGINE=InnoDB;
BEGIN;
INSERT INTO t1 VALUES(0);
SAVEPOINT x;
INSERT INTO t2 VALUES(0);
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES(0);
--error ER_ERROR_DURING_ROLLBACK
ROLLBACK TO SAVEPOINT x;
COMMIT;
SELECT * FROM t1;
SELECT * FROM t2;
DROP TABLE t1,t2;

--echo #
--echo # MDEV-25487 Assertion failed in lock_rec_move
--echo #

CREATE TABLE t1 (a INT KEY) ENGINE=InnoDB;

--error 0,1193
SET @save_limit = @@GLOBAL.innodb_limit_optimistic_insert_debug;
--error 0,1193
SET GLOBAL innodb_limit_optimistic_insert_debug = 2;

BEGIN;
SELECT * FROM t1 LOCK IN SHARE MODE;
INSERT INTO t1 VALUES (0),(1),(2);
--error ER_WRONG_VALUE_COUNT_ON_ROW
INSERT INTO t1 VALUES (0,1);
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES (2);
COMMIT;

--error 0,ER_UNKNOWN_SYSTEM_VARIABLE
SET GLOBAL innodb_limit_optimistic_insert_debug = @save_limit;

SELECT * FROM t1;

DROP TABLE t1;

--echo #
--echo # MDEV-25534 Assertion lock_table_has...LOCK_IX
--echo #
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
SET autocommit=0;
LOCK TABLE t1 WRITE;
INSERT INTO t1 VALUES (1);
COMMIT;
CREATE TEMPORARY TABLE t0 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t0 VALUES (1);
INSERT INTO t1 VALUES (2);
COMMIT;
SET autocommit=1;
DROP TABLE t1;
DROP TEMPORARY TABLE t0;

--echo #
--echo # MDEV-25496 Assertion 'trx->bulk_insert' failed
--echo # in trx_undo_report_row_operation on INSERT
--echo #
CREATE TABLE t (i INT) ENGINE=InnoDB PARTITION BY HASH (i) PARTITIONS 2;
INSERT INTO t VALUES (0);
INSERT INTO t VALUES (1),(0),(1);
DROP TABLE t;