Skip to content

Commit

Permalink
Adding "const" qualifier to Item::compare_collation()
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Barkov committed Mar 13, 2015
1 parent 4d0e521 commit bd21058
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion sql/field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6476,7 +6476,7 @@ bool Field_longstr::can_optimize_group_min_max(const Item_bool_func2 *cond,
return false;

// Don't use an index when comparing strings of different collations.
return charset() == ((Item_bool_func2*) cond)->compare_collation();
return charset() == cond->compare_collation();
}


Expand Down
2 changes: 1 addition & 1 deletion sql/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ class Item {
virtual Item *get_tmp_table_item(THD *thd) { return copy_or_same(thd); }

static CHARSET_INFO *default_charset();
virtual CHARSET_INFO *compare_collation() { return NULL; }
virtual CHARSET_INFO *compare_collation() const { return NULL; }

/*
For backward compatibility, to make numeric
Expand Down
4 changes: 2 additions & 2 deletions sql/item_cmpfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6279,9 +6279,9 @@ void Item_equal::print(String *str, enum_query_type query_type)
}


CHARSET_INFO *Item_equal::compare_collation()
CHARSET_INFO *Item_equal::compare_collation() const
{
Item_equal_fields_iterator it(*this);
Item_equal_fields_iterator it(*((Item_equal*) this));
Item *item= it++;
return item->collation.collation;
}
Expand Down
19 changes: 10 additions & 9 deletions sql/item_cmpfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ class Item_bool_func2 :public Item_bool_func
}

bool is_null() { return MY_TEST(args[0]->is_null() || args[1]->is_null()); }
CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }
CHARSET_INFO *compare_collation() const
{ return cmp.cmp_collation.collation; }
void top_level_item() { abort_on_null= TRUE; }
Arg_comparator *get_comparator() { return &cmp; }
void cleanup()
Expand Down Expand Up @@ -700,7 +701,7 @@ class Item_func_between :public Item_func_opt_neg
bool fix_fields(THD *, Item **);
void fix_length_and_dec();
virtual void print(String *str, enum_query_type query_type);
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
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);
Expand Down Expand Up @@ -1319,7 +1320,7 @@ class Item_func_case :public Item_func_hybrid_field_type
const char *func_name() const { return "case"; }
virtual void print(String *str, enum_query_type query_type);
Item *find_item(String *str);
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
CHARSET_INFO *compare_collation() const { return cmp_collation.collation; }
void cleanup();
void agg_str_lengths(Item *arg);
void agg_num_lengths(Item *arg);
Expand Down Expand Up @@ -1388,7 +1389,7 @@ class Item_func_in :public Item_func_opt_neg
enum Functype functype() const { return IN_FUNC; }
const char *func_name() const { return " IN "; }
bool nulls_in_row();
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
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);
};
Expand Down Expand Up @@ -1428,7 +1429,8 @@ class Item_func_null_predicate :public Item_bool_func
public:
Item_func_null_predicate(Item *a) :Item_bool_func(a) { sargable= true; }
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
CHARSET_INFO *compare_collation() const
{ return args[0]->collation.collation; }
void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=0; }
};

Expand Down Expand Up @@ -1574,8 +1576,7 @@ class Item_func_like :public Item_bool_func2
in case of a "PAD SPACE" collation, but only if "expr2" has '%'
at the end.
*/
return ((Item_func_like *)this)->compare_collation() == &my_charset_bin ?
COND_TRUE : COND_OK;
return compare_collation() == &my_charset_bin ? COND_TRUE : COND_OK;
}
const char *func_name() const { return "like"; }
bool fix_fields(THD *thd, Item **ref);
Expand Down Expand Up @@ -1689,7 +1690,7 @@ class Item_func_regex :public Item_bool_func
print_op(str, query_type);
}

CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
CHARSET_INFO *compare_collation() const { return cmp_collation.collation; }
};


Expand Down Expand Up @@ -1952,7 +1953,7 @@ class Item_equal: public Item_bool_func
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
Item *transform(Item_transformer transformer, uchar *arg);
virtual void print(String *str, enum_query_type query_type);
CHARSET_INFO *compare_collation();
CHARSET_INFO *compare_collation() const;

void set_context_field(Item_field *ctx_field) { context_field= ctx_field; }
void set_link_equal_fields(bool flag) { link_equal_fields= flag; }
Expand Down

0 comments on commit bd21058

Please sign in to comment.