Skip to content

Commit

Permalink
MDEV-23345 Assertion not_redundant() == old.not_redundant()
Browse files Browse the repository at this point in the history
In commit fd9ca2a (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.
  • Loading branch information
dr-m committed Aug 4, 2020
1 parent 57325e4 commit 9a156e1
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
11 changes: 10 additions & 1 deletion mysql-test/suite/innodb/r/default_row_format_alter,compact.rdiff
Original file line number Diff line number Diff line change
@@ -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;
13 changes: 11 additions & 2 deletions mysql-test/suite/innodb/r/default_row_format_alter,redundant.rdiff
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 11 additions & 0 deletions mysql-test/suite/innodb/r/default_row_format_alter.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
10 changes: 10 additions & 0 deletions mysql-test/suite/innodb/t/default_row_format_alter.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
10 changes: 7 additions & 3 deletions storage/innobase/handler/handler0alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9a156e1

Please sign in to comment.