00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00025
00026 #include <drizzled/charset_info.h>
00027 #include <drizzled/item.h>
00028 #include <drizzled/item/bin_string.h>
00029 #include <drizzled/lex_string.h>
00030 #include <drizzled/sql_list.h>
00031 #include <drizzled/type/decimal.h>
00032
00033 #include <drizzled/visibility.h>
00034
00035 namespace drizzled
00036 {
00037
00038 class DRIZZLED_API Item_func :
00039 public Item_result_field
00040 {
00041 Session &_session;
00042
00043 protected:
00044 Item **args, *tmp_arg[2];
00045
00046
00047
00048
00049 uint32_t allowed_arg_cols;
00050
00051 public:
00052
00053 using Item::split_sum_func;
00054
00055 uint32_t arg_count;
00056 table_map used_tables_cache, not_null_tables_cache;
00057 bool const_item_cache;
00058 enum Functype { UNKNOWN_FUNC,EQ_FUNC,EQUAL_FUNC,NE_FUNC,LT_FUNC,LE_FUNC,
00059 GE_FUNC,GT_FUNC,
00060 LIKE_FUNC,ISNULL_FUNC,ISNOTNULL_FUNC,
00061 COND_AND_FUNC, COND_OR_FUNC, COND_XOR_FUNC,
00062 BETWEEN, IN_FUNC, MULT_EQUAL_FUNC,
00063 INTERVAL_FUNC, ISNOTNULLTEST_FUNC,
00064 NOT_FUNC, NOT_ALL_FUNC,
00065 NOW_FUNC, TRIG_COND_FUNC,
00066 SUSERVAR_FUNC, GUSERVAR_FUNC, COLLATE_FUNC,
00067 EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP,
00068 NEG_FUNC };
00069 enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL,
00070 OPTIMIZE_EQUAL };
00071 enum Type type() const { return FUNC_ITEM; }
00072 virtual enum Functype functype() const { return UNKNOWN_FUNC; }
00073 virtual ~Item_func() {}
00074
00075 Item_func(void);
00076
00077 Item_func(Item *a);
00078
00079 Item_func(Item *a,Item *b);
00080
00081 Item_func(Item *a,Item *b,Item *c);
00082
00083 Item_func(Item *a,Item *b,Item *c,Item *d);
00084
00085 Item_func(Item *a,Item *b,Item *c,Item *d,Item* e);
00086
00087 Item_func(List<Item> &list);
00088
00089
00090 Item_func(Session *session, Item_func *item);
00091
00092 bool fix_fields(Session *, Item **ref);
00093 void fix_after_pullout(Select_Lex *new_parent, Item **ref);
00094 table_map used_tables() const;
00095 table_map not_null_tables() const;
00096 void update_used_tables();
00097 bool eq(const Item *item, bool binary_cmp) const;
00098 virtual optimize_type select_optimize() const { return OPTIMIZE_NONE; }
00099 virtual bool have_rev_func() const { return 0; }
00100 virtual Item *key_item() const { return args[0]; }
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 virtual const char *func_name() const { return NULL; }
00112 virtual bool const_item() const { return const_item_cache; }
00113 Item **arguments() const { return args; }
00114 void set_arguments(List<Item> &list);
00115 uint32_t argument_count() const { return arg_count; }
00116 void remove_arguments() { arg_count=0; }
00117
00122 virtual bool check_argument_count(int) { return true ; }
00123 virtual void split_sum_func(Session *session, Item **ref_pointer_array,
00124 List<Item> &fields);
00125
00126 virtual void print(String *str);
00127 void print_op(String *str);
00128 void print_args(String *str, uint32_t from);
00129 virtual void fix_num_length_and_dec();
00130 void count_only_length();
00131 void count_real_length();
00132 void count_decimal_length();
00133
00134 bool get_arg0_date(type::Time <ime, uint32_t fuzzy_date);
00135 bool get_arg0_time(type::Time <ime);
00136
00137 bool is_null();
00138
00139 virtual bool deterministic() const
00140 {
00141 return false;
00142 }
00143
00144 void signal_divide_by_null();
00145
00146 virtual Field *tmp_table_field() { return result_field; }
00147 virtual Field *tmp_table_field(Table *t_arg);
00148
00149 Item *get_tmp_table_item(Session *session);
00150
00151 type::Decimal *val_decimal(type::Decimal *);
00152
00153 bool agg_arg_collations(DTCollation &c, Item **items, uint32_t nitems,
00154 uint32_t flags);
00155 bool agg_arg_collations_for_comparison(DTCollation &c,
00156 Item **items, uint32_t nitems,
00157 uint32_t flags);
00158 bool agg_arg_charsets(DTCollation &c, Item **items, uint32_t nitems,
00159 uint32_t flags, int item_sep);
00160 bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg);
00161 Item *transform(Item_transformer transformer, unsigned char *arg);
00162 Item* compile(Item_analyzer analyzer, unsigned char **arg_p,
00163 Item_transformer transformer, unsigned char *arg_t);
00164 void traverse_cond(Cond_traverser traverser,
00165 void * arg, traverse_order order);
00166 double fix_result(double value);
00167
00168 Session &getSession()
00169 {
00170 return _session;
00171 }
00172
00173 Session *getSessionPtr()
00174 {
00175 return &_session;
00176 }
00177
00178 };
00179
00180 }
00181
00182