Skip to content

Commit

Permalink
MDEV-19304 Segfault in ALTER TABLE after UPDATE for SIMULTANEOUS_ASSI…
Browse files Browse the repository at this point in the history
…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 Aug 11, 2019
1 parent 98758b5 commit 5851e66
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
13 changes: 13 additions & 0 deletions mysql-test/suite/versioning/r/alter.result
Expand Up @@ -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;
11 changes: 11 additions & 0 deletions mysql-test/suite/versioning/t/alter.test
Expand Up @@ -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;
9 changes: 4 additions & 5 deletions sql/sql_base.cc
Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit 5851e66

Please sign in to comment.