summaryrefslogtreecommitdiff
path: root/mysql-test/t/user_var.test
diff options
context:
space:
mode:
authorunknown <evgen@sunlight.local>2006-08-22 17:37:41 +0400
committerunknown <evgen@sunlight.local>2006-08-22 17:37:41 +0400
commitc623e54fb8a939eb877770d875ce184fec543d37 (patch)
treec314e2e59971f43503941c43503c52cd6a91e4a1 /mysql-test/t/user_var.test
parent6071b686b179d1fcc96cd6ccce940d62bd509c70 (diff)
downloadmariadb-git-c623e54fb8a939eb877770d875ce184fec543d37.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. mysql-test/r/user_var.result: Added a test case for bug#16861: User defined variable can have a wrong value if a tmp table was used. mysql-test/t/user_var.test: Added a test case for bug#16861: User defined variable can have a wrong value if a tmp table was used. sql/item_func.cc: Fixed bug#16861: User defined variable can have a wrong value if a tmp table was used. 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. sql/item_func.h: Fixed bug#16861: User defined variable can have a wrong value if a tmp table was used. Added a new SUSERVAR_FUNC function type. Updated the Item_func_set_user_var::check() function declaration. Added the Item_func_set_user_var::send() member function. sql/set_var.cc: Fixed bug#16861: User defined variable can have a wrong value if a tmp table was used. Modified to use updated Item_func_set_user_var::check() function. sql/sql_class.cc: Fixed bug#16861: User defined variable can have a wrong value if a tmp table was used. Modified to use updated Item_func_set_user_var::check() function. sql/sql_select.cc: Fixed bug#16861: User defined variable can have a wrong value if a tmp table was used. Now an Item_func_set_user_var object isn't substituted for an Item_field object after filling a temporary table.
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;