summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/field.cc2
-rw-r--r--sql/item.h2
-rw-r--r--sql/item_cmpfunc.cc4
-rw-r--r--sql/item_cmpfunc.h19
4 files changed, 14 insertions, 13 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 57721d39d32..255b5bd1c99 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -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();
}
diff --git a/sql/item.h b/sql/item.h
index 24ae105421b..db5a94fdb01 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1136,7 +1136,7 @@ public:
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
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 5b7152b57b3..7a5e13d3cb3 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -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;
}
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 7aaef893415..9c5067569c3 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -399,7 +399,8 @@ public:
}
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()
@@ -700,7 +701,7 @@ public:
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);
@@ -1319,7 +1320,7 @@ public:
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);
@@ -1388,7 +1389,7 @@ public:
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);
};
@@ -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; }
};
@@ -1574,8 +1576,7 @@ public:
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);
@@ -1689,7 +1690,7 @@ public:
print_op(str, query_type);
}
- CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
+ CHARSET_INFO *compare_collation() const { return cmp_collation.collation; }
};
@@ -1952,7 +1953,7 @@ public:
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; }