Commit 1e859d4a authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-22973 Assertion in compare_record upon multi-update involving versioned table via view

records_are_comparable() requires this condition:

  bitmap_is_subset(table->write_set, table->read_set)

On first iteration vers_update_fields() changes write_set and
read_set. On second iteration the above condition fails.

Added missing read bit for ROW_START. Also reorganized
bitmap_set_bit() so it is called only when needed.
parent 58cd2a8d
...@@ -410,3 +410,14 @@ select check_row_ts(row_start, row_end) from t1 for system_time all where row_st ...@@ -410,3 +410,14 @@ select check_row_ts(row_start, row_end) from t1 for system_time all where row_st
check_row_ts(row_start, row_end) check_row_ts(row_start, row_end)
CURRENT ROW CURRENT ROW
drop table t1; drop table t1;
#
# MDEV-22973 Assertion in compare_record upon multi-update involving versioned table via view
#
create or replace table t1 (a int, primary key (a)) engine=myisam;
insert into t1 values (0);
create or replace table t2 (pk int, b int, primary key (pk), key(b)) engine=innodb with system versioning;
insert into t2 values (1, 0), (2, 0);
create or replace view v as select a, b from t1, t2;
update v set b= null where a = 0 order by b;
drop view v;
drop table t1, t2;
...@@ -336,4 +336,17 @@ select row_start from t1 into @r; ...@@ -336,4 +336,17 @@ select row_start from t1 into @r;
select check_row_ts(row_start, row_end) from t1 for system_time all where row_start = @r; select check_row_ts(row_start, row_end) from t1 for system_time all where row_start = @r;
drop table t1; drop table t1;
--echo #
--echo # MDEV-22973 Assertion in compare_record upon multi-update involving versioned table via view
--echo #
create or replace table t1 (a int, primary key (a)) engine=myisam;
insert into t1 values (0);
create or replace table t2 (pk int, b int, primary key (pk), key(b)) engine=innodb with system versioning;
insert into t2 values (1, 0), (2, 0);
create or replace view v as select a, b from t1, t2;
update v set b= null where a = 0 order by b;
# cleanup
drop view v;
drop table t1, t2;
source suite/versioning/common_finish.inc; source suite/versioning/common_finish.inc;
...@@ -8161,9 +8161,6 @@ void TABLE::evaluate_update_default_function() ...@@ -8161,9 +8161,6 @@ void TABLE::evaluate_update_default_function()
void TABLE::vers_update_fields() void TABLE::vers_update_fields()
{ {
bitmap_set_bit(write_set, vers_start_field()->field_index);
bitmap_set_bit(write_set, vers_end_field()->field_index);
if (!vers_write) if (!vers_write)
{ {
file->column_bitmaps_signal(); file->column_bitmaps_signal();
...@@ -8172,17 +8169,21 @@ void TABLE::vers_update_fields() ...@@ -8172,17 +8169,21 @@ void TABLE::vers_update_fields()
if (versioned(VERS_TIMESTAMP)) if (versioned(VERS_TIMESTAMP))
{ {
bitmap_set_bit(write_set, vers_start_field()->field_index);
if (vers_start_field()->store_timestamp(in_use->query_start(), if (vers_start_field()->store_timestamp(in_use->query_start(),
in_use->query_start_sec_part())) in_use->query_start_sec_part()))
{ {
DBUG_ASSERT(0); DBUG_ASSERT(0);
} }
vers_start_field()->set_has_explicit_value(); vers_start_field()->set_has_explicit_value();
bitmap_set_bit(read_set, vers_start_field()->field_index);
} }
bitmap_set_bit(write_set, vers_end_field()->field_index);
vers_end_field()->set_max(); vers_end_field()->set_max();
vers_end_field()->set_has_explicit_value(); vers_end_field()->set_has_explicit_value();
bitmap_set_bit(read_set, vers_end_field()->field_index); bitmap_set_bit(read_set, vers_end_field()->field_index);
file->column_bitmaps_signal(); file->column_bitmaps_signal();
if (vfield) if (vfield)
update_virtual_fields(file, VCOL_UPDATE_FOR_READ); update_virtual_fields(file, VCOL_UPDATE_FOR_READ);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment