summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.h
diff options
context:
space:
mode:
authorGleb Shchepa <gshchepa@mysql.com>2009-12-10 10:05:44 +0400
committerGleb Shchepa <gshchepa@mysql.com>2009-12-10 10:05:44 +0400
commit3461cdc1a173d7ca4a5592200440bdc1ac108a29 (patch)
tree90a4246ebf09962da338be60b0c3d27be7ba289d /sql/item_cmpfunc.h
parent644015d23993bf6431cf27b4ffa4504b77297bc4 (diff)
downloadmariadb-git-3461cdc1a173d7ca4a5592200440bdc1ac108a29.tar.gz
Bug #49480: WHERE using YEAR columns returns unexpected results
A few problems were found in the fix for bug 43668: 1) Comparison of the YEAR column with NULL always returned TRUE; 2) Comparison of the YEAR column with constants always returned unpredictable result; 3) Unnecessary conversion warnings when comparing a non-integer constant with a NULL value in the YEAR column; The problems described above have been resolved with an exception: zero (i.e. invalid) YEAR column value comparison with 00 or 2000 still fail (it is not a regression and it was not a regression), so MIN/MAX on YEAR column containing zero value still fail.
Diffstat (limited to 'sql/item_cmpfunc.h')
-rw-r--r--sql/item_cmpfunc.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 52af6a31c0c..d4542dac820 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -42,24 +42,22 @@ class Arg_comparator: public Sql_alloc
bool is_nulls_eq; // TRUE <=> compare for the EQUAL_FUNC
bool set_null; // TRUE <=> set owner->null_value
// when one of arguments is NULL.
- bool year_as_datetime; // TRUE <=> convert YEAR value to
- // the YYYY-00-00 00:00:00 DATETIME
- // format. See compare_year.
enum enum_date_cmp_type { CMP_DATE_DFLT= 0, CMP_DATE_WITH_DATE,
CMP_DATE_WITH_STR, CMP_STR_WITH_DATE };
longlong (*get_value_a_func)(THD *thd, Item ***item_arg, Item **cache_arg,
Item *warn_item, bool *is_null);
longlong (*get_value_b_func)(THD *thd, Item ***item_arg, Item **cache_arg,
Item *warn_item, bool *is_null);
+ bool try_year_cmp_func(Item_result type);
public:
DTCollation cmp_collation;
/* Allow owner function to use string buffers. */
String value1, value2;
Arg_comparator(): thd(0), a_cache(0), b_cache(0), set_null(0),
- year_as_datetime(0), get_value_a_func(0), get_value_b_func(0) {};
+ get_value_a_func(0), get_value_b_func(0) {};
Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), thd(0),
- a_cache(0), b_cache(0), set_null(0), year_as_datetime(0),
+ a_cache(0), b_cache(0), set_null(0),
get_value_a_func(0), get_value_b_func(0) {};
int set_compare_func(Item_result_field *owner, Item_result type);
@@ -101,7 +99,6 @@ public:
int compare_real_fixed();
int compare_e_real_fixed();
int compare_datetime(); // compare args[0] & args[1] as DATETIMEs
- int compare_year();
static enum enum_date_cmp_type can_compare_as_dates(Item *a, Item *b,
ulonglong *const_val_arg);