17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_ITEM_SUM_H
21
#define DRIZZLED_ITEM_SUM_H
23
21
/* classes for sum functions */
26
#include "drizzled/tree.h"
27
#include <drizzled/hybrid_type.h>
28
#include <drizzled/item.h>
29
#include <drizzled/item/field.h>
30
#include <drizzled/item/bin_string.h>
35
int group_concat_key_cmp_with_distinct(void* arg, const void* key1,
38
int group_concat_key_cmp_with_order(void* arg, const void* key1,
24
#include <mysys/my_tree.h>
45
27
Class Item_sum is the base class used for special expressions that SQL calls
51
33
A set function cannot be used in certain positions where expressions are
52
accepted. There are some quite explicable restrictions for the usage of
34
accepted. There are some quite explicable restrictions for the usage of
56
38
SELECT AVG(b) FROM t1 WHERE SUM(b) > 20 GROUP by a
57
39
the usage of the set function AVG(b) is legal, while the usage of SUM(b)
58
is illegal. A WHERE condition must contain expressions that can be
40
is illegal. A WHERE condition must contain expressions that can be
59
41
evaluated for each row of the table. Yet the expression SUM(b) can be
60
42
evaluated only for each group of rows with the same value of column a.
80
62
The problem of finding the query where to aggregate a particular
81
63
set function is not so simple as it seems to be.
84
66
SELECT t1.a FROM t1 GROUP BY t1.a
85
67
HAVING t1.a > ALL(SELECT t2.c FROM t2 GROUP BY t2.c
86
68
HAVING SUM(t1.a) < t2.c)
87
69
the set function can be evaluated for both outer and inner selects.
88
70
If we evaluate SUM(t1.a) for the outer query then we get the value of t1.a
89
multiplied by the cardinality of a group in table t1. In this case
71
multiplied by the cardinality of a group in table t1. In this case
90
72
in each correlated subquery SUM(t1.a) is used as a constant. But we also
91
73
can evaluate SUM(t1.a) for the inner query. In this case t1.a will be a
92
74
constant for each correlated subquery and summation is performed
93
75
for each group of table t2.
94
76
(Here it makes sense to remind that the query
95
SELECT c FROM t GROUP BY a HAVING SUM(1) < a
77
SELECT c FROM t GROUP BY a HAVING SUM(1) < a
96
78
is quite legal in our SQL).
98
80
So depending on what query we assign the set function to we
135
117
3. SELECT t1.a FROM t1 GROUP BY t1.a
136
118
HAVING t1.a > ALL(SELECT t2.b FROM t2
137
WHERE t2.b > ALL (SELECT t3.c FROM t3
119
WHERE t2.b > ALL (SELECT t3.c FROM t3
138
120
WHERE SUM(t1.a+t2.b) < t3.c))
139
121
In this query evaluation of SUM(t1.a+t2.b) is not legal neither in the second
140
122
nor in the third subqueries. So this query is invalid.
163
145
SELECT t2.c FROM t2 GROUP BY t2.c HAVING AVG(t2.c+s)
164
146
than returns some result set.
166
By the same reason the following query with a subquery
148
By the same reason the following query with a subquery
167
149
SELECT t1.a FROM t1 GROUP BY t1.a
168
150
HAVING t1.a IN (SELECT t2.c FROM t2 GROUP BY t2.c
169
151
HAVING AVG(SUM(t1.b)) > 20)
223
205
and reports an error if it is illegal.
224
206
The method register_sum_func serves to link the items for the set functions
225
207
that are aggregated in the embedding (sub)queries. Circular chains of such
226
functions are attached to the corresponding Select_Lex structures
208
functions are attached to the corresponding st_select_lex structures
227
209
through the field inner_sum_func_list.
229
211
Exploiting the fact that the members mentioned above are used in one
230
212
recursive function we could have allocated them on the thread stack.
231
213
Yet we don't do it now.
233
215
We assume that the nesting level of subquries does not exceed 127.
234
216
TODO: to catch queries where the limit is exceeded to make the
239
223
class Item_sum :public Item_result_field
249
233
Item **ref_by; /* pointer to a ref to the object used to register it */
250
234
Item_sum *next; /* next in the circular chain of registered objects */
251
235
uint32_t arg_count;
252
Item_sum *in_sum_func; /* embedding set function if any */
253
Select_Lex * aggr_sel; /* select where the function is aggregated */
236
Item_sum *in_sum_func; /* embedding set function if any */
237
st_select_lex * aggr_sel; /* select where the function is aggregated */
254
238
int8_t nest_level; /* number of the nesting level of the set function */
255
239
int8_t aggr_level; /* nesting level of the aggregating subquery */
256
240
int8_t max_arg_level; /* max level of unbound column references */
265
249
List<Item_field> outer_fields;
268
252
table_map used_tables_cache;
269
253
bool forced_const;
273
257
void mark_as_sum_func();
274
258
Item_sum() :arg_count(0), quick_group(1), forced_const(false)
276
260
mark_as_sum_func();
278
Item_sum(Item *a) :args(tmp_args), arg_count(1), quick_group(1),
262
Item_sum(Item *a) :args(tmp_args), arg_count(1), quick_group(1),
279
263
forced_const(false)
290
274
Item_sum(List<Item> &list);
291
275
//Copy constructor, need to perform subselects with temporary tables
292
Item_sum(Session *session, Item_sum *item);
276
Item_sum(THD *thd, Item_sum *item);
293
277
enum Type type() const { return SUM_FUNC_ITEM; }
294
278
virtual enum Sumfunctype sum_func () const=0;
354
338
{ return new Item_field(field); }
355
339
table_map used_tables() const { return used_tables_cache; }
356
340
void update_used_tables ();
362
346
bool is_null() { return null_value; }
365
used_tables_cache= 0;
349
used_tables_cache= 0;
368
352
virtual bool const_item() const { return forced_const; }
369
void make_field(SendField *field);
353
void make_field(Send_field *field);
370
354
virtual void print(String *str, enum_query_type query_type);
371
355
void fix_num_length_and_dec();
381
365
void no_rows_in_result() { clear(); }
383
virtual bool setup(Session *) {return 0;}
367
virtual bool setup(THD *thd __attribute__((unused))) {return 0;}
384
368
virtual void make_unique(void) {}
385
Item *get_tmp_table_item(Session *session);
369
Item *get_tmp_table_item(THD *thd);
386
370
virtual Field *create_tmp_field(bool group, Table *table,
387
371
uint32_t convert_blob_length);
388
372
bool walk(Item_processor processor, bool walk_subquery, unsigned char *argument);
389
bool init_sum_func_check(Session *session);
390
bool check_sum_func(Session *session, Item **ref);
391
bool register_sum_func(Session *session, Item **ref);
392
Select_Lex *depended_from()
373
bool init_sum_func_check(THD *thd);
374
bool check_sum_func(THD *thd, Item **ref);
375
bool register_sum_func(THD *thd, Item **ref);
376
st_select_lex *depended_from()
393
377
{ return (nest_level == aggr_level ? 0 : aggr_sel); }
401
val_xxx() functions may be called several times during the execution of a
385
val_xxx() functions may be called several times during the execution of a
402
386
query. Derived classes that require extensive calculation in val_xxx()
403
maintain cache of aggregate value. This variable governs the validity of
387
maintain cache of aggregate value. This variable governs the validity of
406
390
bool is_evaluated;
408
392
Item_sum_num() :Item_sum(),is_evaluated(false) {}
409
Item_sum_num(Item *item_par)
393
Item_sum_num(Item *item_par)
410
394
:Item_sum(item_par), is_evaluated(false) {}
411
395
Item_sum_num(Item *a, Item* b) :Item_sum(a,b),is_evaluated(false) {}
412
Item_sum_num(List<Item> &list)
396
Item_sum_num(List<Item> &list)
413
397
:Item_sum(list), is_evaluated(false) {}
414
Item_sum_num(Session *session, Item_sum_num *item)
415
:Item_sum(session, item),is_evaluated(item->is_evaluated) {}
416
bool fix_fields(Session *, Item **);
398
Item_sum_num(THD *thd, Item_sum_num *item)
399
:Item_sum(thd, item),is_evaluated(item->is_evaluated) {}
400
bool fix_fields(THD *, Item **);
404
return (int64_t) rint(val_real()); /* Real as default */
418
406
String *val_str(String*str);
419
407
my_decimal *val_decimal(my_decimal *);
420
408
void reset_field();
427
415
Item_sum_int(Item *item_par) :Item_sum_num(item_par) {}
428
416
Item_sum_int(List<Item> &list) :Item_sum_num(list) {}
429
Item_sum_int(Session *session, Item_sum_int *item) :Item_sum_num(session, item) {}
417
Item_sum_int(THD *thd, Item_sum_int *item) :Item_sum_num(thd, item) {}
430
418
double val_real() { assert(fixed == 1); return (double) val_int(); }
431
419
String *val_str(String*str);
432
420
my_decimal *val_decimal(my_decimal *);
449
437
Item_sum_sum(Item *item_par) :Item_sum_num(item_par) {}
450
Item_sum_sum(Session *session, Item_sum_sum *item);
438
Item_sum_sum(THD *thd, Item_sum_sum *item);
451
439
enum Sumfunctype sum_func () const {return SUM_FUNC;}
481
469
enum enum_field_types table_field_type;
482
470
uint32_t tree_key_length;
484
Item_sum_distinct(Session *session, Item_sum_distinct *item);
472
Item_sum_distinct(THD *thd, Item_sum_distinct *item);
486
474
Item_sum_distinct(Item *item_par);
487
475
~Item_sum_distinct();
489
bool setup(Session *session);
477
bool setup(THD *thd);
502
490
void update_field() {} // not used
503
491
virtual void no_rows_in_result() {}
504
492
void fix_length_and_dec();
505
enum Item_result result_type () const;
493
enum Item_result result_type () const { return val.traits->type(); }
506
494
virtual void calculate_val_and_count();
507
495
virtual bool unique_walk_function(void *elem);
517
505
class Item_sum_sum_distinct :public Item_sum_distinct
520
Item_sum_sum_distinct(Session *session, Item_sum_sum_distinct *item)
521
:Item_sum_distinct(session, item) {}
508
Item_sum_sum_distinct(THD *thd, Item_sum_sum_distinct *item)
509
:Item_sum_distinct(thd, item) {}
523
511
Item_sum_sum_distinct(Item *item_arg) :Item_sum_distinct(item_arg) {}
525
513
enum Sumfunctype sum_func () const { return SUM_DISTINCT_FUNC; }
526
514
const char *func_name() const { return "sum(distinct "; }
527
Item *copy_or_same(Session* session) { return new Item_sum_sum_distinct(session, this); }
515
Item *copy_or_same(THD* thd) { return new Item_sum_sum_distinct(thd, this); }
533
521
class Item_sum_avg_distinct: public Item_sum_distinct
536
Item_sum_avg_distinct(Session *session, Item_sum_avg_distinct *original)
537
:Item_sum_distinct(session, original) {}
524
Item_sum_avg_distinct(THD *thd, Item_sum_avg_distinct *original)
525
:Item_sum_distinct(thd, original) {}
539
527
uint32_t prec_increment;
540
528
Item_sum_avg_distinct(Item *item_arg) : Item_sum_distinct(item_arg) {}
543
531
virtual void calculate_val_and_count();
544
532
enum Sumfunctype sum_func () const { return AVG_DISTINCT_FUNC; }
545
533
const char *func_name() const { return "avg(distinct "; }
546
Item *copy_or_same(Session* session) { return new Item_sum_avg_distinct(session, this); }
534
Item *copy_or_same(THD* thd) { return new Item_sum_avg_distinct(thd, this); }
555
543
Item_sum_count(Item *item_par)
556
544
:Item_sum_int(item_par),count(0)
558
Item_sum_count(Session *session, Item_sum_count *item)
559
:Item_sum_int(session, item), count(item->count)
546
Item_sum_count(THD *thd, Item_sum_count *item)
547
:Item_sum_int(thd, item), count(item->count)
561
549
enum Sumfunctype sum_func () const { return COUNT_FUNC; }
563
551
void no_rows_in_result() { count=0; }
565
void make_const_count(int64_t count_arg)
553
void make_const(int64_t count_arg)
568
556
Item_sum::make_const();
573
561
void update_field();
574
562
const char *func_name() const { return "count("; }
575
Item *copy_or_same(Session* session);
563
Item *copy_or_same(THD* thd);
579
class Tmp_Table_Param;
567
class TMP_TABLE_PARAM;
581
569
class Item_sum_count_distinct :public Item_sum_int
584
572
uint32_t *field_lengths;
585
Tmp_Table_Param *tmp_table_param;
573
TMP_TABLE_PARAM *tmp_table_param;
586
574
bool force_copy_fields;
588
576
If there are no blobs, we can use a tree, which
616
604
force_copy_fields(0), tree(0), count(0),
617
605
original(0), always_null(false)
618
606
{ quick_group= 0; }
619
Item_sum_count_distinct(Session *session, Item_sum_count_distinct *item)
620
:Item_sum_int(session, item), table(item->table),
607
Item_sum_count_distinct(THD *thd, Item_sum_count_distinct *item)
608
:Item_sum_int(thd, item), table(item->table),
621
609
field_lengths(item->field_lengths),
622
610
tmp_table_param(item->tmp_table_param),
623
force_copy_fields(0), tree(item->tree), count(item->count),
611
force_copy_fields(0), tree(item->tree), count(item->count),
624
612
original(item), tree_key_length(item->tree_key_length),
625
613
always_null(item->always_null)
635
623
void reset_field() { return ;} // Never called
636
624
void update_field() { return ; } // Never called
637
625
const char *func_name() const { return "count(distinct "; }
638
bool setup(Session *session);
626
bool setup(THD *thd);
639
627
void make_unique();
640
Item *copy_or_same(Session* session);
628
Item *copy_or_same(THD* thd);
641
629
void no_rows_in_result() {}
663
651
enum_field_types field_type() const
665
653
return hybrid_type == DECIMAL_RESULT ?
666
DRIZZLE_TYPE_DECIMAL : DRIZZLE_TYPE_DOUBLE;
654
DRIZZLE_TYPE_NEWDECIMAL : DRIZZLE_TYPE_DOUBLE;
668
656
void fix_length_and_dec() {}
669
657
enum Item_result result_type () const { return hybrid_type; }
678
666
uint32_t f_precision, f_scale, dec_bin_size;
680
668
Item_sum_avg(Item *item_par) :Item_sum_sum(item_par), count(0) {}
681
Item_sum_avg(Session *session, Item_sum_avg *item)
682
:Item_sum_sum(session, item), count(item->count),
669
Item_sum_avg(THD *thd, Item_sum_avg *item)
670
:Item_sum_sum(thd, item), count(item->count),
683
671
prec_increment(item->prec_increment) {}
685
673
void fix_length_and_dec();
689
677
double val_real();
690
678
// In SPs we might force the "wrong" type with select into a declare variable
679
int64_t val_int() { return (int64_t) rint(val_real()); }
692
680
my_decimal *val_decimal(my_decimal *);
693
681
String *val_str(String *str);
694
682
void reset_field();
695
683
void update_field();
696
Item *result_item(Field *)
684
Item *result_item(Field *field __attribute__((unused)))
697
685
{ return new Item_avg_field(hybrid_type, this); }
698
686
void no_rows_in_result() {}
699
687
const char *func_name() const { return "avg("; }
700
Item *copy_or_same(Session* session);
688
Item *copy_or_same(THD* thd);
701
689
Field *create_tmp_field(bool group, Table *table, uint32_t convert_blob_length);
721
709
Item_variance_field(Item_sum_variance *item);
722
710
enum Type type() const {return FIELD_VARIANCE_ITEM; }
723
711
double val_real();
713
{ /* can't be fix_fields()ed */ return (int64_t) rint(val_real()); }
725
714
String *val_str(String *str)
726
715
{ return val_string_from_real(str); }
727
716
my_decimal *val_decimal(my_decimal *dec_buf)
730
719
enum_field_types field_type() const
732
721
return hybrid_type == DECIMAL_RESULT ?
733
DRIZZLE_TYPE_DECIMAL : DRIZZLE_TYPE_DOUBLE;
722
DRIZZLE_TYPE_NEWDECIMAL : DRIZZLE_TYPE_DOUBLE;
735
724
void fix_length_and_dec() {}
736
725
enum Item_result result_type () const { return hybrid_type; }
743
732
= sum (ai - avg(a))^2 / count(a) )
744
733
= sum (ai^2 - 2*ai*avg(a) + avg(a)^2) / count(a)
745
= (sum(ai^2) - sum(2*ai*avg(a)) + sum(avg(a)^2))/count(a) =
746
= (sum(ai^2) - 2*avg(a)*sum(a) + count(a)*avg(a)^2)/count(a) =
747
= (sum(ai^2) - 2*sum(a)*sum(a)/count(a) + count(a)*sum(a)^2/count(a)^2 )/count(a) =
748
= (sum(ai^2) - 2*sum(a)^2/count(a) + sum(a)^2/count(a) )/count(a) =
734
= (sum(ai^2) - sum(2*ai*avg(a)) + sum(avg(a)^2))/count(a) =
735
= (sum(ai^2) - 2*avg(a)*sum(a) + count(a)*avg(a)^2)/count(a) =
736
= (sum(ai^2) - 2*sum(a)*sum(a)/count(a) + count(a)*sum(a)^2/count(a)^2 )/count(a) =
737
= (sum(ai^2) - 2*sum(a)^2/count(a) + sum(a)^2/count(a) )/count(a) =
749
738
= (sum(ai^2) - sum(a)^2/count(a))/count(a)
751
740
But, this falls prey to catastrophic cancellation. Instead, use the recurrence formulas
753
M_{1} = x_{1}, ~ M_{k} = M_{k-1} + (x_{k} - M_{k-1}) / k newline
742
M_{1} = x_{1}, ~ M_{k} = M_{k-1} + (x_{k} - M_{k-1}) / k newline
754
743
S_{1} = 0, ~ S_{k} = S_{k-1} + (x_{k} - M_{k-1}) times (x_{k} - M_{k}) newline
755
744
for 2 <= k <= n newline
756
745
ital variance = S_{n} / (n-1)
775
764
Item_sum_variance(Item *item_par, uint32_t sample_arg) :Item_sum_num(item_par),
776
765
hybrid_type(REAL_RESULT), count(0), sample(sample_arg)
778
Item_sum_variance(Session *session, Item_sum_variance *item);
767
Item_sum_variance(THD *thd, Item_sum_variance *item);
779
768
enum Sumfunctype sum_func () const { return VARIANCE_FUNC; }
782
771
double val_real();
784
772
my_decimal *val_decimal(my_decimal *);
785
773
void reset_field();
786
774
void update_field();
787
Item *result_item(Field *)
775
Item *result_item(Field *field __attribute__((unused)))
788
776
{ return new Item_variance_field(this); }
789
777
void no_rows_in_result() {}
790
778
const char *func_name() const
791
779
{ return sample ? "var_samp(" : "variance("; }
792
Item *copy_or_same(Session* session);
780
Item *copy_or_same(THD* thd);
793
781
Field *create_tmp_field(bool group, Table *table, uint32_t convert_blob_length);
794
782
enum Item_result result_type () const { return REAL_RESULT; }
822
810
Item_sum_std(Item *item_par, uint32_t sample_arg)
823
811
:Item_sum_variance(item_par, sample_arg) {}
824
Item_sum_std(Session *session, Item_sum_std *item)
825
:Item_sum_variance(session, item)
812
Item_sum_std(THD *thd, Item_sum_std *item)
813
:Item_sum_variance(thd, item)
827
815
enum Sumfunctype sum_func () const { return STD_FUNC; }
828
816
double val_real();
829
Item *result_item(Field *)
817
Item *result_item(Field *field __attribute__((unused)))
830
818
{ return new Item_std_field(this); }
831
819
const char *func_name() const { return "std("; }
832
Item *copy_or_same(Session* session);
820
Item *copy_or_same(THD* thd);
833
821
enum Item_result result_type () const { return REAL_RESULT; }
834
822
enum_field_types field_type() const { return DRIZZLE_TYPE_DOUBLE;}
854
842
hybrid_type(INT_RESULT), hybrid_field_type(DRIZZLE_TYPE_LONGLONG),
855
843
cmp_sign(sign), was_values(true)
856
844
{ collation.set(&my_charset_bin); }
857
Item_sum_hybrid(Session *session, Item_sum_hybrid *item);
858
bool fix_fields(Session *, Item **);
845
Item_sum_hybrid(THD *thd, Item_sum_hybrid *item);
846
bool fix_fields(THD *, Item **);
860
848
double val_real();
861
849
int64_t val_int();
884
872
Item_sum_min(Item *item_par) :Item_sum_hybrid(item_par,1) {}
885
Item_sum_min(Session *session, Item_sum_min *item) :Item_sum_hybrid(session, item) {}
873
Item_sum_min(THD *thd, Item_sum_min *item) :Item_sum_hybrid(thd, item) {}
886
874
enum Sumfunctype sum_func () const {return MIN_FUNC;}
889
877
const char *func_name() const { return "min("; }
890
Item *copy_or_same(Session* session);
878
Item *copy_or_same(THD* thd);
897
885
Item_sum_max(Item *item_par) :Item_sum_hybrid(item_par,-1) {}
898
Item_sum_max(Session *session, Item_sum_max *item) :Item_sum_hybrid(session, item) {}
886
Item_sum_max(THD *thd, Item_sum_max *item) :Item_sum_hybrid(thd, item) {}
899
887
enum Sumfunctype sum_func () const {return MAX_FUNC;}
902
890
const char *func_name() const { return "max("; }
903
Item *copy_or_same(Session* session);
891
Item *copy_or_same(THD* thd);
913
901
Item_sum_bit(Item *item_par,uint64_t reset_arg)
914
902
:Item_sum_int(item_par),reset_bits(reset_arg),bits(reset_arg) {}
915
Item_sum_bit(Session *session, Item_sum_bit *item):
916
Item_sum_int(session, item), reset_bits(item->reset_bits), bits(item->bits) {}
903
Item_sum_bit(THD *thd, Item_sum_bit *item):
904
Item_sum_int(thd, item), reset_bits(item->reset_bits), bits(item->bits) {}
917
905
enum Sumfunctype sum_func () const {return SUM_BIT_FUNC;}
919
907
int64_t val_int();
935
923
Item_sum_or(Item *item_par) :Item_sum_bit(item_par,0) {}
936
Item_sum_or(Session *session, Item_sum_or *item) :Item_sum_bit(session, item) {}
924
Item_sum_or(THD *thd, Item_sum_or *item) :Item_sum_bit(thd, item) {}
938
926
const char *func_name() const { return "bit_or("; }
939
Item *copy_or_same(Session* session);
927
Item *copy_or_same(THD* thd);
946
934
Item_sum_and(Item *item_par) :Item_sum_bit(item_par, UINT64_MAX) {}
947
Item_sum_and(Session *session, Item_sum_and *item) :Item_sum_bit(session, item) {}
935
Item_sum_and(THD *thd, Item_sum_and *item) :Item_sum_bit(thd, item) {}
949
937
const char *func_name() const { return "bit_and("; }
950
Item *copy_or_same(Session* session);
938
Item *copy_or_same(THD* thd);
953
941
class Item_sum_xor :public Item_sum_bit
956
944
Item_sum_xor(Item *item_par) :Item_sum_bit(item_par,0) {}
957
Item_sum_xor(Session *session, Item_sum_xor *item) :Item_sum_bit(session, item) {}
945
Item_sum_xor(THD *thd, Item_sum_xor *item) :Item_sum_bit(thd, item) {}
959
947
const char *func_name() const { return "bit_xor("; }
960
Item *copy_or_same(Session* session);
948
Item *copy_or_same(THD* thd);
977
965
If DISTINCT is used with this GROUP_CONCAT, this member is used to filter
979
967
@see Item_func_group_concat::setup
980
968
@see Item_func_group_concat::add
981
969
@see Item_func_group_concat::clear
983
971
Unique *unique_filter;
986
974
Name_resolution_context *context;
987
975
/** The number of ORDER BY items. */
988
976
uint32_t arg_count_order;
1004
992
const void* key2);
1005
993
friend int group_concat_key_cmp_with_order(void* arg, const void* key1,
1006
994
const void* key2);
1007
friend int dump_leaf_key(unsigned char* key, uint32_t,
1008
Item_func_group_concat *group_concat_item);
995
friend int dump_leaf_key(unsigned char* key,
996
element_count count __attribute__((unused)),
997
Item_func_group_concat *group_concat_item);
1011
1000
Item_func_group_concat(Name_resolution_context *context_arg,
1012
1001
bool is_distinct, List<Item> *is_select,
1013
1002
SQL_LIST *is_order, String *is_separator);
1015
Item_func_group_concat(Session *session, Item_func_group_concat *item);
1004
Item_func_group_concat(THD *thd, Item_func_group_concat *item);
1016
1005
~Item_func_group_concat();
1017
1006
void cleanup();
1031
1020
void reset_field() { assert(0); } // not used
1032
1021
void update_field() { assert(0); } // not used
1033
bool fix_fields(Session *,Item **);
1034
bool setup(Session *session);
1022
bool fix_fields(THD *,Item **);
1023
bool setup(THD *thd);
1035
1024
void make_unique();
1027
String *res; res=val_str(&str_value);
1028
return res ? my_atof(res->c_ptr()) : 0.0;
1035
if (!(res= val_str(&str_value)))
1037
end_ptr= (char*) res->ptr()+ res->length();
1038
return my_strtoll10(res->ptr(), &end_ptr, &error);
1038
1040
my_decimal *val_decimal(my_decimal *decimal_value)
1040
1042
return val_decimal_from_string(decimal_value);
1042
1044
String* val_str(String* str);
1043
Item *copy_or_same(Session* session);
1045
Item *copy_or_same(THD* thd);
1044
1046
void no_rows_in_result() {}
1045
1047
virtual void print(String *str, enum_query_type query_type);
1046
1048
virtual bool change_context_processor(unsigned char *cntx)
1047
1049
{ context= (Name_resolution_context *)cntx; return false; }
1050
} /* namespace drizzled */
1052
#endif /* DRIZZLED_ITEM_SUM_H */