35
35
#include <drizzled/functions/connection_id.h>
36
36
#include <drizzled/functions/decimal_typecast.h>
37
37
#include <drizzled/functions/divide.h>
38
#include <drizzled/functions/get_system_var.h>
38
39
#include <drizzled/functions/int.h>
40
#include <drizzled/functions/bit.h>
41
#include <drizzled/functions/bit_count.h>
42
#include <drizzled/functions/bit_length.h>
43
#include <drizzled/functions/find_in_set.h>
39
44
#include <drizzled/functions/int_divide.h>
40
45
#include <drizzled/functions/length.h>
41
46
#include <drizzled/functions/min_max.h>
49
54
#include <drizzled/functions/abs.h>
50
55
#include <drizzled/functions/plus.h>
51
56
#include <drizzled/functions/real.h>
57
#include <drizzled/functions/rollup_const.h>
52
58
#include <drizzled/functions/dec.h>
53
59
#include <drizzled/functions/int_val.h>
54
60
#include <drizzled/functions/acos.h>
61
#include <drizzled/functions/ascii.h>
55
62
#include <drizzled/functions/asin.h>
56
63
#include <drizzled/functions/atan.h>
64
#include <drizzled/functions/benchmark.h>
65
#include <drizzled/functions/char_length.h>
57
66
#include <drizzled/functions/ceiling.h>
58
67
#include <drizzled/functions/cos.h>
59
68
#include <drizzled/functions/exp.h>
60
69
#include <drizzled/functions/floor.h>
70
#include <drizzled/functions/last_insert.h>
61
71
#include <drizzled/functions/ln.h>
62
72
#include <drizzled/functions/log.h>
73
#include <drizzled/functions/units.h>
74
#include <drizzled/functions/ord.h>
63
75
#include <drizzled/functions/pow.h>
64
76
#include <drizzled/functions/rand.h>
65
77
#include <drizzled/functions/round.h>
77
89
void fix_length_and_dec();
80
class Item_func_units :public Item_real_func
85
Item_func_units(char *name_arg,Item *a,double mul_arg,double add_arg)
86
:Item_real_func(a),name(name_arg),mul(mul_arg),add(add_arg) {}
88
const char *func_name() const { return name; }
89
void fix_length_and_dec()
90
{ decimals= NOT_FIXED_DEC; max_length= float_length(decimals); }
95
Objects of this class are used for ROLLUP queries to wrap up
96
each constant item referred to in GROUP BY list.
99
class Item_func_rollup_const :public Item_func
102
Item_func_rollup_const(Item *a) :Item_func(a)
105
name_length= a->name_length;
107
double val_real() { return args[0]->val_real(); }
108
int64_t val_int() { return args[0]->val_int(); }
109
String *val_str(String *str) { return args[0]->val_str(str); }
110
my_decimal *val_decimal(my_decimal *dec) { return args[0]->val_decimal(dec); }
111
const char *func_name() const { return "rollup_const"; }
112
bool const_item() const { return 0; }
113
Item_result result_type() const { return args[0]->result_type(); }
114
void fix_length_and_dec()
116
collation= args[0]->collation;
117
max_length= args[0]->max_length;
118
decimals=args[0]->decimals;
119
/* The item could be a NULL constant. */
120
null_value= args[0]->is_null();
124
class Item_func_bit_length :public Item_func_length
127
Item_func_bit_length(Item *a) :Item_func_length(a) {}
129
{ assert(fixed == 1); return Item_func_length::val_int()*8; }
130
const char *func_name() const { return "bit_length"; }
133
class Item_func_char_length :public Item_int_func
137
Item_func_char_length(Item *a) :Item_int_func(a) {}
139
const char *func_name() const { return "char_length"; }
140
void fix_length_and_dec() { max_length=10; }
143
class Item_func_coercibility :public Item_int_func
146
Item_func_coercibility(Item *a) :Item_int_func(a) {}
148
const char *func_name() const { return "coercibility"; }
149
void fix_length_and_dec() { max_length=10; maybe_null= 0; }
150
table_map not_null_tables() const { return 0; }
153
class Item_func_locate :public Item_int_func
155
String value1,value2;
156
DTCollation cmp_collation;
158
Item_func_locate(Item *a,Item *b) :Item_int_func(a,b) {}
159
Item_func_locate(Item *a,Item *b,Item *c) :Item_int_func(a,b,c) {}
160
const char *func_name() const { return "locate"; }
162
void fix_length_and_dec();
163
virtual void print(String *str, enum_query_type query_type);
167
92
class Item_func_field :public Item_int_func
176
101
void fix_length_and_dec();
180
class Item_func_ascii :public Item_int_func
184
Item_func_ascii(Item *a) :Item_int_func(a) {}
186
const char *func_name() const { return "ascii"; }
187
void fix_length_and_dec() { max_length=3; }
190
class Item_func_ord :public Item_int_func
194
Item_func_ord(Item *a) :Item_int_func(a) {}
196
const char *func_name() const { return "ord"; }
199
class Item_func_find_in_set :public Item_int_func
204
DTCollation cmp_collation;
206
Item_func_find_in_set(Item *a,Item *b) :Item_int_func(a,b),enum_value(0) {}
208
const char *func_name() const { return "find_in_set"; }
209
void fix_length_and_dec();
212
/* Base class for all bit functions: '~', '|', '^', '&', '>>', '<<' */
214
class Item_func_bit: public Item_int_func
217
Item_func_bit(Item *a, Item *b) :Item_int_func(a, b) {}
218
Item_func_bit(Item *a) :Item_int_func(a) {}
219
void fix_length_and_dec() { unsigned_flag= 1; }
221
virtual inline void print(String *str, enum_query_type query_type)
223
print_op(str, query_type);
227
class Item_func_bit_or :public Item_func_bit
230
Item_func_bit_or(Item *a, Item *b) :Item_func_bit(a, b) {}
232
const char *func_name() const { return "|"; }
235
class Item_func_bit_and :public Item_func_bit
238
Item_func_bit_and(Item *a, Item *b) :Item_func_bit(a, b) {}
240
const char *func_name() const { return "&"; }
243
class Item_func_bit_count :public Item_int_func
246
Item_func_bit_count(Item *a) :Item_int_func(a) {}
248
const char *func_name() const { return "bit_count"; }
249
void fix_length_and_dec() { max_length=2; }
252
class Item_func_shift_left :public Item_func_bit
255
Item_func_shift_left(Item *a, Item *b) :Item_func_bit(a, b) {}
257
const char *func_name() const { return "<<"; }
260
class Item_func_shift_right :public Item_func_bit
263
Item_func_shift_right(Item *a, Item *b) :Item_func_bit(a, b) {}
265
const char *func_name() const { return ">>"; }
268
class Item_func_bit_neg :public Item_func_bit
271
Item_func_bit_neg(Item *a) :Item_func_bit(a) {}
273
const char *func_name() const { return "~"; }
275
virtual inline void print(String *str, enum_query_type query_type)
277
Item_func::print(str, query_type);
282
class Item_func_last_insert_id :public Item_int_func
285
Item_func_last_insert_id() :Item_int_func() {}
286
Item_func_last_insert_id(Item *a) :Item_int_func(a) {}
288
const char *func_name() const { return "last_insert_id"; }
289
void fix_length_and_dec()
292
max_length= args[0]->max_length;
294
bool fix_fields(Session *session, Item **ref);
295
bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
300
class Item_func_benchmark :public Item_int_func
303
Item_func_benchmark(Item *count_expr, Item *expr)
304
:Item_int_func(count_expr, expr)
307
const char *func_name() const { return "benchmark"; }
308
void fix_length_and_dec() { max_length=1; maybe_null=0; }
309
virtual void print(String *str, enum_query_type query_type);
310
bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
314
104
/* replication functions */
316
106
class Item_master_pos_wait :public Item_int_func
447
/* A system variable */
449
class Item_func_get_system_var :public Item_func
452
enum_var_type var_type;
453
LEX_STRING component;
455
Item_func_get_system_var(sys_var *var_arg, enum_var_type var_type_arg,
456
LEX_STRING *component_arg, const char *name_arg,
457
size_t name_len_arg);
458
bool fix_fields(Session *session, Item **ref);
460
Stubs for pure virtual methods. Should never be called: this
461
item is always substituted with a constant in fix_fields().
463
double val_real() { assert(0); return 0.0; }
464
int64_t val_int() { assert(0); return 0; }
465
String* val_str(String*) { assert(0); return 0; }
466
void fix_length_and_dec() { assert(0); }
467
/* TODO: fix to support views */
468
const char *func_name() const { return "get_system_var"; }
470
Indicates whether this system variable is written to the binlog or not.
472
Variables are written to the binlog as part of "status_vars" in
473
Query_log_event, as an Intvar_log_event, or a Rand_log_event.
475
@return true if the variable is written to the binlog, false otherwise.
477
bool is_written_to_binlog();
480
class Item_func_bit_xor : public Item_func_bit
483
Item_func_bit_xor(Item *a, Item *b) :Item_func_bit(a, b) {}
485
const char *func_name() const { return "^"; }
488
237
class Item_func_is_free_lock :public Item_int_func