diff options
author | Mats Kindahl <mats@sun.com> | 2008-10-23 21:27:09 +0200 |
---|---|---|
committer | Mats Kindahl <mats@sun.com> | 2008-10-23 21:27:09 +0200 |
commit | 32c161f3ea7314051090fb02eca03ef347394010 (patch) | |
tree | 09212d65be943c6c5dfd6d6a834841683d81f9f8 /sql/item_func.cc | |
parent | 3be6d967c5d04fa6dbeab1c25f28673d3abf8433 (diff) | |
parent | e291aab7da9587f742291e7cc5e10e568846066e (diff) | |
download | mariadb-git-32c161f3ea7314051090fb02eca03ef347394010.tar.gz |
Merging 5.1 main into 5.1-rpl
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 8bb6bb30117..d7e6fc1f8f2 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3805,6 +3805,25 @@ static user_var_entry *get_variable(HASH *hash, LEX_STRING &name, return entry; } + +bool Item_func_set_user_var::set_entry(THD *thd, bool create_if_not_exists) +{ + if (thd == entry_thd && entry) + goto end; // update entry->update_query_id for PS + entry_thd= thd; + if (!(entry= get_variable(&thd->user_vars, name, create_if_not_exists))) + return TRUE; + /* + Remember the last query which updated it, this way a query can later know + if this variable is a constant item in the query (it is if update_query_id + is different from query_id). + */ +end: + entry->update_query_id= thd->query_id; + return FALSE; +} + + /* When a user variable is updated (in a SET command or a query like SELECT @a:= ). @@ -3814,15 +3833,8 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref) { DBUG_ASSERT(fixed == 0); /* fix_fields will call Item_func_set_user_var::fix_length_and_dec */ - if (Item_func::fix_fields(thd, ref) || - !(entry= get_variable(&thd->user_vars, name, 1))) + if (Item_func::fix_fields(thd, ref) || set_entry(thd, TRUE)) return TRUE; - /* - Remember the last query which updated it, this way a query can later know - if this variable is a constant item in the query (it is if update_query_id - is different from query_id). - */ - entry->update_query_id= thd->query_id; /* As it is wrong and confusing to associate any character set with NULL, @a should be latin2 |