diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result
index 67e55acb29baeb01e7495e0634b33af5dbdb3a56..d94ab6f57c37d31728365f174c48e0098122ba6b 100644
--- a/mysql-test/r/user_var.result
+++ b/mysql-test/r/user_var.result
@@ -42,3 +42,35 @@ select @a:=10,   @b:=2,   @a > @b, @a < @b;
 select @a:="10", @b:="2", @a > @b, @a < @b;
 @a:="10"	@b:="2"	@a > @b	@a < @b
 10	2	0	1
+select @a:=1;
+@a:=1
+1
+select @a, @a:=1;
+@a	@a:=1
+1	1
+create table t1 (id int);
+insert into t1 values (1);
+select @c:=0;
+@c:=0
+0
+update t1 SET id=(@c:=@c+1);
+select @c;
+@c
+1
+select @c:=0;
+@c:=0
+0
+update t1 set id=(@c:=@c+1);
+select @c;
+@c
+1
+select @c:=0;
+@c:=0
+0
+select @c:=@c+1;
+@c:=@c+1
+1
+drop table t1;
+select @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b, @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b;
+@a:=10	@b:=2	@a>@b	@a:="10"	@b:="2"	@a>@b	@a:=10	@b:=2	@a>@b	@a:="10"	@b:="2"	@a>@b
+10	2	1	10	2	0	10	2	1	10	2	0
diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test
index f5f91a8a6808f554fd1216a54017d31cca5be4cd..1e466c149bb75520bffeb846afddc112ea43468d 100644
--- a/mysql-test/t/user_var.test
+++ b/mysql-test/t/user_var.test
@@ -23,3 +23,22 @@ select @a:=10,   @b:=1,   @a > @b, @a < @b;
 select @a:="10", @b:="1", @a > @b, @a < @b;
 select @a:=10,   @b:=2,   @a > @b, @a < @b;
 select @a:="10", @b:="2", @a > @b, @a < @b;
+
+# Fixed bug #1194
+select @a:=1;
+select @a, @a:=1;
+
+create table t1 (id int);
+insert into t1 values (1);
+select @c:=0;
+update t1 SET id=(@c:=@c+1);
+select @c;
+select @c:=0;
+update t1 set id=(@c:=@c+1);
+select @c;
+select @c:=0;
+select @c:=@c+1;
+drop table t1;
+
+# just fof fun :)
+select @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b, @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b;
\ No newline at end of file
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 3b1a35e4d0873be69a8da76ac1e94788fad7ef7c..4e1cc3865bad9d6591eceeee2347994cc086f4de 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1899,52 +1899,61 @@ void Item_func_set_user_var::update_hash(void *ptr, uint length,
   return;
 }
 
-
 bool
 Item_func_set_user_var::update()
 {
+  DBUG_ENTER("Item_func_set_user_var::update");
   switch (cached_result_type) {
-  case REAL_RESULT:
-    (void) val();
-    break;
-  case INT_RESULT:
-    (void) val_int();
-    break;
-  case STRING_RESULT:
-    char buffer[MAX_FIELD_WIDTH];
-    String tmp(buffer,sizeof(buffer));
-    (void) val_str(&tmp);
-    break;
+  case REAL_RESULT:   (void)native_val();     break;
+  case INT_RESULT:    (void)native_val_int(); break;
+  case STRING_RESULT: (void)native_val_str(); break;
   }
-  return current_thd->fatal_error;
+  DBUG_RETURN(current_thd->fatal_error);
 }
 
 
 double
 Item_func_set_user_var::val()
 {
-  double value=args[0]->val();
-  update_hash((void*) &value,sizeof(value), REAL_RESULT);
-  return value;
+  DBUG_ENTER("Item_func_set_user_var::val");
+  switch (cached_result_type) {
+  case REAL_RESULT: return native_val(); break;
+  case INT_RESULT:  return native_val_int(); break;
+  case STRING_RESULT:
+  {
+    String *res= native_val_str(); 
+    return !res ? 0 : atof(res->c_ptr());
+  }
+  }
+  DBUG_RETURN(args[0]->val());
 }
 
 longlong
 Item_func_set_user_var::val_int()
 {
-  longlong value=args[0]->val_int();
-  update_hash((void*) &value,sizeof(longlong),INT_RESULT);
-  return value;
+  DBUG_ENTER("Item_func_set_user_var::val_int");
+  switch (cached_result_type) {
+  case REAL_RESULT: return (longlong)native_val(); break;
+  case INT_RESULT:  return native_val_int(); break;
+  case STRING_RESULT:
+  {
+    String *res= native_val_str(); 
+    return !res ? 0 : strtoull(res->c_ptr(),NULL,10);
+  }
+  }
+  DBUG_RETURN(args[0]->val_int());
 }
 
 String *
 Item_func_set_user_var::val_str(String *str)
 {
-  String *res=args[0]->val_str(str);
-  if (!res)					// Null value
-    update_hash((void*) 0,0,STRING_RESULT);
-  else
-    update_hash(res->c_ptr(),res->length()+1,STRING_RESULT);
-  return res;
+  DBUG_ENTER("Item_func_set_user_var::val_str");
+  switch (cached_result_type) {
+  case REAL_RESULT:   str->set(native_val(),decimals); break;
+  case INT_RESULT:    str->set(native_val_int(),decimals); break;
+  case STRING_RESULT: str= native_val_str(str); break;
+  }
+  DBUG_RETURN(str);
 }
 
 
@@ -1973,6 +1982,7 @@ user_var_entry *Item_func_get_user_var::get_entry()
 String *
 Item_func_get_user_var::val_str(String *str)
 {
+  DBUG_ENTER("Item_func_get_user_var::val_str");
   user_var_entry *entry=get_entry();
   if (!entry)
     return NULL;
@@ -1991,7 +2001,7 @@ Item_func_get_user_var::val_str(String *str)
     }
     break;
   }
-  return str;
+  DBUG_RETURN(str);
 }
 
 
diff --git a/sql/item_func.h b/sql/item_func.h
index bccd0ca7adb9c799d6d0cfadbc04293d96c5004e..ffc587c3cf3bb557645ab06eb700bf7af040b243 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -889,6 +889,38 @@ class Item_func_set_user_var :public Item_func
   LEX_STRING name;
   user_var_entry *entry;
 
+  double native_val()
+    {
+      double value=args[0]->val();
+      update_hash((void*) &value,sizeof(value), REAL_RESULT);
+      return value;
+    }
+  
+  longlong native_val_int()
+    {
+      longlong value=args[0]->val_int();
+      update_hash((void*) &value,sizeof(longlong),INT_RESULT);
+      return value;
+    }
+  
+  String *native_val_str(String *str)
+    {
+      char buffer[MAX_FIELD_WIDTH];
+      String *res=args[0]->val_str(str);
+      if (!res)					// Null value
+	update_hash((void*) 0,0,STRING_RESULT);
+      else
+	update_hash(res->c_ptr(),res->length()+1,STRING_RESULT);
+      return res;
+    }
+
+  String *native_val_str()
+    {
+      char buffer[MAX_FIELD_WIDTH];
+      String tmp(buffer,sizeof(buffer));
+      return native_val_str(&tmp);
+    }
+
 public:
   Item_func_set_user_var(LEX_STRING a,Item *b): Item_func(b), name(a) {}
   double val();