Skip to content

Commit d270525

Browse files
MDEV-23805 Make Online DDL to Instant DDL when table is empty
- In ha_innobase::prepare_inplace_alter_table(), InnoDB should check whether the table is empty. If the table is empty then server should avoid downgrading the MDL after prepare phase. It is more like instant alter, does change only in dicationary and metadata. - Changed few debug test case to make non-empty DDL table
1 parent c5380c3 commit d270525

23 files changed

+73
-13
lines changed

mysql-test/suite/gcol/r/virtual_index_drop.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ t1 CREATE TABLE `t1` (
2525
) ENGINE=InnoDB DEFAULT CHARSET=latin1
2626
DROP TABLE t1;
2727
CREATE TABLE t1(f1 INT, f2 INT AS (f1) VIRTUAL)ENGINE=InnoDB;
28+
INSERT INTO t1(f1) VALUES(1);
2829
SET DEBUG_DBUG="+d,create_index_fail";
2930
SET DEBUG_SYNC="innodb_inplace_alter_table_enter SIGNAL con1_go WAIT_FOR alter_signal";
3031
ALTER TABLE t1 ADD COLUMN f3 INT AS (f1) VIRTUAL, ADD INDEX(f2, f3);
@@ -33,6 +34,7 @@ SET DEBUG_SYNC="now WAIT_FOR con1_go";
3334
BEGIN;
3435
SELECT * FROM t1;
3536
f1 f2
37+
1 1
3638
SET DEBUG_SYNC="now SIGNAL alter_signal";
3739
connection default;
3840
ERROR 23000: Duplicate entry '' for key '*UNKNOWN*'
@@ -47,6 +49,7 @@ t1 CREATE TABLE `t1` (
4749
) ENGINE=InnoDB DEFAULT CHARSET=latin1
4850
DROP TABLE t1;
4951
CREATE TABLE t1(f1 INT, f2 INT AS (f1) VIRTUAL)ENGINE=InnoDB;
52+
INSERT INTO t1(f1) VALUES(1);
5053
SET DEBUG_DBUG="+d,create_index_fail";
5154
SET DEBUG_SYNC="innodb_inplace_alter_table_enter SIGNAL con1_go WAIT_FOR alter_signal";
5255
ALTER TABLE t1 ADD INDEX(f2);

mysql-test/suite/gcol/t/virtual_index_drop.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ DROP TABLE t1;
2929
# new_vcol_info in index when rollback of alter happens
3030

3131
CREATE TABLE t1(f1 INT, f2 INT AS (f1) VIRTUAL)ENGINE=InnoDB;
32+
INSERT INTO t1(f1) VALUES(1);
3233
SET DEBUG_DBUG="+d,create_index_fail";
3334
SET DEBUG_SYNC="innodb_inplace_alter_table_enter SIGNAL con1_go WAIT_FOR alter_signal";
3435
SEND ALTER TABLE t1 ADD COLUMN f3 INT AS (f1) VIRTUAL, ADD INDEX(f2, f3);
@@ -47,6 +48,7 @@ SHOW CREATE TABLE t1;
4748
DROP TABLE t1;
4849

4950
CREATE TABLE t1(f1 INT, f2 INT AS (f1) VIRTUAL)ENGINE=InnoDB;
51+
INSERT INTO t1(f1) VALUES(1);
5052
SET DEBUG_DBUG="+d,create_index_fail";
5153
SET DEBUG_SYNC="innodb_inplace_alter_table_enter SIGNAL con1_go WAIT_FOR alter_signal";
5254
send ALTER TABLE t1 ADD INDEX(f2);

mysql-test/suite/innodb/r/alter_candidate_key.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ CREATE TABLE t1(f1 INT, f2 INT,
3434
PRIMARY KEY(f1, f2),
3535
UNIQUE INDEX uidx2 (f1, f2),
3636
UNIQUE INDEX uidx1 (f2))ENGINE=InnoDB;
37+
INSERT INTO t1 VALUES(2, 2);
3738
ALTER TABLE t1 DROP PRIMARY KEY;
3839
SHOW CREATE TABLE t1;
3940
Table Create Table
@@ -66,6 +67,7 @@ test.t1 check status OK
6667
DROP TABLE t1;
6768
SET SQL_MODE= strict_trans_tables;
6869
CREATE TABLE t1(a INT UNIQUE) ENGINE=InnoDB;
70+
INSERT INTO t1 VALUES(1);
6971
SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL dml WAIT_FOR dml_done';
7072
ALTER TABLE t1 MODIFY COLUMN a INT NOT NULL;
7173
connection con1;

mysql-test/suite/innodb/r/alter_not_null_debug.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ SET DEBUG_SYNC='RESET';
8080
#
8181
CREATE TABLE t1 (f VARCHAR(8) CHARACTER SET latin1 COLLATE latin1_swedish_ci)
8282
ENGINE=InnoDB;
83+
INSERT INTO t1 VALUES('ZERO');
8384
connection con1;
8485
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL scanned WAIT_FOR insert_done';
8586
ALTER TABLE t1 MODIFY f VARCHAR(256) COLLATE latin1_german2_ci NOT NULL;
@@ -96,5 +97,6 @@ ALTER TABLE t1 CHANGE f eins VARCHAR(257) COLLATE latin1_german1_ci NOT NULL,
9697
ALGORITHM=INSTANT;
9798
SELECT * FROM t1;
9899
eins
100+
ZERO
99101
one
100102
DROP TABLE t1;

