summaryrefslogtreecommitdiff
path: root/sql/item_sum.h
diff options
context:
space:
mode:
authorunknown <holyfoot/hf@mysql.com/deer.(none)>2006-11-17 10:30:16 +0400
committerunknown <holyfoot/hf@mysql.com/deer.(none)>2006-11-17 10:30:16 +0400
commit96ad04dec087442aaa60eff7a74d8f8910a5e422 (patch)
treecb20b9f192e4db85bad99d431083278909cfe454 /sql/item_sum.h
parente971334eced6516f92ea5b63b06ac703e145192b (diff)
parent1019dd404c273b722daa4039d42b1a920439e6b1 (diff)
downloadmariadb-git-96ad04dec087442aaa60eff7a74d8f8910a5e422.tar.gz
Merge bk@192.168.21.1:mysql-5.0-opt
into mysql.com:/home/hf/work/mysql-5.0-0mrg BitKeeper/deleted/.del-mysql_client.test: Auto merged include/mysql.h: Auto merged libmysqld/lib_sql.cc: Auto merged mysql-test/r/order_by.result: Auto merged mysql-test/r/query_cache.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/type_newdecimal.result: Auto merged mysql-test/t/flush.test: Auto merged mysql-test/t/flush_block_commit.test: Auto merged mysql-test/t/innodb-deadlock.test: Auto merged mysql-test/t/innodb-lock.test: Auto merged mysql-test/t/lock_multi.test: Auto merged mysql-test/t/mysql.test: Auto merged mysql-test/t/query_cache.test: Auto merged mysql-test/t/rename.test: Auto merged mysql-test/t/show_check.test: Auto merged mysql-test/t/status.test: Auto merged mysql-test/t/subselect.test: Auto merged mysql-test/t/type_newdecimal.test: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/handler.cc: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_subselect.cc: Auto merged sql/item_subselect.h: Auto merged sql/item_sum.cc: Auto merged sql/item_sum.h: Auto merged sql/item_timefunc.cc: Auto merged sql/item_timefunc.h: Auto merged sql/mysql_priv.h: Auto merged sql/protocol.cc: Auto merged sql/protocol.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.cc: Auto merged sql-common/client.c: Auto merged sql-common/my_time.c: Auto merged Makefile.am: merging client/mysqltest.c: merging include/my_time.h: merging libmysql/libmysql.c: merging mysql-test/t/order_by.test: merging
Diffstat (limited to 'sql/item_sum.h')
-rw-r--r--sql/item_sum.h34
1 files changed, 26 insertions, 8 deletions
diff --git a/sql/item_sum.h b/sql/item_sum.h
index fe7edd76ecf..c11ef7e548a 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -352,12 +352,23 @@ public:
class Item_sum_num :public Item_sum
{
+protected:
+ /*
+ val_xxx() functions may be called several times during the execution of a
+ query. Derived classes that require extensive calculation in val_xxx()
+ maintain cache of aggregate value. This variable governs the validity of
+ that cache.
+ */
+ bool is_evaluated;
public:
- Item_sum_num() :Item_sum() {}
- Item_sum_num(Item *item_par) :Item_sum(item_par) {}
- Item_sum_num(Item *a, Item* b) :Item_sum(a,b) {}
- Item_sum_num(List<Item> &list) :Item_sum(list) {}
- Item_sum_num(THD *thd, Item_sum_num *item) :Item_sum(thd, item) {}
+ Item_sum_num() :Item_sum(),is_evaluated(FALSE) {}
+ Item_sum_num(Item *item_par)
+ :Item_sum(item_par), is_evaluated(FALSE) {}
+ Item_sum_num(Item *a, Item* b) :Item_sum(a,b),is_evaluated(FALSE) {}
+ Item_sum_num(List<Item> &list)
+ :Item_sum(list), is_evaluated(FALSE) {}
+ Item_sum_num(THD *thd, Item_sum_num *item)
+ :Item_sum(thd, item),is_evaluated(item->is_evaluated) {}
bool fix_fields(THD *, Item **);
longlong val_int()
{
@@ -540,6 +551,12 @@ class Item_sum_count_distinct :public Item_sum_int
*/
Unique *tree;
/*
+ Storage for the value of count between calls to val_int() so val_int()
+ will not recalculate on each call. Validitiy of the value is stored in
+ is_evaluated.
+ */
+ longlong count;
+ /*
Following is 0 normal object and pointer to original one for copy
(to correctly free resources)
*/
@@ -556,14 +573,15 @@ class Item_sum_count_distinct :public Item_sum_int
public:
Item_sum_count_distinct(List<Item> &list)
:Item_sum_int(list), table(0), field_lengths(0), tmp_table_param(0),
- force_copy_fields(0), tree(0), original(0), always_null(FALSE)
+ force_copy_fields(0), tree(0), count(0),
+ original(0), always_null(FALSE)
{ quick_group= 0; }
Item_sum_count_distinct(THD *thd, Item_sum_count_distinct *item)
:Item_sum_int(thd, item), table(item->table),
field_lengths(item->field_lengths),
tmp_table_param(item->tmp_table_param),
- force_copy_fields(0), tree(item->tree), original(item),
- tree_key_length(item->tree_key_length),
+ force_copy_fields(0), tree(item->tree), count(item->count),
+ original(item), tree_key_length(item->tree_key_length),
always_null(item->always_null)
{}
~Item_sum_count_distinct();