summaryrefslogtreecommitdiff
path: root/mysql-test/t/user_var.test
diff options
context:
space:
mode:
authorevgen@sunlight.local <>2006-08-22 17:37:41 +0400
committerevgen@sunlight.local <>2006-08-22 17:37:41 +0400
commitf17a536e097fdfe982cf5ccf8102d24199061593 (patch)
treec314e2e59971f43503941c43503c52cd6a91e4a1 /mysql-test/t/user_var.test
parent07a1ed651fb28946ace14bb8ee44b0107c09cf3c (diff)
downloadmariadb-git-f17a536e097fdfe982cf5ccf8102d24199061593.tar.gz
Fixed bug#16861: User defined variable can have a wrong value if a tmp table was
used. Sorting by RAND() uses a temporary table in order to get a correct results. User defined variable was set during filling the temporary table and later on it is substituted for its value from the temporary table. Due to this it contains the last value stored in the temporary table. Now if the result_field is set for the Item_func_set_user_var object it updates variable from the result_field value when being sent to a client. The Item_func_set_user_var::check() now accepts a use_result_field parameter. Depending on its value the result_field or the args[0] is used to get current value.
Diffstat (limited to 'mysql-test/t/user_var.test')
-rw-r--r--mysql-test/t/user_var.test10
1 files changed, 10 insertions, 0 deletions
diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test
index 58c52b59a5a..b2a9728de00 100644
--- a/mysql-test/t/user_var.test
+++ b/mysql-test/t/user_var.test
@@ -202,3 +202,13 @@ SET @a := (select * from bigfailure where afield = (SELECT afield FROM bigfailur
SELECT @a;
drop table bigfailure;
+
+#
+# Bug#16861: User defined variable can have a wrong value if a tmp table was
+# used.
+#
+create table t1(f1 int, f2 int);
+insert into t1 values (1,2),(2,3),(3,1);
+select @var:=f2 from t1 group by f1 order by f2 desc limit 1;
+select @var;
+drop table t1;