~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/func.h

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
 
21
21
 
22
 
#pragma once
 
22
#ifndef DRIZZLED_FUNCTION_FUNC_H
 
23
#define DRIZZLED_FUNCTION_FUNC_H
23
24
 
24
25
/// TODO: Rename this file - func.h is stupid.
25
26
 
26
 
#include <drizzled/charset.h>
 
27
#include <drizzled/charset_info.h>
 
28
#include <drizzled/current_session.h>
27
29
#include <drizzled/item.h>
28
30
#include <drizzled/item/bin_string.h>
29
31
#include <drizzled/lex_string.h>
30
32
#include <drizzled/sql_list.h>
31
33
#include <drizzled/type/decimal.h>
32
34
 
33
 
#include <drizzled/visibility.h>
 
35
#include "drizzled/visibility.h"
34
36
 
35
37
namespace drizzled
36
38
{
37
39
 
38
 
class DRIZZLED_API Item_func : public Item_result_field
 
40
class DRIZZLED_API Item_func :
 
41
  public Item_result_field
39
42
{
 
43
  Session &_session;
 
44
 
40
45
protected:
41
46
  Item **args, *tmp_arg[2];
42
47
  /*
44
49
    0 means get this number from first argument
45
50
  */
46
51
  uint32_t allowed_arg_cols;
47
 
 
48
52
public:
49
53
 
50
54
  using Item::split_sum_func;
69
73
  virtual enum Functype functype() const   { return UNKNOWN_FUNC; }
70
74
  virtual ~Item_func() {}
71
75
 
72
 
  Item_func(void);
 
76
  Item_func(void):
 
77
    _session(*current_session),
 
78
    allowed_arg_cols(1), arg_count(0),
 
79
    const_item_cache(false)
 
80
  {
 
81
    with_sum_func= 0;
 
82
    collation.set(DERIVATION_SYSCONST);
 
83
  }
73
84
 
74
 
  Item_func(Item *a);
75
 
  
76
 
  Item_func(Item *a,Item *b);
77
 
  
78
 
  Item_func(Item *a,Item *b,Item *c);
79
 
  
80
 
  Item_func(Item *a,Item *b,Item *c,Item *d);
81
 
  
82
 
  Item_func(Item *a,Item *b,Item *c,Item *d,Item* e);
 
85
  Item_func(Item *a):
 
86
    _session(*current_session),
 
87
    allowed_arg_cols(1), arg_count(1),
 
88
    const_item_cache(false)
 
89
  {
 
90
    args= tmp_arg;
 
91
    args[0]= a;
 
92
    with_sum_func= a->with_sum_func;
 
93
    collation.set(DERIVATION_SYSCONST);
 
94
  }
 
95
  
 
96
  Item_func(Item *a,Item *b):
 
97
    _session(*current_session),
 
98
    allowed_arg_cols(1), arg_count(2),
 
99
    const_item_cache(false)
 
100
  {
 
101
    args= tmp_arg;
 
102
    args[0]= a; args[1]= b;
 
103
    with_sum_func= a->with_sum_func || b->with_sum_func;
 
104
    collation.set(DERIVATION_SYSCONST);
 
105
  }
 
106
  
 
107
  Item_func(Item *a,Item *b,Item *c):
 
108
    _session(*current_session),
 
109
    allowed_arg_cols(1),
 
110
    const_item_cache(false)
 
111
  {
 
112
    arg_count= 0;
 
113
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*3)))
 
114
    {
 
115
      arg_count= 3;
 
116
      args[0]= a; args[1]= b; args[2]= c;
 
117
      with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
 
118
    }
 
119
    collation.set(DERIVATION_SYSCONST);
 
120
  }
 
121
  
 
122
  Item_func(Item *a,Item *b,Item *c,Item *d):
 
123
    _session(*current_session),
 
124
    allowed_arg_cols(1),
 
125
    const_item_cache(false)
 
126
  {
 
127
    arg_count= 0;
 
128
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*4)))
 
129
    {
 
130
      arg_count= 4;
 
131
      args[0]= a; args[1]= b; args[2]= c; args[3]= d;
 
132
      with_sum_func= a->with_sum_func || b->with_sum_func ||
 
133
        c->with_sum_func || d->with_sum_func;
 
134
    }
 
135
    collation.set(DERIVATION_SYSCONST);
 
136
  }
 
137
  
 
138
  Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):
 
139
    _session(*current_session),
 
140
    allowed_arg_cols(1),
 
141
    const_item_cache(false)
 
142
  {
 
143
    arg_count= 5;
 
144
    if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*5)))
 
145
    {
 
146
      args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;
 
147
      with_sum_func= a->with_sum_func || b->with_sum_func ||
 
148
        c->with_sum_func || d->with_sum_func || e->with_sum_func ;
 
149
    }
 
150
    collation.set(DERIVATION_SYSCONST);
 
151
  }
83
152
  
84
153
  Item_func(List<Item> &list);
85
154
  
120
189
  virtual void split_sum_func(Session *session, Item **ref_pointer_array,
121
190
                              List<Item> &fields);
122
191
 
123
 
  virtual void print(String *str);
124
 
  void print_op(String *str);
125
 
  void print_args(String *str, uint32_t from);
 
192
  virtual void print(String *str, enum_query_type query_type);
 
193
  void print_op(String *str, enum_query_type query_type);
 
194
  void print_args(String *str, uint32_t from, enum_query_type query_type);
126
195
  virtual void fix_num_length_and_dec();
127
196
  void count_only_length();
128
197
  void count_real_length();
161
230
  void traverse_cond(Cond_traverser traverser,
162
231
                     void * arg, traverse_order order);
163
232
  double fix_result(double value);
 
233
 
 
234
  Session &getSession()
 
235
  {
 
236
    return _session;
 
237
  }
 
238
 
 
239
  Session *getSessionPtr()
 
240
  {
 
241
    return &_session;
 
242
  }
 
243
 
164
244
};
165
245
 
166
246
} /* namespace drizzled */
167
247
 
168
248
 
 
249
#endif /* DRIZZLED_FUNCTION_FUNC_H */