Skip to content
Permalink
Browse files

MDEV-19304 Segfault in ALTER TABLE after UPDATE for SIMULTANEOUS_ASSI…

…GNMENT

For MODE_SIMULTANEOUS_ASSIGNMENT it is required to return back field
offsets from record[1] to record[0]. 'continue' in warning branch did
skip of rfield->move_field_offset() call.
  • Loading branch information...
midenok committed May 27, 2019
1 parent 98758b5 commit 5851e668d7a0d51034c7d74779c39ef0f7b8d002
Showing with 28 additions and 5 deletions.
  1. +13 −0 mysql-test/suite/versioning/r/alter.result
  2. +11 −0 mysql-test/suite/versioning/t/alter.test
  3. +4 −5 sql/sql_base.cc
@@ -603,5 +603,18 @@ select * from t1;
a b
1 0
affected rows: 1
#
# MDEV-19304 Segfault in ALTER TABLE after UPDATE for SIMULTANEOUS_ASSIGNMENT
#
create or replace table t1 (a int, s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) engine=myisam with system versioning;
insert into t1 values (null, null, null);
insert into t1 values (null, null, null);
set sql_mode= 'simultaneous_assignment';
update t1 set e= 1;
Warnings:
Warning 1906 The value specified for generated column 'e' in table 't1' has been ignored
Warning 1906 The value specified for generated column 'e' in table 't1' has been ignored
alter table t1 force;
set sql_mode= default;
drop database test;
create database test;
@@ -503,5 +503,16 @@ alter table t1 modify a int with system versioning;
select * from t1;
--disable_info

--echo #
--echo # MDEV-19304 Segfault in ALTER TABLE after UPDATE for SIMULTANEOUS_ASSIGNMENT
--echo #
create or replace table t1 (a int, s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) engine=myisam with system versioning;
insert into t1 values (null, null, null);
insert into t1 values (null, null, null);
set sql_mode= 'simultaneous_assignment';
update t1 set e= 1;
alter table t1 force;
set sql_mode= default;

drop database test;
create database test;
@@ -8304,8 +8304,8 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
rfield->field_index == table->next_number_field->field_index)
table->auto_increment_field_not_null= TRUE;
Item::Type type= value->type();
bool vers_sys_field= table->versioned() && rfield->vers_sys_field();
if ((rfield->vcol_info || vers_sys_field) &&
const bool skip_sys_field= rfield->vers_sys_field(); // TODO: && !thd->vers_modify_history() [MDEV-16546]
if ((rfield->vcol_info || skip_sys_field) &&
type != Item::DEFAULT_VALUE_ITEM &&
type != Item::NULL_ITEM &&
table->s->table_category != TABLE_CATEGORY_TEMPORARY)
@@ -8314,15 +8314,14 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN,
ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN),
rfield->field_name.str, table->s->table_name.str);
if (vers_sys_field)
continue;
}
if (only_unvers_fields && !rfield->vers_update_unversioned())
only_unvers_fields= false;

if (rfield->stored_in_db())
{
if (unlikely(value->save_in_field(rfield, 0) < 0) && !ignore_errors)
if (!skip_sys_field &&
unlikely(value->save_in_field(rfield, 0) < 0) && !ignore_errors)
{
my_message(ER_UNKNOWN_ERROR, ER_THD(thd, ER_UNKNOWN_ERROR), MYF(0));
goto err;

0 comments on commit 5851e66

Please sign in to comment.
You can’t perform that action at this time.