| 1 |
FLUSH TABLES; |
| 2 |
# |
| 3 |
# MDEV-11369: Instant ADD COLUMN for InnoDB |
| 4 |
# |
| 5 |
CREATE TABLE t1(id INT PRIMARY KEY, c2 INT UNIQUE) |
| 6 |
ENGINE=InnoDB STATS_PERSISTENT=0 ROW_FORMAT=REDUNDANT; |
| 7 |
CREATE TABLE t2 LIKE t1; |
| 8 |
INSERT INTO t1 VALUES(0,2); |
| 9 |
INSERT INTO t2 VALUES(2,1); |
| 10 |
ALTER TABLE t2 ADD COLUMN (c3 TEXT NOT NULL DEFAULT 'De finibus bonorum'); |
| 11 |
BEGIN; |
| 12 |
INSERT INTO t2 VALUES(3,4,'accusantium doloremque laudantium'); |
| 13 |
connect ddl, localhost, root; |
| 14 |
SET DEBUG_SYNC='innodb_alter_inplace_before_commit SIGNAL ddl WAIT_FOR ever'; |
| 15 |
ALTER TABLE t1 ADD COLUMN (c3 TEXT NOT NULL DEFAULT ' et malorum'); |
| 16 |
connection default; |
| 17 |
SET DEBUG_SYNC='now WAIT_FOR ddl'; |
| 18 |
SET GLOBAL innodb_flush_log_at_trx_commit=1; |
| 19 |
COMMIT; |
| 20 |
# Kill the server |
| 21 |
disconnect ddl; |
| 22 |
# restart |
| 23 |
SELECT * FROM t1; |
| 24 |
id c2 |
| 25 |
0 2 |
| 26 |
SELECT * FROM t2; |
| 27 |
id c2 c3 |
| 28 |
2 1 De finibus bonorum |
| 29 |
3 4 accusantium doloremque laudantium |
| 30 |
BEGIN; |
| 31 |
DELETE FROM t1; |
| 32 |
ROLLBACK; |
| 33 |
InnoDB 0 transactions not purged |
| 34 |
INSERT INTO t2 VALUES |
| 35 |
(16,1551,'Omnium enim rerum'),(128,1571,' principia parva sunt'); |
| 36 |
BEGIN; |
| 37 |
UPDATE t1 SET c2=c2+1; |
| 38 |
connect ddl, localhost, root; |
| 39 |
SET DEBUG_SYNC='innodb_alter_inplace_before_commit SIGNAL ddl WAIT_FOR ever'; |
| 40 |
ALTER TABLE t2 DROP COLUMN c3, ADD COLUMN c5 TEXT DEFAULT 'naturam abhorrere'; |
| 41 |
connection default; |
| 42 |
SET DEBUG_SYNC='now WAIT_FOR ddl'; |
| 43 |
SET GLOBAL innodb_flush_log_at_trx_commit=1; |
| 44 |
COMMIT; |
| 45 |
# Kill the server |
| 46 |
disconnect ddl; |
| 47 |
# restart |
| 48 |
SELECT * FROM t1; |
| 49 |
id c2 |
| 50 |
0 3 |
| 51 |
SELECT * FROM t2; |
| 52 |
id c2 c3 |
| 53 |
2 1 De finibus bonorum |
| 54 |
3 4 accusantium doloremque laudantium |
| 55 |
16 1551 Omnium enim rerum |
| 56 |
128 1571 principia parva sunt |
| 57 |
BEGIN; |
| 58 |
INSERT INTO t1 SET id=1; |
| 59 |
DELETE FROM t2; |
| 60 |
ROLLBACK; |
| 61 |
InnoDB 0 transactions not purged |
| 62 |
INSERT INTO t2 VALUES (64,42,'De finibus bonorum'), (347,33101,' et malorum'); |
| 63 |
BEGIN; |
| 64 |
DELETE FROM t1; |
| 65 |
connect ddl, localhost, root; |
| 66 |
ALTER TABLE t2 DROP COLUMN c3; |
| 67 |
SET DEBUG_SYNC='innodb_alter_inplace_before_commit SIGNAL ddl WAIT_FOR ever'; |
| 68 |
ALTER TABLE t2 ADD COLUMN (c4 TEXT NOT NULL DEFAULT ' et malorum'); |
| 69 |
connection default; |
| 70 |
SET DEBUG_SYNC='now WAIT_FOR ddl'; |
| 71 |
SET GLOBAL innodb_flush_log_at_trx_commit=1; |
| 72 |
COMMIT; |
| 73 |
# Kill the server |
| 74 |
disconnect ddl; |
| 75 |
# restart |
| 76 |
FOUND 3 /\[Note\] InnoDB: Rolled back recovered transaction / in mysqld.1.err |
| 77 |
SELECT * FROM t1; |
| 78 |
id c2 |
| 79 |
SELECT * FROM t2; |
| 80 |
id c2 |
| 81 |
2 1 |
| 82 |
3 4 |
| 83 |
64 42 |
| 84 |
16 1551 |
| 85 |
128 1571 |
| 86 |
347 33101 |
| 87 |
BEGIN; |
| 88 |
INSERT INTO t1 SET id=1; |
| 89 |
DELETE FROM t2; |
| 90 |
ROLLBACK; |
| 91 |
InnoDB 0 transactions not purged |
| 92 |
FLUSH TABLE t1,t2 FOR EXPORT; |
| 93 |
t1 clustered index root page(type 17855): |
| 94 |
N_RECS=0; LEVEL=0 |
| 95 |
header=0x010000030074 (id=0x696e66696d756d00) |
| 96 |
header=0x010008030000 (id=0x73757072656d756d00) |
| 97 |
t2 clustered index root page(type 18): |
| 98 |
N_RECS=7; LEVEL=0 |
| 99 |
header=0x01000003008f (id=0x0000000000000000) |
| 100 |
header=0x3000100c00d4 (id=0x80000000, |
| 101 |
DB_TRX_ID=0x000000000000, |
| 102 |
DB_ROLL_PTR=0x80000000000000, |
| 103 |
BLOB=0x000000260000000000000008, |
| 104 |
c2=NULL(4 bytes), |
| 105 |
c3=0x44652066696e6962757320626f6e6f72756d) |
| 106 |
header=0x0000180900f4 (id=0x80000002, |
| 107 |
DB_TRX_ID=0x000000000000, |
| 108 |
DB_ROLL_PTR=0x80000000000000, |
| 109 |
c2=0x80000001) |
| 110 |
header=0x0000200b0135 (id=0x80000003, |
| 111 |
DB_TRX_ID=0x000000000000, |
| 112 |
DB_ROLL_PTR=0x80000000000000, |
| 113 |
c2=0x80000004, |
| 114 |
c3=0x6163637573616e7469756d20646f6c6f72656d717565206c617564616e7469756d) |
| 115 |
header=0x0000280b0165 (id=0x80000010, |
| 116 |
DB_TRX_ID=0x000000000000, |
| 117 |
DB_ROLL_PTR=0x80000000000000, |
| 118 |
c2=0x8000060f, |
| 119 |
c3=0x4f6d6e69756d20656e696d20726572756d) |
| 120 |
header=0x000030090185 (id=0x80000040, |
| 121 |
DB_TRX_ID=0x000000000000, |
| 122 |
DB_ROLL_PTR=0x80000000000000, |
| 123 |
c2=0x8000002a) |
| 124 |
header=0x0000380b01ba (id=0x80000080, |
| 125 |
DB_TRX_ID=0x000000000000, |
| 126 |
DB_ROLL_PTR=0x80000000000000, |
| 127 |
c2=0x80000623, |
| 128 |
c3=0x207072696e63697069612070617276612073756e74) |
| 129 |
header=0x0000400b0074 (id=0x8000015b, |
| 130 |
DB_TRX_ID=0x000000000000, |
| 131 |
DB_ROLL_PTR=0x80000000000000, |
| 132 |
c2=0x8000814d, |
| 133 |
c3=0x206574206d616c6f72756d) |
| 134 |
header=0x080008030000 (id=0x000000000000000100) |
| 135 |
UNLOCK TABLES; |
| 136 |
DELETE FROM t2; |
| 137 |
InnoDB 0 transactions not purged |
| 138 |
# |
| 139 |
# MDEV-24323 Crash on recovery after kill during instant ADD COLUMN |
| 140 |
# |
| 141 |
BEGIN; |
| 142 |
INSERT INTO t1 VALUES(0,0); |
| 143 |
connect ddl, localhost, root; |
| 144 |
CREATE TABLE t3(id INT PRIMARY KEY, c2 INT, v2 INT AS(c2) VIRTUAL, UNIQUE(v2)) |
| 145 |
ENGINE=InnoDB; |
| 146 |
INSERT INTO t3 SET id=1,c2=1; |
| 147 |
SET DEBUG_SYNC='innodb_alter_inplace_before_commit SIGNAL ddl WAIT_FOR ever'; |
| 148 |
ALTER TABLE t3 ADD COLUMN c3 TEXT NOT NULL DEFAULT 'sic transit gloria mundi'; |
| 149 |
connection default; |
| 150 |
SET DEBUG_SYNC='now WAIT_FOR ddl'; |
| 151 |
SET GLOBAL innodb_flush_log_at_trx_commit=1; |
| 152 |
COMMIT; |
| 153 |
# Kill the server |
| 154 |
disconnect ddl; |
| 155 |
# restart |
| 156 |
SHOW CREATE TABLE t1; |
| 157 |
Table Create Table |
| 158 |
t1 CREATE TABLE `t1` ( |
| 159 |
`id` int(11) NOT NULL, |
| 160 |
`c2` int(11) DEFAULT NULL, |
| 161 |
PRIMARY KEY (`id`), |
| 162 |
UNIQUE KEY `c2` (`c2`) |
| 163 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci STATS_PERSISTENT=0 ROW_FORMAT=REDUNDANT |
| 164 |
SHOW CREATE TABLE t2; |
| 165 |
Table Create Table |
| 166 |
t2 CREATE TABLE `t2` ( |
| 167 |
`id` int(11) NOT NULL, |
| 168 |
`c2` int(11) DEFAULT NULL, |
| 169 |
PRIMARY KEY (`id`), |
| 170 |
UNIQUE KEY `c2` (`c2`) |
| 171 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci STATS_PERSISTENT=0 ROW_FORMAT=REDUNDANT |
| 172 |
SHOW CREATE TABLE t3; |
| 173 |
Table Create Table |
| 174 |
t3 CREATE TABLE `t3` ( |
| 175 |
`id` int(11) NOT NULL, |
| 176 |
`c2` int(11) DEFAULT NULL, |
| 177 |
`v2` int(11) GENERATED ALWAYS AS (`c2`) VIRTUAL, |
| 178 |
PRIMARY KEY (`id`), |
| 179 |
UNIQUE KEY `v2` (`v2`) |
| 180 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 181 |
DROP TABLE t2,t3; |
| 182 |
# |
| 183 |
# MDEV-29440 InnoDB instant ALTER TABLE recovery wrongly uses |
| 184 |
# READ COMMITTED isolation level instead of READ UNCOMMITTED |
| 185 |
# |
| 186 |
CREATE TABLE t2(a INT UNSIGNED PRIMARY KEY) ENGINE=InnoDB; |
| 187 |
INSERT INTO t2 VALUES (1),(2),(3),(4),(5),(6); |
| 188 |
BEGIN; |
| 189 |
DELETE FROM t1; |
| 190 |
connect ddl, localhost, root; |
| 191 |
SET DEBUG_SYNC='innodb_alter_inplace_before_commit SIGNAL ddl WAIT_FOR ever'; |
| 192 |
ALTER TABLE t2 ADD COLUMN b TINYINT UNSIGNED NOT NULL DEFAULT 42 FIRST; |
| 193 |
connection default; |
| 194 |
SET DEBUG_SYNC='now WAIT_FOR ddl'; |
| 195 |
SET GLOBAL innodb_flush_log_at_trx_commit=1; |
| 196 |
COMMIT; |
| 197 |
# Kill the server |
| 198 |
disconnect ddl; |
| 199 |
# restart |
| 200 |
CHECK TABLE t2; |
| 201 |
Table Op Msg_type Msg_text |
| 202 |
test.t2 check status OK |
| 203 |
DROP TABLE t1,t2; |
| 204 |
db.opt |