summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-08-04 11:49:52 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-08-04 11:49:52 +0300
commit9a156e1a23046ba3e37bdb1e4e1ad887d3f5829b (patch)
tree5db729c25fd8adafb5bdc1b63dc5ab28e792e3c9
parent57325e470615e79f674d82b2d5b09f609508fc6a (diff)
downloadmariadb-git-9a156e1a23046ba3e37bdb1e4e1ad887d3f5829b.tar.gz
MDEV-23345 Assertion not_redundant() == old.not_redundant()
In commit fd9ca2a742abe2e91b2b77e70915dec7bd3cd7e1 (MDEV-23295) we added a debug assertion, which caught a similar bug. prepare_inplace_alter_table_dict(): If we had promised that ALGORITHM=INPLACE or ALGORITHM=NOCOPY is supported, we must preserve the ROW_FORMAT.
-rw-r--r--mysql-test/suite/innodb/r/default_row_format_alter,compact.rdiff11
-rw-r--r--mysql-test/suite/innodb/r/default_row_format_alter,redundant.rdiff13
-rw-r--r--mysql-test/suite/innodb/r/default_row_format_alter.result11
-rw-r--r--mysql-test/suite/innodb/t/default_row_format_alter.test10
-rw-r--r--storage/innobase/handler/handler0alter.cc10
5 files changed, 49 insertions, 6 deletions
diff --git a/mysql-test/suite/innodb/r/default_row_format_alter,compact.rdiff b/mysql-test/suite/innodb/r/default_row_format_alter,compact.rdiff
index 09095c90e29..c6c582fab93 100644
--- a/mysql-test/suite/innodb/r/default_row_format_alter,compact.rdiff
+++ b/mysql-test/suite/innodb/r/default_row_format_alter,compact.rdiff
@@ -1,10 +1,19 @@
--- default_row_format_alter.result
+++ default_row_format_alter,compact.reject
-@@ -91,6 +91,6 @@
+@@ -91,7 +91,7 @@
ALTER TABLE t1 ADD b INT;
SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
ROW_FORMAT
-Dynamic
+Compact
DROP TABLE t1;
+ #
+ # MDEV-23345 Assertion not_redundant() == old.not_redundant() failed
+@@ -102,6 +102,6 @@
+ ALTER TABLE t1 DROP b;
+ SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
+ ROW_FORMAT
+-Dynamic
++Compact
+ DROP TABLE t1;
SET GLOBAL innodb_default_row_format = @row_format;
diff --git a/mysql-test/suite/innodb/r/default_row_format_alter,redundant.rdiff b/mysql-test/suite/innodb/r/default_row_format_alter,redundant.rdiff
index 972ee9bdac8..a05a9914271 100644
--- a/mysql-test/suite/innodb/r/default_row_format_alter,redundant.rdiff
+++ b/mysql-test/suite/innodb/r/default_row_format_alter,redundant.rdiff
@@ -1,10 +1,19 @@
--- default_row_format_alter.result
-+++ default_row_format_alter,compact.reject
-@@ -91,6 +91,6 @@
++++ default_row_format_alter,redundant.reject
+@@ -91,7 +91,7 @@
ALTER TABLE t1 ADD b INT;
SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
ROW_FORMAT
-Dynamic
+Redundant
DROP TABLE t1;
+ #
+ # MDEV-23345 Assertion not_redundant() == old.not_redundant() failed
+@@ -102,6 +102,6 @@
+ ALTER TABLE t1 DROP b;
+ SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
+ ROW_FORMAT
+-Dynamic
++Redundant
+ DROP TABLE t1;
SET GLOBAL innodb_default_row_format = @row_format;
diff --git a/mysql-test/suite/innodb/r/default_row_format_alter.result b/mysql-test/suite/innodb/r/default_row_format_alter.result
index 42d006a2dd3..363954c1a6c 100644
--- a/mysql-test/suite/innodb/r/default_row_format_alter.result
+++ b/mysql-test/suite/innodb/r/default_row_format_alter.result
@@ -93,4 +93,15 @@ SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
ROW_FORMAT
Dynamic
DROP TABLE t1;
+#
+# MDEV-23345 Assertion not_redundant() == old.not_redundant() failed
+#
+SET GLOBAL innodb_default_row_format = @row_format;
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT, KEY(b)) ENGINE=InnoDB;
+SET GLOBAL innodb_default_row_format= COMPACT;
+ALTER TABLE t1 DROP b;
+SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
+ROW_FORMAT
+Dynamic
+DROP TABLE t1;
SET GLOBAL innodb_default_row_format = @row_format;
diff --git a/mysql-test/suite/innodb/t/default_row_format_alter.test b/mysql-test/suite/innodb/t/default_row_format_alter.test
index 6690bc5bddf..1f0b0d56bc4 100644
--- a/mysql-test/suite/innodb/t/default_row_format_alter.test
+++ b/mysql-test/suite/innodb/t/default_row_format_alter.test
@@ -106,4 +106,14 @@ ALTER TABLE t1 ADD b INT;
SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
DROP TABLE t1;
+--echo #
+--echo # MDEV-23345 Assertion not_redundant() == old.not_redundant() failed
+--echo #
+SET GLOBAL innodb_default_row_format = @row_format;
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT, KEY(b)) ENGINE=InnoDB;
+SET GLOBAL innodb_default_row_format= COMPACT;
+ALTER TABLE t1 DROP b;
+SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
+DROP TABLE t1;
+
SET GLOBAL innodb_default_row_format = @row_format;
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 3f63cc82f89..d8694da02d7 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -6209,9 +6209,13 @@ prepare_inplace_alter_table_dict(
user_table = ctx->new_table;
- if (ha_alter_info->inplace_supported == HA_ALTER_INPLACE_INSTANT) {
- /* If we promised ALGORITHM=INSTANT capability, we must
- retain the original ROW_FORMAT of the table. */
+ switch (ha_alter_info->inplace_supported) {
+ default: break;
+ case HA_ALTER_INPLACE_INSTANT:
+ case HA_ALTER_INPLACE_NOCOPY_LOCK:
+ case HA_ALTER_INPLACE_NOCOPY_NO_LOCK:
+ /* If we promised ALGORITHM=NOCOPY or ALGORITHM=INSTANT,
+ we must retain the original ROW_FORMAT of the table. */
flags = (user_table->flags & (DICT_TF_MASK_COMPACT
| DICT_TF_MASK_ATOMIC_BLOBS))
| (flags & ~(DICT_TF_MASK_COMPACT