summaryrefslogtreecommitdiff
path: root/sql/item.h
diff options
context:
space:
mode:
authorunknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru>2007-11-21 08:01:00 +0400
committerunknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru>2007-11-21 08:01:00 +0400
commitf2a631f0dcd87d6d53ae0293bfb70364ca30dc4d (patch)
treecd48c8b1187ac8681709e99b0a327f08c93e7009 /sql/item.h
parentcaa031e0f76c769f044d39c4f244c8fbee71c3f0 (diff)
downloadmariadb-git-f2a631f0dcd87d6d53ae0293bfb70364ca30dc4d.tar.gz
Fix for bug #32021: Using Date 000-00-01 in WHERE causes wrong result
Problem: caching 00000000-00000099 dates as integer values we're improperly shifting them up twice in the get_datetime_value(). Fix: don't shift cached DATETIME values up for the second time. mysql-test/r/type_date.result: Fix for bug #32021: Using Date 000-00-01 in WHERE causes wrong result - test result. mysql-test/t/type_date.test: Fix for bug #32021: Using Date 000-00-01 in WHERE causes wrong result - test case. sql/item.h: Fix for bug #32021: Using Date 000-00-01 in WHERE causes wrong result - Item_cache::field_type() method added. - new Item_cache(enum_field_types) and Item_cache_int(enum_field_types) constructors added. sql/item_cmpfunc.cc: Fix for bug #32021: Using Date 000-00-01 in WHERE causes wrong result - don't shift cached DATETIME values for the second time in the get_datetime_value(): creating new Item_cache_int set DATETIME filed type, check the type before shifting.
Diffstat (limited to 'sql/item.h')
-rw-r--r--sql/item.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/sql/item.h b/sql/item.h
index 6990d9ed021..379eb8a24be 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -2620,8 +2620,20 @@ class Item_cache: public Item
protected:
Item *example;
table_map used_table_map;
+ enum enum_field_types cached_field_type;
public:
- Item_cache(): example(0), used_table_map(0) {fixed= 1; null_value= 1;}
+ Item_cache():
+ example(0), used_table_map(0), cached_field_type(MYSQL_TYPE_STRING)
+ {
+ fixed= 1;
+ null_value= 1;
+ }
+ Item_cache(enum_field_types field_type_arg):
+ example(0), used_table_map(0), cached_field_type(field_type_arg)
+ {
+ fixed= 1;
+ null_value= 1;
+ }
void set_used_tables(table_map map) { used_table_map= map; }
@@ -2637,6 +2649,7 @@ public:
};
virtual void store(Item *)= 0;
enum Type type() const { return CACHE_ITEM; }
+ enum_field_types field_type() const { return cached_field_type; }
static Item_cache* get_cache(const Item *item);
table_map used_tables() const { return used_table_map; }
virtual void keep_array() {}
@@ -2652,6 +2665,8 @@ protected:
longlong value;
public:
Item_cache_int(): Item_cache(), value(0) {}
+ Item_cache_int(enum_field_types field_type_arg):
+ Item_cache(field_type_arg), value(0) {}
void store(Item *item);
void store(Item *item, longlong val_arg);