diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 344bce2a204..f1a32ea0c17 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1329,6 +1329,18 @@ update v1,t1 set v1.s1='c' where t1.s1=v1.s1; select * from v1; s1 c +prepare stmt1 from "update v1,t1 set v1.s1=? where t1.s1=v1.s1"; +set @arg='d'; +execute stmt1 using @arg; +select * from v1; +s1 +d +set @arg='e'; +execute stmt1 using @arg; +select * from v1; +s1 +e +deallocate prepare stmt1; drop view v1; drop table t1; create table t1 (a int); diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index cfad7e34d0d..a9fd65bbb09 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1297,6 +1297,14 @@ update v1 set s1='b'; select * from v1; update v1,t1 set v1.s1='c' where t1.s1=v1.s1; select * from v1; +prepare stmt1 from "update v1,t1 set v1.s1=? where t1.s1=v1.s1"; +set @arg='d'; +execute stmt1 using @arg; +select * from v1; +set @arg='e'; +execute stmt1 using @arg; +select * from v1; +deallocate prepare stmt1; drop view v1; drop table t1; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 7a643933c46..00e70ccb484 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -80,9 +80,8 @@ static bool check_fields(THD *thd, List &items) we make temporary copy of Item_field, to avoid influence of changing result_field on Item_ref which refer on this field */ - field= new Item_field(thd, field); - it.replace(field); - ((Item_field *)item)->register_item_tree_changing(it.ref()); + it.replace(new Item_field(thd, field)); + field->register_item_tree_changing(it.ref()); } return FALSE; }