~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_func.h

code clean move Item_func_floor, Item_func_length, Item_func_min_max, Item_func_rand, Item_func_round to functions directory

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>
55
57
#include <drizzled/functions/ceiling.h>
56
58
#include <drizzled/functions/cos.h>
57
59
#include <drizzled/functions/exp.h>
 
60
#include <drizzled/functions/floor.h>
58
61
#include <drizzled/functions/ln.h>
59
62
#include <drizzled/functions/log.h>
60
63
#include <drizzled/functions/pow.h>
 
64
#include <drizzled/functions/rand.h>
 
65
#include <drizzled/functions/round.h>
61
66
#include <drizzled/functions/sin.h>
62
67
#include <drizzled/functions/sqrt.h>
 
68
#include <drizzled/functions/sign.h>
63
69
#include <drizzled/functions/signed.h>
64
70
#include <drizzled/functions/tan.h>
65
71
#include <drizzled/functions/unsigned.h>
71
77
  void fix_length_and_dec();
72
78
};
73
79
 
74
 
class Item_func_floor :public Item_func_int_val
75
 
{
76
 
public:
77
 
  Item_func_floor(Item *a) :Item_func_int_val(a) {}
78
 
  const char *func_name() const { return "floor"; }
79
 
  int64_t int_op();
80
 
  double real_op();
81
 
  my_decimal *decimal_op(my_decimal *);
82
 
  bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
83
 
  { return false; }
84
 
};
85
 
 
86
 
/* This handles round and truncate */
87
 
 
88
 
class Item_func_round :public Item_func_num1
89
 
{
90
 
  bool truncate;
91
 
public:
92
 
  Item_func_round(Item *a, Item *b, bool trunc_arg)
93
 
    :Item_func_num1(a,b), truncate(trunc_arg) {}
94
 
  const char *func_name() const { return truncate ? "truncate" : "round"; }
95
 
  double real_op();
96
 
  int64_t int_op();
97
 
  my_decimal *decimal_op(my_decimal *);
98
 
  void fix_length_and_dec();
99
 
};
100
 
 
101
 
 
102
 
class Item_func_rand :public Item_real_func
103
 
{
104
 
  struct rand_struct *rand;
105
 
public:
106
 
  Item_func_rand(Item *a) :Item_real_func(a), rand(0) {}
107
 
  Item_func_rand()        :Item_real_func() {}
108
 
  double val_real();
109
 
  const char *func_name() const { return "rand"; }
110
 
  bool const_item() const { return 0; }
111
 
  void update_used_tables();
112
 
  bool fix_fields(THD *thd, Item **ref);
113
 
  bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
114
 
  { return true; }
115
 
private:
116
 
  void seed_random (Item * val);  
117
 
};
118
 
 
119
 
 
120
 
class Item_func_sign :public Item_int_func
121
 
{
122
 
public:
123
 
  Item_func_sign(Item *a) :Item_int_func(a) {}
124
 
  const char *func_name() const { return "sign"; }
125
 
  int64_t val_int();
126
 
};
127
 
 
128
 
 
129
80
class Item_func_units :public Item_real_func
130
81
{
131
82
  char *name;
140
91
};
141
92
 
142
93
 
143
 
class Item_func_min_max :public Item_func
144
 
{
145
 
  Item_result cmp_type;
146
 
  String tmp_value;
147
 
  int cmp_sign;
148
 
  /* TRUE <=> arguments should be compared in the DATETIME context. */
149
 
  bool compare_as_dates;
150
 
  /* An item used for issuing warnings while string to DATETIME conversion. */
151
 
  Item *datetime_item;
152
 
  THD *thd;
153
 
protected:
154
 
  enum_field_types cached_field_type;
155
 
public:
156
 
  Item_func_min_max(List<Item> &list,int cmp_sign_arg) :Item_func(list),
157
 
    cmp_type(INT_RESULT), cmp_sign(cmp_sign_arg), compare_as_dates(false),
158
 
    datetime_item(0) {}
159
 
  double val_real();
160
 
  int64_t val_int();
161
 
  String *val_str(String *);
162
 
  my_decimal *val_decimal(my_decimal *);
163
 
  void fix_length_and_dec();
164
 
  enum Item_result result_type () const { return cmp_type; }
165
 
  bool result_as_int64_t() { return compare_as_dates; };
166
 
  uint32_t cmp_datetimes(uint64_t *value);
167
 
  enum_field_types field_type() const { return cached_field_type; }
168
 
};
169
 
 
170
 
class Item_func_min :public Item_func_min_max
171
 
{
172
 
public:
173
 
  Item_func_min(List<Item> &list) :Item_func_min_max(list,1) {}
174
 
  const char *func_name() const { return "least"; }
175
 
};
176
 
 
177
 
class Item_func_max :public Item_func_min_max
178
 
{
179
 
public:
180
 
  Item_func_max(List<Item> &list) :Item_func_min_max(list,-1) {}
181
 
  const char *func_name() const { return "greatest"; }
182
 
};
183
 
 
184
 
 
185
94
/* 
186
95
  Objects of this class are used for ROLLUP queries to wrap up 
187
96
  each constant item referred to in GROUP BY list. 
212
121
  }
213
122
};
214
123
 
215
 
 
216
 
class Item_func_length :public Item_int_func
217
 
{
218
 
  String value;
219
 
public:
220
 
  Item_func_length(Item *a) :Item_int_func(a) {}
221
 
  int64_t val_int();
222
 
  const char *func_name() const { return "length"; }
223
 
  void fix_length_and_dec() { max_length=10; }
224
 
};
225
 
 
226
124
class Item_func_bit_length :public Item_func_length
227
125
{
228
126
public: