summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-05-16 00:30:12 +0400
committerunknown <evgen@moonbone.local>2007-05-16 00:30:12 +0400
commit9aa67a40962e87f9170c8c70a3dbe3689659322e (patch)
treeb0e377c240d77ec7e5f0736987dfefd78b8dd363 /sql/item_cmpfunc.cc
parent963fae4b80d6ad96d495a9f187a1897ef0f88a07 (diff)
downloadmariadb-git-9aa67a40962e87f9170c8c70a3dbe3689659322e.tar.gz
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/t/type_datetime.test: Added a test case for the bug#28208: Wrong result of a non-const STRING function with a const DATETIME function. mysql-test/r/type_datetime.result: 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: 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.
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 4f0347dd506..9a251312aca 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -661,7 +661,7 @@ int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg,
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 @@ int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg,
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. */