diff options
author | Gleb Shchepa <gshchepa@mysql.com> | 2008-09-18 13:38:44 +0500 |
---|---|---|
committer | Gleb Shchepa <gshchepa@mysql.com> | 2008-09-18 13:38:44 +0500 |
commit | e9cb71fc3a2f4e83720f1bab4f470e10ca878eb6 (patch) | |
tree | 2645104a2a73aa7f9368263d59ff44c7052e9599 /sql/sql_lex.cc | |
parent | 4efa8d5a9a52f712378cae49886843879a113db9 (diff) | |
download | mariadb-git-e9cb71fc3a2f4e83720f1bab4f470e10ca878eb6.tar.gz |
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.
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r-- | sql/sql_lex.cc | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 1822176f00a..18c61910e89 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -293,6 +293,7 @@ void lex_start(THD *thd) lex->select_lex.init_query(); lex->value_list.empty(); lex->update_list.empty(); + lex->set_var_list.empty(); lex->param_list.empty(); lex->view_list.empty(); lex->prepared_stmt_params.empty(); |