mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/usr/home/bar/mysql-5.0 sql/field.cc: Auto merged
This commit is contained in:
@ -344,6 +344,9 @@ SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1;
|
|||||||
double_val cast_val
|
double_val cast_val
|
||||||
-1e+30 -9223372036854775808
|
-1e+30 -9223372036854775808
|
||||||
1e+30 9223372036854775807
|
1e+30 9223372036854775807
|
||||||
|
Warnings:
|
||||||
|
Warning 1292 Truncated incorrect INTEGER value: '-1e+30'
|
||||||
|
Warning 1292 Truncated incorrect INTEGER value: '1e+30'
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
select cast('1.2' as decimal(3,2));
|
select cast('1.2' as decimal(3,2));
|
||||||
cast('1.2' as decimal(3,2))
|
cast('1.2' as decimal(3,2))
|
||||||
|
23
sql/field.cc
23
sql/field.cc
@ -4232,6 +4232,7 @@ double Field_double::val_real(void)
|
|||||||
longlong Field_double::val_int(void)
|
longlong Field_double::val_int(void)
|
||||||
{
|
{
|
||||||
double j;
|
double j;
|
||||||
|
longlong res;
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
if (table->s->db_low_byte_first)
|
if (table->s->db_low_byte_first)
|
||||||
{
|
{
|
||||||
@ -4242,10 +4243,28 @@ longlong Field_double::val_int(void)
|
|||||||
doubleget(j,ptr);
|
doubleget(j,ptr);
|
||||||
/* Check whether we fit into longlong range */
|
/* Check whether we fit into longlong range */
|
||||||
if (j <= (double) LONGLONG_MIN)
|
if (j <= (double) LONGLONG_MIN)
|
||||||
return (longlong) LONGLONG_MIN;
|
{
|
||||||
|
res= (longlong) LONGLONG_MIN;
|
||||||
|
goto warn;
|
||||||
|
}
|
||||||
if (j >= (double) (ulonglong) LONGLONG_MAX)
|
if (j >= (double) (ulonglong) LONGLONG_MAX)
|
||||||
return (longlong) LONGLONG_MAX;
|
{
|
||||||
|
res= (longlong) LONGLONG_MAX;
|
||||||
|
goto warn;
|
||||||
|
}
|
||||||
return (longlong) rint(j);
|
return (longlong) rint(j);
|
||||||
|
|
||||||
|
warn:
|
||||||
|
{
|
||||||
|
char buf[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
|
||||||
|
String tmp(buf, sizeof(buf), &my_charset_latin1), *str;
|
||||||
|
str= val_str(&tmp, 0);
|
||||||
|
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||||
|
ER_TRUNCATED_WRONG_VALUE,
|
||||||
|
ER(ER_TRUNCATED_WRONG_VALUE), "INTEGER",
|
||||||
|
str->c_ptr());
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user