Commit d5f5cd28 authored by Alexander Barkov's avatar Alexander Barkov

A cleanup: removing duplicate code: Item_func::val_decimal()

Using val_decimal_from_int() instead, which provides exactly
the same functionality.
parent 3e27677b
...@@ -329,6 +329,7 @@ my_decimal *Item::val_decimal_from_real(my_decimal *decimal_value) ...@@ -329,6 +329,7 @@ my_decimal *Item::val_decimal_from_real(my_decimal *decimal_value)
my_decimal *Item::val_decimal_from_int(my_decimal *decimal_value) my_decimal *Item::val_decimal_from_int(my_decimal *decimal_value)
{ {
DBUG_ASSERT(is_fixed());
longlong nr= val_int(); longlong nr= val_int();
if (null_value) if (null_value)
return 0; return 0;
......
...@@ -646,16 +646,6 @@ bool Item_func::is_expensive_processor(uchar *arg) ...@@ -646,16 +646,6 @@ bool Item_func::is_expensive_processor(uchar *arg)
} }
*/ */
my_decimal *Item_func::val_decimal(my_decimal *decimal_value)
{
DBUG_ASSERT(fixed);
longlong nr= val_int();
if (null_value)
return 0; /* purecov: inspected */
int2my_decimal(E_DEC_FATAL_ERROR, nr, unsigned_flag, decimal_value);
return decimal_value;
}
bool Item_hybrid_func::fix_attributes(Item **items, uint nitems) bool Item_hybrid_func::fix_attributes(Item **items, uint nitems)
{ {
......
...@@ -192,8 +192,6 @@ class Item_func :public Item_func_or_sum, ...@@ -192,8 +192,6 @@ class Item_func :public Item_func_or_sum,
{ return tmp_table_field_from_field_type(root, table); } { return tmp_table_field_from_field_type(root, table); }
Item *get_tmp_table_item(THD *thd); Item *get_tmp_table_item(THD *thd);
my_decimal *val_decimal(my_decimal *);
void fix_char_length_ulonglong(ulonglong max_char_length_arg) void fix_char_length_ulonglong(ulonglong max_char_length_arg)
{ {
ulonglong max_result_length= max_char_length_arg * ulonglong max_result_length= max_char_length_arg *
...@@ -1005,6 +1003,10 @@ class Item_int_func :public Item_func ...@@ -1005,6 +1003,10 @@ class Item_int_func :public Item_func
{ collation.set_numeric(); } { collation.set_numeric(); }
double val_real(); double val_real();
String *val_str(String*str); String *val_str(String*str);
my_decimal *val_decimal(my_decimal *decimal_value)
{
return val_decimal_from_int(decimal_value);
}
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{ return get_date_from_int(thd, ltime, fuzzydate); } { return get_date_from_int(thd, ltime, fuzzydate); }
const Type_handler *type_handler() const= 0; const Type_handler *type_handler() const= 0;
...@@ -2424,6 +2426,10 @@ class Item_func_udf_int :public Item_udf_func ...@@ -2424,6 +2426,10 @@ class Item_func_udf_int :public Item_udf_func
Item_udf_func(thd, udf_arg, list) {} Item_udf_func(thd, udf_arg, list) {}
longlong val_int(); longlong val_int();
double val_real() { return (double) Item_func_udf_int::val_int(); } double val_real() { return (double) Item_func_udf_int::val_int(); }
my_decimal *val_decimal(my_decimal *decimal_value)
{
return val_decimal_from_int(decimal_value);
}
String *val_str(String *str); String *val_str(String *str);
const Type_handler *type_handler() const { return &type_handler_longlong; } const Type_handler *type_handler() const { return &type_handler_longlong; }
bool fix_length_and_dec() { decimals= 0; max_length= 21; return FALSE; } bool fix_length_and_dec() { decimals= 0; max_length= 21; return FALSE; }
......
...@@ -182,6 +182,10 @@ class Item_func_month :public Item_func ...@@ -182,6 +182,10 @@ class Item_func_month :public Item_func
str->set(nr, collation.collation); str->set(nr, collation.collation);
return str; return str;
} }
my_decimal *val_decimal(my_decimal *decimal_value)
{
return val_decimal_from_int(decimal_value);
}
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{ {
return get_date_from_int(thd, ltime, fuzzydate); return get_date_from_int(thd, ltime, fuzzydate);
...@@ -451,6 +455,10 @@ class Item_func_weekday :public Item_func ...@@ -451,6 +455,10 @@ class Item_func_weekday :public Item_func
str->set(val_int(), &my_charset_bin); str->set(val_int(), &my_charset_bin);
return null_value ? 0 : str; return null_value ? 0 : str;
} }
my_decimal *val_decimal(my_decimal *decimal_value)
{
return val_decimal_from_int(decimal_value);
}
const char *func_name() const const char *func_name() const
{ {
return (odbc_type ? "dayofweek" : "weekday"); return (odbc_type ? "dayofweek" : "weekday");
......
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