~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_func.h

  • Committer: Brian Aker
  • Date: 2008-10-15 06:16:05 UTC
  • mfrom: (511.1.3 codestyle)
  • Revision ID: brian@tangent.org-20081015061605-8bb3vss9m23dns5t
Monty merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include <drizzled/functions/divide.h>
38
38
#include <drizzled/functions/int.h>
39
39
#include <drizzled/functions/int_divide.h>
 
40
#include <drizzled/functions/length.h>
 
41
#include <drizzled/functions/min_max.h>
40
42
#include <drizzled/functions/minus.h>
41
43
#include <drizzled/functions/mod.h>
42
44
#include <drizzled/functions/multiply.h>
48
50
#include <drizzled/functions/plus.h>
49
51
#include <drizzled/functions/real.h>
50
52
#include <drizzled/functions/dec.h>
 
53
#include <drizzled/functions/int_val.h>
 
54
#include <drizzled/functions/acos.h>
 
55
#include <drizzled/functions/asin.h>
 
56
#include <drizzled/functions/atan.h>
 
57
#include <drizzled/functions/ceiling.h>
 
58
#include <drizzled/functions/cos.h>
51
59
#include <drizzled/functions/exp.h>
 
60
#include <drizzled/functions/floor.h>
52
61
#include <drizzled/functions/ln.h>
53
62
#include <drizzled/functions/log.h>
 
63
#include <drizzled/functions/pow.h>
 
64
#include <drizzled/functions/rand.h>
 
65
#include <drizzled/functions/round.h>
 
66
#include <drizzled/functions/sin.h>
 
67
#include <drizzled/functions/sqrt.h>
 
68
#include <drizzled/functions/sign.h>
54
69
#include <drizzled/functions/signed.h>
 
70
#include <drizzled/functions/tan.h>
55
71
#include <drizzled/functions/unsigned.h>
56
72
 
57
 
class Item_func_sqrt :public Item_dec_func
58
 
{
59
 
public:
60
 
  Item_func_sqrt(Item *a) :Item_dec_func(a) {}
61
 
  double val_real();
62
 
  const char *func_name() const { return "sqrt"; }
63
 
};
64
 
 
65
 
 
66
 
class Item_func_pow :public Item_dec_func
67
 
{
68
 
public:
69
 
  Item_func_pow(Item *a,Item *b) :Item_dec_func(a,b) {}
70
 
  double val_real();
71
 
  const char *func_name() const { return "pow"; }
72
 
};
73
 
 
74
 
 
75
 
class Item_func_acos :public Item_dec_func
76
 
{
77
 
public:
78
 
  Item_func_acos(Item *a) :Item_dec_func(a) {}
79
 
  double val_real();
80
 
  const char *func_name() const { return "acos"; }
81
 
};
82
 
 
83
 
class Item_func_asin :public Item_dec_func
84
 
{
85
 
public:
86
 
  Item_func_asin(Item *a) :Item_dec_func(a) {}
87
 
  double val_real();
88
 
  const char *func_name() const { return "asin"; }
89
 
};
90
 
 
91
 
class Item_func_atan :public Item_dec_func
92
 
{
93
 
public:
94
 
  Item_func_atan(Item *a) :Item_dec_func(a) {}
95
 
  Item_func_atan(Item *a,Item *b) :Item_dec_func(a,b) {}
96
 
  double val_real();
97
 
  const char *func_name() const { return "atan"; }
98
 
};
99
 
 
100
 
class Item_func_cos :public Item_dec_func
101
 
{
102
 
public:
103
 
  Item_func_cos(Item *a) :Item_dec_func(a) {}
104
 
  double val_real();
105
 
  const char *func_name() const { return "cos"; }
106
 
};
107
 
 
108
 
class Item_func_sin :public Item_dec_func
109
 
{
110
 
public:
111
 
  Item_func_sin(Item *a) :Item_dec_func(a) {}
112
 
  double val_real();
113
 
  const char *func_name() const { return "sin"; }
114
 
};
115
 
 
116
 
class Item_func_tan :public Item_dec_func
117
 
{
118
 
public:
119
 
  Item_func_tan(Item *a) :Item_dec_func(a) {}
120
 
  double val_real();
121
 
  const char *func_name() const { return "tan"; }
122
 
};
123
 
 
124
73
class Item_func_integer :public Item_int_func
125
74
{
126
75
public:
128
77
  void fix_length_and_dec();
129
78
};
130
79
 
131
 
 
132
 
class Item_func_int_val :public Item_func_num1
133
 
{
134
 
public:
135
 
  Item_func_int_val(Item *a) :Item_func_num1(a) {}
136
 
  void fix_num_length_and_dec();
137
 
  void find_num_type();
138
 
};
139
 
 
140
 
 
141
 
class Item_func_ceiling :public Item_func_int_val
142
 
