diff options
author | unknown <jimw@mysql.com> | 2005-10-12 13:27:49 -0700 |
---|---|---|
committer | unknown <jimw@mysql.com> | 2005-10-12 13:27:49 -0700 |
commit | 101d9189bd585887b9a49f099f26d8dc751f576a (patch) | |
tree | 4c6a5ef7eb7fcaf505f80279ef9adef99af675e1 | |
parent | 9a3bce50ae0e9e334f952bcb67c8c5575c39a0bd (diff) | |
parent | 13fa84a7e2f25f69fcaf8ad5893ac6fe152d6ff8 (diff) | |
download | mariadb-git-101d9189bd585887b9a49f099f26d8dc751f576a.tar.gz |
Merge mysql.com:/home/jimw/my/mysql-4.1-13344
into mysql.com:/home/jimw/my/mysql-4.1-clean
mysql-test/r/cast.result:
Auto merged
mysql-test/t/cast.test:
Auto merged
sql/item.h:
Auto merged
-rw-r--r-- | mysql-test/r/cast.result | 3 | ||||
-rw-r--r-- | mysql-test/t/cast.test | 5 | ||||
-rw-r--r-- | sql/item.h | 8 |
3 files changed, 16 insertions, 0 deletions
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index 1b681941a1d..69a4cb24276 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -264,3 +264,6 @@ cast(repeat('1',20) as signed) -7335632962598440505 Warnings: Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement +select cast(1.0e+300 as signed int); +cast(1.0e+300 as signed int) +9223372036854775807 diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index bb01e8cea83..ea0a0e4b352 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -147,4 +147,9 @@ select cast(concat('184467440','73709551615') as signed); select cast(repeat('1',20) as unsigned); select cast(repeat('1',20) as signed); +# +# Bug #13344: cast of large decimal to signed int not handled correctly +# +select cast(1.0e+300 as signed int); + # End of 4.1 tests diff --git a/sql/item.h b/sql/item.h index b1aed733101..1d01ce0d3f3 100644 --- a/sql/item.h +++ b/sql/item.h @@ -703,6 +703,14 @@ public: longlong val_int() { DBUG_ASSERT(fixed == 1); + if (value <= (double) LONGLONG_MIN) + { + return LONGLONG_MIN; + } + else if (value >= (double) (ulonglong) LONGLONG_MAX) + { + return LONGLONG_MAX; + } return (longlong) (value+(value > 0 ? 0.5 : -0.5)); } String *val_str(String*); |