Commit f1f14c20 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-20015 Assertion `!in_use->is_error()' failed in TABLE::update_virtual_field

update_virtual_field() is called as part of index rebuild in
ha_myisam::repair() (MDEV-5800) which is done on bulk INSERT finish.

Assertion in update_virtual_field() was put as part of MDEV-16222
because update_virtual_field() returns in_use->is_error(). The idea:
wrongly mixed semantics of error status before update_virtual_field()
and the status returned by update_virtual_field(). The former can
falsely influence the latter.
parent 6a26e0c7
......@@ -408,3 +408,12 @@ SELECT * FROM t1 WHERE d2 < d1;
i d1 d2 t
1 2023-03-16 2023-03-15 1
DROP TABLE t1;
#
# MDEV-20015 Assertion `!in_use->is_error()' failed in TABLE::update_virtual_field
#
create or replace table t1 (a int);
insert into t1 (a) values (1), (1);
create or replace table t2 (pk int, b int, c int as (b) virtual, primary key (pk), key(c));
insert into t2 (pk) select a from t1;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
drop tables t1, t2;
......@@ -300,3 +300,14 @@ DROP TABLE t1;
# Cleanup
--let $datadir= `SELECT @@datadir`
--remove_file $datadir/test/load_t1
--echo #
--echo # MDEV-20015 Assertion `!in_use->is_error()' failed in TABLE::update_virtual_field
--echo #
create or replace table t1 (a int);
insert into t1 (a) values (1), (1);
create or replace table t2 (pk int, b int, c int as (b) virtual, primary key (pk), key(c));
--error ER_DUP_ENTRY
insert into t2 (pk) select a from t1;
drop tables t1, t2;
......@@ -7778,15 +7778,17 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode)
int TABLE::update_virtual_field(Field *vf)
{
DBUG_ASSERT(!in_use->is_error());
Query_arena backup_arena;
DBUG_ENTER("TABLE::update_virtual_field");
Query_arena backup_arena;
Counting_error_handler count_errors;
in_use->push_internal_handler(&count_errors);
in_use->set_n_backup_active_arena(expr_arena, &backup_arena);
bitmap_clear_all(&tmp_set);
vf->vcol_info->expr->walk(&Item::update_vcol_processor, 0, &tmp_set);
vf->vcol_info->expr->save_in_field(vf, 0);
in_use->restore_active_arena(expr_arena, &backup_arena);
DBUG_RETURN(in_use->is_error());
in_use->pop_internal_handler();
DBUG_RETURN(count_errors.errors);
}
......
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