Commit 44cad14b authored by evgen@moonbone.local's avatar evgen@moonbone.local

item_cmpfunc.cc, item.cc:

  Additional fix for bug #21475
item_func.h, item_func.cc:
  Additional fix for bug#16861
parent f0edc908
...@@ -305,6 +305,7 @@ Item::Item(): ...@@ -305,6 +305,7 @@ Item::Item():
maybe_null=null_value=with_sum_func=unsigned_flag=0; maybe_null=null_value=with_sum_func=unsigned_flag=0;
decimals= 0; max_length= 0; decimals= 0; max_length= 0;
with_subselect= 0; with_subselect= 0;
cmp_context= (Item_result)-1;
/* Put item in free list so that we can free all items at end */ /* Put item in free list so that we can free all items at end */
THD *thd= current_thd; THD *thd= current_thd;
...@@ -343,7 +344,8 @@ Item::Item(THD *thd, Item *item): ...@@ -343,7 +344,8 @@ Item::Item(THD *thd, Item *item):
unsigned_flag(item->unsigned_flag), unsigned_flag(item->unsigned_flag),
with_sum_func(item->with_sum_func), with_sum_func(item->with_sum_func),
fixed(item->fixed), fixed(item->fixed),
collation(item->collation) collation(item->collation),
cmp_context(item->cmp_context)
{ {
next= thd->free_list; // Put in free list next= thd->free_list; // Put in free list
thd->free_list= this; thd->free_list= this;
...@@ -3788,7 +3790,8 @@ Item *Item_field::equal_fields_propagator(byte *arg) ...@@ -3788,7 +3790,8 @@ Item *Item_field::equal_fields_propagator(byte *arg)
The same problem occurs when comparing a DATE/TIME field with a The same problem occurs when comparing a DATE/TIME field with a
DATE/TIME represented as an int and as a string. DATE/TIME represented as an int and as a string.
*/ */
if (!item || item->cmp_context != cmp_context) if (!item ||
(cmp_context != (Item_result)-1 && item->cmp_context != cmp_context))
item= this; item= this;
return item; return item;
} }
......
...@@ -1220,6 +1220,7 @@ void Item_func_between::fix_length_and_dec() ...@@ -1220,6 +1220,7 @@ void Item_func_between::fix_length_and_dec()
if (!args[0] || !args[1] || !args[2]) if (!args[0] || !args[1] || !args[2])
return; return;
agg_cmp_type(thd, &cmp_type, args, 3); agg_cmp_type(thd, &cmp_type, args, 3);
args[0]->cmp_context= args[1]->cmp_context= args[2]->cmp_context= cmp_type;
if (cmp_type == STRING_RESULT) if (cmp_type == STRING_RESULT)
agg_arg_charsets(cmp_collation, args, 3, MY_COLL_CMP_CONV, 1); agg_arg_charsets(cmp_collation, args, 3, MY_COLL_CMP_CONV, 1);
......
...@@ -3897,6 +3897,19 @@ bool Item_func_set_user_var::send(Protocol *protocol, String *str_arg) ...@@ -3897,6 +3897,19 @@ bool Item_func_set_user_var::send(Protocol *protocol, String *str_arg)
return Item::send(protocol, str_arg); return Item::send(protocol, str_arg);
} }
void Item_func_set_user_var::make_field(Send_field *tmp_field)
{
if (result_field)
{
result_field->make_field(tmp_field);
DBUG_ASSERT(tmp_field->table_name != 0);
if (Item::name)
tmp_field->col_name=Item::name; // Use user supplied name
}
else
Item::make_field(tmp_field);
}
String * String *
Item_func_get_user_var::val_str(String *str) Item_func_get_user_var::val_str(String *str)
{ {
......
...@@ -1175,6 +1175,7 @@ public: ...@@ -1175,6 +1175,7 @@ public:
bool update_hash(void *ptr, uint length, enum Item_result type, bool update_hash(void *ptr, uint length, enum Item_result type,
CHARSET_INFO *cs, Derivation dv, bool unsigned_arg= 0); CHARSET_INFO *cs, Derivation dv, bool unsigned_arg= 0);
bool send(Protocol *protocol, String *str_arg); bool send(Protocol *protocol, String *str_arg);
void make_field(Send_field *tmp_field);
bool check(bool use_result_field); bool check(bool use_result_field);
bool update(); bool update();
enum Item_result result_type () const { return cached_result_type; } enum Item_result result_type () const { return cached_result_type; }
......
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