Commit 81bf7d33 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

Merge branch 'bb-10.3-release' into 10.3

parents 8a46b706 bf2f3916
...@@ -116,3 +116,17 @@ x ...@@ -116,3 +116,17 @@ x
2 2
1 1
drop table t1; 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;
...@@ -295,5 +295,9 @@ primary key (pk) ...@@ -295,5 +295,9 @@ primary key (pk)
create or replace view v1 as select * from t1; create or replace view v1 as select * from t1;
insert into t1 values (1, null, 'd') , (2, null, 'i') ; insert into t1 values (1, null, 'd') , (2, null, 'i') ;
update v1 set a= null where b = ''; update v1 set a= null where b = '';
create or replace table t1 (id int, k int, primary key (id)) engine=innodb with system versioning;
insert into t1 values (1,1),(2,2);
create or replace view v1 as select * from t1;
update v1 set id= 2 where k = 0;
drop view v1; drop view v1;
drop table t1; drop table t1;
...@@ -79,4 +79,19 @@ delete from t1; ...@@ -79,4 +79,19 @@ delete from t1;
select x from t1 for system_time all; select x from t1 for system_time all;
drop table t1; 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 --source suite/versioning/common_finish.inc
...@@ -214,6 +214,11 @@ create or replace view v1 as select * from t1; ...@@ -214,6 +214,11 @@ create or replace view v1 as select * from t1;
insert into t1 values (1, null, 'd') , (2, null, 'i') ; insert into t1 values (1, null, 'd') , (2, null, 'i') ;
update v1 set a= null where b = ''; update v1 set a= null where b = '';
create or replace table t1 (id int, k int, primary key (id)) engine=innodb with system versioning;
insert into t1 values (1,1),(2,2);
create or replace view v1 as select * from t1;
update v1 set id= 2 where k = 0;
# cleanup # cleanup
drop view v1; drop view v1;
drop table t1; drop table t1;
......
...@@ -919,7 +919,7 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, ...@@ -919,7 +919,7 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list,
DBUG_ASSERT(table_list->table); DBUG_ASSERT(table_list->table);
// conds could be cached from previous SP call // 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()); !*conds || thd->stmt_arena->is_stmt_execute());
if (select_lex->vers_setup_conds(thd, table_list)) if (select_lex->vers_setup_conds(thd, table_list))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
......
...@@ -707,8 +707,9 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived) ...@@ -707,8 +707,9 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
case SQLCOM_DELETE_MULTI: case SQLCOM_DELETE_MULTI:
case SQLCOM_UPDATE: case SQLCOM_UPDATE:
case SQLCOM_UPDATE_MULTI: case SQLCOM_UPDATE_MULTI:
if ((res= unit->prepare(derived, derived->derived_result, 0))) if ((res= unit->first_select()->vers_setup_conds(thd, derived->merge_underlying_list)))
goto exit; goto exit;
derived->where= and_items(thd, derived->where, derived->merge_underlying_list->where);
default: default:
break; break;
} }
......
...@@ -1266,7 +1266,7 @@ bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list, ...@@ -1266,7 +1266,7 @@ bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
DBUG_ASSERT(table_list->table); DBUG_ASSERT(table_list->table);
// conds could be cached from previous SP call // 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()); !*conds || thd->stmt_arena->is_stmt_execute());
if (select_lex->vers_setup_conds(thd, table_list)) if (select_lex->vers_setup_conds(thd, table_list))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
......
...@@ -1912,6 +1912,10 @@ struct vers_select_conds_t ...@@ -1912,6 +1912,10 @@ struct vers_select_conds_t
{ {
return orig_type != SYSTEM_TIME_UNSPECIFIED; 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 resolve_units(THD *thd);
bool eq(const vers_select_conds_t &conds) const; 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