Commit b70d5476 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-31244 Assertion "not SELECT" in vers_set_hist_part()

The assertion was to make sure we don't do vers_set_hist_part() for
SELECT (or any non-DML). But actually we must do it if SELECT calls
some function that does DML. Patch moves the assertion to non-routines
only.
parent 4700f2ac
......@@ -3387,4 +3387,23 @@ insert into t () values (),(),(),(),(),();
update t set a = 1;
update t set a = 2 limit 0;
drop table t;
#
# MDEV-31244 Assertion "not SELECT" in vers_set_hist_part()
#
create table t (a int) with system versioning partition by system_time;
create function f() returns int
begin
update t set a = 1;
return 1;
end $
create procedure p() select f();
call p();
f()
1
call p();
f()
1
drop procedure p;
drop function f;
drop table t;
set global innodb_stats_persistent= @save_persistent;
......@@ -2605,6 +2605,25 @@ update t set a = 2 limit 0;
# cleanup
drop table t;
--echo #
--echo # MDEV-31244 Assertion "not SELECT" in vers_set_hist_part()
--echo #
create table t (a int) with system versioning partition by system_time;
--delimiter $
create function f() returns int
begin
update t set a = 1;
return 1;
end $
--delimiter ;
create procedure p() select f();
call p();
call p();
# cleanup
drop procedure p;
drop function f;
drop table t;
--disable_prepare_warnings
set global innodb_stats_persistent= @save_persistent;
--source suite/versioning/common_finish.inc
......@@ -799,9 +799,6 @@ bool partition_info::has_unique_name(partition_element *element)
*/
bool partition_info::vers_set_hist_part(THD *thd, uint *create_count)
{
DBUG_ASSERT(!thd->lex->last_table() ||
!thd->lex->last_table()->vers_conditions.delete_history);
const bool auto_hist= create_count && vers_info->auto_hist;
if (vers_info->limit)
......
......@@ -1749,6 +1749,8 @@ bool TABLE::vers_switch_partition(THD *thd, TABLE_LIST *table_list,
}
break;
}
DBUG_ASSERT(!thd->lex->last_table() ||
!thd->lex->last_table()->vers_conditions.delete_history);
}
if (table_list->partition_names)
......
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