summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorigor@rurik.mysql.com <>2006-04-12 13:23:11 -0700
committerigor@rurik.mysql.com <>2006-04-12 13:23:11 -0700
commitfb75fcde654669a90458a40a22b975d41e18942a (patch)
tree0e931bec089509ebd89a8eb00a6cb2c028f8050f /sql
parent6a3bb50ce66f38d820cf4c34fce9ff1088dbff4d (diff)
parentabc16b5b007e20a43b5403770473f1b58dbad76c (diff)
downloadmariadb-git-fb75fcde654669a90458a40a22b975d41e18942a.tar.gz
Merge rurik.mysql.com:/home/igor/dev/mysql-5.0-0
into rurik.mysql.com:/home/igor/dev/mysql-5.1-0
Diffstat (limited to 'sql')
-rw-r--r--sql/item_cmpfunc.cc12
-rw-r--r--sql/item_timefunc.cc35
-rw-r--r--sql/item_timefunc.h1
3 files changed, 38 insertions, 10 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 493c3dbc60e..acee912c912 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -52,7 +52,6 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems)
{
uint i;
Field *field= NULL;
- bool all_constant= TRUE;
/* If the first argument is a FIELD_ITEM, pull out the field. */
if (items[0]->real_item()->type() == Item::FIELD_ITEM)
@@ -65,16 +64,9 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems)
for (i= 1; i < nitems; i++)
{
type[0]= item_cmp_type(type[0], items[i]->result_type());
- if (field && !convert_constant_item(thd, field, &items[i]))
- all_constant= FALSE;
+ if (field && convert_constant_item(thd, field, &items[i]))
+ type[0]= INT_RESULT;
}
-
- /*
- If we had a field that can be compared as a longlong, and all constant
- items, then the aggregate result will be an INT_RESULT.
- */
- if (field && all_constant)
- type[0]= INT_RESULT;
}
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 99cb7078eba..6fbd6db1a89 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -2002,6 +2002,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 fd2f3945fca..c5ea618dafe 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -647,6 +647,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);
};