summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/user_var.result19
-rw-r--r--mysql-test/t/user_var.test11
-rw-r--r--sql/sql_handler.cc13
3 files changed, 43 insertions, 0 deletions
diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result
index d7c41d5dbc4..3e83438b273 100644
--- a/mysql-test/r/user_var.result
+++ b/mysql-test/r/user_var.result
@@ -97,3 +97,22 @@ 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 1 10 2 1 10 2 1
+create table t1 (i int not null);
+insert t1 values (1),(2),(2),(3),(3),(3);
+select @a:=0;
+@a:=0
+0
+select @a, @a:=@a+count(*), count(*), @a from t1 group by i;
+@a @a:=@a+count(*) count(*) @a
+0 1 1 0
+0 2 2 0
+0 3 3 0
+select @a:=0;
+@a:=0
+0
+select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i;
+@a+0 @a:=@a+0+count(*) count(*) @a+0
+0 1 1 0
+1 3 2 0
+3 6 3 0
+drop table t1;
diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test
index 56528405a2a..9cb5d5e1eb0 100644
--- a/mysql-test/t/user_var.test
+++ b/mysql-test/t/user_var.test
@@ -53,3 +53,14 @@ drop table t1;
# just for 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;
+
+#
+# bug#1739
+# Item_func_set_user_var sets update_query_id, Item_func_get_user_var checks it
+#
+create table t1 (i int not null);
+insert t1 values (1),(2),(2),(3),(3),(3);
+select @a:=0; select @a, @a:=@a+count(*), count(*), @a from t1 group by i;
+select @a:=0; select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i;
+drop table t1;
+
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index dd8dfb31163..208545a435b 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -285,7 +285,20 @@ static TABLE **find_table_ptr_by_name(THD *thd, const char *db,
{
if (!memcmp(table->table_cache_key, db, dblen) &&
!my_strcasecmp((is_alias ? table->table_name : table->real_name),table_name))
+ {
+ if (table->version != refresh_version)
+ {
+ VOID(pthread_mutex_lock(&LOCK_open));
+ if (close_thread_table(thd, ptr))
+ {
+ /* Tell threads waiting for refresh that something has happened */
+ VOID(pthread_cond_broadcast(&COND_refresh));
+ }
+ VOID(pthread_mutex_unlock(&LOCK_open));
+ continue;
+ }
break;
+ }
ptr=&(table->next);
}
return ptr;