2079
2079
max_used_connections= 1; /* We set it to one, because we know we exist */
2080
2080
pthread_mutex_unlock(&LOCK_status);
2083
#define extra_size sizeof(double)
2085
user_var_entry *Session::getVariable(LEX_STRING &name, bool create_if_not_exists)
2087
user_var_entry *entry= NULL;
2089
assert(name.length == strlen (name.str));
2090
entry= (user_var_entry*) hash_search(&user_vars, (unsigned char*) name.str, name.length);
2092
if ((entry == NULL) && create_if_not_exists)
2094
uint32_t size=ALIGN_SIZE(sizeof(user_var_entry))+name.length+1+extra_size;
2095
if (!hash_inited(&user_vars))
2097
if (!(entry = (user_var_entry*) malloc(size)))
2099
entry->name.str=(char*) entry+ ALIGN_SIZE(sizeof(user_var_entry))+
2101
entry->name.length=name.length;
2104
entry->update_query_id=0;
2105
entry->collation.set(NULL, DERIVATION_IMPLICIT, 0);
2106
entry->unsigned_flag= 0;
2108
If we are here, we were called from a SET or a query which sets a
2109
variable. Imagine it is this:
2110
INSERT INTO t SELECT @a:=10, @a:=@a+1.
2111
Then when we have a Item_func_get_user_var (because of the @a+1) so we
2112
think we have to write the value of @a to the binlog. But before that,
2113
we have a Item_func_set_user_var to create @a (@a:=10), in this we mark
2114
the variable as "already logged" (line below) so that it won't be logged
2115
by Item_func_get_user_var (because that's not necessary).
2117
entry->used_query_id= query_id;
2118
entry->type=STRING_RESULT;
2119
memcpy(entry->name.str, name.str, name.length+1);
2120
if (my_hash_insert(&user_vars, (unsigned char*) entry))
2123
free((char*) entry);