{
143
 
public:
144
 
  Item_func_ceiling(Item *a) :Item_func_int_val(a) {}
145
 
  const char *func_name() const { return "ceiling"; }
146
 
  int64_t int_op();
147
 
  double real_op();
148
 
  my_decimal *decimal_op(my_decimal *);
149
 
  bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
150
 
  { return false; }
151
 
};
152
 
 
153
 
 
154
 
class Item_func_floor :public Item_func_int_val
155
 
{
156
 
public:
157
 
  Item_func_floor(Item *a) :Item_func_int_val(a) {}
158
 
  const char *func_name() const { return "floor"; }
159
 
  int64_t int_op();
160
 
  double real_op();
161
 
  my_decimal *decimal_op(my_decimal *);
162
 
  bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
163
 
  { return false; }
164
 
};
165
 
 
166
 
/* This handles round and truncate */
167
 
 
168
 
class Item_func_round :public Item_func_num1
169
 
{
170
 
  bool truncate;
171
 
public:
172
 
  Item_func_round(Item *a, Item *b, bool trunc_arg)
173
 
    :Item_func_num1(a,b), truncate(trunc_arg) {}
174
 
  const char *func_name() const { return truncate ? "truncate" : "round"; }
175
 
  double real_op();
176
 
  int64_t int_op();
177
 
  my_decimal *decimal_op(my_decimal *);
178
 
  void fix_length_and_dec();
179
 
};
180
 
 
181
 
 
182
 
class Item_func_rand :public Item_real_func
183
 
{
184
 
  struct rand_struct *rand;
185
 
public:
186
 
  Item_func_rand(Item *a) :Item_real_func(a), rand(0) {}
187
 
  Item_func_rand()        :Item_real_func() {}
188
 
  double val_real();
189
 
  const char *func_name() const { return "rand"; }
190
 
  bool const_item() const { return 0; }
191
 
  void update_used_tables();
192
 
  bool fix_fields(THD *thd, Item **ref);
193
 
  bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
194
 
  { return true; }
195
 
private:
196
 
  void seed_random (Item * val);  
197
 
};
198
 
 
199
 
 
200
 
class Item_func_sign :public Item_int_func
201
 
{
202
 
public:
203
 
  Item_func_sign(Item *a) :Item_int_func(a) {}
204
 
  const char *func_name() const { return "sign"; }
205
 
  int64_t val_int();
206
 
};
207
 
 
208
 
 
209
80
class Item_func_units :public Item_real_func
210
81
{
211
82
  char *name;
220
91
};
221
92
 
222
93
 
223
 
class Item_func_min_max :public Item_func
224
 
{
225
 
  Item_result cmp_type;
226
 
  String tmp_value;
227
 
  int cmp_sign;
228
 
  /* TRUE <=> arguments should be compared in the DATETIME context. */
229
 
  bool compare_as_dates;
230
 
  /* An item used for issuing warnings while string to DATETIME conversion. */
231
 
  Item *datetime_item;
232
 
  THD *thd;
233
 
protected:
234
 
  enum_field_types cached_field_type;
235
 
public:
236
 
  Item_func_min_max(List<Item> &list,int cmp_sign_arg) :Item_func(list),
237
 
    cmp_type(INT_RESULT), cmp_sign(cmp_sign_arg), compare_as_dates(false),
238
 
    datetime_item(0) {}
239
 
  double val_real();
240
 
  int64_t val_int();
241
 
  String *val_str(String *);
242
 
  my_decimal *val_decimal(my_decimal *);
243
 
  void fix_length_and_dec();
244
 
  enum Item_result result_type () const { return cmp_type; }
245
 
  bool result_as_int64_t() { return compare_as_dates; };
246
 
  uint32_t cmp_datetimes(uint64_t *value);
247
 
  enum_field_types field_type() const { return cached_field_type; }
248
 
};
249
 
 
250
 
class Item_func_min :public Item_func_min_max
251
 
{
252
 
public:
253
 
  Item_func_min(List<Item> &list) :Item_func_min_max(list,1) {}
254
 
  const char *func_name() const { return "least"; }
255
 
};
256
 
 
257
 
class Item_func_max :public Item_func_min_max
258
 
{
259
 
public:
260
 
  Item_func_max(List<Item> &list) :Item_func_min_max(list,-1) {}
261
 
  const char *func_name() const { return "greatest"; }
262
 
};
263
 
 
264
 
 
265
94
/* 
266
95
  Objects of this class are used for ROLLUP queries to wrap up 
267
96
  each constant item referred to in GROUP BY list. 
292
121
  }
293
122
};
294
123
 
295
 
 
296
 
class Item_func_length :public Item_int_func
297
 
{
298
 
  String value;
299
 
public:
300
 
  Item_func_length(Item *a) :Item_int_func(a) {}
301
 
  int64_t val_int();
302
 
  const char *func_name() const { return "length"; }
303
 
  void fix_length_and_dec() { max_length=10; }
304
 
};
305
 
 
306
124
class Item_func_bit_length :public Item_func_length
307
125
{
308
126
public: