Skip to content

Commit

Permalink
Moving common members of Item_func_in and Item_func_between to their
Browse files Browse the repository at this point in the history
parent Item_func_opt_neg. A pre-requisite patch for a number of
upcoming equal field propagation related bug fixes.
  • Loading branch information
Alexander Barkov committed Aug 29, 2015
1 parent 3ba2a95 commit b4e56a5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
24 changes: 12 additions & 12 deletions sql/item_cmpfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2197,9 +2197,9 @@ void Item_func_between::fix_length_and_dec()
*/
if (!args[0] || !args[1] || !args[2])
return;
if ( agg_cmp_type(&cmp_type, args, 3))
if (agg_cmp_type(&m_compare_type, args, 3))
return;
if (cmp_type == STRING_RESULT &&
if (m_compare_type == STRING_RESULT &&
agg_arg_charsets_for_comparison(cmp_collation, args, 3))
return;

Expand All @@ -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
strings as.
*/
if (cmp_type == TIME_RESULT)
if (m_compare_type == TIME_RESULT)
compare_as_dates= find_date_time_item(args, 3, 0);

/* See the comment about the similar block in Item_bool_func2 */
Expand All @@ -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_arg2= convert_const_to_int(thd, field_item, &args[2]);
if (cvt_arg1 && cvt_arg2)
cmp_type=INT_RESULT; // Works for all types.
m_compare_type= INT_RESULT; // Works for all types.
}
}
}
Expand All @@ -2235,7 +2235,7 @@ longlong Item_func_between::val_int()
{
DBUG_ASSERT(fixed == 1);

switch (cmp_type) {
switch (m_compare_type) {
case TIME_RESULT:
{
THD *thd= current_thd;
Expand Down Expand Up @@ -3972,7 +3972,7 @@ void Item_func_in::fix_length_and_dec()
Item *date_arg= 0;
uint found_types= 0;
uint type_cnt= 0, i;
Item_result cmp_type= STRING_RESULT;
m_compare_type= STRING_RESULT;
left_result_type= args[0]->cmp_type();
if (!(found_types= collect_cmp_types(args, arg_count, true)))
return;
Expand All @@ -3990,18 +3990,18 @@ void Item_func_in::fix_length_and_dec()
if (found_types & (1U << i))
{
(type_cnt)++;
cmp_type= (Item_result) i;
m_compare_type= (Item_result) i;
}
}

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))
return;
arg_types_compatible= TRUE;

if (cmp_type == ROW_RESULT)
if (m_compare_type == ROW_RESULT)
{
uint cols= args[0]->cols();
cmp_item_row *cmp= 0;
Expand Down Expand Up @@ -4051,7 +4051,7 @@ void Item_func_in::fix_length_and_dec()
See the comment about the similar block in Item_bool_func2
*/
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());
if (field_item->field_type() == MYSQL_TYPE_LONGLONG ||
Expand All @@ -4064,10 +4064,10 @@ void Item_func_in::fix_length_and_dec()
all_converted= FALSE;
}
if (all_converted)
cmp_type= INT_RESULT;
m_compare_type= INT_RESULT;
}
}
switch (cmp_type) {
switch (m_compare_type) {
case STRING_RESULT:
array=new (thd->mem_root) in_string(arg_count-1,(qsort2_cmp) srtcmp_in,
cmp_collation.collation);
Expand Down
14 changes: 11 additions & 3 deletions sql/item_cmpfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,17 @@ class Item_func_ne :public Item_bool_rowready_func2

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:
bool negated; /* <=> the item represents NOT <func> */
bool pred_level; /* <=> [NOT] <func> is used on a predicate level */
Expand Down Expand Up @@ -708,12 +719,10 @@ class Item_func_opt_neg :public Item_bool_func

class Item_func_between :public Item_func_opt_neg
{
DTCollation cmp_collation;
protected:
SEL_TREE *get_func_mm_tree(RANGE_OPT_PARAM *param,
Field *field, Item *value, Item_result cmp_type);
public:
Item_result cmp_type;
String value0,value1,value2;
/* TRUE <=> arguments will be compared as dates. */
Item *compare_as_dates;
Expand Down Expand Up @@ -1355,7 +1364,6 @@ class Item_func_in :public Item_func_opt_neg
bool arg_types_compatible;
Item_result left_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_opt_neg(thd, list), array(0), have_null(0),
Expand Down

0 comments on commit b4e56a5

Please sign in to comment.