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