Commit 9f31df64 authored by Georgi Kodinov's avatar Georgi Kodinov

Bug #32124 addendum

 Fixed the handling of system variable retrieval
in prepared statements : added a cleanup method
that clears up the cache and restores the 
original scope of the variable (which is overwritten
at fix_fields()).

sql/item_func.cc:
  ug #32124: 
   - preserve the requested variable scope
   - clean up the cache and restore the variable
     scope for prepared statements.
sql/item_func.h:
  Bug #32124: preserve the requested variable scope
parent 835cbfd3
...@@ -4800,8 +4800,8 @@ Item_func_get_system_var:: ...@@ -4800,8 +4800,8 @@ Item_func_get_system_var::
Item_func_get_system_var(sys_var *var_arg, enum_var_type var_type_arg, Item_func_get_system_var(sys_var *var_arg, enum_var_type var_type_arg,
LEX_STRING *component_arg, const char *name_arg, LEX_STRING *component_arg, const char *name_arg,
size_t name_len_arg) size_t name_len_arg)
:var(var_arg), var_type(var_type_arg), component(*component_arg), :var(var_arg), var_type(var_type_arg), orig_var_type(var_type_arg),
cache_present(0) component(*component_arg), cache_present(0)
{ {
/* set_name() will allocate the name */ /* set_name() will allocate the name */
set_name(name_arg, name_len_arg, system_charset_info); set_name(name_arg, name_len_arg, system_charset_info);
...@@ -5186,6 +5186,15 @@ bool Item_func_get_system_var::eq(const Item *item, bool binary_cmp) const ...@@ -5186,6 +5186,15 @@ bool Item_func_get_system_var::eq(const Item *item, bool binary_cmp) const
} }
void Item_func_get_system_var::cleanup()
{
Item_func::cleanup();
cache_present= NULL;
var_type= orig_var_type;
cached_strval.free();
}
longlong Item_func_inet_aton::val_int() longlong Item_func_inet_aton::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
......
...@@ -1433,7 +1433,7 @@ public: ...@@ -1433,7 +1433,7 @@ public:
class Item_func_get_system_var :public Item_func class Item_func_get_system_var :public Item_func
{ {
sys_var *var; sys_var *var;
enum_var_type var_type; enum_var_type var_type, orig_var_type;
LEX_STRING component; LEX_STRING component;
longlong cached_llval; longlong cached_llval;
double cached_dval; double cached_dval;
...@@ -1468,6 +1468,8 @@ public: ...@@ -1468,6 +1468,8 @@ public:
*/ */
bool is_written_to_binlog(); bool is_written_to_binlog();
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
void cleanup();
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment