summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2022-03-14 22:35:11 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2022-03-14 22:35:11 +0530
commit1c43660aea349a92c13e04994941ded1b91714ff (patch)
treee137e948f0321a3af841723f9259667a7dd46f0a
parent8afabca6fd1f6b3a4cdeb77669e9a9f9040b461b (diff)
downloadmariadb-git-1c43660aea349a92c13e04994941ded1b91714ff.tar.gz
MDEV-28060 Online DDL fails while checking for instant alter condition
- InnoDB fails to skip newly created column while checking for change column when table is in redundant row format. This issue is caused the MDEV-18035 (ccb1acbd3c15f0d99d1ea3cd1b206da38fa1c17f)
-rw-r--r--mysql-test/suite/innodb/r/instant_alter_bugs.result9
-rw-r--r--mysql-test/suite/innodb/t/instant_alter_bugs.test9
-rw-r--r--storage/innobase/handler/handler0alter.cc7
3 files changed, 24 insertions, 1 deletions
diff --git a/mysql-test/suite/innodb/r/instant_alter_bugs.result b/mysql-test/suite/innodb/r/instant_alter_bugs.result
index e0457155d6a..0c82ee8f070 100644
--- a/mysql-test/suite/innodb/r/instant_alter_bugs.result
+++ b/mysql-test/suite/innodb/r/instant_alter_bugs.result
@@ -448,4 +448,13 @@ ALTER TABLE t ADD d INT;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
DROP TABLE t;
+#
+# MDEV-28060 Online DDL fails while checking for instant
+# alter condition
+#
+CREATE TABLE t1(f1 CHAR(10) NOT NULL)ROW_FORMAT=REDUNDANT,ENGINE=InnoDB;
+ALTER TABLE t1 ADD COLUMN(f2 INT NOT NULL, f3 INT NOT NULL,
+f4 INT NOT NULL, f5 INT NOT NULL),
+CHANGE COLUMN f1 f1 CHAR(10) DEFAULT NULL;
+DROP TABLE t1;
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
diff --git a/mysql-test/suite/innodb/t/instant_alter_bugs.test b/mysql-test/suite/innodb/t/instant_alter_bugs.test
index 1ba6442c860..b22d4bbbae1 100644
--- a/mysql-test/suite/innodb/t/instant_alter_bugs.test
+++ b/mysql-test/suite/innodb/t/instant_alter_bugs.test
@@ -466,4 +466,13 @@ ALTER TABLE t ADD d INT;
--disable_info
DROP TABLE t;
+--echo #
+--echo # MDEV-28060 Online DDL fails while checking for instant
+--echo # alter condition
+--echo #
+CREATE TABLE t1(f1 CHAR(10) NOT NULL)ROW_FORMAT=REDUNDANT,ENGINE=InnoDB;
+ALTER TABLE t1 ADD COLUMN(f2 INT NOT NULL, f3 INT NOT NULL,
+ f4 INT NOT NULL, f5 INT NOT NULL),
+ CHANGE COLUMN f1 f1 CHAR(10) DEFAULT NULL;
+DROP TABLE t1;
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index e812bfc4928..e79d9d67dbf 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -1795,8 +1795,13 @@ set_max_size:
Field** af = altered_table->field;
Field** const end = altered_table->field
+ altered_table->s->fields;
+ List_iterator_fast<Create_field> cf_it(
+ ha_alter_info->alter_info->create_list);
for (unsigned c = 0; af < end; af++) {
- if (!(*af)->stored_in_db()) {
+ const Create_field* cf = cf_it++;
+ if (!cf->field || !(*af)->stored_in_db()) {
+ /* Ignore virtual or newly created
+ column */
continue;
}