Commit cef2b34f authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-18929 2nd execution of SP does not detect ER_VERS_NOT_VERSIONED

Wrong assertion condition. SYSTEM_TIME_ALL indicates that
vers_setup_conds() is done. In case FOR SYSTEM_TIME ALL is specified
in command the assertion passes but not checks anything.
parent db32d945
......@@ -116,3 +116,17 @@ x
2
1
drop table t1;
#
# MDEV-18929 2nd execution of SP does not detect ER_VERS_NOT_VERSIONED
#
create or replace table t1 (a int) with system versioning;
replace into t1 values (1), (2);
create or replace trigger tr before delete on t1 for each row delete from xx;
create or replace procedure pr() delete from t1;
call pr;
ERROR 42S02: Table 'test.xx' doesn't exist
call pr;
ERROR 42S02: Table 'test.xx' doesn't exist
drop procedure pr;
drop trigger tr;
drop table t1;
......@@ -79,4 +79,19 @@ delete from t1;
select x from t1 for system_time all;
drop table t1;
--echo #
--echo # MDEV-18929 2nd execution of SP does not detect ER_VERS_NOT_VERSIONED
--echo #
create or replace table t1 (a int) with system versioning;
replace into t1 values (1), (2);
create or replace trigger tr before delete on t1 for each row delete from xx;
create or replace procedure pr() delete from t1;
--error ER_NO_SUCH_TABLE
call pr;
--error ER_NO_SUCH_TABLE
call pr;
drop procedure pr;
drop trigger tr;
drop table t1;
--source suite/versioning/common_finish.inc
......@@ -919,7 +919,7 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list,
DBUG_ASSERT(table_list->table);
// conds could be cached from previous SP call
DBUG_ASSERT(!table_list->vers_conditions.is_set() ||
DBUG_ASSERT(!table_list->vers_conditions.need_setup() ||
!*conds || thd->stmt_arena->is_stmt_execute());
if (select_lex->vers_setup_conds(thd, table_list))
DBUG_RETURN(TRUE);
......
......@@ -1266,7 +1266,7 @@ bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
DBUG_ASSERT(table_list->table);
// conds could be cached from previous SP call
DBUG_ASSERT(!table_list->vers_conditions.is_set() ||
DBUG_ASSERT(!table_list->vers_conditions.need_setup() ||
!*conds || thd->stmt_arena->is_stmt_execute());
if (select_lex->vers_setup_conds(thd, table_list))
DBUG_RETURN(TRUE);
......
......@@ -1912,6 +1912,10 @@ struct vers_select_conds_t
{
return orig_type != SYSTEM_TIME_UNSPECIFIED;
}
bool need_setup() const
{
return type != SYSTEM_TIME_UNSPECIFIED && type != SYSTEM_TIME_ALL;
}
bool resolve_units(THD *thd);
bool eq(const vers_select_conds_t &conds) const;
};
......
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