summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-09-23 20:26:35 +0200
committerSergei Golubchik <serg@mariadb.org>2018-09-24 11:46:08 +0200
commit5ae8fce50bb5cbd7916acd6b03bd699f79c10616 (patch)
tree6291ec25e408ea225531e8b79a4f4fd7f3a81329 /sql/item.cc
parent76098f45b8b1f2224eb25cf5d94450c6f4a1414c (diff)
parent1fc5a6f30c3a9c047dcf9a36b00026d98f286f6b (diff)
downloadmariadb-git-5ae8fce50bb5cbd7916acd6b03bd699f79c10616.tar.gz
Merge branch '10.1' into 10.2
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc180
1 files changed, 2 insertions, 178 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 45382c0a6f1..35de01b1186 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -3949,7 +3949,7 @@ longlong Item_param::val_int()
// There's no "default". See comments in Item_param::save_in_field().
switch (state) {
case REAL_VALUE:
- return (longlong) rint(value.real);
+ return Converter_double_to_longlong(value.real, unsigned_flag).result();
case INT_VALUE:
return value.integer;
case DECIMAL_VALUE:
@@ -4490,32 +4490,6 @@ bool Item_param::append_for_log(THD *thd, String *str)
return str->append(*val);
}
-/****************************************************************************
- Item_copy
-****************************************************************************/
-
-Item_copy *Item_copy::create(THD *thd, Item *item)
-{
- MEM_ROOT *mem_root= thd->mem_root;
- switch (item->result_type())
- {
- case STRING_RESULT:
- return new (mem_root) Item_copy_string(thd, item);
- case REAL_RESULT:
- return new (mem_root) Item_copy_float(thd, item);
- case INT_RESULT:
- return item->unsigned_flag ?
- new (mem_root) Item_copy_uint(thd, item) :
- new (mem_root) Item_copy_int(thd, item);
- case DECIMAL_RESULT:
- return new (mem_root) Item_copy_decimal(thd, item);
- case TIME_RESULT:
- case ROW_RESULT:
- DBUG_ASSERT (0);
- }
- /* should not happen */
- return NULL;
-}
/****************************************************************************
Item_copy_string
@@ -4573,156 +4547,6 @@ my_decimal *Item_copy_string::val_decimal(my_decimal *decimal_value)
}
-/****************************************************************************
- Item_copy_int
-****************************************************************************/
-
-void Item_copy_int::copy()
-{
- cached_value= item->val_int();
- null_value=item->null_value;
-}
-
-static int save_int_value_in_field (Field *, longlong, bool, bool);
-
-int Item_copy_int::save_in_field(Field *field, bool no_conversions)
-{
- return save_int_value_in_field(field, cached_value,
- null_value, unsigned_flag);
-}
-
-
-String *Item_copy_int::val_str(String *str)
-{
- if (null_value)
- return (String *) 0;
-
- str->set(cached_value, &my_charset_bin);
- return str;
-}
-
-
-my_decimal *Item_copy_int::val_decimal(my_decimal *decimal_value)
-{
- if (null_value)
- return (my_decimal *) 0;
-
- int2my_decimal(E_DEC_FATAL_ERROR, cached_value, unsigned_flag, decimal_value);
- return decimal_value;
-}
-
-
-/****************************************************************************
- Item_copy_uint
-****************************************************************************/
-
-String *Item_copy_uint::val_str(String *str)
-{
- if (null_value)
- return (String *) 0;
-
- str->set((ulonglong) cached_value, &my_charset_bin);
- return str;
-}
-
-
-/****************************************************************************
- Item_copy_float
-****************************************************************************/
-
-String *Item_copy_float::val_str(String *str)
-{
- if (null_value)
- return (String *) 0;
- else
- {
- double nr= val_real();
- str->set_real(nr,decimals, &my_charset_bin);
- return str;
- }
-}
-
-
-my_decimal *Item_copy_float::val_decimal(my_decimal *decimal_value)
-{
- if (null_value)
- return (my_decimal *) 0;
- else
- {
- double nr= val_real();
- double2my_decimal(E_DEC_FATAL_ERROR, nr, decimal_value);
- return decimal_value;
- }
-}
-
-
-int Item_copy_float::save_in_field(Field *field, bool no_conversions)
-{
- if (null_value)
- return set_field_to_null(field);
- field->set_notnull();
- return field->store(cached_value);
-}
-
-
-/****************************************************************************
- Item_copy_decimal
-****************************************************************************/
-
-int Item_copy_decimal::save_in_field(Field *field, bool no_conversions)
-{
- if (null_value)
- return set_field_to_null(field);
- field->set_notnull();
- return field->store_decimal(&cached_value);
-}
-
-
-String *Item_copy_decimal::val_str(String *result)
-{
- if (null_value)
- return (String *) 0;
- result->set_charset(&my_charset_bin);
- my_decimal2string(E_DEC_FATAL_ERROR, &cached_value, 0, 0, 0, result);
- return result;
-}
-
-
-double Item_copy_decimal::val_real()
-{
- if (null_value)
- return 0.0;
- else
- {
- double result;
- my_decimal2double(E_DEC_FATAL_ERROR, &cached_value, &result);
- return result;
- }
-}
-
-
-longlong Item_copy_decimal::val_int()
-{
- if (null_value)
- return 0;
- else
- {
- longlong result;
- my_decimal2int(E_DEC_FATAL_ERROR, &cached_value, unsigned_flag, &result);
- return result;
- }
-}
-
-
-void Item_copy_decimal::copy()
-{
- my_decimal *nr= item->val_decimal(&cached_value);
- if (nr && nr != &cached_value)
- my_decimal2decimal (nr, &cached_value);
- null_value= item->null_value;
-}
-
-
/*
Functions to convert item to field (for send_result_set_metadata)
*/
@@ -9983,7 +9807,7 @@ longlong Item_cache_real::val_int()
DBUG_ASSERT(fixed == 1);
if (!has_value())
return 0;
- return (longlong) rint(value);
+ return Converter_double_to_longlong(value, unsigned_flag).result();
}