17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_FUNCTION_FUNC_H
21
#define DRIZZLED_FUNCTION_FUNC_H
20
#ifndef drizzled_functions_func_h
21
#define drizzled_functions_func_h
23
23
/// TODO: Rename this file - func.h is stupid.
25
25
#include <drizzled/item.h>
26
26
#include <drizzled/sql_list.h>
27
#include <drizzled/item/bin_string.h>
28
#include "drizzled/current_session.h"
33
29
class Item_func :public Item_result_field
38
32
Item **args, *tmp_arg[2];
64
55
enum Type type() const { return FUNC_ITEM; }
65
56
virtual enum Functype functype() const { return UNKNOWN_FUNC; }
66
virtual ~Item_func() {}
69
_session(*current_session),
70
58
allowed_arg_cols(1), arg_count(0)
73
collation.set(DERIVATION_SYSCONST);
76
62
Item_func(Item *a):
77
_session(*current_session),
78
63
allowed_arg_cols(1), arg_count(1)
82
67
with_sum_func= a->with_sum_func;
83
collation.set(DERIVATION_SYSCONST);
86
69
Item_func(Item *a,Item *b):
87
_session(*current_session),
88
70
allowed_arg_cols(1), arg_count(2)
91
73
args[0]= a; args[1]= b;
92
74
with_sum_func= a->with_sum_func || b->with_sum_func;
93
collation.set(DERIVATION_SYSCONST);
96
76
Item_func(Item *a,Item *b,Item *c):
97
_session(*current_session),
98
77
allowed_arg_cols(1)
101
if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*3)))
80
if ((args= (Item**) sql_alloc(sizeof(Item*)*3)))
104
83
args[0]= a; args[1]= b; args[2]= c;
105
84
with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
107
collation.set(DERIVATION_SYSCONST);
110
87
Item_func(Item *a,Item *b,Item *c,Item *d):
111
_session(*current_session),
112
88
allowed_arg_cols(1)
115
if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*4)))
91
if ((args= (Item**) sql_alloc(sizeof(Item*)*4)))
118
94
args[0]= a; args[1]= b; args[2]= c; args[3]= d;
119
95
with_sum_func= a->with_sum_func || b->with_sum_func ||
120
96
c->with_sum_func || d->with_sum_func;
122
collation.set(DERIVATION_SYSCONST);
125
99
Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):
126
_session(*current_session),
127
100
allowed_arg_cols(1)
130
if ((args= (Item**) memory::sql_alloc(sizeof(Item*)*5)))
103
if ((args= (Item**) sql_alloc(sizeof(Item*)*5)))
132
105
args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;
133
106
with_sum_func= a->with_sum_func || b->with_sum_func ||
134
107
c->with_sum_func || d->with_sum_func || e->with_sum_func ;
136
collation.set(DERIVATION_SYSCONST);
139
110
Item_func(List<Item> &list);
141
111
// Constructor used for Item_cond_and/or (see Item comment)
142
112
Item_func(Session *session, Item_func *item);
144
113
bool fix_fields(Session *, Item **ref);
145
void fix_after_pullout(Select_Lex *new_parent, Item **ref);
114
void fix_after_pullout(st_select_lex *new_parent, Item **ref);
146
115
table_map used_tables() const;
147
116
table_map not_null_tables() const;
148
117
void update_used_tables();
160
129
{Sum}Functype and Item_func::functype()/Item_sum::sum_func()
163
virtual const char *func_name() const { return NULL; }
132
virtual const char *func_name() const { return NULL; };
164
133
virtual bool const_item() const { return const_item_cache; }
165
134
Item **arguments() const { return args; }
166
135
void set_arguments(List<Item> &list);
167
136
uint32_t argument_count() const { return arg_count; }
168
137
void remove_arguments() { arg_count=0; }
171
* Check if the UDF supports the number of arguments passed in
172
* @param number of args
174
virtual bool check_argument_count(int) { return true ; }
175
virtual void split_sum_func(Session *session, Item **ref_pointer_array,
138
void split_sum_func(Session *session, Item **ref_pointer_array, List<Item> &fields);
178
139
virtual void print(String *str, enum_query_type query_type);
179
140
void print_op(String *str, enum_query_type query_type);
180
141
void print_args(String *str, uint32_t from, enum_query_type query_type);