Bug#26020: User-Defined Variables are not consistent with
columns data types The "SELECT @lastId, @lastId := Id FROM t" query returns different result sets depending on the type of the Id column (INT or BIGINT). Note: this fix doesn't cover the case when a select query references an user variable and stored function that updates a value of that variable, in this case a result is indeterminate. The server uses incorrect assumption about a constantness of an user variable value as a select list item: The server caches a last query number where that variable was changed and compares this number with a current query number. If these numbers are different, the server guesses, that the variable is not updating in the current query, so a respective select list item is a constant. However, in some common cases the server updates cached query number too late. The server has been modified to memorize user variable assignments during the parse phase to take them into account on the next (query preparation) phase independently of the order of user variable references/assignments in a select item list. mysql-test/r/user_var.result: Added test case for bug #26020. mysql-test/t/user_var.test: Added test case for bug #26020. sql/item_func.cc: An update of entry and update_query_id variables has been moved from Item_func_set_user_var::fix_fields() to a separate method, Item_func_set_user_var::set_entry(). sql/item_func.h: 1. The Item_func_set_user_var::set_entry() method has been added to update Item_func_set_user_var::entry. 2. The Item_func_set_user_var::entry_thd field has beend added to update Item_func_set_user_var::entry only when needed. sql/sql_base.cc: Fix: setup_fiedls() calls Item_func_set_user_var::set_entry() for all items from the thd->lex->set_var_list before the first call of ::fix_fields(). sql/sql_lex.cc: The lex_start function has been modified to reset the st_lex::set_var_list list. sql/sql_lex.h: New st_lex::set_var_list field has been added to memorize all user variable assignments in the current select query. sql/sql_yacc.yy: The variable_aux rule has been modified to memorize in-query user variable assignments in the st_lex::set_var_list list.
Showing
Please register or sign in to comment