Commit 4ffd74e5 authored by bar@bar.mysql.r18.ru's avatar bar@bar.mysql.r18.ru

Coercibility is now stored in user vars

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