drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
function/func.h
1/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2008 Sun Microsystems, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20
21
22#pragma once
23
25
26#include <drizzled/charset.h>
27#include <drizzled/item.h>
28#include <drizzled/item/bin_string.h>
29#include <drizzled/lex_string.h>
30#include <drizzled/sql_list.h>
31#include <drizzled/type/decimal.h>
32
33#include <drizzled/visibility.h>
34
35namespace drizzled {
36
37class DRIZZLED_API Item_func : public Item_result_field
38{
39protected:
40 Item **args, *tmp_arg[2];
41 /*
42 Allowed numbers of columns in result (usually 1, which means scalar value)
43 0 means get this number from first argument
44 */
45 uint32_t allowed_arg_cols;
46
47public:
48
49 using Item::split_sum_func;
50
51 uint32_t arg_count;
52 table_map used_tables_cache, not_null_tables_cache;
53 bool const_item_cache;
54 enum Functype { UNKNOWN_FUNC,EQ_FUNC,EQUAL_FUNC,NE_FUNC,LT_FUNC,LE_FUNC,
55 GE_FUNC,GT_FUNC,
56 LIKE_FUNC,ISNULL_FUNC,ISNOTNULL_FUNC,
57 COND_AND_FUNC, COND_OR_FUNC, COND_XOR_FUNC,
58 BETWEEN, IN_FUNC, MULT_EQUAL_FUNC,
59 INTERVAL_FUNC, ISNOTNULLTEST_FUNC,
60 NOT_FUNC, NOT_ALL_FUNC,
61 NOW_FUNC, TRIG_COND_FUNC,
62 SUSERVAR_FUNC, GUSERVAR_FUNC, COLLATE_FUNC,
63 EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP,
64 NEG_FUNC };
65 enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL,
66 OPTIMIZE_EQUAL };
67 enum Type type() const { return FUNC_ITEM; }
68 virtual enum Functype functype() const { return UNKNOWN_FUNC; }
69 virtual ~Item_func() {}
70
71 Item_func(void);
72
73 Item_func(Item *a);
74
75 Item_func(Item *a,Item *b);
76
77 Item_func(Item *a,Item *b,Item *c);
78
79 Item_func(Item *a,Item *b,Item *c,Item *d);
80
81 Item_func(Item *a,Item *b,Item *c,Item *d,Item* e);
82
83 Item_func(List<Item> &list);
84
85 // Constructor used for Item_cond_and/or (see Item comment)
86 Item_func(Session *session, Item_func *item);
87
88 bool fix_fields(Session *, Item **ref);
89 void fix_after_pullout(Select_Lex *new_parent, Item **ref);
90 table_map used_tables() const;
91 table_map not_null_tables() const;
92 void update_used_tables();
93 bool eq(const Item *item, bool binary_cmp) const;
94 virtual optimize_type select_optimize() const { return OPTIMIZE_NONE; }
95 virtual bool have_rev_func() const { return 0; }
96 virtual Item *key_item() const { return args[0]; }
97 /*
98 This method is used for debug purposes to print the name of an
99 item to the debug log. The second use of this method is as
100 a helper function of print(), where it is applicable.
101 To suit both goals it should return a meaningful,
102 distinguishable and sintactically correct string. This method
103 should not be used for runtime type identification, use enum
104 {Sum}Functype and Item_func::functype()/Item_sum::sum_func()
105 instead.
106 */
107 virtual const char *func_name() const { return NULL; }
108 virtual bool const_item() const { return const_item_cache; }
109 Item **arguments() const { return args; }
110 void set_arguments(List<Item> &list);
111 uint32_t argument_count() const { return arg_count; }
112 void remove_arguments() { arg_count=0; }
113
118 virtual bool check_argument_count(int) { return true ; }
119 virtual void split_sum_func(Session *session, Item **ref_pointer_array,
120 List<Item> &fields);
121
122 virtual void print(String *str);
123 void print_op(String *str);
124 void print_args(String *str, uint32_t from);
125 virtual void fix_num_length_and_dec();
126 void count_only_length();
127 void count_real_length();
128 void count_decimal_length();
129
130 bool get_arg0_date(type::Time &ltime, uint32_t fuzzy_date);
131 bool get_arg0_time(type::Time &ltime);
132
133 bool is_null();
134
135 virtual bool deterministic() const
136 {
137 return false;
138 }
139
140 void signal_divide_by_null();
141
142 virtual Field *tmp_table_field() { return result_field; }
143 virtual Field *tmp_table_field(Table *t_arg);
144
145 Item *get_tmp_table_item(Session *session);
146
147 type::Decimal *val_decimal(type::Decimal *);
148
149 bool agg_arg_collations(DTCollation &c, Item **items, uint32_t nitems,
150 uint32_t flags);
151 bool agg_arg_collations_for_comparison(DTCollation &c,
152 Item **items, uint32_t nitems,
153 uint32_t flags);
154 bool agg_arg_charsets(DTCollation &c, Item **items, uint32_t nitems,
155 uint32_t flags, int item_sep);
156 bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg);
157 Item *transform(Item_transformer transformer, unsigned char *arg);
158 Item* compile(Item_analyzer analyzer, unsigned char **arg_p,
159 Item_transformer transformer, unsigned char *arg_t);
160 void traverse_cond(Cond_traverser traverser,
161 void * arg, traverse_order order);
162 double fix_result(double value);
163};
164
165} /* namespace drizzled */
166
167
bool eq(const Item *item, bool binary_cmp) const
Definition func.cc:477
void fix_after_pullout(Select_Lex *new_parent, Item **ref)
Definition func.cc:257
table_map used_tables() const
Definition func.cc:430
virtual bool const_item() const
table_map not_null_tables() const
Definition func.cc:436
virtual bool check_argument_count(int)
TODO: Rename this file - func.h is stupid.
Visibility Control Macros.
#define DRIZZLED_API
Definition visibility.h:38