summaryrefslogtreecommitdiff
path: root/mysql-test/r/cast.result
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-05-04 00:53:37 +0400
committerunknown <evgen@moonbone.local>2007-05-04 00:53:37 +0400
commit1a0e3a285818f0a71cdc7f387a63f7cc72c72972 (patch)
treefff05caa7dbba43c21b8f101c269bdd062a5e2ea /mysql-test/r/cast.result
parentc004ad09444b8b3be367b6620aa4f0716684bdc3 (diff)
downloadmariadb-git-1a0e3a285818f0a71cdc7f387a63f7cc72c72972.tar.gz
Bug#23656: Wrong conversion result of a DATETIME to integer using CAST function.
The generic string to int conversion was used by the Item_func_signed and the Item_func_unsigned classes to convert DATE/DATETIME values to the SIGNED/UNSIGNED type. But this conversion produces wrong results for such values. Now if the item which result has to be converted can return its result as longlong then the item->val_int() method is used to allow the item to carry out the conversion itself and return the correct result. This condition is checked in the Item_func_signed::val_int() and the Item_func_unsigned::val_int() functions. mysql-test/t/cast.test: Added a test case for the bug#23656: Wrong conversion result of a DATETIME to integer using CAST function. mysql-test/r/cast.result: Added a test case for the bug#23656: Wrong conversion result of a DATETIME to integer using CAST function. sql/item_func.cc: Bug#23656: Wrong conversion result of a DATETIME to integer using CAST function. Now if the item which result has to be converted can return its result as longlong then the item->val_int() method is used to allow the item to carry out the conversion itself and return the correct result. This condition is checked in the Item_func_signed::val_int() and the Item_func_unsigned::val_int() functions.
Diffstat (limited to 'mysql-test/r/cast.result')
-rw-r--r--mysql-test/r/cast.result6
1 files changed, 6 insertions, 0 deletions
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result
index 23c38bb792c..f6f46bd4079 100644
--- a/mysql-test/r/cast.result
+++ b/mysql-test/r/cast.result
@@ -281,4 +281,10 @@ 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