Skip to content

Commit

Permalink
MDEV-18869 Assertion `!((field)->vcol_info && (field)->stored_in_db()…
Browse files Browse the repository at this point in the history
…)' failed in innodb_col_no upon altering table with system versioning

WITH/WITHOUT SYSTEM VERSIONING is not supported for generated columns
at parser level (see definition of field_def rule).
  • Loading branch information
midenok authored and dr-m committed Mar 26, 2019
1 parent ffc69db commit a138d06
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 1 deletion.
61 changes: 61 additions & 0 deletions mysql-test/suite/versioning/r/alter.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
34 changes: 34 additions & 0 deletions mysql-test/suite/versioning/t/alter.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion storage/innobase/handler/handler0alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit a138d06

Please sign in to comment.