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.
Showing
Please register or sign in to comment