~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/func.h

  • Committer: Monty Taylor
  • Date: 2009-04-25 20:29:54 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 1003.
  • Revision ID: mordred@inaugust.com-20090425202954-slopmkjj7vxal5lk
Migrated archive.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <drizzled/item.h>
26
26
#include <drizzled/sql_list.h>
27
27
#include <drizzled/item/bin_string.h>
28
 
#include "drizzled/current_session.h"
29
28
 
30
 
namespace drizzled
31
 
{
32
29
 
33
30
class Item_func :public Item_result_field
34
31
{
35
 
  Session &_session;
36
 
 
37
32
protected:
38
33
  Item **args, *tmp_arg[2];
39
34
  /*
63
58
                       OPTIMIZE_EQUAL };
64
59
  enum Type type() const { return FUNC_ITEM; }
65
60
  virtual enum Functype functype() const   { return UNKNOWN_FUNC; }
66
 
  virtual ~Item_func() {}
67
 
 
68
61
  Item_func(void):
69
 
    _session(*current_session),
70
62
    allowed_arg_cols(1), arg_count(0)
71
63
  {
72
64
    with_sum_func= 0;
73
 
    collation.set(DERIVATION_SYSCONST);
74
65
  }
75
 
 
76
66
  Item_func(Item *a):
77
 
    _session(*current_session),
78
67
    allowed_arg_cols(1), arg_count(1)
79
68
  {
80
69
    args= tmp_arg;
81
70
    args[0]= a;
82
71
    with_sum_func= a->with_sum_func;
83
 
    collation.set(DERIVATION_SYSCONST);
84
72
  }
85
 
  
86
73
  Item_func(Item *a,Item *b):
87
 
    _session(*current_session),
88
74
    allowed_arg_cols(1), arg_count(2)
89
75
  {
90
76
    args= tmp_arg;
91
77
    args[0]= a; args[1]= b;
92
78
    with_sum_func= a->with_sum_func || b->with_sum_func;
93
 
    collation.set(DERIVATION_SYSCONST);
94
79
  }
95
 
  
96
80
  Item_func(Item *a,Item *b,Item *c):
97
 
    _session(*current_session),
98
81
    allowed_arg_cols(1)
99
82
  {
100
83
    arg_count= 0;
101
 
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*3)))
 
84
    if ((args= (Item**) sql_alloc(sizeof(Item*)*3)))
102
85
    {
103
86
      arg_count= 3;
104
87
      args[0]= a; args[1]= b; args[2]= c;
105
88
      with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
106
89
    }
107
 
    collation.set(DERIVATION_SYSCONST);
108
90
  }
109
 
  
110
91
  Item_func(Item *a,Item *b,Item *c,Item *d):
111
 
    _session(*current_session),
112
92
    allowed_arg_cols(1)
113
93
  {
114
94
    arg_count= 0;
115
 
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*4)))
 
95
    if ((args= (Item**) sql_alloc(sizeof(Item*)*4)))
116
96
    {
117
97
      arg_count= 4;
118
98
      args[0]= a; args[1]= b; args[2]= c; args[3]= d;
119
99
      with_sum_func= a->with_sum_func || b->with_sum_func ||
120
100
        c->with_sum_func || d->with_sum_func;
121
101
    }
122
 
    collation.set(DERIVATION_SYSCONST);
123
102
  }
124
 
  
125
103
  Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):
126
 
    _session(*current_session),
127
104
    allowed_arg_cols(1)
128
105
  {
129
106
    arg_count= 5;
130
 
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*5)))
 
107
    if ((args= (Item**) sql_alloc(sizeof(Item*)*5)))
131
108
    {
132
109
      args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;
133
110
      with_sum_func= a->with_sum_func || b->with_sum_func ||
134
111
        c->with_sum_func || d->with_sum_func || e->with_sum_func ;
135
112
    }
136
 
    collation.set(DERIVATION_SYSCONST);
137
113
  }
138
 
  
139
114
  Item_func(List<Item> &list);
140
 
  
141
115
  // Constructor used for Item_cond_and/or (see Item comment)
142
116
  Item_func(Session *session, Item_func *item);
143
 
  
144
117
  bool fix_fields(Session *, Item **ref);
145
118
  void fix_after_pullout(Select_Lex *new_parent, Item **ref);
146
119
  table_map used_tables() const;
160
133
    {Sum}Functype and Item_func::functype()/Item_sum::sum_func()
161
134
    instead.
162
135
  */
163
 
  virtual const char *func_name() const { return NULL; }
 
136
  virtual const char *func_name() const { return NULL; };
164
137
  virtual bool const_item() const { return const_item_cache; }
165
138
  Item **arguments() const { return args; }
166
139
  void set_arguments(List<Item> &list);
167
140
  uint32_t argument_count() const { return arg_count; }
168
141
  void remove_arguments() { arg_count=0; }
169
 
 
170
 
  /**
171
 
   * Check if the UDF supports the number of arguments passed in
172
 
   * @param number of args
173
 
   */
174
 
  virtual bool check_argument_count(int) { return true ; }
175
142
  virtual void split_sum_func(Session *session, Item **ref_pointer_array,
176
143
                              List<Item> &fields);
177
144
 
212
179
                     void * arg, traverse_order order);
213
180
  double fix_result(double value);
214
181
 
215
 
  Session &getSession()
216
 
  {
217
 
    return _session;
218
 
  }
219
 
 
220
 
  Session *getSessionPtr()
221
 
  {
222
 
    return &_session;
223
 
  }
224
 
 
225
182
};
226
183
 
227
 
} /* namespace drizzled */
228
 
 
229
184
 
230
185
#endif /* DRIZZLED_FUNCTION_FUNC_H */