Commit b4e56a56 authored by Alexander Barkov's avatar Alexander Barkov

Moving common members of Item_func_in and Item_func_between to their

parent Item_func_opt_neg. A pre-requisite patch for a number of
upcoming equal field propagation related bug fixes.
parent 3ba2a958
...@@ -2197,9 +2197,9 @@ void Item_func_between::fix_length_and_dec() ...@@ -2197,9 +2197,9 @@ void Item_func_between::fix_length_and_dec()
*/ */
if (!args[0] || !args[1] || !args[2]) if (!args[0] || !args[1] || !args[2])
return; return;
if ( agg_cmp_type(&cmp_type, args, 3)) if (agg_cmp_type(&m_compare_type, args, 3))
return; return;
if (cmp_type == STRING_RESULT && if (m_compare_type == STRING_RESULT &&
agg_arg_charsets_for_comparison(cmp_collation, args, 3)) agg_arg_charsets_for_comparison(cmp_collation, args, 3))
return; return;
...@@ -2211,7 +2211,7 @@ void Item_func_between::fix_length_and_dec() ...@@ -2211,7 +2211,7 @@ void Item_func_between::fix_length_and_dec()
For this to work, we need to know what date/time type we compare For this to work, we need to know what date/time type we compare
strings as. strings as.
*/ */
if (cmp_type == TIME_RESULT) if (m_compare_type == TIME_RESULT)
compare_as_dates= find_date_time_item(args, 3, 0); compare_as_dates= find_date_time_item(args, 3, 0);
/* See the comment about the similar block in Item_bool_func2 */ /* See the comment about the similar block in Item_bool_func2 */
...@@ -2225,7 +2225,7 @@ void Item_func_between::fix_length_and_dec() ...@@ -2225,7 +2225,7 @@ void Item_func_between::fix_length_and_dec()
const bool cvt_arg1= convert_const_to_int(thd, field_item, &args[1]); const bool cvt_arg1= convert_const_to_int(thd, field_item, &args[1]);
const bool cvt_arg2= convert_const_to_int(thd, field_item, &args[2]); const bool cvt_arg2= convert_const_to_int(thd, field_item, &args[2]);
if (cvt_arg1 && cvt_arg2) if (cvt_arg1 && cvt_arg2)
cmp_type=INT_RESULT; // Works for all types. m_compare_type= INT_RESULT; // Works for all types.
} }
} }
} }
...@@ -2235,7 +2235,7 @@ longlong Item_func_between::val_int() ...@@ -2235,7 +2235,7 @@ longlong Item_func_between::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
switch (cmp_type) { switch (m_compare_type) {
case TIME_RESULT: case TIME_RESULT:
{ {
THD *thd= current_thd; THD *thd= current_thd;
...@@ -3972,7 +3972,7 @@ void Item_func_in::fix_length_and_dec() ...@@ -3972,7 +3972,7 @@ void Item_func_in::fix_length_and_dec()
Item *date_arg= 0; Item *date_arg= 0;
uint found_types= 0; uint found_types= 0;
uint type_cnt= 0, i; uint type_cnt= 0, i;
Item_result cmp_type= STRING_RESULT; m_compare_type= STRING_RESULT;
left_result_type= args[0]->cmp_type(); left_result_type= args[0]->cmp_type();
if (!(found_types= collect_cmp_types(args, arg_count, true))) if (!(found_types= collect_cmp_types(args, arg_count, true)))
return; return;
...@@ -3990,18 +3990,18 @@ void Item_func_in::fix_length_and_dec() ...@@ -3990,18 +3990,18 @@ void Item_func_in::fix_length_and_dec()
if (found_types & (1U << i)) if (found_types & (1U << i))
{ {
(type_cnt)++; (type_cnt)++;
cmp_type= (Item_result) i; m_compare_type= (Item_result) i;
} }
} }
if (type_cnt == 1) if (type_cnt == 1)
{ {
if (cmp_type == STRING_RESULT && if (m_compare_type == STRING_RESULT &&
agg_arg_charsets_for_comparison(cmp_collation, args, arg_count)) agg_arg_charsets_for_comparison(cmp_collation, args, arg_count))
return; return;
arg_types_compatible= TRUE; arg_types_compatible= TRUE;
if (cmp_type == ROW_RESULT) if (m_compare_type == ROW_RESULT)
{ {
uint cols= args[0]->cols(); uint cols= args[0]->cols();
cmp_item_row *cmp= 0; cmp_item_row *cmp= 0;
...@@ -4051,7 +4051,7 @@ void Item_func_in::fix_length_and_dec() ...@@ -4051,7 +4051,7 @@ void Item_func_in::fix_length_and_dec()
See the comment about the similar block in Item_bool_func2 See the comment about the similar block in Item_bool_func2
*/ */
if (args[0]->real_item()->type() == FIELD_ITEM && if (args[0]->real_item()->type() == FIELD_ITEM &&
!thd->lex->is_view_context_analysis() && cmp_type != INT_RESULT) !thd->lex->is_view_context_analysis() && m_compare_type != INT_RESULT)
{ {
Item_field *field_item= (Item_field*) (args[0]->real_item()); Item_field *field_item= (Item_field*) (args[0]->real_item());
if (field_item->field_type() == MYSQL_TYPE_LONGLONG || if (field_item->field_type() == MYSQL_TYPE_LONGLONG ||
...@@ -4064,10 +4064,10 @@ void Item_func_in::fix_length_and_dec() ...@@ -4064,10 +4064,10 @@ void Item_func_in::fix_length_and_dec()
all_converted= FALSE; all_converted= FALSE;
} }
if (all_converted) if (all_converted)
cmp_type= INT_RESULT; m_compare_type= INT_RESULT;
} }
} }
switch (cmp_type) { switch (m_compare_type) {
case STRING_RESULT: case STRING_RESULT:
array=new (thd->mem_root) in_string(arg_count-1,(qsort2_cmp) srtcmp_in, array=new (thd->mem_root) in_string(arg_count-1,(qsort2_cmp) srtcmp_in,
cmp_collation.collation); cmp_collation.collation);
......
...@@ -679,6 +679,17 @@ public: ...@@ -679,6 +679,17 @@ public:
class Item_func_opt_neg :public Item_bool_func class Item_func_opt_neg :public Item_bool_func
{ {
protected:
/*
The result type that will be used for comparison.
cmp_type() of all arguments are collected to here.
*/
Item_result m_compare_type;
/*
The collation that will be used for comparison in case
when m_compare_type is STRING_RESULT.
*/
DTCollation cmp_collation;
public: public:
bool negated; /* <=> the item represents NOT <func> */ bool negated; /* <=> the item represents NOT <func> */
bool pred_level; /* <=> [NOT] <func> is used on a predicate level */ bool pred_level; /* <=> [NOT] <func> is used on a predicate level */
...@@ -708,12 +719,10 @@ public: ...@@ -708,12 +719,10 @@ public:
class Item_func_between :public Item_func_opt_neg class Item_func_between :public Item_func_opt_neg
{ {
DTCollation cmp_collation;
protected: protected:
SEL_TREE *get_func_mm_tree(RANGE_OPT_PARAM *param, SEL_TREE *get_func_mm_tree(RANGE_OPT_PARAM *param,
Field *field, Item *value, Item_result cmp_type); Field *field, Item *value, Item_result cmp_type);
public: public:
Item_result cmp_type;
String value0,value1,value2; String value0,value1,value2;
/* TRUE <=> arguments will be compared as dates. */ /* TRUE <=> arguments will be compared as dates. */
Item *compare_as_dates; Item *compare_as_dates;
...@@ -1355,7 +1364,6 @@ public: ...@@ -1355,7 +1364,6 @@ public:
bool arg_types_compatible; bool arg_types_compatible;
Item_result left_result_type; Item_result left_result_type;
cmp_item *cmp_items[6]; /* One cmp_item for each result type */ cmp_item *cmp_items[6]; /* One cmp_item for each result type */
DTCollation cmp_collation;
Item_func_in(THD *thd, List<Item> &list): Item_func_in(THD *thd, List<Item> &list):
Item_func_opt_neg(thd, list), array(0), have_null(0), Item_func_opt_neg(thd, list), array(0), have_null(0),
......
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