1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
4
* Copyright (C) 2008 Sun Microsystems
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
20
#ifndef DRIZZLED_FUNCTION_FUNC_H
23
21
#define DRIZZLED_FUNCTION_FUNC_H
25
23
/// TODO: Rename this file - func.h is stupid.
27
#include <drizzled/charset_info.h>
28
25
#include <drizzled/item.h>
26
#include <drizzled/sql_list.h>
29
27
#include <drizzled/item/bin_string.h>
30
#include <drizzled/lex_string.h>
31
#include <drizzled/sql_list.h>
32
#include <drizzled/type/decimal.h>
34
#include <drizzled/visibility.h>
39
class DRIZZLED_API Item_func :
40
public Item_result_field
30
class Item_func :public Item_result_field
45
33
Item **args, *tmp_arg[2];
72
59
enum Type type() const { return FUNC_ITEM; }
73
60
virtual enum Functype functype() const { return UNKNOWN_FUNC; }
74
61
virtual ~Item_func() {}
80
Item_func(Item *a,Item *b);
82
Item_func(Item *a,Item *b,Item *c);
84
Item_func(Item *a,Item *b,Item *c,Item *d);
86
Item_func(Item *a,Item *b,Item *c,Item *d,Item* e);
63
allowed_arg_cols(1), arg_count(0)
68
allowed_arg_cols(1), arg_count(1)
72
with_sum_func= a->with_sum_func;
74
Item_func(Item *a,Item *b):
75
allowed_arg_cols(1), arg_count(2)
78
args[0]= a; args[1]= b;
79
with_sum_func= a->with_sum_func || b->with_sum_func;
81
Item_func(Item *a,Item *b,Item *c):
85
if ((args= (Item**) sql_alloc(sizeof(Item*)*3)))
88
args[0]= a; args[1]= b; args[2]= c;
89
with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
92
Item_func(Item *a,Item *b,Item *c,Item *d):
96
if ((args= (Item**) sql_alloc(sizeof(Item*)*4)))
99
args[0]= a; args[1]= b; args[2]= c; args[3]= d;
100
with_sum_func= a->with_sum_func || b->with_sum_func ||
101
c->with_sum_func || d->with_sum_func;
104
Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):
108
if ((args= (Item**) sql_alloc(sizeof(Item*)*5)))
110
args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;
111
with_sum_func= a->with_sum_func || b->with_sum_func ||
112
c->with_sum_func || d->with_sum_func || e->with_sum_func ;
88
115
Item_func(List<Item> &list);
90
116
// Constructor used for Item_cond_and/or (see Item comment)
91
117
Item_func(Session *session, Item_func *item);
93
118
bool fix_fields(Session *, Item **ref);
94
119
void fix_after_pullout(Select_Lex *new_parent, Item **ref);
95
120
table_map used_tables() const;
109
134
{Sum}Functype and Item_func::functype()/Item_sum::sum_func()
112
virtual const char *func_name() const { return NULL; }
137
virtual const char *func_name() const { return NULL; };
113
138
virtual bool const_item() const { return const_item_cache; }
114
139
Item **arguments() const { return args; }
115
140
void set_arguments(List<Item> &list);
132
157
void count_real_length();
133
158
void count_decimal_length();
135
bool get_arg0_date(type::Time <ime, uint32_t fuzzy_date);
136
bool get_arg0_time(type::Time <ime);
160
bool get_arg0_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date);
161
bool get_arg0_time(DRIZZLE_TIME *ltime);
140
virtual bool deterministic() const
145
165
void signal_divide_by_null();
147
167
virtual Field *tmp_table_field() { return result_field; }
150
170
Item *get_tmp_table_item(Session *session);
152
type::Decimal *val_decimal(type::Decimal *);
172
my_decimal *val_decimal(my_decimal *);
154
174
bool agg_arg_collations(DTCollation &c, Item **items, uint32_t nitems,