diff options
-rw-r--r-- | mysql-test/suite/versioning/r/update.result | 8 | ||||
-rw-r--r-- | mysql-test/suite/versioning/t/update.test | 9 | ||||
-rw-r--r-- | sql/sp_head.cc | 6 | ||||
-rw-r--r-- | sql/sql_derived.cc | 10 |
4 files changed, 26 insertions, 7 deletions
diff --git a/mysql-test/suite/versioning/r/update.result b/mysql-test/suite/versioning/r/update.result index 94f6f8fa998..e7c617f9196 100644 --- a/mysql-test/suite/versioning/r/update.result +++ b/mysql-test/suite/versioning/r/update.result @@ -299,5 +299,13 @@ create or replace table t1 (id int, k int, primary key (id)) engine=innodb with 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; +create or replace table t1 (a int) with system versioning; +create or replace view v1 as select * from t1; +create or replace procedure sp() update v1 set xx = 1; +call sp; +ERROR 42S22: Unknown column 'xx' in 'field list' +call sp; +ERROR 42S22: Unknown column 'xx' in 'field list' +drop procedure sp; drop view v1; drop table t1; diff --git a/mysql-test/suite/versioning/t/update.test b/mysql-test/suite/versioning/t/update.test index 0af3c450ce5..548505bd39a 100644 --- a/mysql-test/suite/versioning/t/update.test +++ b/mysql-test/suite/versioning/t/update.test @@ -219,7 +219,16 @@ 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; +create or replace table t1 (a int) with system versioning; +create or replace view v1 as select * from t1; +create or replace procedure sp() update v1 set xx = 1; +--error ER_BAD_FIELD_ERROR +call sp; +--error ER_BAD_FIELD_ERROR +call sp; + # cleanup +drop procedure sp; drop view v1; drop table t1; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 48166fac4c6..ab7faf51849 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -3379,11 +3379,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp, Update the state of the active arena if no errors on open_tables stage. */ - if (likely(!res) || likely(!thd->is_error()) || - (thd->get_stmt_da()->sql_errno() != ER_CANT_REOPEN_TABLE && - thd->get_stmt_da()->sql_errno() != ER_NO_SUCH_TABLE && - thd->get_stmt_da()->sql_errno() != ER_NO_SUCH_TABLE_IN_ENGINE && - thd->get_stmt_da()->sql_errno() != ER_UPDATE_TABLE_USED)) + if (likely(!res) || likely(!thd->is_error())) thd->stmt_arena->state= Query_arena::STMT_EXECUTED; /* diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 9d6748937ad..1f465a100c9 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -707,9 +707,15 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived) case SQLCOM_DELETE_MULTI: case SQLCOM_UPDATE: case SQLCOM_UPDATE_MULTI: - if ((res= unit->first_select()->vers_setup_conds(thd, derived->merge_underlying_list))) + if ((res= first_select->vers_setup_conds(thd, + derived->merge_underlying_list))) goto exit; - derived->where= and_items(thd, derived->where, derived->merge_underlying_list->where); + if (derived->merge_underlying_list->where) + { + Query_arena_stmt on_stmt_arena(thd); + derived->where= and_items(thd, derived->where, + derived->merge_underlying_list->where); + } default: break; } |