Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-05-04 00:10:22+04:00, evgen@stripped +3 -0
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/r/cast.result@stripped, 2007-05-04 00:08:15+04:00, evgen@stripped +6 -0
Added a test case for the bug#23656: Wrong conversion result of a DATETIME to integer
using CAST function.
mysql-test/t/cast.test@stripped, 2007-05-04 00:07:54+04:00, evgen@stripped +6 -0
Added a test case for the bug#23656: Wrong conversion result of a DATETIME to integer
using CAST function.
sql/item_func.cc@stripped, 2007-05-04 00:09:29+04:00, evgen@stripped +4 -2
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.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: evgen
# Host: moonbone.local
# Root: /mnt/gentoo64/work/23656-bug-5.0-opt-mysql
--- 1.334/sql/item_func.cc 2007-04-18 11:39:02.000000000 +0400
+++ 1.335/sql/item_func.cc 2007-05-04 00:09:29.000000000 +0400
@@ -947,7 +947,8 @@
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 @@
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;
--- 1.48/mysql-test/r/cast.result 2007-02-06 12:57:15.000000000 +0300
+++ 1.49/mysql-test/r/cast.result 2007-05-04 00:08:15.000000000 +0400
@@ -395,4 +395,10 @@
select hex(cast('a' as char(2) binary));
hex(cast('a' as char(2) binary))
61
+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 5.0 tests
--- 1.34/mysql-test/t/cast.test 2007-02-06 12:57:15.000000000 +0300
+++ 1.35/mysql-test/t/cast.test 2007-05-04 00:07:54.000000000 +0400
@@ -225,4 +225,10 @@
select hex(cast('a' as binary(2)));
select hex(cast('a' as char(2) binary));
+#
+# 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 5.0 tests
| Thread |
|---|
| • bk commit into 5.0 tree (evgen:1.2470) BUG#23656 | eugene | 3 May |