Commit 40e5acea authored by Alexander Barkov's avatar Alexander Barkov

Removing Item_int_func::sargable. Adding virtual implementations of

count_sargable_conds() instead for Item_func_in, Item_func_null_predicate,
Item_bool_func2. There other Item_int_func descendants that used to set
"sargable" to true (Item_func_between, Item_equal) already have their
own implementation of count_sargable_conds(). There is no sense to
have two parallel coding models for the same thing.
parent 43641186
......@@ -3827,6 +3827,13 @@ cmp_item *cmp_item_datetime::make_same()
}
bool Item_func_in::count_sargable_conds(uchar *arg)
{
((SELECT_LEX*) arg)->cond_count++;
return 0;
}
bool Item_func_in::nulls_in_row()
{
Item **arg,**arg_end;
......@@ -4729,6 +4736,13 @@ Item *and_expressions(Item *a, Item *b, Item **org_item)
}
bool Item_func_null_predicate::count_sargable_conds(uchar *arg)
{
((SELECT_LEX*) arg)->cond_count++;
return 0;
}
longlong Item_func_isnull::val_int()
{
DBUG_ASSERT(fixed == 1);
......@@ -4781,6 +4795,13 @@ void Item_func_isnotnull::print(String *str, enum_query_type query_type)
}
bool Item_bool_func2::count_sargable_conds(uchar *arg)
{
((SELECT_LEX*) arg)->cond_count++;
return 0;
}
longlong Item_func_like::val_int()
{
DBUG_ASSERT(fixed == 1);
......@@ -5638,7 +5659,6 @@ Item_equal::Item_equal(THD *thd_arg, Item *f1, Item *f2, bool with_const_item)
equal_items.push_back(f2, thd_arg->mem_root);
compare_as_dates= with_const_item && f2->cmp_type() == TIME_RESULT;
upper_levels= NULL;
sargable= TRUE;
}
......@@ -5669,7 +5689,6 @@ Item_equal::Item_equal(THD *thd_arg, Item_equal *item_equal)
compare_as_dates= item_equal->compare_as_dates;
cond_false= item_equal->cond_false;
upper_levels= item_equal->upper_levels;
sargable= TRUE;
}
......
......@@ -288,7 +288,7 @@ class Item_bool_func2 :public Item_bool_func
{ /* Bool with 2 string args */
public:
Item_bool_func2(Item *a,Item *b)
:Item_bool_func(a,b) { sargable= TRUE; }
:Item_bool_func(a,b) { }
optimize_type select_optimize() const { return OPTIMIZE_OP; }
virtual enum Functype rev_functype() const { return UNKNOWN_FUNC; }
bool have_rev_func() const { return rev_functype() != UNKNOWN_FUNC; }
......@@ -301,7 +301,7 @@ public:
bool is_null() { return MY_TEST(args[0]->is_null() || args[1]->is_null()); }
COND *remove_eq_conds(THD *thd, Item::cond_result *cond_value,
bool top_level);
bool count_sargable_conds(uchar *arg);
};
class Item_bool_rowready_func2 :public Item_bool_func2
......@@ -636,7 +636,7 @@ public:
/* TRUE <=> arguments will be compared as dates. */
Item *compare_as_dates;
Item_func_between(Item *a, Item *b, Item *c)
:Item_func_opt_neg(a, b, c), compare_as_dates(FALSE) { sargable= TRUE; }
:Item_func_opt_neg(a, b, c), compare_as_dates(FALSE) { }
longlong val_int();
optimize_type select_optimize() const { return OPTIMIZE_KEY; }
enum Functype functype() const { return BETWEEN; }
......@@ -1311,7 +1311,6 @@ public:
{
bzero(&cmp_items, sizeof(cmp_items));
allowed_arg_cols= 0; // Fetch this value from first argument
sargable= TRUE;
}
longlong val_int();
bool fix_fields(THD *, Item **);
......@@ -1342,6 +1341,7 @@ public:
CHARSET_INFO *compare_collation() const { return cmp_collation.collation; }
bool eval_not_null_tables(uchar *opt_arg);
void fix_after_pullout(st_select_lex *new_parent, Item **ref);
bool count_sargable_conds(uchar *arg);
};
class cmp_item_row :public cmp_item
......@@ -1377,13 +1377,14 @@ public:
class Item_func_null_predicate :public Item_bool_func
{
public:
Item_func_null_predicate(Item *a) :Item_bool_func(a) { sargable= true; }
Item_func_null_predicate(Item *a) :Item_bool_func(a) { }
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
void add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
table_map usable_tables, SARGABLE_PARAM **sargables);
CHARSET_INFO *compare_collation() const
{ return args[0]->collation.collation; }
void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=0; }
bool count_sargable_conds(uchar *arg);
};
......
......@@ -732,16 +732,6 @@ double Item_int_func::val_real()
return unsigned_flag ? (double) ((ulonglong) val_int()) : (double) val_int();
}
bool Item_int_func::count_sargable_conds(uchar *arg)
{
if (sargable)
{
SELECT_LEX *sel= (SELECT_LEX *) arg;
sel->cond_count++;
}
return 0;
}
String *Item_int_func::val_str(String *str)
{
......
......@@ -580,28 +580,25 @@ class Item_num_op :public Item_func_numhybrid
class Item_int_func :public Item_func
{
protected:
bool sargable;
public:
Item_int_func() :Item_func()
{ collation.set_numeric(); fix_char_length(21); sargable= false; }
{ collation.set_numeric(); fix_char_length(21); }
Item_int_func(Item *a) :Item_func(a)
{ collation.set_numeric(); fix_char_length(21); sargable= false; }
{ collation.set_numeric(); fix_char_length(21); }
Item_int_func(Item *a,Item *b) :Item_func(a,b)
{ collation.set_numeric(); fix_char_length(21); sargable= false; }
{ collation.set_numeric(); fix_char_length(21); }
Item_int_func(Item *a,Item *b,Item *c) :Item_func(a,b,c)
{ collation.set_numeric(); fix_char_length(21); sargable= false; }
{ collation.set_numeric(); fix_char_length(21); }
Item_int_func(Item *a,Item *b,Item *c, Item *d) :Item_func(a,b,c,d)
{ collation.set_numeric(); fix_char_length(21); sargable= false; }
{ collation.set_numeric(); fix_char_length(21); }
Item_int_func(List<Item> &list) :Item_func(list)
{ collation.set_numeric(); fix_char_length(21); sargable= false; }
{ collation.set_numeric(); fix_char_length(21); }
Item_int_func(THD *thd, Item_int_func *item) :Item_func(thd, item)
{ collation.set_numeric(); sargable= false; }
{ collation.set_numeric(); }
double val_real();
String *val_str(String*str);
enum Item_result result_type () const { return INT_RESULT; }
void fix_length_and_dec() {}
bool count_sargable_conds(uchar *arg);
};
......
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