Skip to content

Commit

Permalink
MDEV-16783 Assertion `!conds' failed in mysql_delete upon 2nd executi…
Browse files Browse the repository at this point in the history
…on of SP with DELETE HISTORY

* remove assertion
* do not setup `conds` if it's already cached

Fixes #823
  • Loading branch information
FooBarrior authored and vuvova committed Aug 24, 2018
1 parent 6c6ca90 commit db3be33
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
6 changes: 6 additions & 0 deletions mysql-test/suite/versioning/r/truncate.result
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,11 @@ ERROR 42S02: 'v' is a view
unlock tables;
drop view v;
drop table t;
create table t1 (i int) with system versioning;
create procedure pr() delete history from t1 before system_time now();
call pr;
call pr;
drop procedure pr;
drop table t1;
drop database test;
create database test;
10 changes: 10 additions & 0 deletions mysql-test/suite/versioning/t/truncate.test
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,15 @@ unlock tables;
drop view v;
drop table t;

#
# MDEV-16783 Assertion `!conds' failed in mysql_delete upon 2nd execution of SP with DELETE HISTORY
#
create table t1 (i int) with system versioning;
create procedure pr() delete history from t1 before system_time now();
call pr;
call pr;
drop procedure pr;
drop table t1;

drop database test;
create database test;
14 changes: 9 additions & 5 deletions sql/sql_delete.cc
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,16 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
DBUG_ASSERT(table);

DBUG_ASSERT(!conds || thd->stmt_arena->is_stmt_execute());
if (select_lex->vers_setup_conds(thd, table_list))
DBUG_RETURN(TRUE);

DBUG_ASSERT(!conds);
conds= table_list->on_expr;
table_list->on_expr= NULL;
// conds could be cached from previous SP call
if (!conds)
{
if (select_lex->vers_setup_conds(thd, table_list))
DBUG_RETURN(TRUE);

conds= table_list->on_expr;
table_list->on_expr= NULL;
}
}

if (mysql_handle_list_of_derived(thd->lex, table_list, DT_MERGE_FOR_INSERT))
Expand Down

0 comments on commit db3be33

Please sign in to comment.