From: Date: May 15 2007 10:30pm Subject: bk commit into 5.0 tree (evgen:1.2487) BUG#28208 List-Archive: http://lists.mysql.com/commits/26737 X-Bug: 28208 Message-Id: <20070515203015.5C7F022CB9F@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-05-16 00:30:12+04:00, evgen@stripped +3 -0 Bug#28208: Wrong result of a non-const STRING function with a const DATETIME function. A wrong condition was used to check that the Arg_comparator::can_compare_as_dates() function calculated the value of the string constant. When comparing a non-const STRING function with a constant DATETIME function it leads to saving an arbitrary value as a cached value of the DATETIME function. Now the Arg_comparator::set_cmp_func() function initializes the const_value variable to the impossible DATETIME value (-1) and this const_value is cached only if it was changed by the Arg_comparator::can_compare_as_dates() function. mysql-test/r/type_datetime.result@stripped, 2007-05-16 00:29:50+04:00, evgen@stripped +6 -0 Added a test case for the bug#28208: Wrong result of a non-const STRING function with a const DATETIME function. mysql-test/t/type_datetime.test@stripped, 2007-05-16 00:29:48+04:00, evgen@stripped +9 -0 Added a test case for the bug#28208: Wrong result of a non-const STRING function with a const DATETIME function. sql/item_cmpfunc.cc@stripped, 2007-05-16 00:29:50+04:00, evgen@stripped +2 -3 Bug#28208: Wrong result of a non-const STRING function with a const DATETIME function. Now the Arg_comparator::set_cmp_func() function initializes the const_value variable to the impossible DATETIME value (-1) and this const_value is cached only if it was changed by the Arg_comparator::can_compare_as_dates() function. # 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/28208-bug-5.0-opt-mysql --- 1.250/sql/item_cmpfunc.cc 2007-05-07 22:22:16.000000000 +0400 +++ 1.251/sql/item_cmpfunc.cc 2007-05-16 00:29:50.000000000 +0400 @@ -661,7 +661,7 @@ Item_result type) { enum enum_date_cmp_type cmp_type; - ulonglong const_value; + ulonglong const_value= (ulonglong)-1; a= a1; b= a2; @@ -674,8 +674,7 @@ a_cache= 0; b_cache= 0; - if (cmp_type != CMP_DATE_WITH_DATE && - ((*b)->const_item() || (*a)->const_item())) + if (const_value != (ulonglong)-1) { Item_cache_int *cache= new Item_cache_int(); /* Mark the cache as non-const to prevent re-caching. */ --- 1.42/mysql-test/r/type_datetime.result 2007-05-11 19:56:20.000000000 +0400 +++ 1.43/mysql-test/r/type_datetime.result 2007-05-16 00:29:50.000000000 +0400 @@ -346,3 +346,9 @@ a b a_then_b b_then_a c_then_a 2007-04-10 2007-04-11 2007-04-10 2007-04-10 2004-04-09 00:00:00 drop procedure test27759; +create table t1 (f1 date); +insert into t1 values (curdate()); +select left(f1,10) = curdate() from t1; +left(f1,10) = curdate() +1 +drop table t1; --- 1.28/mysql-test/t/type_datetime.test 2007-05-11 19:56:20.000000000 +0400 +++ 1.29/mysql-test/t/type_datetime.test 2007-05-16 00:29:48.000000000 +0400 @@ -225,3 +225,12 @@ DELIMITER ;| call test27759(); drop procedure test27759; + +# +# Bug#28208: Wrong result of a non-const STRING function with a const +# DATETIME function. +# +create table t1 (f1 date); +insert into t1 values (curdate()); +select left(f1,10) = curdate() from t1; +drop table t1;