Commit 97aa07ab authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-21147 Assertion `marked_for_read()' upon UPDATE on versioned table 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.
parent 498a96a4
......@@ -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;
......@@ -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;
......@@ -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)
......@@ -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:
......
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