mysql-test/suite/innodb/r/alter_primary_key.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#
55
CREATE TABLE t0 (pk INT PRIMARY KEY) ENGINE=InnoDB;
66
CREATE TABLE t1 (c CHAR(2) NOT NULL) ENGINE=InnoDB;
7+
INSERT INTO t1 VALUES('cd');
78
connect con1,localhost,root,,;
89
BEGIN;
910
INSERT INTO t0 VALUES(1);
@@ -21,6 +22,7 @@ ERROR 23000: Duplicate entry 'a' for key 'PRIMARY'
2122
SET DEBUG_SYNC='RESET';
2223
SELECT * FROM t1;
2324
c
25+
cd
2426
ab
2527
ac
2628
DROP TABLE t0,t1;

mysql-test/suite/innodb/r/ddl_purge.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CREATE TABLE t0 (pk INT PRIMARY KEY) ENGINE=InnoDB;
22
CREATE TABLE t1 (pk INT PRIMARY KEY, b INT) ENGINE=InnoDB;
3+
INSERT INTO t1 VALUES(100, 100);
34
connect con1,localhost,root,,test;
45
BEGIN;
56
INSERT INTO t0 SET pk=1;

mysql-test/suite/innodb/r/innodb-alter-tempfile.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ connect con1,localhost,root,,;
6161
BEGIN;
6262
DELETE FROM mysql.innodb_table_stats;
6363
connect con2,localhost,root,,;
64-
SET DEBUG_SYNC='inplace_after_index_build SIGNAL blocked WAIT_FOR ever';
64+
SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL blocked WAIT_FOR ever';
6565
ALTER TABLE t1 FORCE;
6666
connection default;
6767
SET DEBUG_SYNC='now WAIT_FOR blocked';

mysql-test/suite/innodb/r/innodb-index-debug.result

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ COUNT(k1) k2 k3
8181
drop table t1;
8282
create table t1(k1 int auto_increment primary key,
8383
k2 char(200),k3 char(200))engine=innodb;
84+
INSERT INTO t1 VALUES(1, "test", "test");
8485
SET DEBUG_SYNC= 'row_merge_after_scan
8586
SIGNAL opened WAIT_FOR flushed';
8687
ALTER TABLE t1 FORCE, ADD COLUMN k4 int;
@@ -100,6 +101,7 @@ SELECT COUNT(k1),k2,k3 FROM t1 GROUP BY k2,k3;
100101
COUNT(k1) k2 k3
101102
480 aaa bbb
102103
480 aaaa bbbb
104+
1 test test
103105
disconnect con1;
104106
connection default;
105107
show create table t1;
@@ -109,14 +111,15 @@ t1 CREATE TABLE `t1` (
109111
`k2` char(200) DEFAULT NULL,
110112
`k3` char(200) DEFAULT NULL,
111113
PRIMARY KEY (`k1`)
112-
) ENGINE=InnoDB AUTO_INCREMENT=1023 DEFAULT CHARSET=latin1
114+
) ENGINE=InnoDB AUTO_INCREMENT=1024 DEFAULT CHARSET=latin1
113115
drop table t1;
114116
drop table t480;
115117
#
116118
# MDEV-12827 Assertion failure when reporting duplicate key error
117119
# in online table rebuild
118120
#
119121
CREATE TABLE t1 (j INT UNIQUE, i INT UNIQUE) ENGINE=InnoDB;
122+
INSERT INTO t1 VALUES(2, 2);
120123
connect con1,localhost,root,,test;
121124
SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL built WAIT_FOR log';
122125
ALTER TABLE t1 DROP j, FORCE;

mysql-test/suite/innodb/r/innodb-index-online.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ DROP TABLE t1;
509509
# MDEV-13205 assertion !dict_index_is_online_ddl(index) upon ALTER TABLE
510510
#
511511
CREATE TABLE t1 (c VARCHAR(64)) ENGINE=InnoDB;
512+
INSERT INTO t1 VALUES('foo');
512513
SET DEBUG_SYNC = 'row_log_apply_before SIGNAL t1u_created WAIT_FOR dup_done';
513514
ALTER TABLE t1 ADD UNIQUE(c);
514515
connection con1;

mysql-test/suite/innodb/r/instant_alter_debug.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ connect stop_purge,localhost,root;
171171
START TRANSACTION WITH CONSISTENT SNAPSHOT;
172172
connect ddl,localhost,root,,test;
173173
DELETE FROM t1;
174+
INSERT INTO t1 VALUES(1, 2);
174175
SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL copied WAIT_FOR logged';
175176
ALTER TABLE t1 FORCE;
176177
connection default;
@@ -449,6 +450,7 @@ DROP TABLE t1;
449450
CREATE TABLE t1
450451
(a INT NOT NULL, b INT, c INT, d INT, e INT, f INT, g INT, h INT, i TEXT)
451452
ENGINE=InnoDB;
453+
INSERT INTO t1 VALUES(1, 2, 3, 4, 5, 6, 7, 8, "test");
452454
ALTER TABLE t1 MODIFY a INT NULL;
453455
SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL alter WAIT_FOR go';
454456
ALTER TABLE t1 ADD PRIMARY KEY (a);
@@ -462,6 +464,7 @@ connection default;
462464
disconnect con1;
463465
SELECT * FROM t1;
464466
a b c d e f g h i
467+
1 2 3 4 5 6 7 8 test
465468
DROP TABLE t1;
466469
SET DEBUG_SYNC=RESET;
467470
# End of 10.4 tests

0 commit comments

Comments
 (0)