~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/func.h

edit

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
 
 
21
 
 
22
20
#ifndef DRIZZLED_FUNCTION_FUNC_H
23
21
#define DRIZZLED_FUNCTION_FUNC_H
24
22
 
25
23
/// TODO: Rename this file - func.h is stupid.
26
24
 
27
 
#include <drizzled/charset_info.h>
28
25
#include <drizzled/item.h>
 
26
#include <drizzled/sql_list.h>
29
27
#include <drizzled/item/bin_string.h>
30
 
#include <drizzled/lex_string.h>
31
 
#include <drizzled/sql_list.h>
32
 
#include <drizzled/type/decimal.h>
33
 
 
34
 
#include <drizzled/visibility.h>
 
28
#include "drizzled/current_session.h"
35
29
 
36
30
namespace drizzled
37
31
{
38
32
 
39
 
class DRIZZLED_API Item_func :
40
 
  public Item_result_field
 
33
class Item_func :public Item_result_field
41
34
{
42
35
  Session &_session;
43
36
 
48
41
    0 means get this number from first argument
49
42
  */
50
43
  uint32_t allowed_arg_cols;
51
 
 
52
44
public:
53
45
 
54
46
  using Item::split_sum_func;
73
65
  virtual enum Functype functype() const   { return UNKNOWN_FUNC; }
74
66
  virtual ~Item_func() {}
75
67
 
76
 
  Item_func(void);
 
68
  Item_func(void):
 
69
    _session(*current_session),
 
70
    allowed_arg_cols(1), arg_count(0),
 
71
    const_item_cache(false)
 
72
  {
 
73
    with_sum_func= 0;
 
74
    collation.set(DERIVATION_SYSCONST);
 
75
  }
77
76
 
78
 
  Item_func(Item *a);
79
 
  
80
 
  Item_func(Item *a,Item *b);
81
 
  
82
 
  Item_func(Item *a,Item *b,Item *c);
83
 
  
84
 
  Item_func(Item *a,Item *b,Item *c,Item *d);
85
 
  
86
 
  Item_func(Item *a,Item *b,Item *c,Item *d,Item* e);
 
77
  Item_func(Item *a):
 
78
    _session(*current_session),
 
79
    allowed_arg_cols(1), arg_count(1),
 
80
    const_item_cache(false)
 
81
  {
 
82
    args= tmp_arg;
 
83
    args[0]= a;
 
84
    with_sum_func= a->with_sum_func;
 
85
    collation.set(DERIVATION_SYSCONST);
 
86
  }
 
87
  
 
88
  Item_func(Item *a,Item *b):
 
89
    _session(*current_session),
 
90
    allowed_arg_cols(1), arg_count(2),
 
91
    const_item_cache(false)
 
92
  {
 
93
    args= tmp_arg;
 
94
    args[0]= a; args[1]= b;
 
95
    with_sum_func= a->with_sum_func || b->with_sum_func;
 
96
    collation.set(DERIVATION_SYSCONST);
 
97
  }
 
98
  
 
99
  Item_func(Item *a,Item *b,Item *c):
 
100
    _session(*current_session),
 
101
    allowed_arg_cols(1),
 
102
    const_item_cache(false)
 
103
  {
 
104
    arg_count= 0;
 
105
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*3)))
 
106
    {
 
107
      arg_count= 3;
 
108
      args[0]= a; args[1]= b; args[2]= c;
 
109
      with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
 
110
    }
 
111
    collation.set(DERIVATION_SYSCONST);
 
112
  }
 
113
  
 
114
  Item_func(Item *a,Item *b,Item *c,Item *d):
 
115
    _session(*current_session),
 
116
    allowed_arg_cols(1),
 
117
    const_item_cache(false)
 
118
  {
 
119
    arg_count= 0;
 
120
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*4)))
 
121
    {
 
122
      arg_count= 4;
 
123
      args[0]= a; args[1]= b; args[2]= c; args[3]= d;
 
124
      with_sum_func= a->with_sum_func || b->with_sum_func ||
 
125
        c->with_sum_func || d->with_sum_func;
 
126
    }
 
127
    collation.set(DERIVATION_SYSCONST);
 
128
  }
 
129
  
 
130
  Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):
 
131
    _session(*current_session),
 
132
    allowed_arg_cols(1),
 
133
    const_item_cache(false)
 
134
  {
 
135
    arg_count= 5;
 
136
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*5)))
 
137
    {
 
138
      args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;
 
139
      with_sum_func= a->with_sum_func || b->with_sum_func ||
 
140
        c->with_sum_func || d->with_sum_func || e->with_sum_func ;
 
141
    }
 
142
    collation.set(DERIVATION_SYSCONST);
 
143
  }
87
144
  
88
145
  Item_func(List<Item> &list);
89
146
  
132
189
  void count_real_length();
133
190
  void count_decimal_length();
134
191
 
135
 
  bool get_arg0_date(type::Time &ltime, uint32_t fuzzy_date);
136
 
  bool get_arg0_time(type::Time &ltime);
 
192
  bool get_arg0_date(type::Time *ltime, uint32_t fuzzy_date);
 
193
  bool get_arg0_time(type::Time *ltime);
137
194
 
138
195
  bool is_null();
139
196