From: Date: July 19 2007 10:06pm Subject: bk commit into 5.0 tree (evgen:1.2539) BUG#29898 List-Archive: http://lists.mysql.com/commits/31202 X-Bug: 29898 Message-Id: <20070719200638.7237022CBD9@moonbone.moonbone.local> 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-07-20 00:06:35+04:00, evgen@stripped +3 -0 Bug#29898: Item_date_typecast::val_int doesn't reset the null_value flag. The Item_date_typecast::val_int function doesn't reset null_value flag. This makes all values that follows the first null value to be treated as nulls and led to a wrong result. Now the Item_date_typecast::val_int function correctly sets the null_value flag for both null and non-null values. mysql-test/r/cast.result@stripped, 2007-07-20 00:05:28+04:00, evgen@stripped +11 -0 Added a test case for the bug#29898: Item_date_typecast::val_int doesn't reset the null_value flag. mysql-test/t/cast.test@stripped, 2007-07-20 00:05:09+04:00, evgen@stripped +9 -0 Added a test case for the bug#29898: Item_date_typecast::val_int doesn't reset the null_value flag. sql/item_timefunc.cc@stripped, 2007-07-20 00:05:41+04:00, evgen@stripped +1 -4 Bug#29898: Item_date_typecast::val_int doesn't reset the null_value flag. Now the Item_date_typecast::val_int function correctly sets the null_value flag for both null and non-null values. diff -Nrup a/mysql-test/r/cast.result b/mysql-test/r/cast.result --- a/mysql-test/r/cast.result 2007-05-11 17:12:14 +04:00 +++ b/mysql-test/r/cast.result 2007-07-20 00:05:28 +04:00 @@ -403,4 +403,15 @@ hex(cast('a' as binary(2))) select hex(cast('a' as char(2) binary)); hex(cast('a' as char(2) binary)) 61 +CREATE TABLE t1 (d1 datetime); +INSERT INTO t1(d1) VALUES ('2007-07-19 08:30:00'), (NULL), +('2007-07-19 08:34:00'), (NULL), ('2007-07-19 08:36:00'); +SELECT cast(date(d1) as signed) FROM t1; +cast(date(d1) as signed) +20070719 +NULL +20070719 +NULL +20070719 +drop table t1; End of 5.0 tests diff -Nrup a/mysql-test/t/cast.test b/mysql-test/t/cast.test --- a/mysql-test/t/cast.test 2007-05-23 16:43:02 +04:00 +++ b/mysql-test/t/cast.test 2007-07-20 00:05:09 +04:00 @@ -237,4 +237,13 @@ select hex(cast('a' as char(2) binary)); select hex(cast('a' as binary(2))); select hex(cast('a' as char(2) binary)); +# +# Bug#29898: Item_date_typecast::val_int doesn't reset the null_value flag. +# +CREATE TABLE t1 (d1 datetime); +INSERT INTO t1(d1) VALUES ('2007-07-19 08:30:00'), (NULL), + ('2007-07-19 08:34:00'), (NULL), ('2007-07-19 08:36:00'); +SELECT cast(date(d1) as signed) FROM t1; +drop table t1; + --echo End of 5.0 tests diff -Nrup a/sql/item_timefunc.cc b/sql/item_timefunc.cc --- a/sql/item_timefunc.cc 2007-06-11 21:32:06 +04:00 +++ b/sql/item_timefunc.cc 2007-07-20 00:05:41 +04:00 @@ -2662,11 +2662,8 @@ longlong Item_date_typecast::val_int() { DBUG_ASSERT(fixed == 1); MYSQL_TIME ltime; - if (args[0]->get_date(<ime, TIME_FUZZY_DATE)) - { - null_value= 1; + if ((null_value= args[0]->get_date(<ime, TIME_FUZZY_DATE))) return 0; - } return (longlong) (ltime.year * 10000L + ltime.month * 100 + ltime.day); }