diff options
-rw-r--r-- | mysql-test/suite/innodb/r/alter_not_null.result | 6 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/alter_not_null.test | 8 | ||||
-rw-r--r-- | storage/innobase/handler/handler0alter.cc | 4 |
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)); } |