Commit 48df5b75 authored by unknown's avatar unknown

Coercibility is now stored in user vars


sql/item.h:
  Change constant values order according to the word "coercibility" nature
sql/item_func.cc:
  Change constant values order according to the word "coercibility" nature
parent 310545ad
......@@ -39,8 +39,8 @@ class Item {
SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM};
enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };
enum coercion { COER_NOCOLL=0, COER_COERCIBLE=1,
COER_IMPLICIT=2, COER_EXPLICIT=3 };
enum coercion { COER_NOCOLL=3, COER_COERCIBLE=2,
COER_IMPLICIT=1, COER_EXPLICIT=0 };
String str_value; /* used to store value */
my_string name; /* Name from select */
......
......@@ -132,7 +132,7 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
coercibility= (*arg)->coercibility;
set_charset((*arg)->charset());
}
else if ((*arg)->coercibility > coercibility)
else if ((*arg)->coercibility < coercibility)
{
if (strcmp(charset()->csname,(*arg)->charset()->csname))
{
......@@ -2007,6 +2007,7 @@ static user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
}
bool Item_func_set_user_var::fix_fields(THD *thd, TABLE_LIST *tables,
Item **ref)
{
......@@ -2030,7 +2031,8 @@ Item_func_set_user_var::fix_length_and_dec()
void Item_func_set_user_var::update_hash(void *ptr, uint length,
Item_result type,
CHARSET_INFO *cs)
CHARSET_INFO *cs,
enum coercion coercibility)
{
if ((null_value=args[0]->null_value))
{
......@@ -2040,6 +2042,7 @@ void Item_func_set_user_var::update_hash(void *ptr, uint length,
entry->value=0;
entry->length=0;
entry->var_charset=cs;
entry->var_coercibility= coercibility;
}
else
{
......@@ -2071,6 +2074,7 @@ void Item_func_set_user_var::update_hash(void *ptr, uint length,
entry->length= length;
entry->type=type;
entry->var_charset=cs;
entry->var_coercibility= coercibility;
}
return;
......@@ -2112,7 +2116,8 @@ double
Item_func_set_user_var::val()
{
double value=args[0]->val();
update_hash((void*) &value,sizeof(value), REAL_RESULT, default_charset_info);
update_hash((void*) &value,sizeof(value), REAL_RESULT,
&my_charset_bin, COER_NOCOLL);
return value;
}
......@@ -2121,7 +2126,7 @@ Item_func_set_user_var::val_int()
{
longlong value=args[0]->val_int();
update_hash((void*) &value, sizeof(longlong), INT_RESULT,
default_charset_info);
&my_charset_bin, COER_NOCOLL);
return value;
}
......@@ -2130,10 +2135,10 @@ Item_func_set_user_var::val_str(String *str)
{
String *res=args[0]->val_str(str);
if (!res) // Null value
update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin);
update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin, COER_NOCOLL);
else
update_hash((void*) res->ptr(), res->length(), STRING_RESULT,
res->charset());
res->charset(), args[0]->coercibility);
return res;
}
......
......@@ -934,7 +934,8 @@ class Item_func_set_user_var :public Item_func
double val();
longlong val_int();
String *val_str(String *str);
void update_hash(void *ptr, uint length, enum Item_result type, CHARSET_INFO *cs);
void update_hash(void *ptr, uint length, enum Item_result type,
CHARSET_INFO *cs, enum coercion coercibility);
bool update();
enum Item_result result_type () const { return cached_result_type; }
bool fix_fields(THD *thd, struct st_table_list *tables, Item **ref);
......
......@@ -2177,7 +2177,7 @@ int User_var_log_event::exec_event(struct st_relay_log_info* rli)
}
Item_func_set_user_var e(user_var_name, it);
e.fix_fields(thd, 0, 0);
e.update_hash(val, val_len, type, charset);
e.update_hash(val, val_len, type, charset, Item::COER_NOCOLL);
free_root(&thd->mem_root,0);
rli->inc_pending(get_event_len());
......
......@@ -935,6 +935,7 @@ class user_var_entry
ulong length, update_query_id, used_query_id;
Item_result type;
CHARSET_INFO *var_charset;
enum Item::coercion var_coercibility;
};
/* Class for unique (removing of duplicates) */
......
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