summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@rakia.gmz>2006-10-31 16:15:35 +0200
committerunknown <gkodinov/kgeorge@rakia.gmz>2006-10-31 16:15:35 +0200
commit704d5d6083c4d5f069ceec58e2ce16b3636c512d (patch)
treedc2e97faddf5841099f97fa25f4d91997aa28197 /sql/item.cc
parent24e4fed73d70fa76f5e8febb4b398d6482a256e2 (diff)
parentbf3ff2eaf422dcdf27113912a768d927e540c62e (diff)
downloadmariadb-git-704d5d6083c4d5f069ceec58e2ce16b3636c512d.tar.gz
Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into rakia.gmz:/home/kgeorge/mysql/autopush/B21809-5.0-opt sql/item.cc: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc26
1 files changed, 24 insertions, 2 deletions
diff --git a/sql/item.cc b/sql/item.cc
index d56ca95093b..d0777f8f2a2 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1148,6 +1148,28 @@ void Item_name_const::print(String *str)
/*
+ need a special class to adjust printing : references to aggregate functions
+ must not be printed as refs because the aggregate functions that are added to
+ the front of select list are not printed as well.
+*/
+class Item_aggregate_ref : public Item_ref
+{
+public:
+ Item_aggregate_ref(Name_resolution_context *context_arg, Item **item,
+ const char *table_name_arg, const char *field_name_arg)
+ :Item_ref(context_arg, item, table_name_arg, field_name_arg) {}
+
+ void print (String *str)
+ {
+ if (ref)
+ (*ref)->print(str);
+ else
+ Item_ident::print(str);
+ }
+};
+
+
+/*
Move SUM items out from item tree and replace with reference
SYNOPSIS
@@ -1200,8 +1222,8 @@ void Item::split_sum_func2(THD *thd, Item **ref_pointer_array,
Item *new_item, *real_itm= real_item();
ref_pointer_array[el]= real_itm;
- if (!(new_item= new Item_ref(&thd->lex->current_select->context,
- ref_pointer_array + el, 0, name)))
+ if (!(new_item= new Item_aggregate_ref(&thd->lex->current_select->context,
+ ref_pointer_array + el, 0, name)))
return; // fatal_error is set
fields.push_front(real_itm);
thd->change_item_tree(ref, new_item);