diff options
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/sql/item.cc b/sql/item.cc index 72231497a22..22bcbf39ab3 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_IMPLEMENTATION @@ -265,6 +265,40 @@ longlong Item::val_int_unsigned_typecast_from_str() } +longlong Item::val_int_signed_typecast_from_real() +{ + double nr= val_real(); + if (null_value) + return 0; + Converter_double_to_longlong conv(nr, false); + if (conv.error()) + { + THD *thd= current_thd; + push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, + ER_DATA_OVERFLOW, ER_THD(thd, ER_DATA_OVERFLOW), + ErrConvDouble(nr).ptr(), "SIGNED BIGINT"); + } + return conv.result(); +} + + +longlong Item::val_int_unsigned_typecast_from_real() +{ + double nr= val_real(); + if (null_value) + return 0; + Converter_double_to_longlong conv(nr, true); + if (conv.error()) + { + THD *thd= current_thd; + push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, + ER_DATA_OVERFLOW, ER_THD(thd, ER_DATA_OVERFLOW), + ErrConvDouble(nr).ptr(), "UNSIGNED BIGINT"); + } + return conv.result(); +} + + longlong Item::val_int_signed_typecast_from_int() { longlong value= val_int(); @@ -9929,7 +9963,7 @@ longlong Item_cache_real::val_int() } -String* Item_cache_real::val_str(String *str) +String* Item_cache_double::val_str(String *str) { if (!has_value()) return NULL; @@ -9938,6 +9972,15 @@ String* Item_cache_real::val_str(String *str) } +String* Item_cache_float::val_str(String *str) +{ + if (!has_value()) + return NULL; + Float(value).to_string(str, decimals); + return str; +} + + my_decimal *Item_cache_real::val_decimal(my_decimal *decimal_val) { if (!has_value()) |