diff options
author | unknown <gkodinov/kgeorge@magare.gmz> | 2007-05-04 12:09:29 +0300 |
---|---|---|
committer | unknown <gkodinov/kgeorge@magare.gmz> | 2007-05-04 12:09:29 +0300 |
commit | 3ebd2e55b99ed99a6f3bba224a1b618c74dac173 (patch) | |
tree | d5be25393ecf27ce615162e35d7a17980e4ca623 | |
parent | ad06c4c08ee5bc9258dfce3455aabe39747d4875 (diff) | |
parent | 74c794d0e4a14b6deddc90e74ed718c2f00653df (diff) | |
download | mariadb-git-3ebd2e55b99ed99a6f3bba224a1b618c74dac173.tar.gz |
Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into magare.gmz:/home/kgeorge/mysql/autopush/B27807-5.0-opt
-rw-r--r-- | mysql-test/r/cast.result | 6 | ||||
-rw-r--r-- | mysql-test/t/cast.test | 6 | ||||
-rw-r--r-- | sql/item_func.cc | 6 |
3 files changed, 16 insertions, 2 deletions
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index d8e50128902..454a3766572 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -351,6 +351,12 @@ DROP TABLE t1; select isnull(date(NULL)), isnull(cast(NULL as DATE)); isnull(date(NULL)) isnull(cast(NULL as DATE)) 1 1 +SELECT CAST(cast('01-01-01' as date) AS UNSIGNED); +CAST(cast('01-01-01' as date) AS UNSIGNED) +20010101 +SELECT CAST(cast('01-01-01' as date) AS SIGNED); +CAST(cast('01-01-01' as date) AS SIGNED) +20010101 End of 4.1 tests select cast('1.2' as decimal(3,2)); cast('1.2' as decimal(3,2)) diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 502c5781f1f..004ef69182d 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -182,6 +182,12 @@ DROP TABLE t1; select isnull(date(NULL)), isnull(cast(NULL as DATE)); +# +# Bug#23656: Wrong result of CAST from DATE to int +# +SELECT CAST(cast('01-01-01' as date) AS UNSIGNED); +SELECT CAST(cast('01-01-01' as date) AS SIGNED); + --echo End of 4.1 tests diff --git a/sql/item_func.cc b/sql/item_func.cc index 503b4362e7a..eaef07f0cd6 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -947,7 +947,8 @@ longlong Item_func_signed::val_int() longlong value; int error; - if (args[0]->cast_to_int_type() != STRING_RESULT) + if (args[0]->cast_to_int_type() != STRING_RESULT || + args[0]->result_as_longlong()) { value= args[0]->val_int(); null_value= args[0]->null_value; @@ -986,7 +987,8 @@ longlong Item_func_unsigned::val_int() my_decimal2int(E_DEC_FATAL_ERROR, dec, 1, &value); return value; } - else if (args[0]->cast_to_int_type() != STRING_RESULT) + else if (args[0]->cast_to_int_type() != STRING_RESULT || + args[0]->result_as_longlong()) { value= args[0]->val_int(); null_value= args[0]->null_value; |