~drizzle-trunk/drizzle/development

489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
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
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
20
21
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
22
#ifndef DRIZZLED_FUNCTION_FUNC_H
23
#define DRIZZLED_FUNCTION_FUNC_H
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
24
25
/// TODO: Rename this file - func.h is stupid.
26
2154.2.4 by Brian Aker
This fixes 716459
27
#include <drizzled/charset_info.h>
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
28
#include <drizzled/item.h>
2154.2.4 by Brian Aker
This fixes 716459
29
#include <drizzled/item/bin_string.h>
30
#include <drizzled/lex_string.h>
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
31
#include <drizzled/sql_list.h>
2154.2.4 by Brian Aker
This fixes 716459
32
#include <drizzled/type/decimal.h>
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
33
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
34
#include <drizzled/visibility.h>
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
35
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
36
namespace drizzled
37
{
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
38
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
39
class DRIZZLED_API Item_func :
40
  public Item_result_field
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
41
{
1633.4.7 by Brian Aker
Put a copy of the Session in the root of function to make use of.
42
  Session &_session;
43
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
44
protected:
45
  Item **args, *tmp_arg[2];
46
  /*
47
    Allowed numbers of columns in result (usually 1, which means scalar value)
48
    0 means get this number from first argument
49
  */
50
  uint32_t allowed_arg_cols;
2154.2.19 by Brian Aker
Remove need for current_session in include.
51
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
52
public:
779.3.18 by Monty Taylor
Cleaned up warnings up through innodb.
53
54
  using Item::split_sum_func;
55
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
56
  uint32_t arg_count;
57
  table_map used_tables_cache, not_null_tables_cache;
58
  bool const_item_cache;
59
  enum Functype { UNKNOWN_FUNC,EQ_FUNC,EQUAL_FUNC,NE_FUNC,LT_FUNC,LE_FUNC,
60
                  GE_FUNC,GT_FUNC,
61
                  LIKE_FUNC,ISNULL_FUNC,ISNOTNULL_FUNC,
62
                  COND_AND_FUNC, COND_OR_FUNC, COND_XOR_FUNC,
63
                  BETWEEN, IN_FUNC, MULT_EQUAL_FUNC,
64
                  INTERVAL_FUNC, ISNOTNULLTEST_FUNC,
65
                  NOT_FUNC, NOT_ALL_FUNC,
66
                  NOW_FUNC, TRIG_COND_FUNC,
67
                  SUSERVAR_FUNC, GUSERVAR_FUNC, COLLATE_FUNC,
68
                  EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP,
69
                  NEG_FUNC };
70
  enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL,
71
                       OPTIMIZE_EQUAL };
72
  enum Type type() const { return FUNC_ITEM; }
73
  virtual enum Functype functype() const   { return UNKNOWN_FUNC; }
1022.2.29 by Monty Taylor
Fixed some no-inline warnings.
74
  virtual ~Item_func() {}
1633.4.7 by Brian Aker
Put a copy of the Session in the root of function to make use of.
75
2154.2.19 by Brian Aker
Remove need for current_session in include.
76
  Item_func(void);
1633.4.7 by Brian Aker
Put a copy of the Session in the root of function to make use of.
77
2154.2.19 by Brian Aker
Remove need for current_session in include.
78
  Item_func(Item *a);
79
  
80
  Item_func(Item *a,Item *b);
81
  
82
  Item_func(Item *a,Item *b,Item *c);
83
  
84
  Item_func(Item *a,Item *b,Item *c,Item *d);
85
  
86
  Item_func(Item *a,Item *b,Item *c,Item *d,Item* e);
1633.4.7 by Brian Aker
Put a copy of the Session in the root of function to make use of.
87
  
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
88
  Item_func(List<Item> &list);
1633.4.7 by Brian Aker
Put a copy of the Session in the root of function to make use of.
89
  
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
90
  // Constructor used for Item_cond_and/or (see Item comment)
520.1.22 by Brian Aker
Second pass of thd cleanup
91
  Item_func(Session *session, Item_func *item);
1633.4.7 by Brian Aker
Put a copy of the Session in the root of function to make use of.
92
  
520.1.21 by Brian Aker
THD -> Session rename
93
  bool fix_fields(Session *, Item **ref);
846 by Brian Aker
Removing on typedeffed class.
94
  void fix_after_pullout(Select_Lex *new_parent, Item **ref);
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
95
  table_map used_tables() const;
96
  table_map not_null_tables() const;
97
  void update_used_tables();
98
  bool eq(const Item *item, bool binary_cmp) const;
99
  virtual optimize_type select_optimize() const { return OPTIMIZE_NONE; }
100
  virtual bool have_rev_func() const { return 0; }
101
  virtual Item *key_item() const { return args[0]; }
102
  /*
103
    This method is used for debug purposes to print the name of an
104
    item to the debug log. The second use of this method is as
105
    a helper function of print(), where it is applicable.
106
    To suit both goals it should return a meaningful,
107
    distinguishable and sintactically correct string.  This method
108
    should not be used for runtime type identification, use enum
109
    {Sum}Functype and Item_func::functype()/Item_sum::sum_func()
110
    instead.
111
  */
1891.2.1 by Monty Taylor
Fixed things to make things compile with clang
112
  virtual const char *func_name() const { return NULL; }
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
113
  virtual bool const_item() const { return const_item_cache; }
114
  Item **arguments() const { return args; }
115
  void set_arguments(List<Item> &list);
116
  uint32_t argument_count() const { return arg_count; }
117
  void remove_arguments() { arg_count=0; }
1005.1.2 by Monty Taylor
Merged Stewart from lp:~stewart-flamingspork/drizzle/fix-function-arguments
118
119
  /**
120
   * Check if the UDF supports the number of arguments passed in
121
   * @param number of args
122
   */
123
  virtual bool check_argument_count(int) { return true ; }
779.3.16 by Monty Taylor
Some Sun warning fixes.
124
  virtual void split_sum_func(Session *session, Item **ref_pointer_array,
125
                              List<Item> &fields);
126
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
127
  virtual void print(String *str, enum_query_type query_type);
128
  void print_op(String *str, enum_query_type query_type);
129
  void print_args(String *str, uint32_t from, enum_query_type query_type);
130
  virtual void fix_num_length_and_dec();
131
  void count_only_length();
132
  void count_real_length();
133
  void count_decimal_length();
134
2104.2.8 by Brian Aker
Merge in reference from pointer.
135
  bool get_arg0_date(type::Time &ltime, uint32_t fuzzy_date);
136
  bool get_arg0_time(type::Time &ltime);
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
137
138
  bool is_null();
139
2060 by Brian Aker
Added native functions into the function table.
140
  virtual bool deterministic() const
141
  {
142
    return false;
143
  }
144
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
145
  void signal_divide_by_null();
146
779.3.16 by Monty Taylor
Some Sun warning fixes.
147
  virtual Field *tmp_table_field() { return result_field; }
148
  virtual Field *tmp_table_field(Table *t_arg);
149
520.1.22 by Brian Aker
Second pass of thd cleanup
150
  Item *get_tmp_table_item(Session *session);
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
151
2030.1.4 by Brian Aker
Change my_decimal to Decimal
152
  type::Decimal *val_decimal(type::Decimal *);
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
153
154
  bool agg_arg_collations(DTCollation &c, Item **items, uint32_t nitems,
155
                          uint32_t flags);
156
  bool agg_arg_collations_for_comparison(DTCollation &c,
157
                                         Item **items, uint32_t nitems,
158
                                         uint32_t flags);
159
  bool agg_arg_charsets(DTCollation &c, Item **items, uint32_t nitems,
160
                        uint32_t flags, int item_sep);
161
  bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg);
162
  Item *transform(Item_transformer transformer, unsigned char *arg);
163
  Item* compile(Item_analyzer analyzer, unsigned char **arg_p,
164
                Item_transformer transformer, unsigned char *arg_t);
165
  void traverse_cond(Cond_traverser traverser,
166
                     void * arg, traverse_order order);
167
  double fix_result(double value);
168
1633.4.7 by Brian Aker
Put a copy of the Session in the root of function to make use of.
169
  Session &getSession()
170
  {
171
    return _session;
172
  }
173
174
  Session *getSessionPtr()
175
  {
176
    return &_session;
177
  }
178
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
179
};
180
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
181
} /* namespace drizzled */
182
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
183
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
184
#endif /* DRIZZLED_FUNCTION_FUNC_H */