summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2018-05-02 16:42:00 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2018-05-02 16:42:00 +0530
commitdcc5de66f45e6362ce20f2a8f1437b032735f996 (patch)
tree833908bcbcd69d7c16c75abb7ce792661f18b366
parent8a941bad7d80ecdd3364f8128100d03dfeb2c6b4 (diff)
downloadmariadb-git-dcc5de66f45e6362ce20f2a8f1437b032735f996.tar.gz
MDEV-16071 Server crashed in innobase_build_col_map / prepare_inplace_alter_table_dict or Assertion `tuple' failed in dtuple_get_nth_field upon altering table with virtual column
- Virtual column should be considered during innobase_build_col_map() to find out whether the field changed from NULL to NOT NULL.
-rw-r--r--mysql-test/suite/innodb/r/alter_not_null.result6
-rw-r--r--mysql-test/suite/innodb/t/alter_not_null.test8
-rw-r--r--storage/innobase/handler/handler0alter.cc4
3 files changed, 16 insertions, 2 deletions
diff --git a/mysql-test/suite/innodb/r/alter_not_null.result b/mysql-test/suite/innodb/r/alter_not_null.result
index db24bf91223..c30b0f91d22 100644
--- a/mysql-test/suite/innodb/r/alter_not_null.result
+++ b/mysql-test/suite/innodb/r/alter_not_null.result
@@ -73,3 +73,9 @@ f1 b
ALTER TABLE t1 CHANGE b b TINYINT NOT NULL DEFAULT if(unix_timestamp()>1,1000,0), algorithm=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: cannot convert NULL to non-constant DEFAULT. Try ALGORITHM=COPY
DROP TABLE t1;
+CREATE TABLE t1(a INT, v INT AS (a), c INT, d INT NOT NULL, e INT) ENGINE=InnoDB;
+ALTER TABLE t1 DROP COLUMN c, CHANGE COLUMN e e INT NOT NULL, ALGORITHM=INPLACE;
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, v INT AS (a), d INT NOT NULL, e INT) ENGINE=InnoDB;
+ALTER TABLE t1 FORCE, ALGORITHM=INPLACE;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/alter_not_null.test b/mysql-test/suite/innodb/t/alter_not_null.test
index b0c1f7b8bb3..1c210eff9dc 100644
--- a/mysql-test/suite/innodb/t/alter_not_null.test
+++ b/mysql-test/suite/innodb/t/alter_not_null.test
@@ -56,3 +56,11 @@ SELECT * FROM t1;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1 CHANGE b b TINYINT NOT NULL DEFAULT if(unix_timestamp()>1,1000,0), algorithm=INPLACE;
DROP TABLE t1;
+
+CREATE TABLE t1(a INT, v INT AS (a), c INT, d INT NOT NULL, e INT) ENGINE=InnoDB;
+ALTER TABLE t1 DROP COLUMN c, CHANGE COLUMN e e INT NOT NULL, ALGORITHM=INPLACE;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT, v INT AS (a), d INT NOT NULL, e INT) ENGINE=InnoDB;
+ALTER TABLE t1 FORCE, ALGORITHM=INPLACE;
+DROP TABLE t1;
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index bb0f971f4bf..686037cd70f 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -3282,13 +3282,13 @@ innobase_build_col_map(
if (new_field->field == field) {
const Field* altered_field =
- altered_table->field[i];
+ altered_table->field[i + num_v];
if (field->real_maybe_null()
&& !altered_field->real_maybe_null()) {
innobase_build_col_map_add(
heap, dtuple_get_nth_field(
- defaults, i),
+ defaults, i + num_v),
altered_field,
dict_table_is_comp(new_table));
}