From: Date: June 24 2005 1:17am Subject: bk commit into 5.0 tree (evgen:1.2002) BUG#11325 List-Archive: http://lists.mysql.com/internals/26383 X-Bug: 11325 Message-Id: <20050623231724.29165152046@localhost.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 1.2002 05/06/24 03:17:19 evgen@stripped +3 -0 Fix bug#11325 Wrong date comparison in views Wrong comparing method were choosen which results in false comparison. Make Item_bool_func2::fix_length_and_dec() to get type and field from real_item() to make REF_ITEM pass the check. mysql-test/r/view.result 1.86 05/06/24 03:10:33 evgen@stripped +11 -0 Test case for bug #11325 Wrong date comparison in views mysql-test/t/view.test 1.74 05/06/24 03:10:00 evgen@stripped +11 -0 Test case for bug #11325 Wrong date comparison in views sql/item_cmpfunc.cc 1.158 05/06/24 03:09:12 evgen@stripped +4 -4 Fix bug#11325 Wrong date comparison in views # 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: /work/mysql-5.0-bug-11325 --- 1.157/sql/item_cmpfunc.cc 2005-06-17 23:26:18 +04:00 +++ 1.158/sql/item_cmpfunc.cc 2005-06-24 03:09:12 +04:00 @@ -238,9 +238,9 @@ return; } - if (args[0]->type() == FIELD_ITEM) + if (args[0]->real_item()->type() == FIELD_ITEM) { - Field *field=((Item_field*) args[0])->field; + Field *field= ((Item_field*) args[0]->real_item())->field; if (field->can_be_compared_as_longlong()) { if (convert_constant_item(thd, field,&args[1])) @@ -251,9 +251,9 @@ } } } - if (args[1]->type() == FIELD_ITEM /* && !args[1]->const_item() */) + if (args[1]->real_item()->type() == FIELD_ITEM) { - Field *field=((Item_field*) args[1])->field; + Field *field= ((Item_field*) args[1]->real_item())->field; if (field->can_be_compared_as_longlong()) { if (convert_constant_item(thd, field,&args[0])) --- 1.85/mysql-test/r/view.result 2005-06-22 09:52:02 +04:00 +++ 1.86/mysql-test/r/view.result 2005-06-24 03:10:33 +04:00 @@ -1831,3 +1831,14 @@ t 01:00 drop view v1; +create table t1 (f1 date); +insert into t1 values ('2005-01-01'),('2005-02-02'); +create view v1 as select * from t1; +select * from v1 where f1='2005.02.02'; +f1 +2005-02-02 +select * from v1 where '2005.02.02'=f1; +f1 +2005-02-02 +drop view v1; +drop table t1; --- 1.73/mysql-test/t/view.test 2005-06-22 09:42:00 +04:00 +++ 1.74/mysql-test/t/view.test 2005-06-24 03:10:00 +04:00 @@ -1673,3 +1673,14 @@ create view v1 as SELECT TIME_FORMAT(SEC_TO_TIME(3600),'%H:%i') as t; select * from v1; drop view v1; + +# +# bug #11325 Wrong date comparison in views +# +create table t1 (f1 date); +insert into t1 values ('2005-01-01'),('2005-02-02'); +create view v1 as select * from t1; +select * from v1 where f1='2005.02.02'; +select * from v1 where '2005.02.02'=f1; +drop view v1; +drop table t1;