Commit 1398160a authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-24522 Assertion `inited==NONE' fails upon UPDATE on versioned table with unique blob

Cause: no table->update_handler cloned at the moment of
vers_insert_history_row(). update_handler is needed because there
can't be several inited indexes at once in the same handler. First
index is inited by QUICK_RANGE_SELECT::reset(). Then when history row
is inserted check_duplicate_long_entry_key() is done and it requires
another index.
parent e626f511
......@@ -399,3 +399,19 @@ a check_row(row_start, row_end)
1 HISTORICAL ROW
1 CURRENT ROW
drop tables t1, t2, t3;
#
# MDEV-24522 Assertion `inited==NONE' fails upon UPDATE on versioned table with unique blob
create table t1 (a int, b int, c text, unique(c), key (b)) engine=myisam with system versioning;
insert into t1 values (1, 1, 'foo'), (2, 11, 'bar');
update t1 set a = 3 where b <= 9;
update t1 set a = 3 where b <= 10;
drop table t1;
create table t1 (a int, b int, c text, unique(c), key (b)) engine=myisam with system versioning;
create table t2 (a int, b int, c text, unique(c), key (b)) engine=myisam with system versioning;
insert into t1 values (1, 1, 'foo'), (2, 11, 'bar');
insert into t2 values (1, 1, 'foo'), (2, 11, 'bar');
update t1 set a = 3 where b <= 9;
update t2 set a = 3 where b <= 9;
update t1, t2 set t1.a = 3, t2.a = 3 where t1.b <= 10 and t2.b <= 10 and t1.b = t2.b;
drop tables t1, t2;
......@@ -326,4 +326,28 @@ select *, check_row(row_start, row_end) from t2 for system_time all order by row
# cleanup
drop tables t1, t2, t3;
--echo #
--echo # MDEV-24522 Assertion `inited==NONE' fails upon UPDATE on versioned table with unique blob
--echo
create table t1 (a int, b int, c text, unique(c), key (b)) engine=myisam with system versioning;
insert into t1 values (1, 1, 'foo'), (2, 11, 'bar');
update t1 set a = 3 where b <= 9;
update t1 set a = 3 where b <= 10;
# cleanup
drop table t1;
create table t1 (a int, b int, c text, unique(c), key (b)) engine=myisam with system versioning;
create table t2 (a int, b int, c text, unique(c), key (b)) engine=myisam with system versioning;
insert into t1 values (1, 1, 'foo'), (2, 11, 'bar');
insert into t2 values (1, 1, 'foo'), (2, 11, 'bar');
update t1 set a = 3 where b <= 9;
update t2 set a = 3 where b <= 9;
update t1, t2 set t1.a = 3, t2.a = 3 where t1.b <= 10 and t2.b <= 10 and t1.b = t2.b;
# cleanup
drop tables t1, t2;
source suite/versioning/common_finish.inc;
......@@ -3191,7 +3191,7 @@ class handler :public Sql_alloc
{
cached_table_flags= table_flags();
}
/* ha_ methods: pubilc wrappers for private virtual API */
/* ha_ methods: public wrappers for private virtual API */
int ha_open(TABLE *table, const char *name, int mode, uint test_if_locked,
MEM_ROOT *mem_root= 0, List<String> *partitions_to_open=NULL);
......
......@@ -1108,6 +1108,7 @@ int mysql_update(THD *thd,
{
store_record(table, record[2]);
table->mark_columns_per_binlog_row_image();
table->clone_handler_for_update();
error= vers_insert_history_row(table);
restore_record(table, record[2]);
if (unlikely(error))
......@@ -2599,6 +2600,7 @@ int multi_update::send_data(List<Item> &not_used_values)
if (has_vers_fields && table->versioned(VERS_TIMESTAMP))
{
store_record(table, record[2]);
table->clone_handler_for_update();
if (unlikely(error= vers_insert_history_row(table)))
{
restore_record(table, record[2]);
......
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