diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index 9acdb27a2d6d63b46571cc858162bfa26bf51315..07835201acbb02cf75d74df00d1eb5f18cc19aec 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -302,4 +302,20 @@ call bug2272()|
 ERROR 42S22: Unknown column 'v' in 'field list'
 delete from t1|
 drop procedure bug2272|
+create procedure bug2329_1()
+begin
+declare v int;
+insert into t1 (v) values (5);
+end|
+create procedure bug2329_2()
+begin
+declare v int;
+replace t1 set v = 5;
+end|
+call bug2329_1()|
+ERROR 42S22: Unknown column 'v' in 'field list'
+call bug2329_2()|
+ERROR 42S22: Unknown column 'v' in 'field list'
+drop procedure bug2329_1|
+drop procedure bug2329_2|
 drop table t1|
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index db989481aa3677afe59db7fb39af5a617a6180b7..5972ee53d0dfb89bb9baa559cfa68dca2fbcf1af 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -75,6 +75,20 @@ id	data
 locset	21
 delete from t1|
 drop procedure locset|
+create procedure setcontext()
+begin
+declare data int default 2;
+insert into t1 (id, data) values ("foo", 1);
+replace t1 set data = data, id = "bar";
+update t1 set id = "kaka", data = 3 where t1.data = data;
+end|
+call setcontext()|
+select * from t1|
+id	data
+foo	1
+kaka	3
+delete from t1|
+drop procedure setcontext|
 drop table if exists t3|
 create table t3 ( d date, i int, f double, s varchar(32) )|
 create procedure nullset()
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index 4ac47257b1b9722a4ee8bfe644889f8913d7911b..c72dcaedb4e276a8c7654993b89e84b24ce57f9a 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -421,6 +421,30 @@ call bug2272()|
 delete from t1|
 drop procedure bug2272|
 
+#
+# BUG#2329
+#
+create procedure bug2329_1()
+begin
+  declare v int;
+
+  insert into t1 (v) values (5);
+end|
+
+create procedure bug2329_2()
+begin
+  declare v int;
+
+  replace t1 set v = 5;
+end|
+
+--error 1054
+call bug2329_1()|
+--error 1054
+call bug2329_2()|
+drop procedure bug2329_1|
+drop procedure bug2329_2|
+
 drop table t1|
 
 delimiter ;|
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index be9bc53b9fc6a0d08c6f35203fc8022a4db0b7ed..dcfa032c7a409ba0097825ef95a08a01dfe55638 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -109,6 +109,23 @@ delete from t1|
 drop procedure locset|
 
 
+# In some contexts local variables are not recognized
+# (and in some, you have to qualify the identifier).
+create procedure setcontext()
+begin
+  declare data int default 2;
+
+  insert into t1 (id, data) values ("foo", 1);
+  replace t1 set data = data, id = "bar";
+  update t1 set id = "kaka", data = 3 where t1.data = data;
+end|
+
+call setcontext()|
+select * from t1|
+delete from t1|
+drop procedure setcontext|
+
+
 # Set things to null
 --disable_warnings
 drop table if exists t3|
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index cec85db8ca63b698292a58aa578de78e5f695991..d908af6f6247e779564b7d43462a7b0705303b88 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -4903,7 +4903,7 @@ ident_eq_list:
 	ident_eq_value;
 
 ident_eq_value:
-	simple_ident equal expr_or_default
+	simple_ident_nospvar equal expr_or_default
 	 {
 	  LEX *lex=Lex;
 	  if (lex->field_list.push_back($1) ||
@@ -4990,7 +4990,7 @@ update:
 	;
 
 update_list:
-	update_list ',' simple_ident equal expr_or_default
+	update_list ',' simple_ident_nospvar equal expr_or_default
 	{
 	  if (add_item_to_list(YYTHD, $3) || add_value_to_list(YYTHD, $5))
 	    YYABORT;
@@ -5629,7 +5629,7 @@ NUM_literal:
 **********************************************************************/
 
 insert_ident:
-	simple_ident	 { $$=$1; }
+	simple_ident_nospvar { $$=$1; }
 	| table_wild	 { $$=$1; };
 
 table_wild: