summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc53
1 files changed, 49 insertions, 4 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 59005930e31..30dad9d3f18 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2000-2003
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -400,6 +400,7 @@ longlong Item_func_strcmp::val_int()
return !value ? 0 : (value < 0 ? (longlong) -1 : (longlong) 1);
}
+
void Item_func_interval::fix_length_and_dec()
{
if (row->cols() > 8)
@@ -420,8 +421,24 @@ void Item_func_interval::fix_length_and_dec()
}
maybe_null= 0;
max_length= 2;
+ used_tables_cache|= item->used_tables();
+ with_sum_func= with_sum_func || item->with_sum_func;
}
+
+void Item_func_interval::split_sum_func(List<Item> &fields)
+{
+ if (item->with_sum_func && item->type() != SUM_FUNC_ITEM)
+ item->split_sum_func(fields);
+ else if (item->used_tables() || item->type() == SUM_FUNC_ITEM)
+ {
+ fields.push_front(item);
+ item= new Item_ref((Item**) fields.head_ref(), 0, item->name);
+ }
+ Item_int_func::split_sum_func(fields);
+}
+
+
/*
return -1 if null value,
0 if lower than lowest
@@ -907,17 +924,47 @@ Item_func_case::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
{
used_tables_cache|=(first_expr)->used_tables();
const_item_cache&= (first_expr)->const_item();
+ with_sum_func= with_sum_func || (first_expr)->with_sum_func;
}
if (else_expr)
{
used_tables_cache|=(else_expr)->used_tables();
const_item_cache&= (else_expr)->const_item();
+ with_sum_func= with_sum_func || (else_expr)->with_sum_func;
}
if (!else_expr || else_expr->maybe_null)
maybe_null=1; // The result may be NULL
return 0;
}
+
+void Item_func_case::split_sum_func(List<Item> &fields)
+{
+ if (first_expr)
+ {
+ if (first_expr->with_sum_func && first_expr->type() != SUM_FUNC_ITEM)
+ first_expr->split_sum_func(fields);
+ else if (first_expr->used_tables() || first_expr->type() == SUM_FUNC_ITEM)
+ {
+ fields.push_front(first_expr);
+ first_expr= new Item_ref((Item**) fields.head_ref(), 0,
+ first_expr->name);
+ }
+ }
+ if (else_expr)
+ {
+ if (else_expr->with_sum_func && else_expr->type() != SUM_FUNC_ITEM)
+ else_expr->split_sum_func(fields);
+ else if (else_expr->used_tables() || else_expr->type() == SUM_FUNC_ITEM)
+ {
+ fields.push_front(else_expr);
+ else_expr= new Item_ref((Item**) fields.head_ref(), 0, else_expr->name);
+ }
+ }
+ Item_func::split_sum_func(fields);
+}
+
+
void Item_func_case::set_outer_resolving()
{
first_expr->set_outer_resolving();
@@ -1388,9 +1435,7 @@ void Item_func_in::split_sum_func(Item **ref_pointer_array, List<Item> &fields)
uint el= fields.elements;
fields.push_front(item);
ref_pointer_array[el]= item;
- item=new Item_ref(ref_pointer_array + el,
- 0, item->name);
-
+ item= new Item_ref(ref_pointer_array + el, 0, item->name);
}
Item_func::split_sum_func(ref_pointer_array, fields);
}