diff options
author | unknown <bar@mysql.com> | 2005-12-06 16:54:13 +0400 |
---|---|---|
committer | unknown <bar@mysql.com> | 2005-12-06 16:54:13 +0400 |
commit | 4ccd3761004caa83004558c5999052414d4d2df4 (patch) | |
tree | 9276c1e68940cdd05cea49e7896b452006f3f65b /sql | |
parent | 966ab524a336bb22088d4adbb7db7a090762551e (diff) | |
download | mariadb-git-4ccd3761004caa83004558c5999052414d4d2df4.tar.gz |
Bug#15098 CAST(column double TO signed int), wrong result
field.cc:
Adding longlong range checking to return
LONGLONG_MIN or LONGLONG_MAX when out of range.
Using (longlong) cast only when range is ok.
cast.test:
Adding test case.
cast.result:
Fixing results accordingly.
sql/field.cc:
Bug#15098 CAST(column double TO signed int), wrong result
Adding longlong range checking.
mysql-test/t/cast.test:
Bug#15098 CAST(column double TO signed int), wrong result
Adding longlong range checking.
mysql-test/r/cast.result:
Fixing results accordingly.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sql/field.cc b/sql/field.cc index abb5297f458..d9bcabfe3cd 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3385,6 +3385,11 @@ longlong Field_double::val_int(void) else #endif doubleget(j,ptr); + /* Check whether we fit into longlong range */ + if (j <= (double) LONGLONG_MIN) + return (longlong) LONGLONG_MIN; + if (j >= (double) (ulonglong) LONGLONG_MAX) + return (longlong) LONGLONG_MAX; return ((longlong) j); } |