~drizzle-trunk/drizzle/development

390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
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.
390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
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
 */
1 by brian
clean slate
19
20
/* Functions to create an item. Used by sql/sql_yacc.yy */
21
1122.2.10 by Monty Taylor
Fixed all of the include guards.
22
#ifndef DRIZZLED_ITEM_CREATE_H
23
#define DRIZZLED_ITEM_CREATE_H
1 by brian
clean slate
24
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
25
#include <drizzled/item/func.h>
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
26
#include <drizzled/plugin/function.h>
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
27
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
28
namespace drizzled
29
{
30
1 by brian
clean slate
31
/**
32
  Public function builder interface.
33
  The parser (sql/sql_yacc.yy) uses a factory / builder pattern to
34
  construct an <code>Item</code> object for each function call.
35
  All the concrete function builders implements this interface,
36
  either directly or indirectly with some adapter helpers.
37
  Keeping the function creation separated from the bison grammar allows
38
  to simplify the parser, and avoid the need to introduce a new token
39
  for each function, which has undesirable side effects in the grammar.
40
*/
41
42
class Create_func
43
{
44
public:
45
  /**
46
    The builder create method.
47
    Given the function name and list or arguments, this method creates
48
    an <code>Item</code> that represents the function call.
49
    In case or errors, a NULL item is returned, and an error is reported.
520.1.22 by Brian Aker
Second pass of thd cleanup
50
    Note that the <code>session</code> object may be modified by the builder.
1 by brian
clean slate
51
    In particular, the following members/methods can be set/called,
52
    depending on the function called and the function possible side effects.
53
    <ul>
520.1.22 by Brian Aker
Second pass of thd cleanup
54
      <li><code>session->lex->binlog_row_based_if_mixed</code></li>
55
      <li><code>session->lex->current_context()</code></li>
56
      <li><code>session->lex->safe_to_cache_query</code></li>
57
      <li><code>session->lex->uncacheable(UNCACHEABLE_SIDEEFFECT)</code></li>
58
      <li><code>session->lex->uncacheable(UNCACHEABLE_RAND)</code></li>
59
      <li><code>session->lex->add_time_zone_tables_to_query_tables(session)</code></li>
1 by brian
clean slate
60
    </ul>
520.1.22 by Brian Aker
Second pass of thd cleanup
61
    @param session The current thread
1 by brian
clean slate
62
    @param name The function name
63
    @param item_list The list of arguments to the function, can be NULL
64
    @return An item representing the parsed function call, or NULL
65
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
66
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list) = 0;
1 by brian
clean slate
67
68
protected:
69
  /** Constructor */
70
  Create_func() {}
71
  /** Destructor */
72
  virtual ~Create_func() {}
73
};
74
75
/**
76
  Function builder for qualified functions.
77
  This builder is used with functions call using a qualified function name
78
  syntax, as in <code>db.func(expr, expr, ...)</code>.
79
*/
80
81
class Create_qfunc : public Create_func
82
{
83
public:
84
  /**
85
    The builder create method, for unqualified functions.
86
    This builder will use the current database for the database name.
520.1.22 by Brian Aker
Second pass of thd cleanup
87
    @param session The current thread
1 by brian
clean slate
88
    @param name The function name
89
    @param item_list The list of arguments to the function, can be NULL
90
    @return An item representing the parsed function call
91
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
92
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
93
94
  /**
95
    The builder create method, for qualified functions.
520.1.22 by Brian Aker
Second pass of thd cleanup
96
    @param session The current thread
1 by brian
clean slate
97
    @param db The database name
98
    @param name The function name
99
    @param use_explicit_name Should the function be represented as 'db.name'?
100
    @param item_list The list of arguments to the function, can be NULL
101
    @return An item representing the parsed function call
102
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
103
  virtual Item* create(Session *session, LEX_STRING db, LEX_STRING name,
1 by brian
clean slate
104
                       bool use_explicit_name, List<Item> *item_list) = 0;
105
106
protected:
107
  /** Constructor. */
108
  Create_qfunc() {}
109
  /** Destructor. */
110
  virtual ~Create_qfunc() {}
111
};
112
113
114
/**
115
  Find the native function builder associated with a given function name.
116
  @param name The native function name
117
  @return The native function builder associated with the name, or NULL
118
*/
873.2.19 by Monty Taylor
Removed another HASH and another set of useless utf8 hashing.
119
extern Create_func * find_native_function_builder(LEX_STRING name);
1 by brian
clean slate
120
121
122
/**
123
  Find the function builder for qualified functions.
520.1.22 by Brian Aker
Second pass of thd cleanup
124
  @param session The current thread
1 by brian
clean slate
125
  @return A function builder for qualified functions
126
*/
520.1.22 by Brian Aker
Second pass of thd cleanup
127
extern Create_qfunc * find_qualified_function_builder(Session *session);
1 by brian
clean slate
128
129
130
/**
131
  Function builder for User Defined Functions.
132
*/
133
134
class Create_udf_func : public Create_func
135
{
136
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
137
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
138
139
  /**
140
    The builder create method, for User Defined Functions.
520.1.22 by Brian Aker
Second pass of thd cleanup
141
    @param session The current thread
1 by brian
clean slate
142
    @param fct The User Defined Function metadata
143
    @param item_list The list of arguments to the function, can be NULL
144
    @return An item representing the parsed function call
145
  */
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
146
  Item *create(Session *session,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
147
               const plugin::Function *fct,
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
148
               List<Item> *item_list);
1 by brian
clean slate
149
150
  /** Singleton. */
151
  static Create_udf_func s_singleton;
152
153
protected:
154
  /** Constructor. */
155
  Create_udf_func() {}
156
  /** Destructor. */
157
  virtual ~Create_udf_func() {}
158
};
159
160
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
161
create_func_char_cast(Session *session, Item *a, int len, const CHARSET_INFO * const cs);
1 by brian
clean slate
162
163
/**
164
  Builder for cast expressions.
520.1.22 by Brian Aker
Second pass of thd cleanup
165
  @param session The current thread
1 by brian
clean slate
166
  @param a The item to cast
167
  @param cast_type the type casted into
168
  @param len TODO
169
  @param dec TODO
170
  @param cs The character set
171
*/
172
Item *
520.1.22 by Brian Aker
Second pass of thd cleanup
173
create_func_cast(Session *session, Item *a, Cast_target cast_type,
1 by brian
clean slate
174
                 const char *len, const char *dec,
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
175
                 const CHARSET_INFO * const cs);
243.1.7 by Jay Pipes
* Moved the Item factory creation functions into the item_create.h header,
176
177
int item_create_init();
178
void item_create_cleanup();
179
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
180
} /* namespace drizzled */
181
1122.2.10 by Monty Taylor
Fixed all of the include guards.
182
#endif /* DRIZZLED_ITEM_CREATE_H */