36
class Item_func :public Item_result_field
39
Item **args, *tmp_arg[2];
41
Allowed numbers of columns in result (usually 1, which means scalar value)
42
0 means get this number from first argument
44
uint32_t allowed_arg_cols;
47
table_map used_tables_cache, not_null_tables_cache;
48
bool const_item_cache;
49
enum Functype { UNKNOWN_FUNC,EQ_FUNC,EQUAL_FUNC,NE_FUNC,LT_FUNC,LE_FUNC,
51
LIKE_FUNC,ISNULL_FUNC,ISNOTNULL_FUNC,
52
COND_AND_FUNC, COND_OR_FUNC, COND_XOR_FUNC,
53
BETWEEN, IN_FUNC, MULT_EQUAL_FUNC,
54
INTERVAL_FUNC, ISNOTNULLTEST_FUNC,
55
NOT_FUNC, NOT_ALL_FUNC,
56
NOW_FUNC, TRIG_COND_FUNC,
57
SUSERVAR_FUNC, GUSERVAR_FUNC, COLLATE_FUNC,
58
EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP,
60
enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL,
62
enum Type type() const { return FUNC_ITEM; }
63
virtual enum Functype functype() const { return UNKNOWN_FUNC; }
65
allowed_arg_cols(1), arg_count(0)
70
allowed_arg_cols(1), arg_count(1)
74
with_sum_func= a->with_sum_func;
76
Item_func(Item *a,Item *b):
77
allowed_arg_cols(1), arg_count(2)
80
args[0]= a; args[1]= b;
81
with_sum_func= a->with_sum_func || b->with_sum_func;
83
Item_func(Item *a,Item *b,Item *c):
87
if ((args= (Item**) sql_alloc(sizeof(Item*)*3)))
90
args[0]= a; args[1]= b; args[2]= c;
91
with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
94
Item_func(Item *a,Item *b,Item *c,Item *d):
98
if ((args= (Item**) sql_alloc(sizeof(Item*)*4)))
101
args[0]= a; args[1]= b; args[2]= c; args[3]= d;
102
with_sum_func= a->with_sum_func || b->with_sum_func ||
103
c->with_sum_func || d->with_sum_func;
106
Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):
110
if ((args= (Item**) sql_alloc(sizeof(Item*)*5)))
112
args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;
113
with_sum_func= a->with_sum_func || b->with_sum_func ||
114
c->with_sum_func || d->with_sum_func || e->with_sum_func ;
117
Item_func(List<Item> &list);
118
// Constructor used for Item_cond_and/or (see Item comment)
119
Item_func(THD *thd, Item_func *item);
120
bool fix_fields(THD *, Item **ref);
121
void fix_after_pullout(st_select_lex *new_parent, Item **ref);
122
table_map used_tables() const;
123
table_map not_null_tables() const;
124
void update_used_tables();
125
bool eq(const Item *item, bool binary_cmp) const;
126
virtual optimize_type select_optimize() const { return OPTIMIZE_NONE; }
127
virtual bool have_rev_func() const { return 0; }
128
virtual Item *key_item() const { return args[0]; }
130
This method is used for debug purposes to print the name of an
131
item to the debug log. The second use of this method is as
132
a helper function of print(), where it is applicable.
133
To suit both goals it should return a meaningful,
134
distinguishable and sintactically correct string. This method
135
should not be used for runtime type identification, use enum
136
{Sum}Functype and Item_func::functype()/Item_sum::sum_func()
139
virtual const char *func_name() const { return NULL; };
140
virtual bool const_item() const { return const_item_cache; }
141
inline Item **arguments() const { return args; }
142
void set_arguments(List<Item> &list);
143
inline uint32_t argument_count() const { return arg_count; }
144
inline void remove_arguments() { arg_count=0; }
145
void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
146
virtual void print(String *str, enum_query_type query_type);
147
void print_op(String *str, enum_query_type query_type);
148
void print_args(String *str, uint32_t from, enum_query_type query_type);
149
virtual void fix_num_length_and_dec();
150
void count_only_length();
151
void count_real_length();
152
void count_decimal_length();
153
inline bool get_arg0_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date)
155
return (null_value=args[0]->get_date(ltime, fuzzy_date));
157
inline bool get_arg0_time(DRIZZLE_TIME *ltime)
159
return (null_value=args[0]->get_time(ltime));
165
void signal_divide_by_null();
167
Field *tmp_table_field() { return result_field; }
168
Field *tmp_table_field(Table *t_arg);
169
Item *get_tmp_table_item(THD *thd);
171
my_decimal *val_decimal(my_decimal *);
173
bool agg_arg_collations(DTCollation &c, Item **items, uint32_t nitems,
176
return agg_item_collations(c, func_name(), items, nitems, flags, 1);
178
bool agg_arg_collations_for_comparison(DTCollation &c,
179
Item **items, uint32_t nitems,
182
return agg_item_collations_for_comparison(c, func_name(),
183
items, nitems, flags);
185
bool agg_arg_charsets(DTCollation &c, Item **items, uint32_t nitems,
186
uint32_t flags, int item_sep)
188
return agg_item_charsets(c, func_name(), items, nitems, flags, item_sep);
190
bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg);
191
Item *transform(Item_transformer transformer, unsigned char *arg);
192
Item* compile(Item_analyzer analyzer, unsigned char **arg_p,
193
Item_transformer transformer, unsigned char *arg_t);
194
void traverse_cond(Cond_traverser traverser,
195
void * arg, traverse_order order);
196
inline double fix_result(double value)
198
if (CMATH_C99_NAMESPACE isfinite(value))
36
#include <drizzled/functions/func.h>
37
#include <drizzled/functions/int.h>
206
39
class Item_real_func :public Item_func