diff --git a/mysql-test/suite/versioning/r/alter.result b/mysql-test/suite/versioning/r/alter.result index f1637d79543..528c6ca7c2f 100644 --- a/mysql-test/suite/versioning/r/alter.result +++ b/mysql-test/suite/versioning/r/alter.result @@ -542,5 +542,66 @@ alter table t add check (a > 0); insert into t values (0); ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t` insert into t values (2); +# +# MDEV-18869 Assertion `!((field)->vcol_info && (field)->stored_in_db())' failed in innodb_col_no upon altering table with system versioning +# +set system_versioning_alter_history= keep; +create or replace table t1 (a int, b int generated always as (0) stored) engine=innodb with system versioning; +insert into t1 (a) values (1); +alter table t1 modify a int without system versioning, algorithm=copy; +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +alter table t1 modify a int with system versioning, algorithm=copy; +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +alter table t1 modify a int without system versioning; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +alter table t1 modify a int with system versioning; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) GENERATED ALWAYS AS (0) STORED +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +select * from t1; +a b +1 0 +alter table t1 modify b int generated always as (0) stored without system versioning; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'without system versioning' at line 1 +alter table t1 modify b int generated always as (0) stored with system versioning; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'system versioning' at line 1 +alter table t1 modify b int without system versioning; +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +select * from t1; +a b +1 0 +create or replace table t1 (a int, b int generated always as (0) virtual) engine=innodb with system versioning; +insert into t1 (a) values (1); +alter table t1 modify a int without system versioning, algorithm=copy; +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +alter table t1 modify a int with system versioning, algorithm=copy; +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 +alter table t1 modify a int without system versioning; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +alter table t1 modify a int with system versioning; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +select * from t1; +a b +1 0 +affected rows: 1 drop database test; create database test; diff --git a/mysql-test/suite/versioning/t/alter.test b/mysql-test/suite/versioning/t/alter.test index 05bd6019a32..4af937b96e7 100644 --- a/mysql-test/suite/versioning/t/alter.test +++ b/mysql-test/suite/versioning/t/alter.test @@ -469,5 +469,39 @@ alter table t add check (a > 0); insert into t values (0); insert into t values (2); +--echo # +--echo # MDEV-18869 Assertion `!((field)->vcol_info && (field)->stored_in_db())' failed in innodb_col_no upon altering table with system versioning +--echo # +set system_versioning_alter_history= keep; +create or replace table t1 (a int, b int generated always as (0) stored) engine=innodb with system versioning; +insert into t1 (a) values (1); +--enable_info +alter table t1 modify a int without system versioning, algorithm=copy; +alter table t1 modify a int with system versioning, algorithm=copy; +alter table t1 modify a int without system versioning; +alter table t1 modify a int with system versioning; +--disable_info +show create table t1; +select * from t1; +--enable_info +--error ER_PARSE_ERROR +alter table t1 modify b int generated always as (0) stored without system versioning; +--error ER_PARSE_ERROR +alter table t1 modify b int generated always as (0) stored with system versioning; +alter table t1 modify b int without system versioning; +--disable_info +show create table t1; +select * from t1; + +create or replace table t1 (a int, b int generated always as (0) virtual) engine=innodb with system versioning; +insert into t1 (a) values (1); +--enable_info +alter table t1 modify a int without system versioning, algorithm=copy; +alter table t1 modify a int with system versioning, algorithm=copy; +alter table t1 modify a int without system versioning; +alter table t1 modify a int with system versioning; +select * from t1; +--disable_info + drop database test; create database test; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 96cef4eabd0..796a3763da0 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -8588,7 +8588,7 @@ vers_change_fields_cache( ha_alter_info->alter_info->create_list); while (const Create_field* create_field = it++) { - if (!create_field->field) { + if (!create_field->field || create_field->field->vcol_info) { continue; } dict_col_t* col = dict_table_get_nth_col(