Skip to content

Commit b4e56a5

Browse files
author
Alexander Barkov
committed
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.
1 parent 3ba2a95 commit b4e56a5

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

sql/item_cmpfunc.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,9 +2197,9 @@ void Item_func_between::fix_length_and_dec()
21972197
*/
21982198
if (!args[0] || !args[1] || !args[2])
21992199
return;
2200-
if ( agg_cmp_type(&cmp_type, args, 3))
2200+
if (agg_cmp_type(&m_compare_type, args, 3))
22012201
return;
2202-
if (cmp_type == STRING_RESULT &&
2202+
if (m_compare_type == STRING_RESULT &&
22032203
agg_arg_charsets_for_comparison(cmp_collation, args, 3))
22042204
return;
22052205

@@ -2211,7 +2211,7 @@ void Item_func_between::fix_length_and_dec()
22112211
For this to work, we need to know what date/time type we compare
22122212
strings as.
22132213
*/
2214-
if (cmp_type == TIME_RESULT)
2214+
if (m_compare_type == TIME_RESULT)
22152215
compare_as_dates= find_date_time_item(args, 3, 0);
22162216

22172217
/* See the comment about the similar block in Item_bool_func2 */
@@ -2225,7 +2225,7 @@ void Item_func_between::fix_length_and_dec()
22252225
const bool cvt_arg1= convert_const_to_int(thd, field_item, &args[1]);
22262226
const bool cvt_arg2= convert_const_to_int(thd, field_item, &args[2]);
22272227
if (cvt_arg1 && cvt_arg2)
2228-
cmp_type=INT_RESULT; // Works for all types.
2228+
m_compare_type= INT_RESULT; // Works for all types.
22292229
}
22302230
}
22312231
}
@@ -2235,7 +2235,7 @@ longlong Item_func_between::val_int()
22352235
{
22362236
DBUG_ASSERT(fixed == 1);
22372237

2238-
switch (cmp_type) {
2238+
switch (m_compare_type) {
22392239
case TIME_RESULT:
22402240
{
22412241
THD *thd= current_thd;
@@ -3972,7 +3972,7 @@ void Item_func_in::fix_length_and_dec()
39723972
Item *date_arg= 0;
39733973
uint found_types= 0;
39743974
uint type_cnt= 0, i;
3975-
Item_result cmp_type= STRING_RESULT;
3975+
m_compare_type= STRING_RESULT;
39763976
left_result_type= args[0]->cmp_type();
39773977
if (!(found_types= collect_cmp_types(args, arg_count, true)))
39783978
return;
@@ -3990,18 +3990,18 @@ void Item_func_in::fix_length_and_dec()
39903990
if (found_types & (1U << i))
39913991
{
39923992
(type_cnt)++;
3993-
cmp_type= (Item_result) i;
3993+
m_compare_type= (Item_result) i;
39943994
}
39953995
}
39963996

39973997
if (type_cnt == 1)
39983998
{
3999-
if (cmp_type == STRING_RESULT &&
3999+
if (m_compare_type == STRING_RESULT &&
40004000
agg_arg_charsets_for_comparison(cmp_collation, args, arg_count))
40014001
return;
40024002
arg_types_compatible= TRUE;
40034003

4004-
if (cmp_type == ROW_RESULT)
4004+
if (m_compare_type == ROW_RESULT)
40054005
{
40064006
uint cols= args[0]->cols();
40074007
cmp_item_row *cmp= 0;
@@ -4051,7 +4051,7 @@ void Item_func_in::fix_length_and_dec()
40514051
See the comment about the similar block in Item_bool_func2
40524052
*/
40534053
if (args[0]->real_item()->type() == FIELD_ITEM &&
4054-
!thd->lex->is_view_context_analysis() && cmp_type != INT_RESULT)
4054+
!thd->lex->is_view_context_analysis() && m_compare_type != INT_RESULT)
40554055
{
40564056
Item_field *field_item= (Item_field*) (args[0]->real_item());
40574057
if (field_item->field_type() == MYSQL_TYPE_LONGLONG ||
@@ -4064,10 +4064,10 @@ void Item_func_in::fix_length_and_dec()
40644064
all_converted= FALSE;
40654065
}
40664066
if (all_converted)
4067-
cmp_type= INT_RESULT;
4067+
m_compare_type= INT_RESULT;
40684068
}
40694069
}
4070-
switch (cmp_type) {
4070+
switch (m_compare_type) {
40714071
case STRING_RESULT:
40724072
array=new (thd->mem_root) in_string(arg_count-1,(qsort2_cmp) srtcmp_in,
40734073
cmp_collation.collation);

sql/item_cmpfunc.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,17 @@ class Item_func_ne :public Item_bool_rowready_func2
679679

680680
class Item_func_opt_neg :public Item_bool_func
681681
{
682+
protected:
683+
/*
684+
The result type that will be used for comparison.
685+
cmp_type() of all arguments are collected to here.
686+
*/
687+
Item_result m_compare_type;
688+
/*
689+
The collation that will be used for comparison in case
690+
when m_compare_type is STRING_RESULT.
691+
*/
692+
DTCollation cmp_collation;
682693
public:
683694
bool negated; /* <=> the item represents NOT <func> */
684695
bool pred_level; /* <=> [NOT] <func> is used on a predicate level */
@@ -708,12 +719,10 @@ class Item_func_opt_neg :public Item_bool_func
708719

709720
class Item_func_between :public Item_func_opt_neg
710721
{
711-
DTCollation cmp_collation;
712722
protected:
713723
SEL_TREE *get_func_mm_tree(RANGE_OPT_PARAM *param,
714724
Field *field, Item *value, Item_result cmp_type);
715725
public:
716-
Item_result cmp_type;
717726
String value0,value1,value2;
718727
/* TRUE <=> arguments will be compared as dates. */
719728
Item *compare_as_dates;
@@ -1355,7 +1364,6 @@ class Item_func_in :public Item_func_opt_neg
13551364
bool arg_types_compatible;
13561365
Item_result left_result_type;
13571366
cmp_item *cmp_items[6]; /* One cmp_item for each result type */
1358-
DTCollation cmp_collation;
13591367

13601368
Item_func_in(THD *thd, List<Item> &list):
13611369
Item_func_opt_neg(thd, list), array(0), have_null(0),

0 commit comments

Comments
 (0)