Skip to content

Commit

Permalink
MDEV-14631 Assertion `!sys_trx_start && !sys_trx_end' failed in crete…
Browse files Browse the repository at this point in the history
…_tmp_table

SQL: remove unneeded assertion
SQL: disallow set sys_trx fields in INSERT ... SELECT

Fixes by @midenok.
  • Loading branch information
kevgs authored and midenok committed Dec 12, 2017
1 parent c66a20b commit 717f274
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 40 deletions.
7 changes: 7 additions & 0 deletions mysql-test/suite/versioning/r/insert.result
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ select *, sys_trx_end = 18446744073709551615 as current from t1 for system_time
x y current
2 2 1
1 1 0
create or replace table t1 (i int) with system versioning engine innodb;
insert into t1 values (1),(2);
insert into t1 (sys_trx_start) select sys_trx_end from t1;
ERROR HY000: Column 'sys_trx_start' is not updatable
insert into t1 (sys_trx_start, sys_trx_end) values (DEFAULT, 1);
ERROR HY000: Column 'sys_trx_end' is not updatable
insert into t1 (sys_trx_start, sys_trx_end) values (DEFAULT, DEFAULT);
drop table t1;
drop table t2;
drop procedure test_01;
Expand Down
46 changes: 23 additions & 23 deletions mysql-test/suite/versioning/r/optimized.result
Original file line number Diff line number Diff line change
Expand Up @@ -17,59 +17,59 @@ a b b+0
1 NULL NULL
3 NULL NULL
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select * from t for system_time as of timestamp now(6);
a b
1 NULL
3 NULL
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select count(*) from t group by b for system_time as of timestamp now(6);
count(*)
2
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select * from t for system_time as of timestamp now(6) order by b asc;
a b
1 NULL
3 NULL
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select * from t for system_time as of timestamp now(6) order by b desc;
a b
1 NULL
3 NULL
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select * from t group by a having a=2 for system_time as of timestamp now(6);
a b
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select * from t group by b having b=2 for system_time as of timestamp now(6);
a b
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select a from t where b=2 for system_time as of timestamp now(6);
a
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select a from t where b=NULL for system_time as of timestamp now(6);
a
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select a from t where b is NULL for system_time as of timestamp now(6);
a
1
3
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select count(*), b from t group by b having b=NULL for system_time as of timestamp now(6);
count(*) b
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select a, b from t;
a b
1 2
Expand All @@ -78,29 +78,29 @@ select count(*) from t for system_time as of timestamp now(6) group by b;
count(*)
2
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select * from t for system_time as of timestamp now(6) group by b having b=2;
a b
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select a from t for system_time as of timestamp now(6) where b=2;
a
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select a from t for system_time as of timestamp now(6) where b=NULL;
a
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select a from t for system_time as of timestamp now(6) where b is NULL;
a
1
3
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select count(*), b from t for system_time as of timestamp now(6) group by b having b=NULL;
count(*) b
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
create or replace table t (
a int,
b int not null without system versioning
Expand All @@ -111,12 +111,12 @@ a b
1 NULL
3 NULL
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
select * from t for system_time as of timestamp now(6) where b is NULL;
a b
1 NULL
3 NULL
Warnings:
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4112 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
Warning 4111 Attempt to read unversioned field `b` in historical query
drop table t;
12 changes: 6 additions & 6 deletions mysql-test/suite/versioning/r/partition.result
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERS
alter table t1 add partition (
partition p1 versioning);
Warnings:
Warning 4115 Maybe missing parameters: no rotation condition for multiple `VERSIONING` partitions.
Warning 4114 Maybe missing parameters: no rotation condition for multiple `VERSIONING` partitions.
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
Expand Down Expand Up @@ -209,7 +209,7 @@ x
2
delete from t1;
Warnings:
Note 4116 Switching from partition `p0` to `p1`
Note 4115 Switching from partition `p0` to `p1`
select * from t1 partition (p0) for system_time all;
x
1
Expand All @@ -219,7 +219,7 @@ x
insert into t1 values (3);
delete from t1;
Warnings:
Warning 4114 Using full partition `p1`, need more VERSIONING partitions!
Warning 4113 Using full partition `p1`, need more VERSIONING partitions!
select * from t1 partition (p1) for system_time all;
x
2
Expand Down Expand Up @@ -252,7 +252,7 @@ x
insert into t1 values (4);
delete from t1;
Warnings:
Note 4116 Switching from partition `p0` to `p1`
Note 4115 Switching from partition `p0` to `p1`
select * from t1 partition (p1) for system_time all;
x
4
Expand All @@ -274,8 +274,8 @@ x
2
delete from t1;
Warnings:
Note 4116 Switching from partition `p0` to `p1`
Warning 4114 Using full partition `p1`, need more VERSIONING partitions!
Note 4115 Switching from partition `p0` to `p1`
Warning 4113 Using full partition `p1`, need more VERSIONING partitions!
select * from t1 partition (p0sp0) for system_time all;
x
1
Expand Down
8 changes: 8 additions & 0 deletions mysql-test/suite/versioning/t/insert.test
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ insert into t1 values (1, null);
update t1 set x= x + 1;
select *, sys_trx_end = 18446744073709551615 as current from t1 for system_time all;

create or replace table t1 (i int) with system versioning engine innodb;
insert into t1 values (1),(2);
--error ER_NONUPDATEABLE_COLUMN
insert into t1 (sys_trx_start) select sys_trx_end from t1;
--error ER_NONUPDATEABLE_COLUMN
insert into t1 (sys_trx_start, sys_trx_end) values (DEFAULT, 1);
insert into t1 (sys_trx_start, sys_trx_end) values (DEFAULT, DEFAULT);

drop table t1;
drop table t2;

Expand Down
3 changes: 0 additions & 3 deletions sql/share/errmsg-utf8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7815,9 +7815,6 @@ ER_INVALID_VALUE_TO_LIMIT
ER_VERSIONING_REQUIRED
eng "System Versioning required: %s"

ER_VERS_READONLY_FIELD
eng "System field %`s is read-only"

ER_UPDATE_INFO_WITH_SYSTEM_VERSIONING
eng "Rows matched: %ld Changed: %ld Inserted: %ld Warnings: %ld"

Expand Down
7 changes: 3 additions & 4 deletions sql/sql_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8067,12 +8067,11 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),
rfield->field_name.str, table->s->table_name.str);
}
if (table->versioned() && rfield->vers_sys_field() &&
!ignore_errors)
if (table->versioned() && rfield->vers_sys_field())
{
if (type == Item::DEFAULT_VALUE_ITEM)
continue;
my_error(ER_VERS_READONLY_FIELD, MYF(0), rfield->field_name.str);
my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), rfield->field_name.str);
goto err;
}

Expand Down Expand Up @@ -8308,7 +8307,7 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,

if (table->versioned() && field->vers_sys_field() && !ignore_errors)
{
my_error(ER_VERS_READONLY_FIELD, MYF(0), field->field_name.str);
my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), field->field_name.str);
goto err;
}

Expand Down
4 changes: 0 additions & 4 deletions sql/sql_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17632,10 +17632,6 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
share->row_start_field= sys_trx_start->field_index;
share->row_end_field= sys_trx_end->field_index;
}
else
{
DBUG_ASSERT(!sys_trx_start && !sys_trx_end);
}

DBUG_ASSERT(fieldnr == (uint) (reg_field - table->field));
DBUG_ASSERT(field_count >= (uint) (reg_field - table->field));
Expand Down

0 comments on commit 717f274

Please sign in to comment.