summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-05-07 19:29:23 +0400
committerAlexander Barkov <bar@mariadb.org>2017-05-07 19:29:23 +0400
commitda63db1e3b174209a4de1fe8e66e9bbe9ac3b11d (patch)
tree370a1a4185a509081ca87b5aa4df75a1141cdc5b /sql
parent02ada41744382fea11621a5a8094cbbea06c9487 (diff)
downloadmariadb-git-da63db1e3b174209a4de1fe8e66e9bbe9ac3b11d.tar.gz
MDEV-12719 Determine Item::result_type() from Item::type_handler()
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc8
-rw-r--r--sql/item.h57
-rw-r--r--sql/item_func.cc41
-rw-r--r--sql/item_func.h15
-rw-r--r--sql/item_row.h1
-rw-r--r--sql/item_strfunc.h1
-rw-r--r--sql/item_subselect.cc5
-rw-r--r--sql/item_subselect.h2
-rw-r--r--sql/item_sum.cc34
-rw-r--r--sql/item_sum.h15
-rw-r--r--sql/item_timefunc.h4
-rw-r--r--sql/item_windowfunc.cc4
-rw-r--r--sql/item_windowfunc.h5
-rw-r--r--sql/procedure.h3
-rw-r--r--sql/sql_type.h1
15 files changed, 28 insertions, 168 deletions
diff --git a/sql/item.cc b/sql/item.cc
index c3ecf7d8597..e775862ca3a 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -9840,7 +9840,7 @@ Item_type_holder::Item_type_holder(THD *thd, Item *item)
DBUG_ASSERT(item->fixed);
maybe_null= item->maybe_null;
get_full_info(item);
- DBUG_ASSERT(!decimals || Item_type_holder::result_type() != INT_RESULT);
+ DBUG_ASSERT(!decimals || result_type() != INT_RESULT);
prev_decimal_int_part= item->decimal_int_part();
}
@@ -9889,14 +9889,14 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
which is on the right side of the UNION, the data type handler
changes to type_handler_longlong, while decimals is still NOT_FIXED_DEC.
*/
- if (Item_type_holder::result_type() == INT_RESULT)
+ if (result_type() == INT_RESULT)
decimals= 0;
else
decimals= MY_MAX(decimals, item->decimals);
Type_geometry_attributes::join(item);
- if (Item_type_holder::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
decimals= MY_MIN(MY_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
int item_int_part= item->decimal_int_part();
@@ -9908,7 +9908,7 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
unsigned_flag);
}
- switch (Item_type_holder::result_type())
+ switch (result_type())
{
case STRING_RESULT:
{
diff --git a/sql/item.h b/sql/item.h
index 2b25df5520e..ad34320c560 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -746,7 +746,7 @@ public:
return type_handler();
}
/* result_type() of an item specifies how the value should be returned */
- virtual Item_result result_type() const
+ Item_result result_type() const
{
return type_handler()->result_type();
}
@@ -2230,8 +2230,6 @@ public:
inline enum Type type() const;
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
- enum Item_result result_type () const
- { return Type_handler_hybrid_field_type::result_type(); }
uint cols() const { return this_item()->cols(); }
Item* element_index(uint i) { return this_item()->element_index(i); }
Item** addr(uint i) { return this_item()->addr(i); }
@@ -2389,7 +2387,6 @@ public:
Item **this_item_addr(THD *thd, Item **);
inline enum Type type() const;
- inline Item_result result_type() const;
const Type_handler *type_handler() const { return this_item()->type_handler(); }
public:
@@ -2414,12 +2411,6 @@ inline enum Item::Type Item_case_expr::type() const
return this_item()->type();
}
-inline Item_result Item_case_expr::result_type() const
-{
- return this_item()->result_type();
-}
-
-
/*
NAME_CONST(given_name, const_value).
This 'function' has all properties of the supplied const_value (which is
@@ -2457,11 +2448,6 @@ public:
return value_item->type_handler();
}
- Item_result result_type() const
- {
- return value_item->result_type();
- }
-
bool const_item() const
{
return TRUE;
@@ -2683,10 +2669,6 @@ public:
const Type_handler *handler= field->type_handler();
return handler->type_handler_for_item_field();
}
- enum Item_result result_type () const
- {
- return field->result_type();
- }
const Type_handler *cast_to_int_type_handler() const
{
return field->type_handler()->cast_to_int_type_handler();
@@ -2830,7 +2812,6 @@ public:
{ return get_item_copy<Item_field_row>(thd, mem_root, this); }
const Type_handler *type_handler() const { return &type_handler_row; }
- Item_result result_type() const{ return ROW_RESULT ; }
uint cols() const { return arg_count; }
bool element_index_by_name(uint *idx, const LEX_CSTRING &name) const;
Item* element_index(uint i) { return arg_count ? args[i] : this; }
@@ -2909,7 +2890,6 @@ public:
int save_in_field(Field *field, bool no_conversions);
int save_safe_in_field(Field *field);
bool send(Protocol *protocol, st_value *buffer);
- enum Item_result result_type () const { return STRING_RESULT; }
const Type_handler *type_handler() const { return &type_handler_null; }
bool basic_const_item() const { return 1; }
Item *clone_item(THD *thd);
@@ -3089,8 +3069,6 @@ public:
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
- enum Item_result result_type () const
- { return Type_handler_hybrid_field_type::result_type(); }
Item_param(THD *thd, const LEX_CSTRING *name_arg,
uint pos_in_query_arg, uint len_in_query_arg);
@@ -3225,7 +3203,6 @@ public:
}
Item_int(THD *thd, const char *str_arg, uint length=64);
enum Type type() const { return INT_ITEM; }
- enum Item_result result_type () const { return INT_RESULT; }
const Type_handler *type_handler() const
{
// The same condition is repeated in Item::create_tmp_field()
@@ -3317,7 +3294,6 @@ public:
Item_decimal(THD *thd, const uchar *bin, int precision, int scale);
enum Type type() const { return DECIMAL_ITEM; }
- enum Item_result result_type () const { return DECIMAL_RESULT; }
const Type_handler *type_handler() const { return &type_handler_newdecimal; }
longlong val_int();
double val_real();
@@ -3498,7 +3474,6 @@ public:
}
my_decimal *val_decimal(my_decimal *);
int save_in_field(Field *field, bool no_conversions);
- enum Item_result result_type () const { return STRING_RESULT; }
const Type_handler *type_handler() const { return &type_handler_varchar; }
bool basic_const_item() const { return 1; }
bool eq(const Item *item, bool binary_cmp) const
@@ -3770,7 +3745,6 @@ public:
hex_string_init(thd, str, str_length);
}
enum Type type() const { return VARBIN_ITEM; }
- enum Item_result result_type () const { return STRING_RESULT; }
const Type_handler *type_handler() const { return &type_handler_varchar; }
virtual Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs)
{
@@ -3907,7 +3881,6 @@ public:
bool const_item() const { return true; }
enum Type type() const { return DATE_ITEM; }
bool eq(const Item *item, bool binary_cmp) const;
- enum Item_result result_type () const { return STRING_RESULT; }
bool check_partition_func_processor(void *int_arg) {return FALSE;}
@@ -4305,7 +4278,6 @@ public:
void save_org_in_field(Field *field, fast_field_copier optimizer_data);
fast_field_copier setup_fast_field_copier(Field *field)
{ return (*ref)->setup_fast_field_copier(field); }
- enum Item_result result_type () const { return (*ref)->result_type(); }
const Type_handler *type_handler() const { return (*ref)->type_handler(); }
const Type_handler *real_type_handler() const
{ return (*ref)->real_type_handler(); }
@@ -4603,7 +4575,6 @@ public:
}
int save_in_field(Field *to, bool no_conversions);
const Type_handler *type_handler() const { return orig_item->type_handler(); }
- enum Item_result result_type () const { return orig_item->result_type(); }
table_map used_tables() const { return orig_item->used_tables(); }
void update_used_tables()
{
@@ -5023,8 +4994,6 @@ public:
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
- enum Item_result result_type () const
- { return Type_handler_hybrid_field_type::result_type(); }
void make_field(THD *thd, Send_field *field) { item->make_field(thd, field); }
table_map used_tables() const { return (table_map) 1L; }
@@ -5551,8 +5520,6 @@ public:
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
- enum Item_result result_type () const
- { return Type_handler_hybrid_field_type::result_type(); }
virtual void keep_array() {}
virtual void print(String *str, enum_query_type query_type);
@@ -5653,7 +5620,6 @@ public:
longlong val_int();
String* val_str(String *str);
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type() const { return INT_RESULT; }
bool cache_value();
int save_in_field(Field *field, bool no_conversions);
Item *convert_to_basic_const_item(THD *thd);
@@ -5699,7 +5665,6 @@ public:
longlong val_int();
String* val_str(String *str);
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type() const { return REAL_RESULT; }
bool cache_value();
Item *convert_to_basic_const_item(THD *thd);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -5718,7 +5683,6 @@ public:
longlong val_int();
String* val_str(String *str);
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type() const { return DECIMAL_RESULT; }
bool cache_value();
Item *convert_to_basic_const_item(THD *thd);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -5745,7 +5709,6 @@ public:
longlong val_int();
String* val_str(String *);
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type() const { return STRING_RESULT; }
CHARSET_INFO *charset() const { return value->charset(); };
int save_in_field(Field *field, bool no_conversions);
bool cache_value();
@@ -5827,8 +5790,6 @@ public:
return 0;
};
- enum Item_result result_type() const { return ROW_RESULT; }
-
uint cols() const { return item_count; }
Item *element_index(uint i) { return values[i]; }
Item **addr(uint i) { return (Item **) (values + i); }
@@ -5878,22 +5839,6 @@ public:
const Type_handler *handler= Type_handler_hybrid_field_type::type_handler();
return handler->type_handler_for_item_field();
}
- enum Item_result result_type () const
- {
- /*
- In 10.1 Item_type_holder::result_type() returned
- Field::result_merge_type(field_type()), which returned STRING_RESULT
- for the BIT data type. In 10.2 it returns INT_RESULT, similar
- to what Field_bit::result_type() does. This should not be
- important because Item_type_holder is a limited purpose Item
- and its result_type() should not be called from outside of
- Item_type_holder. It's called only internally from decimal_int_part()
- from join_types(), to calculate "decimals" of the result data type.
- As soon as we get BIT as one of the joined types, the result field
- type cannot be numeric: it's either BIT, or VARBINARY.
- */
- return Type_handler_hybrid_field_type::result_type();
- }
const Type_handler *real_type_handler() const
{
return Type_handler_hybrid_field_type::type_handler();
diff --git a/sql/item_func.cc b/sql/item_func.cc
index c961264e9fd..8df5c301f3a 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -4745,7 +4745,7 @@ Item_func_set_user_var::check(bool use_result_field)
if (use_result_field && !result_field)
use_result_field= FALSE;
- switch (Item_func_set_user_var::result_type()) {
+ switch (result_type()) {
case REAL_RESULT:
{
save_result.vreal= use_result_field ? result_field->val_real() :
@@ -4838,7 +4838,7 @@ Item_func_set_user_var::update()
bool res= 0;
DBUG_ENTER("Item_func_set_user_var::update");
- switch (Item_func_set_user_var::result_type()) {
+ switch (result_type()) {
case REAL_RESULT:
{
res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal),
@@ -5308,7 +5308,7 @@ void Item_func_get_user_var::fix_length_and_dec()
max_length= m_var_entry->length;
collation.set(m_var_entry->charset(), DERIVATION_IMPLICIT);
set_handler_by_result_type(m_var_entry->type);
- switch (Item_func_get_user_var::result_type()) {
+ switch (result_type()) {
case REAL_RESULT:
fix_char_length(DBL_DIG + 8);
break;
@@ -5585,32 +5585,6 @@ bool Item_func_get_system_var::check_vcol_func_processor(void *arg)
return mark_unsupported_function("@@", var->name.str, arg, VCOL_SESSION_FUNC);
}
-enum Item_result Item_func_get_system_var::result_type() const
-{
- switch (var->show_type())
- {
- case SHOW_BOOL:
- case SHOW_MY_BOOL:
- case SHOW_SINT:
- case SHOW_SLONG:
- case SHOW_SLONGLONG:
- case SHOW_UINT:
- case SHOW_ULONG:
- case SHOW_ULONGLONG:
- case SHOW_HA_ROWS:
- return INT_RESULT;
- case SHOW_CHAR:
- case SHOW_CHAR_PTR:
- case SHOW_LEX_STRING:
- return STRING_RESULT;
- case SHOW_DOUBLE:
- return REAL_RESULT;
- default:
- my_error(ER_VAR_CANT_BE_READ, MYF(0), var->name.str);
- return STRING_RESULT; // keep the compiler happy
- }
-}
-
const Type_handler *Item_func_get_system_var::type_handler() const
{
@@ -6453,20 +6427,13 @@ Item_func_sp::make_field(THD *thd, Send_field *tmp_field)
const Type_handler *Item_func_sp::type_handler() const
{
DBUG_ENTER("Item_func_sp::type_handler");
+ DBUG_PRINT("info", ("m_sp = %p", (void *) m_sp));
DBUG_ASSERT(sp_result_field);
// This converts ENUM/SET to STRING
const Type_handler *handler= sp_result_field->type_handler();
DBUG_RETURN(handler->type_handler_for_item_field());
}
-Item_result
-Item_func_sp::result_type() const
-{
- DBUG_ENTER("Item_func_sp::result_type");
- DBUG_PRINT("info", ("m_sp = %p", (void *) m_sp));
- DBUG_ASSERT(sp_result_field);
- DBUG_RETURN(sp_result_field->result_type());
-}
longlong Item_func_found_rows::val_int()
{
diff --git a/sql/item_func.h b/sql/item_func.h
index 02b2244cc55..74c986545cd 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -370,7 +370,6 @@ public:
my_decimal *val_decimal(my_decimal *decimal_value);
longlong val_int()
{ DBUG_ASSERT(fixed == 1); return (longlong) rint(val_real()); }
- enum Item_result result_type () const { return REAL_RESULT; }
const Type_handler *type_handler() const { return &type_handler_double; }
void fix_length_and_dec()
{ decimals= NOT_FIXED_DEC; max_length= float_length(decimals); }
@@ -397,8 +396,6 @@ public:
:Item_func(thd, item), Type_handler_hybrid_field_type(item) { }
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
- enum Item_result result_type () const
- { return Type_handler_hybrid_field_type::result_type(); }
Field::geometry_type get_geometry_type() const
{ return Type_geometry_attributes::get_geometry_type(); };
};
@@ -731,7 +728,6 @@ public:
{ collation.set_numeric(); }
double val_real();
String *val_str(String*str);
- enum Item_result result_type () const { return INT_RESULT; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec() {}
};
@@ -903,7 +899,6 @@ public:
double val_real();
longlong val_int();
my_decimal *val_decimal(my_decimal*);
- enum Item_result result_type () const { return DECIMAL_RESULT; }
const Type_handler *type_handler() const { return &type_handler_newdecimal; }
void fix_length_and_dec_generic() {}
void fix_length_and_dec()
@@ -1539,7 +1534,6 @@ public:
my_decimal *val_decimal(my_decimal *dec) { return args[0]->val_decimal(dec); }
const char *func_name() const { return "rollup_const"; }
bool const_item() const { return 0; }
- Item_result result_type() const { return args[0]->result_type(); }
const Type_handler *type_handler() const { return args[0]->type_handler(); }
void fix_length_and_dec()
{
@@ -1913,7 +1907,6 @@ public:
}
}
void cleanup();
- Item_result result_type () const { return udf.result_type(); }
table_map not_null_tables() const { return 0; }
bool is_expensive() { return 1; }
virtual void print(String *str, enum_query_type query_type);
@@ -1965,7 +1958,6 @@ public:
longlong val_int();
double val_real() { return (double) Item_func_udf_int::val_int(); }
String *val_str(String *str);
- enum Item_result result_type () const { return INT_RESULT; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec() { decimals= 0; max_length= 21; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -1984,7 +1976,6 @@ public:
double val_real();
my_decimal *val_decimal(my_decimal *);
String *val_str(String *str);
- enum Item_result result_type () const { return DECIMAL_RESULT; }
const Type_handler *type_handler() const { return &type_handler_newdecimal; }
void fix_length_and_dec() { fix_num_length_and_dec(); }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -2024,7 +2015,6 @@ public:
string2my_decimal(E_DEC_FATAL_ERROR, res, dec_buf);
return dec_buf;
}
- enum Item_result result_type () const { return STRING_RESULT; }
const Type_handler *type_handler() const { return string_type_handler(); }
void fix_length_and_dec();
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -2077,7 +2067,6 @@ public:
{ DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
double val_real() { DBUG_ASSERT(fixed == 1); null_value= 1; return 0.0; }
longlong val_int() { DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
- enum Item_result result_type () const { return STRING_RESULT; }
void fix_length_and_dec() { maybe_null=1; max_length=0; }
};
@@ -2390,7 +2379,6 @@ public:
void print(String *str, enum_query_type query_type);
bool const_item() const { return true; }
table_map used_tables() const { return 0; }
- enum Item_result result_type() const;
const Type_handler *type_handler() const;
double val_real();
longlong val_int();
@@ -2661,8 +2649,6 @@ public:
}
void make_field(THD *thd, Send_field *tmp_field);
- Item_result result_type() const;
-
longlong val_int()
{
if (execute())
@@ -2834,7 +2820,6 @@ public:
String *val_str(String *);
my_decimal *val_decimal(my_decimal *);
void fix_length_and_dec();
- enum Item_result result_type () const { return last_value->result_type(); }
const char *func_name() const { return "last_value"; }
table_map not_null_tables() const { return 0; }
const Type_handler *type_handler() const { return last_value->type_handler(); }
diff --git a/sql/item_row.h b/sql/item_row.h
index 375321e4755..83ceb80a359 100644
--- a/sql/item_row.h
+++ b/sql/item_row.h
@@ -90,7 +90,6 @@ public:
List<Item> &fields, uint flags);
table_map used_tables() const { return used_tables_cache; };
bool const_item() const { return const_item_cache; };
- enum Item_result result_type() const { return ROW_RESULT; }
void update_used_tables()
{
used_tables_and_const_cache_init();
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 664b5bf2455..267408187f3 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -64,7 +64,6 @@ public:
longlong val_int();
double val_real();
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type () const { return STRING_RESULT; }
const Type_handler *type_handler() const { return string_type_handler(); }
void left_right_max_length();
bool fix_fields(THD *thd, Item **ref);
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 4dc2546866c..09fbf3e239c 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -1172,11 +1172,6 @@ void Item_singlerow_subselect::store(uint i, Item *item)
row[i]->cache_value();
}
-enum Item_result Item_singlerow_subselect::result_type() const
-{
- return engine->result_type();
-}
-
const Type_handler *Item_singlerow_subselect::type_handler() const
{
return engine->type_handler();
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index ff6293e6e5c..5d9e2e7c0cd 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -303,7 +303,6 @@ public:
my_decimal *val_decimal(my_decimal *);
bool val_bool();
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate);
- enum Item_result result_type() const;
const Type_handler *type_handler() const;
void fix_length_and_dec();
@@ -394,7 +393,6 @@ public:
}
void no_rows_in_result();
- enum Item_result result_type() const { return INT_RESULT;}
const Type_handler *type_handler() const { return &type_handler_longlong; }
longlong val_int();
double val_real();
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 6d510253259..6dccd67316f 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1229,7 +1229,7 @@ Item_sum_sum::Item_sum_sum(THD *thd, Item_sum_sum *item)
count(item->count)
{
/* TODO: check if the following assignments are really needed */
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
my_decimal2decimal(item->dec_buffs, dec_buffs);
my_decimal2decimal(item->dec_buffs + 1, dec_buffs + 1);
@@ -1249,7 +1249,7 @@ void Item_sum_sum::clear()
DBUG_ENTER("Item_sum_sum::clear");
null_value=1;
count= 0;
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
curr_dec_buff= 0;
my_decimal_set_zero(dec_buffs);
@@ -1304,7 +1304,7 @@ void Item_sum_sum::add_helper(bool perform_removal)
{
DBUG_ENTER("Item_sum_sum::add_helper");
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
my_decimal value;
const my_decimal *val= aggr->arg_val_decimal(&value);
@@ -1361,7 +1361,7 @@ longlong Item_sum_sum::val_int()
DBUG_ASSERT(fixed == 1);
if (aggr)
aggr->endup();
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
longlong result;
my_decimal2int(E_DEC_FATAL_ERROR, dec_buffs + curr_dec_buff, unsigned_flag,
@@ -1377,7 +1377,7 @@ double Item_sum_sum::val_real()
DBUG_ASSERT(fixed == 1);
if (aggr)
aggr->endup();
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
my_decimal2double(E_DEC_FATAL_ERROR, dec_buffs + curr_dec_buff, &sum);
return sum;
}
@@ -1387,7 +1387,7 @@ String *Item_sum_sum::val_str(String *str)
{
if (aggr)
aggr->endup();
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
return val_string_from_decimal(str);
return val_string_from_real(str);
}
@@ -1397,7 +1397,7 @@ my_decimal *Item_sum_sum::val_decimal(my_decimal *val)
{
if (aggr)
aggr->endup();
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
return null_value ? NULL : (dec_buffs + curr_dec_buff);
return val_decimal_from_real(val);
}
@@ -1642,7 +1642,7 @@ Field *Item_sum_avg::create_tmp_field(bool group, TABLE *table)
and unpack on access.
*/
Field *field= new (table->in_use->mem_root)
- Field_string(((Item_sum_avg::result_type() == DECIMAL_RESULT) ?
+ Field_string(((result_type() == DECIMAL_RESULT) ?
dec_bin_size : sizeof(double)) + sizeof(longlong),
0, &name, &my_charset_bin);
if (field)
@@ -1710,7 +1710,7 @@ my_decimal *Item_sum_avg::val_decimal(my_decimal *val)
For non-DECIMAL result_type() the division will be done in
Item_sum_avg::val_real().
*/
- if (Item_sum_avg::result_type() != DECIMAL_RESULT)
+ if (result_type() != DECIMAL_RESULT)
return val_decimal_from_real(val);
sum_dec= dec_buffs + curr_dec_buff;
@@ -1724,7 +1724,7 @@ String *Item_sum_avg::val_str(String *str)
{
if (aggr)
aggr->endup();
- if (Item_sum_avg::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
return val_string_from_decimal(str);
return val_string_from_real(str);
}
@@ -2307,7 +2307,7 @@ void Item_sum_num::reset_field()
void Item_sum_hybrid::reset_field()
{
- switch(Item_sum_hybrid::result_type()) {
+ switch(result_type()) {
case STRING_RESULT:
{
char buff[MAX_FIELD_WIDTH];
@@ -2390,7 +2390,7 @@ void Item_sum_hybrid::reset_field()
void Item_sum_sum::reset_field()
{
DBUG_ASSERT (aggr->Aggrtype() != Aggregator::DISTINCT_AGGREGATOR);
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
my_decimal value, *arg_val= args[0]->val_decimal(&value);
if (!arg_val) // Null
@@ -2426,7 +2426,7 @@ void Item_sum_avg::reset_field()
{
uchar *res=result_field->ptr;
DBUG_ASSERT (aggr->Aggrtype() != Aggregator::DISTINCT_AGGREGATOR);
- if (Item_sum_avg::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
longlong tmp;
my_decimal value, *arg_dec= args[0]->val_decimal(&value);
@@ -2484,7 +2484,7 @@ void Item_sum_bit::update_field()
void Item_sum_sum::update_field()
{
DBUG_ASSERT (aggr->Aggrtype() != Aggregator::DISTINCT_AGGREGATOR);
- if (Item_sum_sum::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
my_decimal value, *arg_val= args[0]->val_decimal(&value);
if (!args[0]->null_value)
@@ -2539,7 +2539,7 @@ void Item_sum_avg::update_field()
DBUG_ASSERT (aggr->Aggrtype() != Aggregator::DISTINCT_AGGREGATOR);
- if (Item_sum_avg::result_type() == DECIMAL_RESULT)
+ if (result_type() == DECIMAL_RESULT)
{
my_decimal value, *arg_val= args[0]->val_decimal(&value);
if (!args[0]->null_value)
@@ -2578,7 +2578,7 @@ void Item_sum_avg::update_field()
Item *Item_sum_avg::result_item(THD *thd, Field *field)
{
return
- Item_sum_avg::result_type() == DECIMAL_RESULT ?
+ result_type() == DECIMAL_RESULT ?
(Item_avg_field*) new (thd->mem_root) Item_avg_field_decimal(thd, this) :
(Item_avg_field*) new (thd->mem_root) Item_avg_field_double(thd, this);
}
@@ -2586,7 +2586,7 @@ Item *Item_sum_avg::result_item(THD *thd, Field *field)
void Item_sum_hybrid::update_field()
{
- switch (Item_sum_hybrid::result_type()) {
+ switch (result_type()) {
case STRING_RESULT:
min_max_update_str_field();
break;
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 86ef54d8486..dee480ccf0a 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -748,7 +748,6 @@ public:
double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); }
String *val_str(String*str);
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type () const { return INT_RESULT; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec()
{ decimals=0; max_length=21; maybe_null=null_value=0; }
@@ -783,8 +782,6 @@ public:
my_decimal *val_decimal(my_decimal *);
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
- enum Item_result result_type () const
- { return Type_handler_hybrid_field_type::result_type(); }
void fix_length_and_dec_double();
void fix_length_and_dec_decimal();
void reset_field();
@@ -976,7 +973,6 @@ public:
{ return sample ? "var_samp(" : "variance("; }
Item *copy_or_same(THD* thd);
Field *create_tmp_field(bool group, TABLE *table);
- enum Item_result result_type () const { return REAL_RESULT; }
const Type_handler *type_handler() const { return &type_handler_double; }
void cleanup()
{
@@ -1048,8 +1044,6 @@ protected:
}
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
- enum Item_result result_type () const
- { return Type_handler_hybrid_field_type::result_type(); }
void update_field();
void min_max_update_str_field();
void min_max_update_real_field();
@@ -1255,7 +1249,6 @@ public:
Item_avg_field_double(THD *thd, Item_sum_avg *item)
:Item_avg_field(thd, item)
{ }
- enum Item_result result_type () const { return REAL_RESULT; }
const Type_handler *type_handler() const { return &type_handler_double; }
longlong val_int() { return val_int_from_real(); }
my_decimal *val_decimal(my_decimal *dec) { return val_decimal_from_real(dec); }
@@ -1276,7 +1269,6 @@ public:
f_scale(item->f_scale),
dec_bin_size(item->dec_bin_size)
{ }
- enum Item_result result_type () const { return DECIMAL_RESULT; }
const Type_handler *type_handler() const { return &type_handler_newdecimal; }
double val_real() { return val_real_from_decimal(); }
longlong val_int() { return val_int_from_decimal(); }
@@ -1303,7 +1295,6 @@ public:
{ return val_decimal_from_real(dec_buf); }
bool is_null() { update_null_value(); return null_value; }
const Type_handler *type_handler() const { return &type_handler_double; }
- enum Item_result result_type () const { return REAL_RESULT; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_variance_field>(thd, mem_root, this); }
};
@@ -1401,7 +1392,6 @@ class Item_sum_udf_float :public Item_udf_sum
double val_real();
String *val_str(String*str);
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type () const { return REAL_RESULT; }
const Type_handler *type_handler() const { return &type_handler_double; }
void fix_length_and_dec() { fix_num_length_and_dec(); }
Item *copy_or_same(THD* thd);
@@ -1424,7 +1414,6 @@ public:
{ DBUG_ASSERT(fixed == 1); return (double) Item_sum_udf_int::val_int(); }
String *val_str(String*str);
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type () const { return INT_RESULT; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec() { decimals=0; max_length=21; }
Item *copy_or_same(THD* thd);
@@ -1466,7 +1455,6 @@ public:
return cs->cset->strtoll10(cs, res->ptr(), &end, &err_not_used);
}
my_decimal *val_decimal(my_decimal *dec);
- enum Item_result result_type () const { return STRING_RESULT; }
const Type_handler *type_handler() const { return string_type_handler(); }
void fix_length_and_dec();
Item *copy_or_same(THD* thd);
@@ -1488,7 +1476,6 @@ public:
double val_real();
longlong val_int();
my_decimal *val_decimal(my_decimal *);
- enum Item_result result_type () const { return DECIMAL_RESULT; }
const Type_handler *type_handler() const { return &type_handler_newdecimal; }
void fix_length_and_dec() { fix_num_length_and_dec(); }
Item *copy_or_same(THD* thd);
@@ -1564,7 +1551,6 @@ public:
{ DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
double val_real() { DBUG_ASSERT(fixed == 1); null_value=1; return 0.0; }
longlong val_int() { DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
- enum Item_result result_type () const { return STRING_RESULT; }
void fix_length_and_dec() { maybe_null=1; max_length=0; }
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
void clear() {}
@@ -1638,7 +1624,6 @@ public:
enum Sumfunctype sum_func () const {return GROUP_CONCAT_FUNC;}
const char *func_name() const { return "group_concat("; }
- virtual Item_result result_type () const { return STRING_RESULT; }
const Type_handler *type_handler() const
{
if (too_big_for_varchar())
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index a9a7706ceea..ced4bf4b31e 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -155,7 +155,6 @@ public:
return str;
}
const char *func_name() const { return "month"; }
- enum Item_result result_type () const { return INT_RESULT; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec()
{
@@ -405,7 +404,6 @@ public:
{
return (odbc_type ? "dayofweek" : "weekday");
}
- enum Item_result result_type () const { return INT_RESULT; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
void fix_length_and_dec()
{
@@ -430,7 +428,6 @@ class Item_func_dayname :public Item_func_weekday
Item_func_dayname(THD *thd, Item *a): Item_func_weekday(thd, a, 0) {}
const char *func_name() const { return "dayname"; }
String *val_str(String *str);
- enum Item_result result_type () const { return STRING_RESULT; }
const Type_handler *type_handler() const { return &type_handler_varchar; }
void fix_length_and_dec();
bool check_partition_func_processor(void *int_arg) {return TRUE;}
@@ -527,7 +524,6 @@ public:
Item_temporal_func(THD *thd, Item *a): Item_func(thd, a) {}
Item_temporal_func(THD *thd, Item *a, Item *b): Item_func(thd, a, b) {}
Item_temporal_func(THD *thd, Item *a, Item *b, Item *c): Item_func(thd, a, b, c) {}
- enum Item_result result_type () const { return STRING_RESULT; }
String *val_str(String *str);
longlong val_int() { return val_int_from_date(); }
double val_real() { return val_real_from_date(); }
diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc
index 7117ac69548..6ab903a81bb 100644
--- a/sql/item_windowfunc.cc
+++ b/sql/item_windowfunc.cc
@@ -250,7 +250,7 @@ bool Item_sum_hybrid_simple::fix_fields(THD *thd, Item **ref)
set_handler_by_result_type(item2->result_type(),
max_length, collation.collation);
- switch (Item_sum_hybrid_simple::result_type()) {
+ switch (result_type()) {
case INT_RESULT:
case DECIMAL_RESULT:
case STRING_RESULT:
@@ -352,7 +352,7 @@ Field *Item_sum_hybrid_simple::create_tmp_field(bool group, TABLE *table)
void Item_sum_hybrid_simple::reset_field()
{
- switch(Item_sum_hybrid_simple::result_type()) {
+ switch(result_type()) {
case STRING_RESULT:
{
char buff[MAX_FIELD_WIDTH];
diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h
index 5e3a28ffade..77cbd556e60 100644
--- a/sql/item_windowfunc.h
+++ b/sql/item_windowfunc.h
@@ -303,8 +303,6 @@ class Item_sum_hybrid_simple : public Item_sum,
my_decimal *val_decimal(my_decimal *);
void reset_field();
String *val_str(String *);
- enum Item_result result_type() const
- { return Type_handler_hybrid_field_type::result_type(); }
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
void update_field();
@@ -509,7 +507,6 @@ class Item_sum_percent_rank: public Item_sum_window_with_row_count
row_number= 0;
}
bool add();
- enum Item_result result_type () const { return REAL_RESULT; }
const Type_handler *type_handler() const { return &type_handler_double; }
void fix_length_and_dec()
@@ -595,7 +592,6 @@ class Item_sum_cume_dist: public Item_sum_window_with_row_count
}
void update_field() {}
- enum Item_result result_type () const { return REAL_RESULT; }
const Type_handler *type_handler() const { return &type_handler_double; }
void fix_length_and_dec()
@@ -672,7 +668,6 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
void update_field() {}
- enum Item_result result_type () const { return INT_RESULT; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
diff --git a/sql/procedure.h b/sql/procedure.h
index e3350b21369..a1c9b95f20b 100644
--- a/sql/procedure.h
+++ b/sql/procedure.h
@@ -71,7 +71,6 @@ public:
{
decimals=dec; max_length=float_length(dec);
}
- enum Item_result result_type () const { return REAL_RESULT; }
const Type_handler *type_handler() const { return &type_handler_double; }
void set(double nr) { value=nr; }
void set(longlong nr) { value=(double) nr; }
@@ -98,7 +97,6 @@ class Item_proc_int :public Item_proc
public:
Item_proc_int(THD *thd, const char *name_par): Item_proc(thd, name_par)
{ max_length=11; }
- enum Item_result result_type () const { return INT_RESULT; }
const Type_handler *type_handler() const { return &type_handler_longlong; }
void set(double nr) { value=(longlong) nr; }
void set(longlong nr) { value=nr; }
@@ -117,7 +115,6 @@ class Item_proc_string :public Item_proc
public:
Item_proc_string(THD *thd, const char *name_par, uint length):
Item_proc(thd, name_par) { this->max_length=length; }
- enum Item_result result_type () const { return STRING_RESULT; }
const Type_handler *type_handler() const { return &type_handler_varchar; }
void set(double nr) { str_value.set_real(nr, 2, default_charset()); }
void set(longlong nr) { str_value.set(nr, default_charset()); }
diff --git a/sql/sql_type.h b/sql/sql_type.h
index 5127ea5e796..c8b8a936355 100644
--- a/sql/sql_type.h
+++ b/sql/sql_type.h
@@ -2267,7 +2267,6 @@ public:
{
return m_type_handler->real_field_type();
}
- Item_result result_type() const { return m_type_handler->result_type(); }
Item_result cmp_type() const { return m_type_handler->cmp_type(); }
enum_mysql_timestamp_type mysql_timestamp_type() const
{