diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2019-12-03 15:46:49 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2019-12-04 07:10:41 +0300 |
commit | 477629d2cd3176850ef65eacad16f44bbc20fa2b (patch) | |
tree | f7a02501f7d0961733d3325c6205a84ddb4c031b | |
parent | cef2b34f25b45198868be0c06e00a74a1c1ad062 (diff) | |
download | mariadb-git-477629d2cd3176850ef65eacad16f44bbc20fa2b.tar.gz |
MDEV-21147 Assertion `marked_for_read()' upon UPDATE on versioned table via view
Unit prepare prematurely fixed field which must be fixed via
setup_conds() to correctly update table->covering_keys.
Call vers_setup_conds() directly instead, because actually everything
else is not needed.
-rw-r--r-- | mysql-test/suite/versioning/r/update.result | 12 | ||||
-rw-r--r-- | mysql-test/suite/versioning/t/update.test | 14 | ||||
-rw-r--r-- | sql/sql_derived.cc | 9 |
3 files changed, 34 insertions, 1 deletions
diff --git a/mysql-test/suite/versioning/r/update.result b/mysql-test/suite/versioning/r/update.result index 64aa7c7068c..e7c617f9196 100644 --- a/mysql-test/suite/versioning/r/update.result +++ b/mysql-test/suite/versioning/r/update.result @@ -295,5 +295,17 @@ primary key (pk) create or replace view v1 as select * from t1; insert into t1 values (1, null, 'd') , (2, null, 'i') ; 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; +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 baf3c1ec876..548505bd39a 100644 --- a/mysql-test/suite/versioning/t/update.test +++ b/mysql-test/suite/versioning/t/update.test @@ -214,7 +214,21 @@ create or replace view v1 as select * from t1; insert into t1 values (1, null, 'd') , (2, null, 'i') ; 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; + +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/sql_derived.cc b/sql/sql_derived.cc index 652353fb722..1f465a100c9 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -707,8 +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->prepare(derived, derived->derived_result, 0))) + if ((res= first_select->vers_setup_conds(thd, + derived->merge_underlying_list))) goto exit; + 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; } |