Commit 5a644e17 authored by Alexander Barkov's avatar Alexander Barkov

Adding "const" qualifier to Item::cols(), and to the "Item *cmp" parameter to...

Adding "const" qualifier to Item::cols(), and to the "Item *cmp" parameter to Type_handler::make_const_item_for_comparison()
parent 9a360e97
...@@ -1604,7 +1604,7 @@ class Item: public Value_source, ...@@ -1604,7 +1604,7 @@ class Item: public Value_source,
virtual Item **this_item_addr(THD *thd, Item **addr_arg) { return addr_arg; } virtual Item **this_item_addr(THD *thd, Item **addr_arg) { return addr_arg; }
// Row emulation // Row emulation
virtual uint cols() { return 1; } virtual uint cols() const { return 1; }
virtual Item* element_index(uint i) { return this; } virtual Item* element_index(uint i) { return this; }
virtual bool element_index_by_name(uint *idx, const LEX_CSTRING &name) const virtual bool element_index_by_name(uint *idx, const LEX_CSTRING &name) const
{ {
...@@ -2236,7 +2236,7 @@ class Item_splocal :public Item_sp_variable, ...@@ -2236,7 +2236,7 @@ class Item_splocal :public Item_sp_variable,
{ return Type_handler_hybrid_field_type::result_type(); } { return Type_handler_hybrid_field_type::result_type(); }
enum Item_result cmp_type () const enum Item_result cmp_type () const
{ return Type_handler_hybrid_field_type::cmp_type(); } { return Type_handler_hybrid_field_type::cmp_type(); }
uint cols() { return this_item()->cols(); } uint cols() const { return this_item()->cols(); }
Item* element_index(uint i) { return this_item()->element_index(i); } Item* element_index(uint i) { return this_item()->element_index(i); }
Item** addr(uint i) { return this_item()->addr(i); } Item** addr(uint i) { return this_item()->addr(i); }
bool check_cols(uint c); bool check_cols(uint c);
...@@ -2836,7 +2836,7 @@ class Item_field_row: public Item_field, ...@@ -2836,7 +2836,7 @@ class Item_field_row: public Item_field,
const Type_handler *type_handler() const { return &type_handler_row; } const Type_handler *type_handler() const { return &type_handler_row; }
Item_result result_type() const{ return ROW_RESULT ; } Item_result result_type() const{ return ROW_RESULT ; }
Item_result cmp_type() const { return ROW_RESULT; } Item_result cmp_type() const { return ROW_RESULT; }
uint cols() { return arg_count; } uint cols() const { return arg_count; }
bool element_index_by_name(uint *idx, const LEX_CSTRING &name) const; bool element_index_by_name(uint *idx, const LEX_CSTRING &name) const;
Item* element_index(uint i) { return arg_count ? args[i] : this; } Item* element_index(uint i) { return arg_count ? args[i] : this; }
Item** addr(uint i) { return arg_count ? args + i : NULL; } Item** addr(uint i) { return arg_count ? args + i : NULL; }
...@@ -4390,7 +4390,7 @@ class Item_ref :public Item_ident ...@@ -4390,7 +4390,7 @@ class Item_ref :public Item_ident
virtual Ref_Type ref_type() { return REF; } virtual Ref_Type ref_type() { return REF; }
// Row emulation: forwarding of ROW-related calls to ref // Row emulation: forwarding of ROW-related calls to ref
uint cols() uint cols() const
{ {
return ref && result_type() == ROW_RESULT ? (*ref)->cols() : 1; return ref && result_type() == ROW_RESULT ? (*ref)->cols() : 1;
} }
...@@ -4638,7 +4638,7 @@ class Item_cache_wrapper :public Item_result_field ...@@ -4638,7 +4638,7 @@ class Item_cache_wrapper :public Item_result_field
{ return orig_item->field_for_view_update(); } { return orig_item->field_for_view_update(); }
/* Row emulation: forwarding of ROW-related calls to orig_item */ /* Row emulation: forwarding of ROW-related calls to orig_item */
uint cols() uint cols() const
{ return result_type() == ROW_RESULT ? orig_item->cols() : 1; } { return result_type() == ROW_RESULT ? orig_item->cols() : 1; }
Item* element_index(uint i) Item* element_index(uint i)
{ return result_type() == ROW_RESULT ? orig_item->element_index(i) : this; } { return result_type() == ROW_RESULT ? orig_item->element_index(i) : this; }
...@@ -5854,7 +5854,7 @@ class Item_cache_row: public Item_cache ...@@ -5854,7 +5854,7 @@ class Item_cache_row: public Item_cache
enum Item_result result_type() const { return ROW_RESULT; } enum Item_result result_type() const { return ROW_RESULT; }
uint cols() { return item_count; } uint cols() const { return item_count; }
Item *element_index(uint i) { return values[i]; } Item *element_index(uint i) { return values[i]; }
Item **addr(uint i) { return (Item **) (values + i); } Item **addr(uint i) { return (Item **) (values + i); }
bool check_cols(uint c); bool check_cols(uint c);
......
...@@ -114,7 +114,7 @@ class Item_row: public Item, ...@@ -114,7 +114,7 @@ class Item_row: public Item,
Item *transform(THD *thd, Item_transformer transformer, uchar *arg); Item *transform(THD *thd, Item_transformer transformer, uchar *arg);
bool eval_not_null_tables(void *opt_arg); bool eval_not_null_tables(void *opt_arg);
uint cols() { return arg_count; } uint cols() const { return arg_count; }
Item* element_index(uint i) { return args[i]; } Item* element_index(uint i) { return args[i]; }
Item** addr(uint i) { return args + i; } Item** addr(uint i) { return args + i; }
bool check_cols(uint c); bool check_cols(uint c);
......
...@@ -1264,7 +1264,7 @@ Item* Item_singlerow_subselect::expr_cache_insert_transformer(THD *tmp_thd, ...@@ -1264,7 +1264,7 @@ Item* Item_singlerow_subselect::expr_cache_insert_transformer(THD *tmp_thd,
} }
uint Item_singlerow_subselect::cols() uint Item_singlerow_subselect::cols() const
{ {
return engine->cols(); return engine->cols();
} }
...@@ -4263,7 +4263,7 @@ int subselect_indexsubquery_engine::exec() ...@@ -4263,7 +4263,7 @@ int subselect_indexsubquery_engine::exec()
} }
uint subselect_single_select_engine::cols() uint subselect_single_select_engine::cols() const
{ {
//psergey-sj-backport: the following assert was gone in 6.0: //psergey-sj-backport: the following assert was gone in 6.0:
//DBUG_ASSERT(select_lex->join != 0); // should be called after fix_fields() //DBUG_ASSERT(select_lex->join != 0); // should be called after fix_fields()
...@@ -4272,7 +4272,7 @@ uint subselect_single_select_engine::cols() ...@@ -4272,7 +4272,7 @@ uint subselect_single_select_engine::cols()
} }
uint subselect_union_engine::cols() uint subselect_union_engine::cols() const
{ {
DBUG_ASSERT(unit->is_prepared()); // should be called after fix_fields() DBUG_ASSERT(unit->is_prepared()); // should be called after fix_fields()
return unit->types.elements; return unit->types.elements;
......
...@@ -309,7 +309,7 @@ class Item_singlerow_subselect :public Item_subselect ...@@ -309,7 +309,7 @@ class Item_singlerow_subselect :public Item_subselect
const Type_handler *type_handler() const; const Type_handler *type_handler() const;
void fix_length_and_dec(); void fix_length_and_dec();
uint cols(); uint cols() const;
Item* element_index(uint i) { return reinterpret_cast<Item*>(row[i]); } Item* element_index(uint i) { return reinterpret_cast<Item*>(row[i]); }
Item** addr(uint i) { return (Item**)row + i; } Item** addr(uint i) { return (Item**)row + i; }
bool check_cols(uint c); bool check_cols(uint c);
...@@ -819,7 +819,7 @@ class subselect_engine: public Sql_alloc, ...@@ -819,7 +819,7 @@ class subselect_engine: public Sql_alloc,
caller should call exec() again for the new engine. caller should call exec() again for the new engine.
*/ */
virtual int exec()= 0; virtual int exec()= 0;
virtual uint cols()= 0; /* return number of columns in select */ virtual uint cols() const= 0; /* return number of columns in select */
virtual uint8 uncacheable()= 0; /* query is uncacheable */ virtual uint8 uncacheable()= 0; /* query is uncacheable */
virtual void exclude()= 0; virtual void exclude()= 0;
virtual bool may_be_null() { return maybe_null; }; virtual bool may_be_null() { return maybe_null; };
...@@ -856,7 +856,7 @@ class subselect_single_select_engine: public subselect_engine ...@@ -856,7 +856,7 @@ class subselect_single_select_engine: public subselect_engine
int prepare(THD *thd); int prepare(THD *thd);
void fix_length_and_dec(Item_cache** row); void fix_length_and_dec(Item_cache** row);
int exec(); int exec();
uint cols(); uint cols() const;
uint8 uncacheable(); uint8 uncacheable();
void exclude(); void exclude();
table_map upper_select_const_tables(); table_map upper_select_const_tables();
...@@ -891,7 +891,7 @@ class subselect_union_engine: public subselect_engine ...@@ -891,7 +891,7 @@ class subselect_union_engine: public subselect_engine
int prepare(THD *); int prepare(THD *);
void fix_length_and_dec(Item_cache** row); void fix_length_and_dec(Item_cache** row);
int exec(); int exec();
uint cols(); uint cols() const;
uint8 uncacheable(); uint8 uncacheable();
void exclude(); void exclude();
table_map upper_select_const_tables(); table_map upper_select_const_tables();
...@@ -949,7 +949,7 @@ class subselect_uniquesubquery_engine: public subselect_engine ...@@ -949,7 +949,7 @@ class subselect_uniquesubquery_engine: public subselect_engine
int prepare(THD *); int prepare(THD *);
void fix_length_and_dec(Item_cache** row); void fix_length_and_dec(Item_cache** row);
int exec(); int exec();
uint cols() { return 1; } uint cols() const { return 1; }
uint8 uncacheable() { return UNCACHEABLE_DEPENDENT_INJECTED; } uint8 uncacheable() { return UNCACHEABLE_DEPENDENT_INJECTED; }
void exclude(); void exclude();
table_map upper_select_const_tables() { return 0; } table_map upper_select_const_tables() { return 0; }
...@@ -1087,7 +1087,7 @@ class subselect_hash_sj_engine : public subselect_engine ...@@ -1087,7 +1087,7 @@ class subselect_hash_sj_engine : public subselect_engine
int prepare(THD *); int prepare(THD *);
int exec(); int exec();
void print(String *str, enum_query_type query_type); void print(String *str, enum_query_type query_type);
uint cols() { return materialize_engine->cols(); } uint cols() const { return materialize_engine->cols(); }
uint8 uncacheable() { return materialize_engine->uncacheable(); } uint8 uncacheable() { return materialize_engine->uncacheable(); }
table_map upper_select_const_tables() { return 0; } table_map upper_select_const_tables() { return 0; }
bool no_rows() { return !tmp_table->file->stats.records; } bool no_rows() { return !tmp_table->file->stats.records; }
...@@ -1370,7 +1370,7 @@ class subselect_partial_match_engine : public subselect_engine ...@@ -1370,7 +1370,7 @@ class subselect_partial_match_engine : public subselect_engine
int prepare(THD *thd_arg) { set_thd(thd_arg); return 0; } int prepare(THD *thd_arg) { set_thd(thd_arg); return 0; }
int exec(); int exec();
void fix_length_and_dec(Item_cache**) {} void fix_length_and_dec(Item_cache**) {}
uint cols() { /* TODO: what is the correct value? */ return 1; } uint cols() const { /* TODO: what is the correct value? */ return 1; }
uint8 uncacheable() { return UNCACHEABLE_DEPENDENT; } uint8 uncacheable() { return UNCACHEABLE_DEPENDENT; }
void exclude() {} void exclude() {}
table_map upper_select_const_tables() { return 0; } table_map upper_select_const_tables() { return 0; }
......
...@@ -4236,7 +4236,7 @@ bool Type_handler:: ...@@ -4236,7 +4236,7 @@ bool Type_handler::
/***************************************************************************/ /***************************************************************************/
Item *Type_handler_int_result:: Item *Type_handler_int_result::
make_const_item_for_comparison(THD *thd, Item *item, Item *cmp) const make_const_item_for_comparison(THD *thd, Item *item, const Item *cmp) const
{ {
longlong result= item->val_int(); longlong result= item->val_int();
if (item->null_value) if (item->null_value)
...@@ -4247,7 +4247,7 @@ Item *Type_handler_int_result:: ...@@ -4247,7 +4247,7 @@ Item *Type_handler_int_result::
Item *Type_handler_real_result:: Item *Type_handler_real_result::
make_const_item_for_comparison(THD *thd, Item *item, Item *cmp) const make_const_item_for_comparison(THD *thd, Item *item, const Item *cmp) const
{ {
double result= item->val_real(); double result= item->val_real();
if (item->null_value) if (item->null_value)
...@@ -4258,7 +4258,7 @@ Item *Type_handler_real_result:: ...@@ -4258,7 +4258,7 @@ Item *Type_handler_real_result::
Item *Type_handler_decimal_result:: Item *Type_handler_decimal_result::
make_const_item_for_comparison(THD *thd, Item *item, Item *cmp) const make_const_item_for_comparison(THD *thd, Item *item, const Item *cmp) const
{ {
my_decimal decimal_value; my_decimal decimal_value;
my_decimal *result= item->val_decimal(&decimal_value); my_decimal *result= item->val_decimal(&decimal_value);
...@@ -4270,7 +4270,7 @@ Item *Type_handler_decimal_result:: ...@@ -4270,7 +4270,7 @@ Item *Type_handler_decimal_result::
Item *Type_handler_string_result:: Item *Type_handler_string_result::
make_const_item_for_comparison(THD *thd, Item *item, Item *cmp) const make_const_item_for_comparison(THD *thd, Item *item, const Item *cmp) const
{ {
StringBuffer<MAX_FIELD_WIDTH> tmp; StringBuffer<MAX_FIELD_WIDTH> tmp;
String *result= item->val_str(&tmp); String *result= item->val_str(&tmp);
...@@ -4284,7 +4284,7 @@ Item *Type_handler_string_result:: ...@@ -4284,7 +4284,7 @@ Item *Type_handler_string_result::
Item *Type_handler_time_common:: Item *Type_handler_time_common::
make_const_item_for_comparison(THD *thd, Item *item, Item *cmp) const make_const_item_for_comparison(THD *thd, Item *item, const Item *cmp) const
{ {
Item_cache_temporal *cache; Item_cache_temporal *cache;
longlong value= item->val_time_packed(); longlong value= item->val_time_packed();
...@@ -4298,7 +4298,7 @@ Item *Type_handler_time_common:: ...@@ -4298,7 +4298,7 @@ Item *Type_handler_time_common::
Item *Type_handler_temporal_with_date:: Item *Type_handler_temporal_with_date::
make_const_item_for_comparison(THD *thd, Item *item, Item *cmp) const make_const_item_for_comparison(THD *thd, Item *item, const Item *cmp) const
{ {
Item_cache_temporal *cache; Item_cache_temporal *cache;
longlong value= item->val_datetime_packed(); longlong value= item->val_datetime_packed();
...@@ -4312,7 +4312,7 @@ Item *Type_handler_temporal_with_date:: ...@@ -4312,7 +4312,7 @@ Item *Type_handler_temporal_with_date::
Item *Type_handler_row:: Item *Type_handler_row::
make_const_item_for_comparison(THD *thd, Item *item, Item *cmp) const make_const_item_for_comparison(THD *thd, Item *item, const Item *cmp) const
{ {
if (item->type() == Item::ROW_ITEM && cmp->type() == Item::ROW_ITEM) if (item->type() == Item::ROW_ITEM && cmp->type() == Item::ROW_ITEM)
{ {
......
...@@ -765,7 +765,7 @@ class Type_handler ...@@ -765,7 +765,7 @@ class Type_handler
*/ */
virtual Item *make_const_item_for_comparison(THD *thd, virtual Item *make_const_item_for_comparison(THD *thd,
Item *src, Item *src,
Item *cmp) const= 0; const Item *cmp) const= 0;
virtual Item_cache *Item_get_cache(THD *thd, const Item *item) const= 0; virtual Item_cache *Item_get_cache(THD *thd, const Item *item) const= 0;
virtual bool set_comparator_func(Arg_comparator *cmp) const= 0; virtual bool set_comparator_func(Arg_comparator *cmp) const= 0;
virtual bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func, virtual bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
...@@ -955,7 +955,7 @@ class Type_handler_row: public Type_handler ...@@ -955,7 +955,7 @@ class Type_handler_row: public Type_handler
DBUG_ASSERT(0); DBUG_ASSERT(0);
return false; return false;
} }
Item *make_const_item_for_comparison(THD *thd, Item *src, Item *cmp) const; Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const; Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const; bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func, bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
...@@ -1158,7 +1158,7 @@ class Type_handler_real_result: public Type_handler_numeric ...@@ -1158,7 +1158,7 @@ class Type_handler_real_result: public Type_handler_numeric
SORT_FIELD_ATTR *attr) const; SORT_FIELD_ATTR *attr) const;
bool Item_save_in_value(Item *item, st_value *value) const; bool Item_save_in_value(Item *item, st_value *value) const;
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const; int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
Item *make_const_item_for_comparison(THD *thd, Item *src, Item *cmp) const; Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const; Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const; bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func, bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
...@@ -1223,7 +1223,7 @@ class Type_handler_decimal_result: public Type_handler_numeric ...@@ -1223,7 +1223,7 @@ class Type_handler_decimal_result: public Type_handler_numeric
return Item_send_str(item, protocol, buf); return Item_send_str(item, protocol, buf);
} }
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const; int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
Item *make_const_item_for_comparison(THD *thd, Item *src, Item *cmp) const; Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const; Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const; bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func, bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
...@@ -1280,7 +1280,7 @@ class Type_handler_int_result: public Type_handler_numeric ...@@ -1280,7 +1280,7 @@ class Type_handler_int_result: public Type_handler_numeric
SORT_FIELD_ATTR *attr) const; SORT_FIELD_ATTR *attr) const;
bool Item_save_in_value(Item *item, st_value *value) const; bool Item_save_in_value(Item *item, st_value *value) const;
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const; int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
Item *make_const_item_for_comparison(THD *thd, Item *src, Item *cmp) const; Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const; Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const; bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func, bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
...@@ -1424,7 +1424,7 @@ class Type_handler_string_result: public Type_handler ...@@ -1424,7 +1424,7 @@ class Type_handler_string_result: public Type_handler
Item *source_expr, Item *source_const) const; Item *source_expr, Item *source_const) const;
bool subquery_type_allows_materialization(const Item *inner, bool subquery_type_allows_materialization(const Item *inner,
const Item *outer) const; const Item *outer) const;
Item *make_const_item_for_comparison(THD *thd, Item *src, Item *cmp) const; Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
Item_cache *Item_get_cache(THD *thd, const Item *item) const; Item_cache *Item_get_cache(THD *thd, const Item *item) const;
bool set_comparator_func(Arg_comparator *cmp) const; bool set_comparator_func(Arg_comparator *cmp) const;
bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func, bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
...@@ -1717,7 +1717,7 @@ class Type_handler_time_common: public Type_handler_temporal_result ...@@ -1717,7 +1717,7 @@ class Type_handler_time_common: public Type_handler_temporal_result
String *print_item_value(THD *thd, Item *item, String *str) const; String *print_item_value(THD *thd, Item *item, String *str) const;
bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func, bool Item_hybrid_func_fix_attributes(THD *thd, Item_hybrid_func *func,
Item **items, uint nitems) const; Item **items, uint nitems) const;
Item *make_const_item_for_comparison(THD *thd, Item *src, Item *cmp) const; Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
bool set_comparator_func(Arg_comparator *cmp) const; bool set_comparator_func(Arg_comparator *cmp) const;
cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const; cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const;
in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs) const; in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs) const;
...@@ -1761,7 +1761,7 @@ class Type_handler_temporal_with_date: public Type_handler_temporal_result ...@@ -1761,7 +1761,7 @@ class Type_handler_temporal_with_date: public Type_handler_temporal_result
return Item_send_date(item, protocol, buf); return Item_send_date(item, protocol, buf);
} }
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const; int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
Item *make_const_item_for_comparison(THD *thd, Item *src, Item *cmp) const; Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
bool set_comparator_func(Arg_comparator *cmp) const; bool set_comparator_func(Arg_comparator *cmp) const;
cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const; cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const;
in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs) const; in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs) const;
......
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