summaryrefslogtreecommitdiff
path: root/sql/item_sum.h
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-04-05 13:56:05 +0300
committerunknown <monty@mysql.com>2004-04-05 13:56:05 +0300
commit7873b89fc50d420a5f538a5b60faf79131f86c4f (patch)
tree0bfd237ce668df7f8a361ddbc36762c5a16b2bae /sql/item_sum.h
parent9c2e4b0360600840efa1ac396aa2f398ee07f4da (diff)
downloadmariadb-git-7873b89fc50d420a5f538a5b60faf79131f86c4f.tar.gz
Fixed many compiler warnings
Fixed bugs in group_concat with ORDER BY and DISTINCT (Bugs #2695, #3381 and #3319) Fixed crash when doing rollback in slave and the io thread catched up with the sql thread Set locked_in_memory properly include/mysql_com.h: Fixed compiler warning libmysqld/emb_qcache.cc: Removed not used variable libmysqld/lib_sql.cc: Removed not used variable myisam/mi_locking.c: Added comment myisam/mi_rnext.c: Fixed bug in concurrent insert myisam/mi_rprev.c: Simple optimization mysql-test/r/func_gconcat.result: New tests mysql-test/t/func_gconcat.test: New tests mysql-test/t/func_group.test: Cleanup sql-common/client.c: Removed compiler warning sql/derror.cc: Better comments sql/field.cc: Removed not used function/variable sql/field.h: Removed not needed variable sql/ha_innodb.cc: Removed not used function sql/item.cc: Fixed compiler warning sql/item_cmpfunc.cc: Fixed compiler warning sql/item_func.cc: Fixed compiler warning sql/item_geofunc.cc: Fixed compiler warning sql/item_sum.cc: Fixed bugs in group_concat and added more comments (Bugs #2695, #3381 and #3319) - field->abs_offset was not needed - Wrong assumption of field order in temporary table - Some not used variables removed - Added ORDER BY fields after argument fields so that code in sql_select.cc can move all fields to point to temporary tables, if needed. - Optimized loops sql/item_sum.h: Bug fixing and cleanup of group_concat() sql/log.cc: Removed wrong comment sql/log_event.cc: Removed compiler warning sql/mysqld.cc: Set locked_in_memory properly sql/protocol.cc: Removed compiler warning sql/set_var.cc: Code cleanup sql/slave.cc: Fixed crash when doing rollback in slave and the io thread catched up with the sql thread sql/sql_cache.cc: Removed compiler warnings sql/sql_derived.cc: Removed not used variable sql/sql_insert.cc: Removed compiler warnings sql/sql_lex.cc: Removed not used lable sql/sql_lex.h: Removed compiler warnings sql/sql_parse.cc: Removed compiler warnings sql/sql_prepare.cc: Removed compiler warnings sql/sql_select.cc: Removed not used variables Added function comments sql/sql_show.cc: Removed compiler warnings sql/sql_yacc.yy: Fix for ORDER BY handling in GROUP_CONCAT()
Diffstat (limited to 'sql/item_sum.h')
-rw-r--r--sql/item_sum.h85
1 files changed, 34 insertions, 51 deletions
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 1c31f1a9b70..cac080c5807 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -204,18 +204,24 @@ class Item_sum_count_distinct :public Item_sum_int
uint key_length;
CHARSET_INFO *key_charset;
- // calculated based on max_heap_table_size. If reached,
- // walk the tree and dump it into MyISAM table
+ /*
+ Calculated based on max_heap_table_size. If reached,
+ walk the tree and dump it into MyISAM table
+ */
uint max_elements_in_tree;
- // the first few bytes of record ( at least one)
- // are just markers for deleted and NULLs. We want to skip them since
- // they will just bloat the tree without providing any valuable info
+ /*
+ The first few bytes of record ( at least one)
+ are just markers for deleted and NULLs. We want to skip them since
+ they will just bloat the tree without providing any valuable info
+ */
int rec_offset;
- // If there are no blobs, we can use a tree, which
- // is faster than heap table. In that case, we still use the table
- // to help get things set up, but we insert nothing in it
+ /*
+ If there are no blobs, we can use a tree, which
+ is faster than heap table. In that case, we still use the table
+ to help get things set up, but we insert nothing in it
+ */
bool use_tree;
bool always_null; // Set to 1 if the result is always NULL
@@ -236,7 +242,8 @@ class Item_sum_count_distinct :public Item_sum_int
Item_sum_count_distinct(THD *thd, Item_sum_count_distinct *item)
:Item_sum_int(thd, item), table(item->table),
used_table_cache(item->used_table_cache),
- field_lengths(item->field_lengths), tmp_table_param(item->tmp_table_param),
+ field_lengths(item->field_lengths),
+ tmp_table_param(item->tmp_table_param),
tree(item->tree), original(item), key_length(item->key_length),
max_elements_in_tree(item->max_elements_in_tree),
rec_offset(item->rec_offset), use_tree(item->use_tree),
@@ -318,18 +325,17 @@ public:
void fix_length_and_dec() {}
};
-/*
-
-variance(a) =
-
-= sum (ai - avg(a))^2 / count(a) )
-= sum (ai^2 - 2*ai*avg(a) + avg(a)^2) / count(a)
-= (sum(ai^2) - sum(2*ai*avg(a)) + sum(avg(a)^2))/count(a) =
-= (sum(ai^2) - 2*avg(a)*sum(a) + count(a)*avg(a)^2)/count(a) =
-= (sum(ai^2) - 2*sum(a)*sum(a)/count(a) + count(a)*sum(a)^2/count(a)^2 )/count(a) =
-= (sum(ai^2) - 2*sum(a)^2/count(a) + sum(a)^2/count(a) )/count(a) =
-= (sum(ai^2) - sum(a)^2/count(a))/count(a)
+/*
+ variance(a) =
+
+ = sum (ai - avg(a))^2 / count(a) )
+ = sum (ai^2 - 2*ai*avg(a) + avg(a)^2) / count(a)
+ = (sum(ai^2) - sum(2*ai*avg(a)) + sum(avg(a)^2))/count(a) =
+ = (sum(ai^2) - 2*avg(a)*sum(a) + count(a)*avg(a)^2)/count(a) =
+ = (sum(ai^2) - 2*sum(a)*sum(a)/count(a) + count(a)*sum(a)^2/count(a)^2 )/count(a) =
+ = (sum(ai^2) - 2*sum(a)^2/count(a) + sum(a)^2/count(a) )/count(a) =
+ = (sum(ai^2) - sum(a)^2/count(a))/count(a)
*/
class Item_sum_variance : public Item_sum_num
@@ -515,8 +521,9 @@ class Item_sum_xor :public Item_sum_bit
/*
-** user defined aggregates
+ User defined aggregates
*/
+
#ifdef HAVE_DLOPEN
class Item_udf_sum : public Item_sum
@@ -682,12 +689,13 @@ class Item_func_group_concat : public Item_sum
friend int group_concat_key_cmp_with_distinct(void* arg, byte* key1,
byte* key2);
- friend int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2);
+ friend int group_concat_key_cmp_with_order(void* arg, byte* key1,
+ byte* key2);
friend int group_concat_key_cmp_with_distinct_and_order(void* arg,
byte* key1,
byte* key2);
friend int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
- Item_func_group_concat *group_concat_item);
+ Item_func_group_concat *group_concat_item);
public:
String result;
@@ -696,12 +704,13 @@ class Item_func_group_concat : public Item_sum
TREE *tree;
TABLE *table;
ORDER **order;
+ uint *field_offsets;
TABLE_LIST *tables_list;
ulong group_concat_max_len;
uint show_elements;
uint arg_count_order;
uint arg_count_field;
- uint arg_show_fields;
+ uint field_list_offset;
uint count_cut_values;
/*
Following is 0 normal object and pointer to original one for copy
@@ -712,38 +721,12 @@ class Item_func_group_concat : public Item_sum
Item_func_group_concat(bool is_distinct,List<Item> *is_select,
SQL_LIST *is_order,String *is_separator);
- Item_func_group_concat(THD *thd, Item_func_group_concat *item)
- :Item_sum(thd, item),item_thd(thd),
- tmp_table_param(item->tmp_table_param),
- max_elements_in_tree(item->max_elements_in_tree),
- warning(item->warning),
- warning_available(item->warning_available),
- key_length(item->key_length),
- rec_offset(item->rec_offset),
- tree_mode(item->tree_mode),
- distinct(item->distinct),
- warning_for_row(item->warning_for_row),
- separator(item->separator),
- tree(item->tree),
- table(item->table),
- order(item->order),
- tables_list(item->tables_list),
- group_concat_max_len(item->group_concat_max_len),
- show_elements(item->show_elements),
- arg_count_order(item->arg_count_order),
- arg_count_field(item->arg_count_field),
- arg_show_fields(item->arg_show_fields),
- count_cut_values(item->count_cut_values),
- original(item)
- {
- quick_group= item->quick_group;
- };
+ Item_func_group_concat(THD *thd, Item_func_group_concat *item);
~Item_func_group_concat();
void cleanup();
enum Sumfunctype sum_func () const {return GROUP_CONCAT_FUNC;}
const char *func_name() const { return "group_concat"; }
- enum Type type() const { return SUM_FUNC_ITEM; }
virtual Item_result result_type () const { return STRING_RESULT; }
void clear();
bool add();