Skip to content

Commit 1e859d4

Browse files
committed
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.
1 parent 58cd2a8 commit 1e859d4

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

mysql-test/suite/versioning/r/update.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,14 @@ select check_row_ts(row_start, row_end) from t1 for system_time all where row_st
410410
check_row_ts(row_start, row_end)
411411
CURRENT ROW
412412
drop table t1;
413+
#
414+
# MDEV-22973 Assertion in compare_record upon multi-update involving versioned table via view
415+
#
416+
create or replace table t1 (a int, primary key (a)) engine=myisam;
417+
insert into t1 values (0);
418+
create or replace table t2 (pk int, b int, primary key (pk), key(b)) engine=innodb with system versioning;
419+
insert into t2 values (1, 0), (2, 0);
420+
create or replace view v as select a, b from t1, t2;
421+
update v set b= null where a = 0 order by b;
422+
drop view v;
423+
drop table t1, t2;

mysql-test/suite/versioning/t/update.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,4 +336,17 @@ select row_start from t1 into @r;
336336
select check_row_ts(row_start, row_end) from t1 for system_time all where row_start = @r;
337337
drop table t1;
338338

339+
--echo #
340+
--echo # MDEV-22973 Assertion in compare_record upon multi-update involving versioned table via view
341+
--echo #
342+
create or replace table t1 (a int, primary key (a)) engine=myisam;
343+
insert into t1 values (0);
344+
create or replace table t2 (pk int, b int, primary key (pk), key(b)) engine=innodb with system versioning;
345+
insert into t2 values (1, 0), (2, 0);
346+
create or replace view v as select a, b from t1, t2;
347+
update v set b= null where a = 0 order by b;
348+
# cleanup
349+
drop view v;
350+
drop table t1, t2;
351+
339352
source suite/versioning/common_finish.inc;

sql/table.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8161,9 +8161,6 @@ void TABLE::evaluate_update_default_function()
81618161

81628162
void TABLE::vers_update_fields()
81638163
{
8164-
bitmap_set_bit(write_set, vers_start_field()->field_index);
8165-
bitmap_set_bit(write_set, vers_end_field()->field_index);
8166-
81678164
if (!vers_write)
81688165
{
81698166
file->column_bitmaps_signal();
@@ -8172,17 +8169,21 @@ void TABLE::vers_update_fields()
81728169

81738170
if (versioned(VERS_TIMESTAMP))
81748171
{
8172+
bitmap_set_bit(write_set, vers_start_field()->field_index);
81758173
if (vers_start_field()->store_timestamp(in_use->query_start(),
81768174
in_use->query_start_sec_part()))
81778175
{
81788176
DBUG_ASSERT(0);
81798177
}
81808178
vers_start_field()->set_has_explicit_value();
8179+
bitmap_set_bit(read_set, vers_start_field()->field_index);
81818180
}
81828181

8182+
bitmap_set_bit(write_set, vers_end_field()->field_index);
81838183
vers_end_field()->set_max();
81848184
vers_end_field()->set_has_explicit_value();
81858185
bitmap_set_bit(read_set, vers_end_field()->field_index);
8186+
81868187
file->column_bitmaps_signal();
81878188
if (vfield)
81888189
update_virtual_fields(file, VCOL_UPDATE_FOR_READ);

0 commit comments

Comments
 (0)