Skip to content

Commit

Permalink
MDEV-21147 Assertion `marked_for_read()' upon UPDATE on versioned tab…
Browse files Browse the repository at this point in the history
…le via view

"write set" for replication finally got its correct place
(mark_columns_per_binlog_row_image()). When done generally in
mark_columns_needed_for_update() it affects optimization
algorithm. used_key_is_modified, query_plan.using_io_buffer are
wrongly set and that leads to wrong prepare_for_keyread() which limits
read_set.
  • Loading branch information
midenok committed Dec 2, 2019
1 parent 498a96a commit 97aa07a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
12 changes: 12 additions & 0 deletions mysql-test/suite/versioning/r/update.result
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,15 @@ with system versioning;
insert into t1 (a) values ('foo');
update t1 set a = 'bar';
drop table t1;
#
# MDEV-21147 Assertion `marked_for_read()' upon UPDATE on versioned table via view
#
create or replace table t1 (
pk int, a char(8), b char(8),
primary key (pk)
) with system versioning;
create or replace view v1 as select * from t1;
insert into t1 values (1, null, 'd') , (2, null, 'i') ;
update v1 set a= null where b = '';
drop view v1;
drop table t1;
16 changes: 16 additions & 0 deletions mysql-test/suite/versioning/t/update.test
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,20 @@ insert into t1 (a) values ('foo');
update t1 set a = 'bar';
drop table t1;

--echo #
--echo # MDEV-21147 Assertion `marked_for_read()' upon UPDATE on versioned table via view
--echo #
create or replace table t1 (
pk int, a char(8), b char(8),
primary key (pk)
) with system versioning;

create or replace view v1 as select * from t1;
insert into t1 values (1, null, 'd') , (2, null, 'i') ;
update v1 set a= null where b = '';

# cleanup
drop view v1;
drop table t1;

source suite/versioning/common_finish.inc;
16 changes: 10 additions & 6 deletions sql/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6613,12 +6613,8 @@ void TABLE::mark_columns_needed_for_update()
/*
For System Versioning we have to read all columns since we store
a copy of previous row with modified row_end back to a table.
Without write_set versioning.rpl,row is unstable until MDEV-16370 is
applied.
*/
bitmap_union(read_set, &s->all_set);
bitmap_union(write_set, &s->all_set);
need_signal= true;
}
if (check_constraints)
Expand Down Expand Up @@ -6781,8 +6777,16 @@ void TABLE::mark_columns_per_binlog_row_image()
binary log will include all columns read anyway.
*/
mark_columns_used_by_index_no_reset(s->primary_key, read_set);
/* Only write columns that have changed */
rpl_write_set= write_set;
if (versioned())
{
// TODO: After MDEV-18432 we don't pass history rows, so remove this:
rpl_write_set= &s->all_set;
}
else
{
/* Only write columns that have changed */
rpl_write_set= write_set;
}
break;

default:
Expand Down

0 comments on commit 97aa07a

Please sign in to comment.