summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorramil@mysql.com <>2006-04-11 16:13:57 +0500
committerramil@mysql.com <>2006-04-11 16:13:57 +0500
commit1e292442009034244fcf7212f494cec76dd7fc26 (patch)
treee8e9706751cb77c52dd4b07cc0a78de3393e3863 /sql
parentabf41982f8225912a2cdedefd4d7bdd1d82d63dd (diff)
downloadmariadb-git-1e292442009034244fcf7212f494cec76dd7fc26.tar.gz
Fix for bug #14360: Date Between Interval Broken.
Diffstat (limited to 'sql')
-rw-r--r--sql/item_timefunc.cc35
-rw-r--r--sql/item_timefunc.h1
2 files changed, 36 insertions, 0 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index e139eba385e..ee74d30ce53 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -2125,6 +2125,41 @@ longlong Item_date_add_interval::val_int()
((date*100L + ltime.hour)*100L+ ltime.minute)*100L + ltime.second;
}
+
+
+bool Item_date_add_interval::eq(const Item *item, bool binary_cmp) const
+{
+ INTERVAL interval, other_interval;
+ String val= value; // Because of const
+
+ if (this == item)
+ return TRUE;
+
+ if ((item->type() != FUNC_ITEM) ||
+ (arg_count != ((Item_func*) item)->arg_count) ||
+ (func_name() != ((Item_func*) item)->func_name()))
+ return FALSE;
+
+ Item_date_add_interval *other= (Item_date_add_interval*) item;
+
+ if ((int_type != other->int_type) ||
+ (!args[0]->eq(other->args[0], binary_cmp)) ||
+ (get_interval_value(args[1], int_type, &val, &interval)))
+ return FALSE;
+
+ val= other->value;
+
+ if ((get_interval_value(other->args[1], other->int_type, &val,
+ &other_interval)) ||
+ ((date_sub_interval ^ interval.neg) ^
+ (other->date_sub_interval ^ other_interval.neg)))
+ return FALSE;
+
+ // Assume comparing same types here due to earlier check
+ return memcmp(&interval, &other_interval, sizeof(INTERVAL)) == 0;
+}
+
+
static const char *interval_names[]=
{
"year", "quarter", "month", "day", "hour",
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 71f595184ec..761faf85e63 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -656,6 +656,7 @@ public:
double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); }
longlong val_int();
bool get_date(TIME *res, uint fuzzy_date);
+ bool eq(const Item *item, bool binary_cmp) const;
void print(String *str);
};