Skip to content

Commit

Permalink
MDEV-14744 Assertion `table->versioned() == m_prebuilt->table->versio…
Browse files Browse the repository at this point in the history
…ned()' failed in ha_innobase::open
  • Loading branch information
kevgs committed Dec 28, 2017
1 parent 04451f0 commit 0fe67f2
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 18 deletions.
11 changes: 11 additions & 0 deletions mysql-test/suite/versioning/r/alter.result
Original file line number Diff line number Diff line change
Expand Up @@ -432,5 +432,16 @@ alter table t change column if exists b c bigint unsigned generated always as ro
ERROR HY000: This is not yet supported for generated columns
alter table t change column if exists b c bigint unsigned generated always as row end;
ERROR HY000: This is not yet supported for generated columns
drop table t;
# MDEV-14744 trx_id-based and transaction-based mixup in assertion
create or replace table t (c text) engine=innodb with system versioning;
show create table t;
Table Create Table
t CREATE TABLE `t` (
`c` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t add fulltext key (c);
Warnings:
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
drop database test;
create database test;
32 changes: 28 additions & 4 deletions mysql-test/suite/versioning/r/foreign.result
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ id int unique key
) engine innodb;
create table child(
parent_id int,
sys_start SYS_DATATYPE as row start invisible,
sys_end SYS_DATATYPE as row end invisible,
period for system_time(sys_start, sys_end),
foreign key(parent_id) references parent(id)
on delete restrict
on update restrict
Expand Down Expand Up @@ -36,6 +39,9 @@ id int(10) unsigned unique key
) engine innodb;
create table child(
parent_id int(10) unsigned primary key,
sys_start SYS_DATATYPE as row start invisible,
sys_end SYS_DATATYPE as row end invisible,
period for system_time(sys_start, sys_end),
foreign key(parent_id) references parent(id)
) engine innodb with system versioning;
insert into parent values(1);
Expand All @@ -52,6 +58,9 @@ id int unique key
) engine innodb;
create table child(
parent_id int,
sys_start SYS_DATATYPE as row start invisible,
sys_end SYS_DATATYPE as row end invisible,
period for system_time(sys_start, sys_end),
foreign key(parent_id) references parent(id)
on delete cascade
on update cascade
Expand Down Expand Up @@ -83,7 +92,10 @@ parent_id
drop table child;
drop table parent;
create or replace table parent (
id int primary key
id int primary key,
sys_start SYS_DATATYPE as row start invisible,
sys_end SYS_DATATYPE as row end invisible,
period for system_time(sys_start, sys_end)
) with system versioning
engine innodb;
create or replace table child (
Expand Down Expand Up @@ -136,6 +148,9 @@ id int unique key
) engine innodb;
create table child(
parent_id int,
sys_start SYS_DATATYPE as row start invisible,
sys_end SYS_DATATYPE as row end invisible,
period for system_time(sys_start, sys_end),
foreign key(parent_id) references parent(id)
on delete set null
on update set null
Expand Down Expand Up @@ -163,7 +178,10 @@ drop table parent;
# Parent table is foreign #
###########################
create or replace table parent(
id int unique key
id int unique key,
sys_start SYS_DATATYPE as row start invisible,
sys_end SYS_DATATYPE as row end invisible,
period for system_time(sys_start, sys_end)
) engine innodb with system versioning;
create or replace table child(
parent_id int,
Expand Down Expand Up @@ -192,12 +210,18 @@ drop table parent;
###################
create or replace table a (
cola int(10) primary key,
v_cola int(10) as (cola mod 10) virtual
v_cola int(10) as (cola mod 10) virtual,
sys_start SYS_DATATYPE as row start invisible,
sys_end SYS_DATATYPE as row end invisible,
period for system_time(sys_start, sys_end)
) engine=innodb with system versioning;
create index v_cola on a (v_cola);
create or replace table b(
cola int(10),
v_cola int(10)
v_cola int(10),
sys_start SYS_DATATYPE as row start invisible,
sys_end SYS_DATATYPE as row end invisible,
period for system_time(sys_start, sys_end)
) engine=innodb with system versioning;
alter table b add constraint `v_cola_fk`
foreign key (v_cola) references a (v_cola);
Expand Down
6 changes: 6 additions & 0 deletions mysql-test/suite/versioning/t/alter.test
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@ create or replace temporary table t (a int);
alter table t change column if exists b c bigint unsigned generated always as row start;
--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
alter table t change column if exists b c bigint unsigned generated always as row end;
drop table t;

--echo # MDEV-14744 trx_id-based and transaction-based mixup in assertion
create or replace table t (c text) engine=innodb with system versioning;
show create table t;
alter table t add fulltext key (c);


drop database test;
Expand Down
5 changes: 5 additions & 0 deletions mysql-test/suite/versioning/t/foreign.combinations
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[timestamp]
default-storage-engine=innodb

[trx_id]
default-storage-engine=innodb
60 changes: 47 additions & 13 deletions mysql-test/suite/versioning/t/foreign.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- source include/have_innodb.inc
--source suite/versioning/common.inc

--echo #################
--echo # Test RESTRICT #
Expand All @@ -8,8 +8,12 @@ create table parent(
id int unique key
) engine innodb;

create table child(
--replace_result $sys_datatype_expl SYS_DATATYPE
eval create table child(
parent_id int,
sys_start $sys_datatype_expl as row start invisible,
sys_end $sys_datatype_expl as row end invisible,
period for system_time(sys_start, sys_end),
foreign key(parent_id) references parent(id)
on delete restrict
on update restrict
Expand Down Expand Up @@ -42,8 +46,12 @@ create table parent(
id int(10) unsigned unique key
) engine innodb;

create table child(
--replace_result $sys_datatype_expl SYS_DATATYPE
eval create table child(
parent_id int(10) unsigned primary key,
sys_start $sys_datatype_expl as row start invisible,
sys_end $sys_datatype_expl as row end invisible,
period for system_time(sys_start, sys_end),
foreign key(parent_id) references parent(id)
) engine innodb with system versioning;

Expand All @@ -64,8 +72,12 @@ create table parent(
id int unique key
) engine innodb;

create table child(
--replace_result $sys_datatype_expl SYS_DATATYPE
eval create table child(
parent_id int,
sys_start $sys_datatype_expl as row start invisible,
sys_end $sys_datatype_expl as row end invisible,
period for system_time(sys_start, sys_end),
foreign key(parent_id) references parent(id)
on delete cascade
on update cascade
Expand Down Expand Up @@ -93,8 +105,12 @@ select * from child for system_time all;
drop table child;
drop table parent;

create or replace table parent (
id int primary key
--replace_result $sys_datatype_expl SYS_DATATYPE
eval create or replace table parent (
id int primary key,
sys_start $sys_datatype_expl as row start invisible,
sys_end $sys_datatype_expl as row end invisible,
period for system_time(sys_start, sys_end)
) with system versioning
engine innodb;

Expand Down Expand Up @@ -151,8 +167,12 @@ create table parent(
id int unique key
) engine innodb;

create table child(
--replace_result $sys_datatype_expl SYS_DATATYPE
eval create table child(
parent_id int,
sys_start $sys_datatype_expl as row start invisible,
sys_end $sys_datatype_expl as row end invisible,
period for system_time(sys_start, sys_end),
foreign key(parent_id) references parent(id)
on delete set null
on update set null
Expand Down Expand Up @@ -189,8 +209,12 @@ drop table parent;
--echo # Parent table is foreign #
--echo ###########################

create or replace table parent(
id int unique key
--replace_result $sys_datatype_expl SYS_DATATYPE
eval create or replace table parent(
id int unique key,
sys_start $sys_datatype_expl as row start invisible,
sys_end $sys_datatype_expl as row end invisible,
period for system_time(sys_start, sys_end)
) engine innodb with system versioning;

create or replace table child(
Expand Down Expand Up @@ -225,16 +249,24 @@ drop table parent;
--echo # crash on DELETE #
--echo ###################

create or replace table a (
--replace_result $sys_datatype_expl SYS_DATATYPE
eval create or replace table a (
cola int(10) primary key,
v_cola int(10) as (cola mod 10) virtual
v_cola int(10) as (cola mod 10) virtual,
sys_start $sys_datatype_expl as row start invisible,
sys_end $sys_datatype_expl as row end invisible,
period for system_time(sys_start, sys_end)
) engine=innodb with system versioning;

create index v_cola on a (v_cola);

create or replace table b(
--replace_result $sys_datatype_expl SYS_DATATYPE
eval create or replace table b(
cola int(10),
v_cola int(10)
v_cola int(10),
sys_start $sys_datatype_expl as row start invisible,
sys_end $sys_datatype_expl as row end invisible,
period for system_time(sys_start, sys_end)
) engine=innodb with system versioning;

alter table b add constraint `v_cola_fk`
Expand All @@ -246,3 +278,5 @@ insert into b(cola, v_cola) values (10,2);
delete from a;

drop table b, a;

--source suite/versioning/common_finish.inc
2 changes: 2 additions & 0 deletions sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3584,6 +3584,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
*/
if (sql_field->stored_in_db())
record_offset+= sql_field->pack_length;
if (sql_field->flags & VERS_SYSTEM_FIELD)
continue;
if (sql_field->invisible == INVISIBLE_USER &&
sql_field->flags & NOT_NULL_FLAG &&
sql_field->flags & NO_DEFAULT_VALUE_FLAG)
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/handler/handler0alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4995,7 +4995,7 @@ prepare_inplace_alter_table_dict(
field_type |= DATA_UNSIGNED;
}

if (altered_table->versioned(VERS_TRX_ID)) {
if (altered_table->versioned()) {
if (i == altered_table->s->row_start_field) {
field_type |= DATA_VERS_START;
} else if (i ==
Expand Down

0 comments on commit 0fe67f2

Please sign in to comment.