26
#include "item_func.h"
26
28
enum Item_udftype {UDFTYPE_FUNCTION=1,UDFTYPE_AGGREGATE};
28
typedef void (*Udf_func_clear)(UDF_INIT *, uchar *, uchar *);
29
typedef void (*Udf_func_add)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *);
30
typedef void (*Udf_func_deinit)(UDF_INIT*);
31
typedef bool (*Udf_func_init)(UDF_INIT *, UDF_ARGS *, char *);
32
typedef void (*Udf_func_any)();
33
typedef double (*Udf_func_double)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *);
34
typedef int64_t (*Udf_func_int64_t)(UDF_INIT *, UDF_ARGS *, uchar *,
30
typedef Item_func* (*create_func_item)(MEM_ROOT*);
37
typedef struct st_udf_func
43
Udf_func_init func_init;
44
Udf_func_deinit func_deinit;
45
Udf_func_clear func_clear;
46
Udf_func_add func_add;
50
class Item_result_field;
52
class udf_handler :public Sql_alloc
65
table_map used_tables_cache;
66
bool const_item_cache;
68
udf_handler(udf_func *udf_arg) :u_d(udf_arg), buffers(0), error(0),
69
is_null(0), initialized(0), not_original(0)
72
const char *name() const { return u_d ? u_d->name.str : "?"; }
73
Item_result result_type () const
74
{ return u_d ? u_d->returns : STRING_RESULT;}
76
bool fix_fields(THD *thd, Item_result_field *item,
77
uint arg_count, Item **args);
79
double val(bool *null_value)
87
Udf_func_double func= (Udf_func_double) u_d->func;
88
double tmp=func(&initid, &f_args, &is_null, &error);
97
int64_t val_int(bool *null_value)
105
Udf_func_int64_t func= (Udf_func_int64_t) u_d->func;
106
int64_t tmp=func(&initid, &f_args, &is_null, &error);
107
if (is_null || error)
115
my_decimal *val_decimal(bool *null_value, my_decimal *dec_buf);
119
Udf_func_clear func= u_d->func_clear;
120
func(&initid, &is_null, &error);
122
void add(bool *null_value)
129
Udf_func_add func= u_d->func_add;
130
func(&initid, &f_args, &is_null, &error);
131
*null_value= (bool) (is_null || error);
133
String *val_str(String *str,String *save_str);
35
create_func_item create_func;
137
38
void udf_init(void),udf_free(void);
138
39
udf_func *find_udf(const char *name, uint len=0);
139
40
void free_udf(udf_func *udf);