~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/sum.h

  • Committer: Brian Aker
  • Date: 2009-01-24 09:43:35 UTC
  • Revision ID: brian@gir-3.local-20090124094335-6qdtvc35gl5fvivz
Adding in an example singe thread scheduler

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_ITEM_SUM_H
21
 
#define DRIZZLED_ITEM_SUM_H
 
20
#ifndef DRIZZLED_SUM_H
 
21
#define DRIZZLED_SUM_H
22
22
 
23
23
/* classes for sum functions */
24
24
 
25
25
 
26
 
#include "drizzled/tree.h"
 
26
#include <mysys/my_tree.h>
27
27
#include <drizzled/hybrid_type.h>
28
28
#include <drizzled/item.h>
29
29
#include <drizzled/item/field.h>
30
30
#include <drizzled/item/bin_string.h>
31
31
 
32
 
namespace drizzled
33
 
{
34
 
 
35
 
int group_concat_key_cmp_with_distinct(void* arg, const void* key1,
36
 
                                       const void* key2);
37
 
 
38
 
int group_concat_key_cmp_with_order(void* arg, const void* key1,
39
 
                                    const void* key2);
40
 
 
41
 
class Select_Lex;
 
32
 
 
33
class st_select_lex;
42
34
struct order_st;
43
35
 
44
36
/*
223
215
  and reports an error if it is illegal.
224
216
  The method register_sum_func serves to link the items for the set functions
225
217
  that are aggregated in the embedding (sub)queries. Circular chains of such
226
 
  functions are attached to the corresponding Select_Lex structures
 
218
  functions are attached to the corresponding st_select_lex structures
227
219
  through the field inner_sum_func_list.
228
220
 
229
221
  Exploiting the fact that the members mentioned above are used in one
250
242
  Item_sum *next; /* next in the circular chain of registered objects  */
251
243
  uint32_t arg_count;
252
244
  Item_sum *in_sum_func;  /* embedding set function if any */
253
 
  Select_Lex * aggr_sel; /* select where the function is aggregated       */
 
245
  st_select_lex * aggr_sel; /* select where the function is aggregated       */
254
246
  int8_t nest_level;        /* number of the nesting level of the set function */
255
247
  int8_t aggr_level;        /* nesting level of the aggregating subquery       */
256
248
  int8_t max_arg_level;     /* max level of unbound column references          */
366
358
    forced_const= true;
367
359
  }
368
360
  virtual bool const_item() const { return forced_const; }
369
 
  void make_field(SendField *field);
 
361
  void make_field(Send_field *field);
370
362
  virtual void print(String *str, enum_query_type query_type);
371
363
  void fix_num_length_and_dec();
372
364
 
389
381
  bool init_sum_func_check(Session *session);
390
382
  bool check_sum_func(Session *session, Item **ref);
391
383
  bool register_sum_func(Session *session, Item **ref);
392
 
  Select_Lex *depended_from()
 
384
  st_select_lex *depended_from()
393
385
    { return (nest_level == aggr_level ? 0 : aggr_sel); }
394
386
};
395
387
 
562
554
  void clear();
563
555
  void no_rows_in_result() { count=0; }
564
556
  bool add();
565
 
  void make_const_count(int64_t count_arg)
 
557
  void make_const(int64_t count_arg)
566
558
  {
567
559
    count=count_arg;
568
560
    Item_sum::make_const();
576
568
};
577
569
 
578
570
 
579
 
class Tmp_Table_Param;
 
571
class TMP_TABLE_PARAM;
580
572
 
581
573
class Item_sum_count_distinct :public Item_sum_int
582
574
{
583
575
  Table *table;
584
576
  uint32_t *field_lengths;
585
 
  Tmp_Table_Param *tmp_table_param;
 
577
  TMP_TABLE_PARAM *tmp_table_param;
586
578
  bool force_copy_fields;
587
579
  /*
588
580
    If there are no blobs, we can use a tree, which
663
655
  enum_field_types field_type() const
664
656
  {
665
657
    return hybrid_type == DECIMAL_RESULT ?
666
 
      DRIZZLE_TYPE_DECIMAL : DRIZZLE_TYPE_DOUBLE;
 
658
      DRIZZLE_TYPE_NEWDECIMAL : DRIZZLE_TYPE_DOUBLE;
667
659
  }
668
660
  void fix_length_and_dec() {}
669
661
  enum Item_result result_type () const { return hybrid_type; }
730
722
  enum_field_types field_type() const
731
723
  {
732
724
    return hybrid_type == DECIMAL_RESULT ?
733
 
      DRIZZLE_TYPE_DECIMAL : DRIZZLE_TYPE_DOUBLE;
 
725
      DRIZZLE_TYPE_NEWDECIMAL : DRIZZLE_TYPE_DOUBLE;
734
726
  }
735
727
  void fix_length_and_dec() {}
736
728
  enum Item_result result_type () const { return hybrid_type; }
966
958
 
967
959
class Item_func_group_concat : public Item_sum
968
960
{
969
 
  Tmp_Table_Param *tmp_table_param;
 
961
  TMP_TABLE_PARAM *tmp_table_param;
970
962
  DRIZZLE_ERROR *warning;
971
963
  String result;
972
964
  String *separator;
1004
996
                                                const void* key2);
1005
997
  friend int group_concat_key_cmp_with_order(void* arg, const void* key1,
1006
998
                                             const void* key2);
1007
 
  friend int dump_leaf_key(unsigned char* key, uint32_t,
 
999
  friend int dump_leaf_key(unsigned char* key, element_count,
1008
1000
                           Item_func_group_concat *group_concat_item);
1009
1001
 
1010
1002
public:
1033
1025
  bool fix_fields(Session *,Item **);
1034
1026
  bool setup(Session *session);
1035
1027
  void make_unique();
1036
 
  double val_real();
1037
 
  int64_t val_int();
 
1028
  double val_real()
 
1029
  {
 
1030
    String *res;  res=val_str(&str_value);
 
1031
    return res ? my_atof(res->c_ptr()) : 0.0;
 
1032
  }
 
1033
  int64_t val_int()
 
1034
  {
 
1035
    String *res;
 
1036
    char *end_ptr;
 
1037
    int error;
 
1038
    if (!(res= val_str(&str_value)))
 
1039
      return (int64_t) 0;
 
1040
    end_ptr= (char*) res->ptr()+ res->length();
 
1041
    return my_strtoll10(res->ptr(), &end_ptr, &error);
 
1042
  }
1038
1043
  my_decimal *val_decimal(my_decimal *decimal_value)
1039
1044
  {
1040
1045
    return val_decimal_from_string(decimal_value);
1047
1052
    { context= (Name_resolution_context *)cntx; return false; }
1048
1053
};
1049
1054
 
1050
 
} /* namespace drizzled */
1051
 
 
1052
1055
#endif /* DRIZZLED_ITEM_SUM_H */