1
by brian
clean slate |
1 |
/* Copyright (C) 2000-2003 MySQL AB
|
2 |
||
3 |
This program is free software; you can redistribute it and/or modify
|
|
4 |
it under the terms of the GNU General Public License as published by
|
|
5 |
the Free Software Foundation; version 2 of the License.
|
|
6 |
||
7 |
This program is distributed in the hope that it will be useful,
|
|
8 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
GNU General Public License for more details.
|
|
11 |
||
12 |
You should have received a copy of the GNU General Public License
|
|
13 |
along with this program; if not, write to the Free Software
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
14 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
1
by brian
clean slate |
15 |
|
16 |
/**
|
|
17 |
@file
|
|
18 |
||
19 |
@brief
|
|
20 |
Functions to create an item. Used by sql_yac.yy
|
|
21 |
*/
|
|
22 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
23 |
#include <config.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. |
24 |
#include <drizzled/item/create.h> |
25 |
#include <drizzled/item/func.h> |
|
550
by Monty Taylor
Moved error.h into just the files that need it. |
26 |
#include <drizzled/error.h> |
2241.3.2
by Olaf van der Spek
Refactor Session::variables |
27 |
#include <drizzled/system_variables.h> |
1
by brian
clean slate |
28 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
29 |
#include <drizzled/function_container.h> |
1751.3.3
by Brian Aker
Shuffle native functions over to hash such that we have a specific container |
30 |
|
670.1.20
by Monty Taylor
Renamed functions to function... everything else is singular. |
31 |
#include <drizzled/function/str/binary.h> |
32 |
#include <drizzled/function/str/concat.h> |
|
33 |
#include <drizzled/function/str/conv.h> |
|
34 |
#include <drizzled/function/str/export_set.h> |
|
35 |
#include <drizzled/function/str/load_file.h> |
|
36 |
#include <drizzled/function/str/make_set.h> |
|
37 |
#include <drizzled/function/str/pad.h> |
|
38 |
#include <drizzled/function/str/repeat.h> |
|
39 |
#include <drizzled/function/str/str_conv.h> |
|
40 |
#include <drizzled/function/str/trim.h> |
|
642.1.12
by Lee
remove drizzled/item/strfunc.h, no longer needed |
41 |
|
670.1.22
by Monty Taylor
Merged from Lee. |
42 |
#include <drizzled/function/time/date_format.h> |
43 |
#include <drizzled/function/time/dayname.h> |
|
44 |
#include <drizzled/function/time/dayofmonth.h> |
|
45 |
#include <drizzled/function/time/dayofyear.h> |
|
46 |
#include <drizzled/function/time/from_unixtime.h> |
|
47 |
#include <drizzled/function/time/from_days.h> |
|
48 |
#include <drizzled/function/time/last_day.h> |
|
49 |
#include <drizzled/function/time/makedate.h> |
|
50 |
#include <drizzled/function/time/month.h> |
|
51 |
#include <drizzled/function/time/period_add.h> |
|
52 |
#include <drizzled/function/time/period_diff.h> |
|
53 |
#include <drizzled/function/time/to_days.h> |
|
54 |
#include <drizzled/function/time/typecast.h> |
|
55 |
#include <drizzled/function/time/unix_timestamp.h> |
|
56 |
#include <drizzled/function/time/weekday.h> |
|
642.1.13
by Lee
remove drizzled/item/timefunc.h, no longer needed |
57 |
|
584.4.7
by Monty Taylor
Removed a big bank of includes from item.h. |
58 |
#include <drizzled/item/cmpfunc.h> |
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
59 |
#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. |
60 |
#include <drizzled/session.h> |
584.4.7
by Monty Taylor
Removed a big bank of includes from item.h. |
61 |
|
648
by Brian Aker
Fix for create to keep its include files (which speeds up recompiles). |
62 |
/* Function declarations */
|
63 |
||
670.1.20
by Monty Taylor
Renamed functions to function... everything else is singular. |
64 |
#include <drizzled/function/func.h> |
65 |
#include <drizzled/function/additive_op.h> |
|
642.1.30
by Lee
move math functions to drizzled/function/math directory |
66 |
#include <drizzled/function/math/dec.h> |
67 |
#include <drizzled/function/math/decimal_typecast.h> |
|
670.1.20
by Monty Taylor
Renamed functions to function... everything else is singular. |
68 |
#include <drizzled/function/field.h> |
69 |
#include <drizzled/function/find_in_set.h> |
|
70 |
#include <drizzled/function/found_rows.h> |
|
71 |
#include <drizzled/function/get_system_var.h> |
|
642.1.30
by Lee
move math functions to drizzled/function/math directory |
72 |
#include <drizzled/function/math/int_val.h> |
73 |
#include <drizzled/function/math/integer.h> |
|
670.1.20
by Monty Taylor
Renamed functions to function... everything else is singular. |
74 |
#include <drizzled/function/last_insert.h> |
75 |
#include <drizzled/function/locate.h> |
|
76 |
#include <drizzled/function/min_max.h> |
|
77 |
#include <drizzled/function/num1.h> |
|
78 |
#include <drizzled/function/num_op.h> |
|
79 |
#include <drizzled/function/numhybrid.h> |
|
642.1.30
by Lee
move math functions to drizzled/function/math directory |
80 |
#include <drizzled/function/math/real.h> |
670.1.20
by Monty Taylor
Renamed functions to function... everything else is singular. |
81 |
#include <drizzled/function/row_count.h> |
82 |
#include <drizzled/function/set_user_var.h> |
|
83 |
#include <drizzled/function/sign.h> |
|
642.1.30
by Lee
move math functions to drizzled/function/math directory |
84 |
#include <drizzled/function/math/tan.h> |
670.1.20
by Monty Taylor
Renamed functions to function... everything else is singular. |
85 |
#include <drizzled/function/units.h> |
648
by Brian Aker
Fix for create to keep its include files (which speeds up recompiles). |
86 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
87 |
#include <drizzled/function/cast/boolean.h> |
88 |
#include <drizzled/function/cast/signed.h> |
|
89 |
#include <drizzled/function/cast/time.h> |
|
90 |
#include <drizzled/function/cast/unsigned.h> |
|
1999.4.8
by Brian Aker
Adding in time type. |
91 |
|
873.2.19
by Monty Taylor
Removed another HASH and another set of useless utf8 hashing. |
92 |
using namespace std; |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
93 |
|
2241.3.2
by Olaf van der Spek
Refactor Session::variables |
94 |
namespace drizzled { |
648
by Brian Aker
Fix for create to keep its include files (which speeds up recompiles). |
95 |
|
1
by brian
clean slate |
96 |
/*
|
97 |
=============================================================================
|
|
98 |
LOCAL DECLARATIONS
|
|
99 |
=============================================================================
|
|
100 |
*/
|
|
101 |
||
102 |
/**
|
|
103 |
Adapter for native functions with a variable number of arguments.
|
|
104 |
The main use of this class is to discard the following calls:
|
|
105 |
<code>foo(expr1 AS name1, expr2 AS name2, ...)</code>
|
|
106 |
which are syntactically correct (the syntax can refer to a UDF),
|
|
107 |
but semantically invalid for native functions.
|
|
108 |
*/
|
|
109 |
||
2318.6.87
by Olaf van der Spek
Refactor |
110 |
/**
|
111 |
Checks if there are named parameters in a parameter list.
|
|
112 |
The syntax to name parameters in a function call is as follow:
|
|
113 |
<code>foo(expr AS named, expr named, expr AS "named", expr "named")</code>
|
|
114 |
@param params The parameter list, can be null
|
|
115 |
@return true if one or more parameter is named
|
|
116 |
*/
|
|
117 |
static bool has_named_parameters(List<Item>& params) |
|
118 |
{
|
|
119 |
List<Item>::iterator it(params.begin()); |
|
120 |
while (Item* param= it++) |
|
121 |
{
|
|
122 |
if (not param->is_autogenerated_name) |
|
123 |
return true; |
|
124 |
}
|
|
125 |
return false; |
|
126 |
}
|
|
127 |
||
1
by brian
clean slate |
128 |
class Create_native_func : public Create_func |
129 |
{
|
|
130 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
131 |
virtual Item* create(Session* session, str_ref name, List<Item>* item_list) |
2318.6.87
by Olaf van der Spek
Refactor |
132 |
{
|
133 |
if (item_list && has_named_parameters(*item_list)) |
|
134 |
{
|
|
2430.1.1
by Olaf van der Spek
Use lex_string assign(), data() and size() |
135 |
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data()); |
2318.6.87
by Olaf van der Spek
Refactor |
136 |
return NULL; |
137 |
}
|
|
138 |
return create_native(session, name, item_list); |
|
139 |
}
|
|
1
by brian
clean slate |
140 |
|
141 |
/**
|
|
142 |
Builder method, with no arguments.
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
143 |
@param session The current thread
|
1
by brian
clean slate |
144 |
@param name The native function name
|
145 |
@param item_list The function parameters, none of which are named
|
|
146 |
@return An item representing the function call
|
|
147 |
*/
|
|
2440.2.4
by Olaf van der Spek
Refactor |
148 |
virtual Item* create_native(Session*, str_ref name, List<Item>*) = 0; |
1
by brian
clean slate |
149 |
};
|
150 |
||
151 |
||
152 |
/**
|
|
153 |
Adapter for functions that takes exactly zero arguments.
|
|
154 |
*/
|
|
155 |
||
156 |
class Create_func_arg0 : public Create_func |
|
157 |
{
|
|
158 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
159 |
virtual Item* create(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
160 |
|
161 |
/**
|
|
162 |
Builder method, with no arguments.
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
163 |
@param session The current thread
|
1
by brian
clean slate |
164 |
@return An item representing the function call
|
165 |
*/
|
|
2318.6.83
by Olaf van der Spek
Refactor |
166 |
virtual Item* create(Session *session) = 0; |
1
by brian
clean slate |
167 |
};
|
168 |
||
169 |
||
170 |
/**
|
|
171 |
Adapter for functions that takes exactly one argument.
|
|
172 |
*/
|
|
173 |
||
174 |
class Create_func_arg1 : public Create_func |
|
175 |
{
|
|
176 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
177 |
virtual Item* create(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
178 |
|
179 |
/**
|
|
180 |
Builder method, with one argument.
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
181 |
@param session The current thread
|
1
by brian
clean slate |
182 |
@param arg1 The first argument of the function
|
183 |
@return An item representing the function call
|
|
184 |
*/
|
|
2318.6.83
by Olaf van der Spek
Refactor |
185 |
virtual Item* create(Session *session, Item *arg1) = 0; |
1
by brian
clean slate |
186 |
};
|
187 |
||
188 |
||
189 |
/**
|
|
190 |
Adapter for functions that takes exactly two arguments.
|
|
191 |
*/
|
|
192 |
||
193 |
class Create_func_arg2 : public Create_func |
|
194 |
{
|
|
195 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
196 |
virtual Item* create(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
197 |
|
198 |
/**
|
|
199 |
Builder method, with two arguments.
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
200 |
@param session The current thread
|
1
by brian
clean slate |
201 |
@param arg1 The first argument of the function
|
202 |
@param arg2 The second argument of the function
|
|
203 |
@return An item representing the function call
|
|
204 |
*/
|
|
2318.6.83
by Olaf van der Spek
Refactor |
205 |
virtual Item* create(Session *session, Item *arg1, Item *arg2) = 0; |
1
by brian
clean slate |
206 |
};
|
207 |
||
208 |
||
209 |
/**
|
|
210 |
Adapter for functions that takes exactly three arguments.
|
|
211 |
*/
|
|
212 |
||
213 |
class Create_func_arg3 : public Create_func |
|
214 |
{
|
|
215 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
216 |
virtual Item* create(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
217 |
|
218 |
/**
|
|
219 |
Builder method, with three arguments.
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
220 |
@param session The current thread
|
1
by brian
clean slate |
221 |
@param arg1 The first argument of the function
|
222 |
@param arg2 The second argument of the function
|
|
223 |
@param arg3 The third argument of the function
|
|
224 |
@return An item representing the function call
|
|
225 |
*/
|
|
2318.6.83
by Olaf van der Spek
Refactor |
226 |
virtual Item* create(Session *session, Item *arg1, Item *arg2, Item *arg3) = 0; |
1
by brian
clean slate |
227 |
};
|
228 |
||
229 |
||
230 |
/**
|
|
231 |
Function builder for Stored Functions.
|
|
232 |
*/
|
|
233 |
||
234 |
/*
|
|
235 |
Concrete functions builders (native functions).
|
|
236 |
Please keep this list sorted in alphabetical order,
|
|
237 |
it helps to compare code between versions, and helps with merges conflicts.
|
|
238 |
*/
|
|
239 |
||
240 |
||
241 |
class Create_func_bin : public Create_func_arg1 |
|
242 |
{
|
|
243 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
244 |
using Create_func_arg1::create; |
245 |
||
2318.6.83
by Olaf van der Spek
Refactor |
246 |
virtual Item* create(Session *session, Item *arg1); |
1
by brian
clean slate |
247 |
|
248 |
static Create_func_bin s_singleton; |
|
249 |
};
|
|
250 |
||
251 |
class Create_func_concat : public Create_native_func |
|
252 |
{
|
|
253 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
254 |
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
255 |
|
256 |
static Create_func_concat s_singleton; |
|
257 |
};
|
|
258 |
||
259 |
||
260 |
class Create_func_concat_ws : public Create_native_func |
|
261 |
{
|
|
262 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
263 |
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
264 |
|
265 |
static Create_func_concat_ws s_singleton; |
|
266 |
};
|
|
267 |
||
268 |
||
269 |
class Create_func_conv : public Create_func_arg3 |
|
270 |
{
|
|
271 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
272 |
using Create_func_arg3::create; |
273 |
||
2318.6.84
by Olaf van der Spek
Refactor |
274 |
virtual Item* create(Session *session, Item *arg1, Item *arg2, Item *arg3) |
275 |
{
|
|
276 |
return new (session->mem) Item_func_conv(arg1, arg2, arg3); |
|
277 |
}
|
|
1
by brian
clean slate |
278 |
|
279 |
static Create_func_conv s_singleton; |
|
280 |
};
|
|
281 |
||
2318.6.84
by Olaf van der Spek
Refactor |
282 |
Create_func_conv Create_func_conv::s_singleton; |
283 |
||
1
by brian
clean slate |
284 |
class Create_func_cot : public Create_func_arg1 |
285 |
{
|
|
286 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
287 |
using Create_func_arg1::create; |
288 |
||
2318.6.83
by Olaf van der Spek
Refactor |
289 |
virtual Item* create(Session *session, Item *arg1); |
1
by brian
clean slate |
290 |
|
291 |
static Create_func_cot s_singleton; |
|
292 |
};
|
|
293 |
||
294 |
class Create_func_date_format : public Create_func_arg2 |
|
295 |
{
|
|
296 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
297 |
using Create_func_arg2::create; |
298 |
||
2318.6.83
by Olaf van der Spek
Refactor |
299 |
virtual Item* create(Session *session, Item *arg1, Item *arg2) |
300 |
{
|
|
301 |
return new (session->mem) Item_func_date_format(arg1, arg2, 0); |
|
302 |
}
|
|
1
by brian
clean slate |
303 |
|
304 |
static Create_func_date_format s_singleton; |
|
305 |
};
|
|
306 |
||
2318.6.83
by Olaf van der Spek
Refactor |
307 |
Create_func_date_format Create_func_date_format::s_singleton; |
1
by brian
clean slate |
308 |
|
309 |
class Create_func_datediff : public Create_func_arg2 |
|
310 |
{
|
|
311 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
312 |
using Create_func_arg2::create; |
313 |
||
2318.6.83
by Olaf van der Spek
Refactor |
314 |
virtual Item* create(Session *session, Item *arg1, Item *arg2); |
1
by brian
clean slate |
315 |
|
316 |
static Create_func_datediff s_singleton; |
|
317 |
};
|
|
318 |
||
319 |
||
320 |
class Create_func_dayname : public Create_func_arg1 |
|
321 |
{
|
|
322 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
323 |
using Create_func_arg1::create; |
324 |
||
2318.6.83
by Olaf van der Spek
Refactor |
325 |
virtual Item* create(Session *session, Item *arg1) |
326 |
{
|
|
327 |
return new (session->mem) Item_func_dayname(arg1); |
|
328 |
}
|
|
1
by brian
clean slate |
329 |
|
330 |
static Create_func_dayname s_singleton; |
|
331 |
};
|
|
332 |
||
2318.6.83
by Olaf van der Spek
Refactor |
333 |
Create_func_dayname Create_func_dayname::s_singleton; |
1
by brian
clean slate |
334 |
|
335 |
class Create_func_dayofmonth : public Create_func_arg1 |
|
336 |
{
|
|
337 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
338 |
using Create_func_arg1::create; |
339 |
||
2318.6.87
by Olaf van der Spek
Refactor |
340 |
virtual Item* create(Session *session, Item *arg1) |
341 |
{
|
|
342 |
return new (session->mem) Item_func_dayofmonth(arg1); |
|
343 |
}
|
|
1
by brian
clean slate |
344 |
|
345 |
static Create_func_dayofmonth s_singleton; |
|
346 |
};
|
|
347 |
||
2318.6.87
by Olaf van der Spek
Refactor |
348 |
Create_func_dayofmonth Create_func_dayofmonth::s_singleton; |
1
by brian
clean slate |
349 |
|
350 |
class Create_func_dayofweek : public Create_func_arg1 |
|
351 |
{
|
|
352 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
353 |
using Create_func_arg1::create; |
354 |
||
2318.6.87
by Olaf van der Spek
Refactor |
355 |
virtual Item* create(Session *session, Item *arg1) |
356 |
{
|
|
357 |
return new (session->mem) Item_func_weekday(arg1, 1); |
|
358 |
}
|
|
1
by brian
clean slate |
359 |
|
360 |
static Create_func_dayofweek s_singleton; |
|
361 |
};
|
|
362 |
||
2318.6.87
by Olaf van der Spek
Refactor |
363 |
Create_func_dayofweek Create_func_dayofweek::s_singleton; |
1
by brian
clean slate |
364 |
|
365 |
class Create_func_dayofyear : public Create_func_arg1 |
|
366 |
{
|
|
367 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
368 |
using Create_func_arg1::create; |
369 |
||
2318.6.87
by Olaf van der Spek
Refactor |
370 |
virtual Item* create(Session *session, Item *arg1) |
371 |
{
|
|
372 |
return new (session->mem) Item_func_dayofyear(arg1); |
|
373 |
}
|
|
1
by brian
clean slate |
374 |
|
375 |
static Create_func_dayofyear s_singleton; |
|
376 |
};
|
|
377 |
||
2318.6.87
by Olaf van der Spek
Refactor |
378 |
Create_func_dayofyear Create_func_dayofyear::s_singleton; |
1
by brian
clean slate |
379 |
|
380 |
class Create_func_decode : public Create_func_arg2 |
|
381 |
{
|
|
382 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
383 |
using Create_func_arg2::create; |
384 |
||
2318.6.83
by Olaf van der Spek
Refactor |
385 |
virtual Item* create(Session *session, Item *arg1, Item *arg2); |
1
by brian
clean slate |
386 |
|
387 |
static Create_func_decode s_singleton; |
|
388 |
};
|
|
389 |
||
390 |
||
391 |
class Create_func_degrees : public Create_func_arg1 |
|
392 |
{
|
|
393 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
394 |
using Create_func_arg1::create; |
395 |
||
2318.6.87
by Olaf van der Spek
Refactor |
396 |
virtual Item* create(Session *session, Item *arg1) |
397 |
{
|
|
398 |
return new (session->mem) Item_func_units("degrees", arg1, 180/M_PI, 0.0); |
|
399 |
}
|
|
1
by brian
clean slate |
400 |
|
401 |
static Create_func_degrees s_singleton; |
|
402 |
};
|
|
403 |
||
2318.6.87
by Olaf van der Spek
Refactor |
404 |
Create_func_degrees Create_func_degrees::s_singleton; |
405 |
||
1
by brian
clean slate |
406 |
class Create_func_export_set : public Create_native_func |
407 |
{
|
|
1759.3.15
by Stewart Smith
move SQRT() function into math_functions plugin |
408 |
|
1
by brian
clean slate |
409 |
public: |
2440.2.4
by Olaf van der Spek
Refactor |
410 |
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
411 |
|
412 |
static Create_func_export_set s_singleton; |
|
413 |
};
|
|
414 |
||
415 |
||
416 |
class Create_func_field : public Create_native_func |
|
417 |
{
|
|
418 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
419 |
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
420 |
|
421 |
static Create_func_field s_singleton; |
|
422 |
};
|
|
423 |
||
424 |
||
425 |
class Create_func_find_in_set : public Create_func_arg2 |
|
426 |
{
|
|
427 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
428 |
using Create_func_arg2::create; |
429 |
||
2440.2.4
by Olaf van der Spek
Refactor |
430 |
virtual Item* create(Session *session, Item *arg1, Item *arg2) |
431 |
{
|
|
432 |
return new (session->mem) Item_func_find_in_set(arg1, arg2); |
|
433 |
}
|
|
1
by brian
clean slate |
434 |
|
435 |
static Create_func_find_in_set s_singleton; |
|
436 |
};
|
|
437 |
||
438 |
class Create_func_found_rows : public Create_func_arg0 |
|
439 |
{
|
|
440 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
441 |
using Create_func_arg0::create; |
442 |
||
2440.2.4
by Olaf van der Spek
Refactor |
443 |
virtual Item* create(Session *session) |
444 |
{
|
|
445 |
return new (session->mem) Item_func_found_rows(); |
|
446 |
}
|
|
1
by brian
clean slate |
447 |
|
448 |
static Create_func_found_rows s_singleton; |
|
449 |
};
|
|
450 |
||
451 |
||
452 |
class Create_func_from_days : public Create_func_arg1 |
|
453 |
{
|
|
454 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
455 |
using Create_func_arg1::create; |
456 |
||
2440.2.4
by Olaf van der Spek
Refactor |
457 |
virtual Item* create(Session *session, Item *arg1) |
458 |
{
|
|
459 |
return new (session->mem) Item_func_from_days(arg1); |
|
460 |
}
|
|
1
by brian
clean slate |
461 |
|
462 |
static Create_func_from_days s_singleton; |
|
463 |
};
|
|
464 |
||
465 |
||
466 |
class Create_func_from_unixtime : public Create_native_func |
|
467 |
{
|
|
468 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
469 |
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
470 |
|
471 |
static Create_func_from_unixtime s_singleton; |
|
472 |
};
|
|
473 |
||
474 |
||
475 |
class Create_func_greatest : public Create_native_func |
|
476 |
{
|
|
477 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
478 |
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
479 |
|
480 |
static Create_func_greatest s_singleton; |
|
481 |
};
|
|
482 |
||
483 |
||
484 |
class Create_func_ifnull : public Create_func_arg2 |
|
485 |
{
|
|
486 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
487 |
using Create_func_arg2::create; |
488 |
||
2440.2.4
by Olaf van der Spek
Refactor |
489 |
virtual Item* create(Session *session, Item *arg1, Item *arg2) |
490 |
{
|
|
491 |
return new (session->mem) Item_func_ifnull(arg1, arg2); |
|
492 |
}
|
|
1
by brian
clean slate |
493 |
|
494 |
static Create_func_ifnull s_singleton; |
|
495 |
};
|
|
496 |
||
497 |
||
498 |
class Create_func_instr : public Create_func_arg2 |
|
499 |
{
|
|
500 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
501 |
using Create_func_arg2::create; |
502 |
||
2440.2.4
by Olaf van der Spek
Refactor |
503 |
virtual Item* create(Session *session, Item *arg1, Item *arg2) |
504 |
{
|
|
505 |
return new (session->mem) Item_func_locate(arg1, arg2); |
|
506 |
}
|
|
1
by brian
clean slate |
507 |
|
508 |
static Create_func_instr s_singleton; |
|
509 |
};
|
|
510 |
||
511 |
||
512 |
class Create_func_isnull : public Create_func_arg1 |
|
513 |
{
|
|
514 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
515 |
using Create_func_arg1::create; |
516 |
||
2440.2.4
by Olaf van der Spek
Refactor |
517 |
virtual Item* create(Session *session, Item *arg1) |
518 |
{
|
|
519 |
return new (session->mem) Item_func_isnull(arg1); |
|
520 |
}
|
|
1
by brian
clean slate |
521 |
|
522 |
static Create_func_isnull s_singleton; |
|
523 |
};
|
|
524 |
||
525 |
||
526 |
class Create_func_last_day : public Create_func_arg1 |
|
527 |
{
|
|
528 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
529 |
using Create_func_arg1::create; |
530 |
||
2440.2.4
by Olaf van der Spek
Refactor |
531 |
virtual Item* create(Session *session, Item *arg1) |
532 |
{
|
|
533 |
return new (session->mem) Item_func_last_day(arg1); |
|
534 |
}
|
|
1
by brian
clean slate |
535 |
|
536 |
static Create_func_last_day s_singleton; |
|
537 |
};
|
|
538 |
||
539 |
||
540 |
class Create_func_last_insert_id : public Create_native_func |
|
541 |
{
|
|
542 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
543 |
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
544 |
|
545 |
static Create_func_last_insert_id s_singleton; |
|
546 |
};
|
|
547 |
||
548 |
||
549 |
class Create_func_lcase : public Create_func_arg1 |
|
550 |
{
|
|
551 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
552 |
using Create_func_arg1::create; |
553 |
||
2440.2.4
by Olaf van der Spek
Refactor |
554 |
virtual Item* create(Session *session, Item *arg1) |
555 |
{
|
|
556 |
return new (session->mem) Item_func_lcase(arg1); |
|
557 |
}
|
|
1
by brian
clean slate |
558 |
|
559 |
static Create_func_lcase s_singleton; |
|
560 |
};
|
|
561 |
||
562 |
||
563 |
class Create_func_least : public Create_native_func |
|
564 |
{
|
|
565 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
566 |
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
567 |
|
568 |
static Create_func_least s_singleton; |
|
569 |
};
|
|
570 |
||
571 |
class Create_func_load_file : public Create_func_arg1 |
|
572 |
{
|
|
573 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
574 |
using Create_func_arg1::create; |
575 |
||
2440.2.4
by Olaf van der Spek
Refactor |
576 |
virtual Item* create(Session *session, Item *arg1) |
577 |
{
|
|
578 |
return new (session->mem) Item_load_file(*session, arg1); |
|
579 |
}
|
|
1
by brian
clean slate |
580 |
|
581 |
static Create_func_load_file s_singleton; |
|
582 |
};
|
|
583 |
||
584 |
class Create_func_locate : public Create_native_func |
|
585 |
{
|
|
586 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
587 |
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
588 |
|
589 |
static Create_func_locate s_singleton; |
|
590 |
};
|
|
591 |
||
592 |
||
593 |
class Create_func_lpad : public Create_func_arg3 |
|
594 |
{
|
|
595 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
596 |
using Create_func_arg3::create; |
597 |
||
2318.6.86
by Olaf van der Spek
Refactor |
598 |
virtual Item* create(Session *session, Item *arg1, Item *arg2, Item *arg3) |
599 |
{
|
|
600 |
return new (session->mem) Item_func_lpad(*session, arg1, arg2, arg3); |
|
601 |
}
|
|
1
by brian
clean slate |
602 |
|
603 |
static Create_func_lpad s_singleton; |
|
604 |
};
|
|
605 |
||
2318.6.86
by Olaf van der Spek
Refactor |
606 |
Create_func_lpad Create_func_lpad::s_singleton; |
1
by brian
clean slate |
607 |
|
608 |
class Create_func_ltrim : public Create_func_arg1 |
|
609 |
{
|
|
610 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
611 |
using Create_func_arg1::create; |
612 |
||
2318.6.86
by Olaf van der Spek
Refactor |
613 |
virtual Item* create(Session *session, Item *arg1) |
614 |
{
|
|
615 |
return new (session->mem) Item_func_ltrim(arg1); |
|
616 |
}
|
|
1
by brian
clean slate |
617 |
|
618 |
static Create_func_ltrim s_singleton; |
|
619 |
};
|
|
620 |
||
2318.6.86
by Olaf van der Spek
Refactor |
621 |
Create_func_ltrim Create_func_ltrim::s_singleton; |
1
by brian
clean slate |
622 |
|
623 |
class Create_func_makedate : public Create_func_arg2 |
|
624 |
{
|
|
625 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
626 |
using Create_func_arg2::create; |
627 |
||
2318.6.86
by Olaf van der Spek
Refactor |
628 |
virtual Item* create(Session *session, Item *arg1, Item *arg2) |
629 |
{
|
|
630 |
return new (session->mem) Item_func_makedate(arg1, arg2); |
|
631 |
}
|
|
1
by brian
clean slate |
632 |
|
633 |
static Create_func_makedate s_singleton; |
|
634 |
};
|
|
635 |
||
2318.6.86
by Olaf van der Spek
Refactor |
636 |
Create_func_makedate Create_func_makedate::s_singleton; |
637 |
||
1
by brian
clean slate |
638 |
class Create_func_make_set : public Create_native_func |
639 |
{
|
|
640 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
641 |
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
642 |
|
643 |
static Create_func_make_set s_singleton; |
|
644 |
};
|
|
645 |
||
646 |
||
647 |
class Create_func_monthname : public Create_func_arg1 |
|
648 |
{
|
|
649 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
650 |
using Create_func_arg1::create; |
651 |
||
2318.6.89
by Olaf van der Spek
Refactor |
652 |
virtual Item* create(Session *session, Item *arg1) |
653 |
{
|
|
654 |
return new (session->mem) Item_func_monthname(arg1); |
|
655 |
}
|
|
1
by brian
clean slate |
656 |
|
657 |
static Create_func_monthname s_singleton; |
|
658 |
};
|
|
659 |
||
2318.6.89
by Olaf van der Spek
Refactor |
660 |
Create_func_monthname Create_func_monthname::s_singleton; |
1
by brian
clean slate |
661 |
|
662 |
class Create_func_name_const : public Create_func_arg2 |
|
663 |
{
|
|
664 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
665 |
using Create_func_arg2::create; |
666 |
||
2318.6.83
by Olaf van der Spek
Refactor |
667 |
virtual Item* create(Session *session, Item *arg1, Item *arg2); |
1
by brian
clean slate |
668 |
|
669 |
static Create_func_name_const s_singleton; |
|
670 |
};
|
|
671 |
||
672 |
||
673 |
class Create_func_nullif : public Create_func_arg2 |
|
674 |
{
|
|
675 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
676 |
using Create_func_arg2::create; |
677 |
||
2318.6.89
by Olaf van der Spek
Refactor |
678 |
virtual Item* create(Session *session, Item *arg1, Item *arg2) |
679 |
{
|
|
680 |
return new (session->mem) Item_func_nullif(arg1, arg2); |
|
681 |
}
|
|
1
by brian
clean slate |
682 |
|
683 |
static Create_func_nullif s_singleton; |
|
684 |
};
|
|
685 |
||
2318.6.89
by Olaf van der Spek
Refactor |
686 |
Create_func_nullif Create_func_nullif::s_singleton; |
1
by brian
clean slate |
687 |
|
688 |
class Create_func_oct : public Create_func_arg1 |
|
689 |
{
|
|
690 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
691 |
using Create_func_arg1::create; |
692 |
||
2318.6.83
by Olaf van der Spek
Refactor |
693 |
virtual Item* create(Session *session, Item *arg1); |
1
by brian
clean slate |
694 |
|
695 |
static Create_func_oct s_singleton; |
|
696 |
};
|
|
697 |
||
698 |
class Create_func_period_add : public Create_func_arg2 |
|
699 |
{
|
|
700 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
701 |
using Create_func_arg2::create; |
702 |
||
2440.2.4
by Olaf van der Spek
Refactor |
703 |
virtual Item* create(Session *session, Item *arg1, Item *arg2) |
704 |
{
|
|
705 |
return new (session->mem) Item_func_period_add(arg1, arg2); |
|
706 |
}
|
|
1
by brian
clean slate |
707 |
|
708 |
static Create_func_period_add s_singleton; |
|
709 |
};
|
|
710 |
||
711 |
||
712 |
class Create_func_period_diff : public Create_func_arg2 |
|
713 |
{
|
|
714 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
715 |
using Create_func_arg2::create; |
716 |
||
2440.2.4
by Olaf van der Spek
Refactor |
717 |
virtual Item* create(Session *session, Item *arg1, Item *arg2) |
718 |
{
|
|
719 |
return new (session->mem) Item_func_period_diff(arg1, arg2); |
|
720 |
}
|
|
1
by brian
clean slate |
721 |
|
722 |
static Create_func_period_diff s_singleton; |
|
723 |
};
|
|
724 |
||
725 |
||
726 |
class Create_func_pi : public Create_func_arg0 |
|
727 |
{
|
|
728 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
729 |
using Create_func_arg0::create; |
730 |
||
2440.2.4
by Olaf van der Spek
Refactor |
731 |
virtual Item* create(Session *session) |
732 |
{
|
|
733 |
return new (session->mem) Item_static_float_func("pi()", M_PI, 6, 8); |
|
734 |
}
|
|
1
by brian
clean slate |
735 |
|
736 |
static Create_func_pi s_singleton; |
|
737 |
};
|
|
738 |
||
739 |
class Create_func_radians : public Create_func_arg1 |
|
740 |
{
|
|
741 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
742 |
using Create_func_arg1::create; |
743 |
||
2440.2.4
by Olaf van der Spek
Refactor |
744 |
virtual Item* create(Session *session, Item *arg1) |
745 |
{
|
|
746 |
return new (session->mem) Item_func_units("radians", arg1, M_PI/180, 0.0); |
|
747 |
}
|
|
1
by brian
clean slate |
748 |
|
749 |
static Create_func_radians s_singleton; |
|
750 |
};
|
|
751 |
||
752 |
||
753 |
class Create_func_round : public Create_native_func |
|
754 |
{
|
|
755 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
756 |
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
757 |
|
758 |
static Create_func_round s_singleton; |
|
759 |
};
|
|
760 |
||
761 |
||
762 |
class Create_func_row_count : public Create_func_arg0 |
|
763 |
{
|
|
764 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
765 |
using Create_func_arg0::create; |
766 |
||
2318.6.88
by Olaf van der Spek
Refactor |
767 |
virtual Item* create(Session *session) |
768 |
{
|
|
769 |
return new (session->mem) Item_func_row_count(); |
|
770 |
}
|
|
1
by brian
clean slate |
771 |
|
772 |
static Create_func_row_count s_singleton; |
|
773 |
};
|
|
774 |
||
2318.6.88
by Olaf van der Spek
Refactor |
775 |
Create_func_row_count Create_func_row_count::s_singleton; |
1
by brian
clean slate |
776 |
|
777 |
class Create_func_rpad : public Create_func_arg3 |
|
778 |
{
|
|
779 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
780 |
using Create_func_arg3::create; |
781 |
||
2318.6.88
by Olaf van der Spek
Refactor |
782 |
virtual Item* create(Session *session, Item *arg1, Item *arg2, Item *arg3) |
783 |
{
|
|
784 |
return new (session->mem) Item_func_rpad(*session, arg1, arg2, arg3); |
|
785 |
}
|
|
1
by brian
clean slate |
786 |
|
787 |
static Create_func_rpad s_singleton; |
|
788 |
};
|
|
789 |
||
2318.6.88
by Olaf van der Spek
Refactor |
790 |
Create_func_rpad Create_func_rpad::s_singleton; |
1
by brian
clean slate |
791 |
|
792 |
class Create_func_rtrim : public Create_func_arg1 |
|
793 |
{
|
|
794 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
795 |
using Create_func_arg1::create; |
796 |
||
2318.6.88
by Olaf van der Spek
Refactor |
797 |
virtual Item* create(Session *session, Item *arg1) |
798 |
{
|
|
799 |
return new (session->mem) Item_func_rtrim(arg1); |
|
800 |
}
|
|
1
by brian
clean slate |
801 |
|
802 |
static Create_func_rtrim s_singleton; |
|
803 |
};
|
|
804 |
||
2318.6.89
by Olaf van der Spek
Refactor |
805 |
Create_func_rtrim Create_func_rtrim::s_singleton; |
806 |
||
1
by brian
clean slate |
807 |
class Create_func_sign : public Create_func_arg1 |
808 |
{
|
|
809 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
810 |
using Create_func_arg1::create; |
811 |
||
2318.6.88
by Olaf van der Spek
Refactor |
812 |
virtual Item* create(Session *session, Item *arg1) |
813 |
{
|
|
814 |
return new (session->mem) Item_func_sign(arg1); |
|
815 |
}
|
|
1
by brian
clean slate |
816 |
|
817 |
static Create_func_sign s_singleton; |
|
818 |
};
|
|
819 |
||
2318.6.88
by Olaf van der Spek
Refactor |
820 |
Create_func_sign Create_func_sign::s_singleton; |
821 |
||
1
by brian
clean slate |
822 |
class Create_func_space : public Create_func_arg1 |
823 |
{
|
|
824 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
825 |
using Create_func_arg1::create; |
826 |
||
2318.6.83
by Olaf van der Spek
Refactor |
827 |
virtual Item* create(Session *session, Item *arg1); |
1
by brian
clean slate |
828 |
|
829 |
static Create_func_space s_singleton; |
|
830 |
};
|
|
831 |
||
832 |
class Create_func_strcmp : public Create_func_arg2 |
|
833 |
{
|
|
834 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
835 |
using Create_func_arg2::create; |
836 |
||
2318.6.89
by Olaf van der Spek
Refactor |
837 |
virtual Item* create(Session *session, Item *arg1, Item *arg2) |
838 |
{
|
|
839 |
return new (session->mem) Item_func_strcmp(arg1, arg2); |
|
840 |
}
|
|
841 |
||
1
by brian
clean slate |
842 |
static Create_func_strcmp s_singleton; |
843 |
};
|
|
844 |
||
2318.6.89
by Olaf van der Spek
Refactor |
845 |
Create_func_strcmp Create_func_strcmp::s_singleton; |
1
by brian
clean slate |
846 |
|
847 |
class Create_func_tan : public Create_func_arg1 |
|
848 |
{
|
|
849 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
850 |
using Create_func_arg1::create; |
851 |
||
2318.6.89
by Olaf van der Spek
Refactor |
852 |
virtual Item* create(Session *session, Item *arg1) |
853 |
{
|
|
854 |
return new (session->mem) Item_func_tan(arg1); |
|
855 |
}
|
|
1
by brian
clean slate |
856 |
|
857 |
static Create_func_tan s_singleton; |
|
858 |
};
|
|
859 |
||
2318.6.89
by Olaf van der Spek
Refactor |
860 |
Create_func_tan Create_func_tan::s_singleton; |
1
by brian
clean slate |
861 |
|
862 |
class Create_func_time_format : public Create_func_arg2 |
|
863 |
{
|
|
864 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
865 |
using Create_func_arg2::create; |
866 |
||
2318.6.89
by Olaf van der Spek
Refactor |
867 |
virtual Item* create(Session *session, Item *arg1, Item *arg2) |
868 |
{
|
|
869 |
return new (session->mem) Item_func_date_format(arg1, arg2, 1); |
|
870 |
}
|
|
1
by brian
clean slate |
871 |
|
872 |
static Create_func_time_format s_singleton; |
|
873 |
};
|
|
874 |
||
2318.6.89
by Olaf van der Spek
Refactor |
875 |
Create_func_time_format Create_func_time_format::s_singleton; |
1
by brian
clean slate |
876 |
|
877 |
class Create_func_to_days : public Create_func_arg1 |
|
878 |
{
|
|
879 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
880 |
using Create_func_arg1::create; |
881 |
||
2318.6.89
by Olaf van der Spek
Refactor |
882 |
virtual Item* create(Session *session, Item *arg1) |
883 |
{
|
|
884 |
return new (session->mem) Item_func_to_days(arg1); |
|
885 |
}
|
|
1
by brian
clean slate |
886 |
|
887 |
static Create_func_to_days s_singleton; |
|
888 |
};
|
|
889 |
||
2318.6.89
by Olaf van der Spek
Refactor |
890 |
Create_func_to_days Create_func_to_days::s_singleton; |
1
by brian
clean slate |
891 |
|
892 |
class Create_func_ucase : public Create_func_arg1 |
|
893 |
{
|
|
894 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
895 |
using Create_func_arg1::create; |
896 |
||
2318.6.89
by Olaf van der Spek
Refactor |
897 |
virtual Item* create(Session *session, Item *arg1) |
898 |
{
|
|
899 |
return new (session->mem) Item_func_ucase(arg1); |
|
900 |
}
|
|
1
by brian
clean slate |
901 |
|
902 |
static Create_func_ucase s_singleton; |
|
903 |
};
|
|
904 |
||
2318.6.89
by Olaf van der Spek
Refactor |
905 |
Create_func_ucase Create_func_ucase::s_singleton; |
1
by brian
clean slate |
906 |
|
907 |
class Create_func_unix_timestamp : public Create_native_func |
|
908 |
{
|
|
909 |
public: |
|
2440.2.4
by Olaf van der Spek
Refactor |
910 |
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list); |
1
by brian
clean slate |
911 |
|
912 |
static Create_func_unix_timestamp s_singleton; |
|
913 |
};
|
|
914 |
||
915 |
||
916 |
class Create_func_weekday : public Create_func_arg1 |
|
917 |
{
|
|
918 |
public: |
|
892.1.1
by Monty Taylor
Fixed virtual overload warnings. |
919 |
using Create_func_arg1::create; |
920 |
||
2318.6.86
by Olaf van der Spek
Refactor |
921 |
virtual Item* create(Session *session, Item *arg1) |
922 |
{
|
|
923 |
return new (session->mem) Item_func_weekday(arg1, 0); |
|
924 |
}
|
|
1
by brian
clean slate |
925 |
|
926 |
static Create_func_weekday s_singleton; |
|
927 |
};
|
|
928 |
||
2318.6.86
by Olaf van der Spek
Refactor |
929 |
Create_func_weekday Create_func_weekday::s_singleton; |
930 |
||
1
by brian
clean slate |
931 |
/*
|
932 |
=============================================================================
|
|
933 |
IMPLEMENTATION
|
|
934 |
=============================================================================
|
|
935 |
*/
|
|
936 |
||
937 |
Create_udf_func Create_udf_func::s_singleton; |
|
938 |
||
2440.2.4
by Olaf van der Spek
Refactor |
939 |
Item* Create_udf_func::create(Session *session, str_ref name, List<Item> *item_list) |
1
by brian
clean slate |
940 |
{
|
2430.1.8
by Olaf van der Spek
Use assign(), data() and size() |
941 |
return create(session, plugin::Function::get(to_string(name)), item_list); |
2318.6.86
by Olaf van der Spek
Refactor |
942 |
}
|
943 |
||
2318.6.87
by Olaf van der Spek
Refactor |
944 |
Item* Create_udf_func::create(Session *session, const plugin::Function *udf, List<Item> *item_list) |
2318.6.86
by Olaf van der Spek
Refactor |
945 |
{
|
51.1.19
by Jay Pipes
Removed/replace DBUG symbols |
946 |
assert(udf); |
2318.6.83
by Olaf van der Spek
Refactor |
947 |
int arg_count= item_list ? item_list->size() : 0; |
2318.6.85
by Olaf van der Spek
Refactor |
948 |
Item_func* func= (*udf)(&session->mem); |
2318.6.86
by Olaf van der Spek
Refactor |
949 |
if (!func->check_argument_count(arg_count)) |
997.8.1
by Stewart Smith
Add check for argument numbers for UDFs. Fix crc32 and md5 |
950 |
{
|
1124.3.2
by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION |
951 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), func->func_name()); |
997.8.1
by Stewart Smith
Add check for argument numbers for UDFs. Fix crc32 and md5 |
952 |
return NULL; |
953 |
}
|
|
2318.6.85
by Olaf van der Spek
Refactor |
954 |
if (item_list) |
997.8.1
by Stewart Smith
Add check for argument numbers for UDFs. Fix crc32 and md5 |
955 |
func->set_arguments(*item_list); |
1
by brian
clean slate |
956 |
return func; |
957 |
}
|
|
958 |
||
2440.2.4
by Olaf van der Spek
Refactor |
959 |
Item* Create_func_arg0::create(Session *session, str_ref name, List<Item> *item_list) |
2318.6.87
by Olaf van der Spek
Refactor |
960 |
{
|
2440.2.4
by Olaf van der Spek
Refactor |
961 |
if (not item_list || not item_list->size()) |
962 |
return create(session); |
|
963 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
|
964 |
return NULL; |
|
1
by brian
clean slate |
965 |
}
|
966 |
||
2440.2.4
by Olaf van der Spek
Refactor |
967 |
Item* Create_func_arg1::create(Session *session, str_ref name, List<Item> *item_list) |
1
by brian
clean slate |
968 |
{
|
2440.2.4
by Olaf van der Spek
Refactor |
969 |
if (not item_list || item_list->size() != 1) |
1
by brian
clean slate |
970 |
{
|
2430.1.1
by Olaf van der Spek
Use lex_string assign(), data() and size() |
971 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
1
by brian
clean slate |
972 |
return NULL; |
973 |
}
|
|
974 |
||
975 |
Item *param_1= item_list->pop(); |
|
2440.2.4
by Olaf van der Spek
Refactor |
976 |
if (param_1->is_autogenerated_name) |
977 |
return create(session, param_1); |
|
978 |
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data()); |
|
979 |
return NULL; |
|
1
by brian
clean slate |
980 |
}
|
981 |
||
2440.2.4
by Olaf van der Spek
Refactor |
982 |
Item* Create_func_arg2::create(Session *session, str_ref name, List<Item> *item_list) |
1
by brian
clean slate |
983 |
{
|
2440.2.4
by Olaf van der Spek
Refactor |
984 |
if (not item_list || item_list->size() != 2) |
1
by brian
clean slate |
985 |
{
|
2430.1.1
by Olaf van der Spek
Use lex_string assign(), data() and size() |
986 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
1
by brian
clean slate |
987 |
return NULL; |
988 |
}
|
|
989 |
||
990 |
Item *param_1= item_list->pop(); |
|
991 |
Item *param_2= item_list->pop(); |
|
992 |
||
2440.2.4
by Olaf van der Spek
Refactor |
993 |
if (param_1->is_autogenerated_name |
994 |
&& param_2->is_autogenerated_name) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
995 |
return create(session, param_1, param_2); |
2440.2.4
by Olaf van der Spek
Refactor |
996 |
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data()); |
997 |
return NULL; |
|
1
by brian
clean slate |
998 |
}
|
999 |
||
2440.2.4
by Olaf van der Spek
Refactor |
1000 |
Item* Create_func_arg3::create(Session *session, str_ref name, List<Item> *item_list) |
1
by brian
clean slate |
1001 |
{
|
2440.2.4
by Olaf van der Spek
Refactor |
1002 |
if (not item_list || item_list->size() != 3) |
1
by brian
clean slate |
1003 |
{
|
2430.1.1
by Olaf van der Spek
Use lex_string assign(), data() and size() |
1004 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
1
by brian
clean slate |
1005 |
return NULL; |
1006 |
}
|
|
1007 |
||
1008 |
Item *param_1= item_list->pop(); |
|
1009 |
Item *param_2= item_list->pop(); |
|
1010 |
Item *param_3= item_list->pop(); |
|
1011 |
||
2440.2.4
by Olaf van der Spek
Refactor |
1012 |
if (param_1->is_autogenerated_name |
1013 |
&& param_2->is_autogenerated_name |
|
1014 |
&& param_3->is_autogenerated_name) |
|
1015 |
return create(session, param_1, param_2, param_3); |
|
1016 |
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data()); |
|
1017 |
return NULL; |
|
1
by brian
clean slate |
1018 |
}
|
1019 |
||
1020 |
Create_func_bin Create_func_bin::s_singleton; |
|
1021 |
||
2440.2.4
by Olaf van der Spek
Refactor |
1022 |
Item* Create_func_bin::create(Session *session, Item *arg1) |
1
by brian
clean slate |
1023 |
{
|
2318.6.82
by Olaf van der Spek
Refactor |
1024 |
Item *i10= new (session->mem) Item_int(10, 2); |
1025 |
Item *i2= new (session->mem) Item_int(2, 1); |
|
2318.6.81
by Olaf van der Spek
Refactor |
1026 |
return new (session->mem) Item_func_conv(arg1, i10, i2); |
1
by brian
clean slate |
1027 |
}
|
1028 |
||
1029 |
Create_func_concat Create_func_concat::s_singleton; |
|
1030 |
||
2440.2.4
by Olaf van der Spek
Refactor |
1031 |
Item* Create_func_concat::create_native(Session *session, str_ref name, List<Item> *item_list) |
1
by brian
clean slate |
1032 |
{
|
2440.2.4
by Olaf van der Spek
Refactor |
1033 |
if (item_list && item_list->size() >= 1) |
1034 |
return new (session->mem) Item_func_concat(*session, *item_list); |
|
1035 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
|
1036 |
return NULL; |
|
1
by brian
clean slate |
1037 |
}
|
1038 |
||
1039 |
Create_func_concat_ws Create_func_concat_ws::s_singleton; |
|
1040 |
||
2440.2.4
by Olaf van der Spek
Refactor |
1041 |
Item* Create_func_concat_ws::create_native(Session *session, str_ref name, List<Item> *item_list) |
1
by brian
clean slate |
1042 |
{
|
1043 |
/* "WS" stands for "With Separator": this function takes 2+ arguments */
|
|
2440.2.4
by Olaf van der Spek
Refactor |
1044 |
if (item_list && item_list->size() >= 2) |
1045 |
return new (session->mem) Item_func_concat_ws(*session, *item_list); |
|
1046 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
|
1047 |
return NULL; |
|
1
by brian
clean slate |
1048 |
}
|
1049 |
||
1050 |
Create_func_cot Create_func_cot::s_singleton; |
|
1051 |
||
1052 |
Item* |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1053 |
Create_func_cot::create(Session *session, Item *arg1) |
1
by brian
clean slate |
1054 |
{
|
2318.6.82
by Olaf van der Spek
Refactor |
1055 |
Item *i1= new (session->mem) Item_int("1", 1, 1); |
2318.6.81
by Olaf van der Spek
Refactor |
1056 |
Item *i2= new (session->mem) Item_func_tan(arg1); |
1057 |
return new (session->mem) Item_func_div(session, i1, i2); |
|
1
by brian
clean slate |
1058 |
}
|
1059 |
||
1060 |
Create_func_datediff Create_func_datediff::s_singleton; |
|
1061 |
||
1062 |
Item* |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1063 |
Create_func_datediff::create(Session *session, Item *arg1, Item *arg2) |
1
by brian
clean slate |
1064 |
{
|
2318.6.81
by Olaf van der Spek
Refactor |
1065 |
Item *i1= new (session->mem) Item_func_to_days(arg1); |
1066 |
Item *i2= new (session->mem) Item_func_to_days(arg2); |
|
1067 |
return new (session->mem) Item_func_minus(i1, i2); |
|
1
by brian
clean slate |
1068 |
}
|
1069 |
||
1070 |
Create_func_export_set Create_func_export_set::s_singleton; |
|
1071 |
||
1072 |
Item* |
|
2440.2.4
by Olaf van der Spek
Refactor |
1073 |
Create_func_export_set::create_native(Session *session, str_ref name, List<Item> *item_list) |
1
by brian
clean slate |
1074 |
{
|
2318.6.86
by Olaf van der Spek
Refactor |
1075 |
switch (item_list ? item_list->size() : 0) |
2318.6.85
by Olaf van der Spek
Refactor |
1076 |
{
|
1
by brian
clean slate |
1077 |
case 3: |
2318.6.85
by Olaf van der Spek
Refactor |
1078 |
{
|
1079 |
Item *param_1= item_list->pop(); |
|
1080 |
Item *param_2= item_list->pop(); |
|
1081 |
Item *param_3= item_list->pop(); |
|
1082 |
return new (session->mem) Item_func_export_set(param_1, param_2, param_3); |
|
1083 |
}
|
|
1
by brian
clean slate |
1084 |
case 4: |
2318.6.85
by Olaf van der Spek
Refactor |
1085 |
{
|
1086 |
Item *param_1= item_list->pop(); |
|
1087 |
Item *param_2= item_list->pop(); |
|
1088 |
Item *param_3= item_list->pop(); |
|
1089 |
Item *param_4= item_list->pop(); |
|
1090 |
return new (session->mem) Item_func_export_set(param_1, param_2, param_3, param_4); |
|
1091 |
}
|
|
1
by brian
clean slate |
1092 |
case 5: |
2318.6.85
by Olaf van der Spek
Refactor |
1093 |
{
|
1094 |
Item *param_1= item_list->pop(); |
|
1095 |
Item *param_2= item_list->pop(); |
|
1096 |
Item *param_3= item_list->pop(); |
|
1097 |
Item *param_4= item_list->pop(); |
|
1098 |
Item *param_5= item_list->pop(); |
|
1099 |
return new (session->mem) Item_func_export_set(param_1, param_2, param_3, param_4, param_5); |
|
1100 |
}
|
|
1101 |
}
|
|
2440.2.4
by Olaf van der Spek
Refactor |
1102 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
2318.6.85
by Olaf van der Spek
Refactor |
1103 |
return NULL; |
1
by brian
clean slate |
1104 |
}
|
1105 |
||
1106 |
||
1107 |
Create_func_field Create_func_field::s_singleton; |
|
1108 |
||
2440.2.4
by Olaf van der Spek
Refactor |
1109 |
Item* Create_func_field::create_native(Session *session, str_ref name, List<Item> *item_list) |
1
by brian
clean slate |
1110 |
{
|
2440.2.4
by Olaf van der Spek
Refactor |
1111 |
if (item_list && item_list->size() >= 2) |
1112 |
return new (session->mem) Item_func_field(*item_list); |
|
1113 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
|
1114 |
return NULL; |
|
1
by brian
clean slate |
1115 |
}
|
1116 |
||
1117 |
Create_func_find_in_set Create_func_find_in_set::s_singleton; |
|
1118 |
Create_func_found_rows Create_func_found_rows::s_singleton; |
|
1119 |
Create_func_from_days Create_func_from_days::s_singleton; |
|
1120 |
Create_func_from_unixtime Create_func_from_unixtime::s_singleton; |
|
1121 |
||
2440.2.4
by Olaf van der Spek
Refactor |
1122 |
Item* Create_func_from_unixtime::create_native(Session *session, str_ref name, List<Item> *item_list) |
1
by brian
clean slate |
1123 |
{
|
2318.6.86
by Olaf van der Spek
Refactor |
1124 |
switch (item_list ? item_list->size() : 0) |
2318.6.85
by Olaf van der Spek
Refactor |
1125 |
{
|
1
by brian
clean slate |
1126 |
case 1: |
2318.6.85
by Olaf van der Spek
Refactor |
1127 |
{
|
1128 |
Item *param_1= item_list->pop(); |
|
1129 |
return new (session->mem) Item_func_from_unixtime(param_1); |
|
1130 |
}
|
|
1
by brian
clean slate |
1131 |
case 2: |
2318.6.85
by Olaf van der Spek
Refactor |
1132 |
{
|
1133 |
Item *param_1= item_list->pop(); |
|
1134 |
Item *param_2= item_list->pop(); |
|
1135 |
Item *ut= new (session->mem) Item_func_from_unixtime(param_1); |
|
1136 |
return new (session->mem) Item_func_date_format(ut, param_2, 0); |
|
1137 |
}
|
|
1
by brian
clean slate |
1138 |
}
|
2440.2.4
by Olaf van der Spek
Refactor |
1139 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
2318.6.85
by Olaf van der Spek
Refactor |
1140 |
return NULL; |
1
by brian
clean slate |
1141 |
}
|
1142 |
||
1143 |
Create_func_greatest Create_func_greatest::s_singleton; |
|
1144 |
||
2440.2.4
by Olaf van der Spek
Refactor |
1145 |
Item* Create_func_greatest::create_native(Session *session, str_ref name, List<Item> *item_list) |
1
by brian
clean slate |
1146 |
{
|
2440.2.4
by Olaf van der Spek
Refactor |
1147 |
if (item_list && item_list->size() >= 2) |
2318.6.81
by Olaf van der Spek
Refactor |
1148 |
return new (session->mem) Item_func_max(*item_list); |
2440.2.4
by Olaf van der Spek
Refactor |
1149 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
1150 |
return NULL; |
|
1
by brian
clean slate |
1151 |
}
|
1152 |
||
1153 |
Create_func_ifnull Create_func_ifnull::s_singleton; |
|
1154 |
Create_func_instr Create_func_instr::s_singleton; |
|
1155 |
Create_func_isnull Create_func_isnull::s_singleton; |
|
1156 |
Create_func_last_day Create_func_last_day::s_singleton; |
|
1157 |
Create_func_last_insert_id Create_func_last_insert_id::s_singleton; |
|
1158 |
||
2440.2.4
by Olaf van der Spek
Refactor |
1159 |
Item* Create_func_last_insert_id::create_native(Session *session, str_ref name, List<Item> *item_list) |
1
by brian
clean slate |
1160 |
{
|
2318.6.83
by Olaf van der Spek
Refactor |
1161 |
int arg_count= item_list ? item_list->size() : 0; |
1
by brian
clean slate |
1162 |
switch (arg_count) { |
1163 |
case 0: |
|
2318.6.85
by Olaf van der Spek
Refactor |
1164 |
{
|
1165 |
return new (session->mem) Item_func_last_insert_id(); |
|
1166 |
}
|
|
1
by brian
clean slate |
1167 |
case 1: |
2318.6.85
by Olaf van der Spek
Refactor |
1168 |
{
|
1169 |
Item *param_1= item_list->pop(); |
|
1170 |
return new (session->mem) Item_func_last_insert_id(param_1); |
|
1171 |
}
|
|
1
by brian
clean slate |
1172 |
default: |
2430.1.1
by Olaf van der Spek
Use lex_string assign(), data() and size() |
1173 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
2318.6.85
by Olaf van der Spek
Refactor |
1174 |
}
|
1175 |
return NULL; |
|
1
by brian
clean slate |
1176 |
}
|
1177 |
||
1178 |
||
1179 |
Create_func_lcase Create_func_lcase::s_singleton; |
|
1180 |
Create_func_least Create_func_least::s_singleton; |
|
1181 |
||
2440.2.4
by Olaf van der Spek
Refactor |
1182 |
Item* Create_func_least::create_native(Session *session, str_ref name, List<Item> *item_list) |
1
by brian
clean slate |
1183 |
{
|
2318.6.83
by Olaf van der Spek
Refactor |
1184 |
int arg_count= item_list ? item_list->size() : 0; |
1
by brian
clean slate |
1185 |
if (arg_count < 2) |
1186 |
{
|
|
2430.1.1
by Olaf van der Spek
Use lex_string assign(), data() and size() |
1187 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
1
by brian
clean slate |
1188 |
return NULL; |
1189 |
}
|
|
1190 |
||
2318.6.81
by Olaf van der Spek
Refactor |
1191 |
return new (session->mem) Item_func_min(*item_list); |
1
by brian
clean slate |
1192 |
}
|
1193 |
||
1194 |
Create_func_load_file Create_func_load_file::s_singleton; |
|
1195 |
Create_func_locate Create_func_locate::s_singleton; |
|
1196 |
||
1197 |
Item* |
|
2440.2.4
by Olaf van der Spek
Refactor |
1198 |
Create_func_locate::create_native(Session *session, str_ref name, |
1
by brian
clean slate |
1199 |
List<Item> *item_list) |
1200 |
{
|
|
2318.6.83
by Olaf van der Spek
Refactor |
1201 |
int arg_count= item_list ? item_list->size() : 0; |
2318.6.85
by Olaf van der Spek
Refactor |
1202 |
switch (arg_count) |
1203 |
{
|
|
1
by brian
clean slate |
1204 |
case 2: |
2318.6.85
by Olaf van der Spek
Refactor |
1205 |
{
|
1206 |
Item *param_1= item_list->pop(); |
|
1207 |
Item *param_2= item_list->pop(); |
|
1208 |
/* Yes, parameters in that order : 2, 1 */
|
|
1209 |
return new (session->mem) Item_func_locate(param_2, param_1); |
|
1210 |
}
|
|
1
by brian
clean slate |
1211 |
case 3: |
2318.6.85
by Olaf van der Spek
Refactor |
1212 |
{
|
1213 |
Item *param_1= item_list->pop(); |
|
1214 |
Item *param_2= item_list->pop(); |
|
1215 |
Item *param_3= item_list->pop(); |
|
1216 |
/* Yes, parameters in that order : 2, 1, 3 */
|
|
1217 |
return new (session->mem) Item_func_locate(param_2, param_1, param_3); |
|
1218 |
}
|
|
1
by brian
clean slate |
1219 |
default: |
2430.1.1
by Olaf van der Spek
Use lex_string assign(), data() and size() |
1220 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
2318.6.85
by Olaf van der Spek
Refactor |
1221 |
}
|
1222 |
return NULL; |
|
1
by brian
clean slate |
1223 |
}
|
1224 |
||
1225 |
Create_func_make_set Create_func_make_set::s_singleton; |
|
1226 |
||
1227 |
Item* |
|
2440.2.4
by Olaf van der Spek
Refactor |
1228 |
Create_func_make_set::create_native(Session *session_arg, str_ref name, |
1
by brian
clean slate |
1229 |
List<Item> *item_list) |
1230 |
{
|
|
2318.6.83
by Olaf van der Spek
Refactor |
1231 |
int arg_count= item_list ? item_list->size() : 0; |
1
by brian
clean slate |
1232 |
if (arg_count < 2) |
1233 |
{
|
|
2430.1.1
by Olaf van der Spek
Use lex_string assign(), data() and size() |
1234 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
1
by brian
clean slate |
1235 |
return NULL; |
1236 |
}
|
|
1237 |
||
1238 |
Item *param_1= item_list->pop(); |
|
2318.6.81
by Olaf van der Spek
Refactor |
1239 |
return new (session_arg->mem) Item_func_make_set(*session_arg, param_1, *item_list); |
1
by brian
clean slate |
1240 |
}
|
1241 |
||
1242 |
Create_func_oct Create_func_oct::s_singleton; |
|
1243 |
||
1244 |
Item* |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1245 |
Create_func_oct::create(Session *session, Item *arg1) |
1
by brian
clean slate |
1246 |
{
|
2318.6.81
by Olaf van der Spek
Refactor |
1247 |
Item *i10= new (session->mem) Item_int((int32_t) 10,2); |
1248 |
Item *i8= new (session->mem) Item_int((int32_t) 8,1); |
|
1249 |
return new (session->mem) Item_func_conv(arg1, i10, i8); |
|
1
by brian
clean slate |
1250 |
}
|
1251 |
||
1252 |
Create_func_period_add Create_func_period_add::s_singleton; |
|
1253 |
Create_func_period_diff Create_func_period_diff::s_singleton; |
|
1254 |
Create_func_pi Create_func_pi::s_singleton; |
|
1255 |
Create_func_radians Create_func_radians::s_singleton; |
|
1256 |
Create_func_round Create_func_round::s_singleton; |
|
1257 |
||
2440.2.4
by Olaf van der Spek
Refactor |
1258 |
Item* Create_func_round::create_native(Session *session, str_ref name, List<Item> *item_list) |
1
by brian
clean slate |
1259 |
{
|
2318.6.88
by Olaf van der Spek
Refactor |
1260 |
switch (item_list ? item_list->size() : 0) |
1261 |
{
|
|
1
by brian
clean slate |
1262 |
case 1: |
1263 |
{
|
|
1264 |
Item *param_1= item_list->pop(); |
|
2318.6.82
by Olaf van der Spek
Refactor |
1265 |
Item *i0 = new (session->mem) Item_int("0", 0, 1); |
2318.6.88
by Olaf van der Spek
Refactor |
1266 |
return new (session->mem) Item_func_round(param_1, i0, 0); |
1
by brian
clean slate |
1267 |
}
|
1268 |
case 2: |
|
1269 |
{
|
|
1270 |
Item *param_1= item_list->pop(); |
|
1271 |
Item *param_2= item_list->pop(); |
|
2318.6.88
by Olaf van der Spek
Refactor |
1272 |
return new (session->mem) Item_func_round(param_1, param_2, 0); |
1
by brian
clean slate |
1273 |
}
|
1274 |
default: |
|
2430.1.1
by Olaf van der Spek
Use lex_string assign(), data() and size() |
1275 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
2318.6.88
by Olaf van der Spek
Refactor |
1276 |
}
|
1277 |
return NULL; |
|
1
by brian
clean slate |
1278 |
}
|
1279 |
||
1280 |
Create_func_space Create_func_space::s_singleton; |
|
1281 |
||
1282 |
Item* |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1283 |
Create_func_space::create(Session *session, Item *arg1) |
1
by brian
clean slate |
1284 |
{
|
1285 |
/**
|
|
1286 |
TODO: Fix Bug#23637
|
|
1287 |
The parsed item tree should not depend on
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1288 |
<code>session->variables.collation_connection</code>.
|
1
by brian
clean slate |
1289 |
*/
|
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
1290 |
const charset_info_st * const cs= session->variables.getCollation(); |
1
by brian
clean slate |
1291 |
Item *sp; |
1292 |
||
1293 |
if (cs->mbminlen > 1) |
|
1294 |
{
|
|
2318.6.81
by Olaf van der Spek
Refactor |
1295 |
sp= new (session->mem) Item_string("", 0, cs, DERIVATION_COERCIBLE); |
2281.6.2
by Olaf van der Spek
Return void |
1296 |
sp->str_value.copy(" ", 1, cs); |
1
by brian
clean slate |
1297 |
}
|
1298 |
else
|
|
1299 |
{
|
|
2318.6.81
by Olaf van der Spek
Refactor |
1300 |
sp= new (session->mem) Item_string(" ", 1, cs, DERIVATION_COERCIBLE); |
1
by brian
clean slate |
1301 |
}
|
1302 |
||
2318.6.81
by Olaf van der Spek
Refactor |
1303 |
return new (session->mem) Item_func_repeat(*session, sp, arg1); |
1
by brian
clean slate |
1304 |
}
|
1305 |
||
1306 |
Create_func_unix_timestamp Create_func_unix_timestamp::s_singleton; |
|
1307 |
||
2440.2.4
by Olaf van der Spek
Refactor |
1308 |
Item* Create_func_unix_timestamp::create_native(Session *session, str_ref name, List<Item> *item_list) |
1
by brian
clean slate |
1309 |
{
|
2318.6.86
by Olaf van der Spek
Refactor |
1310 |
switch (item_list ? item_list->size() : 0) |
1311 |
{
|
|
1
by brian
clean slate |
1312 |
case 0: |
2318.6.86
by Olaf van der Spek
Refactor |
1313 |
return new (session->mem) Item_func_unix_timestamp(); |
1
by brian
clean slate |
1314 |
case 1: |
2318.6.86
by Olaf van der Spek
Refactor |
1315 |
return new (session->mem) Item_func_unix_timestamp(item_list->pop()); |
1
by brian
clean slate |
1316 |
default: |
2430.1.1
by Olaf van der Spek
Use lex_string assign(), data() and size() |
1317 |
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data()); |
2318.6.86
by Olaf van der Spek
Refactor |
1318 |
}
|
1319 |
return NULL; |
|
1320 |
}
|
|
1321 |
||
1
by brian
clean slate |
1322 |
|
1323 |
struct Native_func_registry |
|
1324 |
{
|
|
2385.2.12
by Olaf van der Spek
Refactor |
1325 |
const char* name; |
1
by brian
clean slate |
1326 |
Create_func *builder; |
1327 |
};
|
|
1328 |
||
1329 |
#define BUILDER(F) & F::s_singleton
|
|
1330 |
||
1331 |
/*
|
|
1332 |
MySQL native functions.
|
|
1333 |
MAINTAINER:
|
|
1334 |
- Keep sorted for human lookup. At runtime, a hash table is used.
|
|
1335 |
- keep 1 line per entry, it makes grep | sort easier
|
|
1336 |
*/
|
|
1337 |
||
1338 |
static Native_func_registry func_array[] = |
|
1339 |
{
|
|
2385.2.12
by Olaf van der Spek
Refactor |
1340 |
{ "BIN", BUILDER(Create_func_bin)}, |
1341 |
{ "CONCAT", BUILDER(Create_func_concat)}, |
|
1342 |
{ "CONCAT_WS", BUILDER(Create_func_concat_ws)}, |
|
1343 |
{ "CONV", BUILDER(Create_func_conv)}, |
|
1344 |
{ "COT", BUILDER(Create_func_cot)}, |
|
1345 |
{ "DATEDIFF", BUILDER(Create_func_datediff)}, |
|
1346 |
{ "DATE_FORMAT", BUILDER(Create_func_date_format)}, |
|
1347 |
{ "DAYNAME", BUILDER(Create_func_dayname)}, |
|
1348 |
{ "DAYOFMONTH", BUILDER(Create_func_dayofmonth)}, |
|
1349 |
{ "DAYOFWEEK", BUILDER(Create_func_dayofweek)}, |
|
1350 |
{ "DAYOFYEAR", BUILDER(Create_func_dayofyear)}, |
|
1351 |
{ "DEGREES", BUILDER(Create_func_degrees)}, |
|
1352 |
{ "EXPORT_SET", BUILDER(Create_func_export_set)}, |
|
1353 |
{ "FIELD", BUILDER(Create_func_field)}, |
|
1354 |
{ "FIND_IN_SET", BUILDER(Create_func_find_in_set)}, |
|
1355 |
{ "FOUND_ROWS", BUILDER(Create_func_found_rows)}, |
|
1356 |
{ "FROM_DAYS", BUILDER(Create_func_from_days)}, |
|
1357 |
{ "FROM_UNIXTIME", BUILDER(Create_func_from_unixtime)}, |
|
1358 |
{ "GREATEST", BUILDER(Create_func_greatest)}, |
|
1359 |
{ "IFNULL", BUILDER(Create_func_ifnull)}, |
|
1360 |
{ "INSTR", BUILDER(Create_func_instr)}, |
|
1361 |
{ "ISNULL", BUILDER(Create_func_isnull)}, |
|
1362 |
{ "LAST_DAY", BUILDER(Create_func_last_day)}, |
|
1363 |
{ "LAST_INSERT_ID", BUILDER(Create_func_last_insert_id)}, |
|
1364 |
{ "LCASE", BUILDER(Create_func_lcase)}, |
|
1365 |
{ "LEAST", BUILDER(Create_func_least)}, |
|
1366 |
{ "LOAD_FILE", BUILDER(Create_func_load_file)}, |
|
1367 |
{ "LOCATE", BUILDER(Create_func_locate)}, |
|
1368 |
{ "LOWER", BUILDER(Create_func_lcase)}, |
|
1369 |
{ "LPAD", BUILDER(Create_func_lpad)}, |
|
1370 |
{ "LTRIM", BUILDER(Create_func_ltrim)}, |
|
1371 |
{ "MAKEDATE", BUILDER(Create_func_makedate)}, |
|
1372 |
{ "MAKE_SET", BUILDER(Create_func_make_set)}, |
|
1373 |
{ "MONTHNAME", BUILDER(Create_func_monthname)}, |
|
1374 |
{ "NULLIF", BUILDER(Create_func_nullif)}, |
|
1375 |
{ "OCT", BUILDER(Create_func_oct)}, |
|
1376 |
{ "PERIOD_ADD", BUILDER(Create_func_period_add)}, |
|
1377 |
{ "PERIOD_DIFF", BUILDER(Create_func_period_diff)}, |
|
1378 |
{ "PI", BUILDER(Create_func_pi)}, |
|
1379 |
{ "RADIANS", BUILDER(Create_func_radians)}, |
|
1380 |
{ "ROUND", BUILDER(Create_func_round)}, |
|
1381 |
{ "ROW_COUNT", BUILDER(Create_func_row_count)}, |
|
1382 |
{ "RPAD", BUILDER(Create_func_rpad)}, |
|
1383 |
{ "RTRIM", BUILDER(Create_func_rtrim)}, |
|
1384 |
{ "SIGN", BUILDER(Create_func_sign)}, |
|
1385 |
{ "SPACE", BUILDER(Create_func_space)}, |
|
1386 |
{ "STRCMP", BUILDER(Create_func_strcmp)}, |
|
1387 |
{ "TAN", BUILDER(Create_func_tan)}, |
|
1388 |
{ "TIME_FORMAT", BUILDER(Create_func_time_format)}, |
|
1389 |
{ "TO_DAYS", BUILDER(Create_func_to_days)}, |
|
1390 |
{ "UCASE", BUILDER(Create_func_ucase)}, |
|
1391 |
{ "UNIX_TIMESTAMP", BUILDER(Create_func_unix_timestamp)}, |
|
1392 |
{ "UPPER", BUILDER(Create_func_ucase)}, |
|
1393 |
{ "WEEKDAY", BUILDER(Create_func_weekday)}, |
|
1394 |
{ NULL, NULL} |
|
1
by brian
clean slate |
1395 |
};
|
1396 |
||
1397 |
/*
|
|
1398 |
Load the hash table for native functions.
|
|
1399 |
Note: this code is not thread safe, and is intended to be used at server
|
|
1400 |
startup only (before going multi-threaded)
|
|
1401 |
*/
|
|
1402 |
||
2318.6.77
by Olaf van der Spek
Refactor |
1403 |
void item_create_init() |
1404 |
{
|
|
1405 |
for (Native_func_registry* func= func_array; func->builder; func++) |
|
2385.2.12
by Olaf van der Spek
Refactor |
1406 |
FunctionContainer::getMutableMap()[func->name]= func->builder; |
2318.6.77
by Olaf van der Spek
Refactor |
1407 |
}
|
1408 |
||
2440.2.4
by Olaf van der Spek
Refactor |
1409 |
Create_func* find_native_function_builder(str_ref name) |
2318.6.77
by Olaf van der Spek
Refactor |
1410 |
{
|
2430.1.1
by Olaf van der Spek
Use lex_string assign(), data() and size() |
1411 |
return find_ptr2(FunctionContainer::getMap(), name.data()); |
2318.6.77
by Olaf van der Spek
Refactor |
1412 |
}
|
1413 |
||
2385.2.12
by Olaf van der Spek
Refactor |
1414 |
Item* create_func_char_cast(Session *session, Item *a, int len, const charset_info_st* cs) |
2318.6.77
by Olaf van der Spek
Refactor |
1415 |
{
|
2318.6.81
by Olaf van der Spek
Refactor |
1416 |
return new (session->mem) Item_char_typecast(a, len, cs ? cs : session->variables.getCollation()); |
2318.6.77
by Olaf van der Spek
Refactor |
1417 |
}
|
1418 |
||
2318.6.86
by Olaf van der Spek
Refactor |
1419 |
Item* create_func_cast(Session *session, Item *a, Cast_target cast_type, const char *c_len, const char *c_dec, const charset_info_st * const cs) |
1
by brian
clean slate |
1420 |
{
|
2318.6.86
by Olaf van der Spek
Refactor |
1421 |
switch (cast_type) |
1422 |
{
|
|
2015.1.3
by Brian Aker
Merge in CAST operators for SIGNED/UNSIGNED |
1423 |
case ITEM_CAST_SIGNED: |
2318.6.86
by Olaf van der Spek
Refactor |
1424 |
return new (session->mem) function::cast::Signed(a); |
2015.1.3
by Brian Aker
Merge in CAST operators for SIGNED/UNSIGNED |
1425 |
case ITEM_CAST_UNSIGNED: |
2318.6.86
by Olaf van der Spek
Refactor |
1426 |
return new (session->mem) function::cast::Unsigned(a); |
1
by brian
clean slate |
1427 |
case ITEM_CAST_BINARY: |
2318.6.86
by Olaf van der Spek
Refactor |
1428 |
return new (session->mem) Item_func_binary(a); |
2023.2.4
by Brian Aker
Merge in cast() for BOOLEAN. |
1429 |
case ITEM_CAST_BOOLEAN: |
2318.6.86
by Olaf van der Spek
Refactor |
1430 |
return new (session->mem) function::cast::Boolean(a); |
1999.4.8
by Brian Aker
Adding in time type. |
1431 |
case ITEM_CAST_TIME: |
2318.6.86
by Olaf van der Spek
Refactor |
1432 |
return new (session->mem) function::cast::Time(a); |
1
by brian
clean slate |
1433 |
case ITEM_CAST_DATE: |
2318.6.86
by Olaf van der Spek
Refactor |
1434 |
return new (session->mem) Item_date_typecast(a); |
1
by brian
clean slate |
1435 |
case ITEM_CAST_DATETIME: |
2318.6.86
by Olaf van der Spek
Refactor |
1436 |
return new (session->mem) Item_datetime_typecast(a); |
1
by brian
clean slate |
1437 |
case ITEM_CAST_DECIMAL: |
1999.4.8
by Brian Aker
Adding in time type. |
1438 |
{
|
2318.6.86
by Olaf van der Spek
Refactor |
1439 |
uint32_t len= c_len ? atoi(c_len) : 0; |
1440 |
uint32_t dec= c_dec ? atoi(c_dec) : 0; |
|
2030.1.2
by Brian Aker
First pass in refactoring of the name of my_decimal. |
1441 |
class_decimal_trim(&len, &dec); |
1999.4.8
by Brian Aker
Adding in time type. |
1442 |
if (len < dec) |
1443 |
{
|
|
1444 |
my_error(ER_M_BIGGER_THAN_D, MYF(0), ""); |
|
1445 |
return 0; |
|
1446 |
}
|
|
1447 |
if (len > DECIMAL_MAX_PRECISION) |
|
1448 |
{
|
|
2318.6.86
by Olaf van der Spek
Refactor |
1449 |
my_error(ER_TOO_BIG_PRECISION, MYF(0), len, a->name, DECIMAL_MAX_PRECISION); |
1999.4.8
by Brian Aker
Adding in time type. |
1450 |
return 0; |
1451 |
}
|
|
1452 |
if (dec > DECIMAL_MAX_SCALE) |
|
1453 |
{
|
|
2318.6.86
by Olaf van der Spek
Refactor |
1454 |
my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->name, DECIMAL_MAX_SCALE); |
1999.4.8
by Brian Aker
Adding in time type. |
1455 |
return 0; |
1456 |
}
|
|
2318.6.86
by Olaf van der Spek
Refactor |
1457 |
return new (session->mem) Item_decimal_typecast(a, len, dec); |
1999.4.8
by Brian Aker
Adding in time type. |
1458 |
}
|
1
by brian
clean slate |
1459 |
case ITEM_CAST_CHAR: |
2318.6.86
by Olaf van der Spek
Refactor |
1460 |
return create_func_char_cast(session, a, c_len ? atoi(c_len) : -1, cs); |
1999.4.8
by Brian Aker
Adding in time type. |
1461 |
}
|
2318.6.86
by Olaf van der Spek
Refactor |
1462 |
return NULL; |
1
by brian
clean slate |
1463 |
}
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1464 |
|
1465 |
} /* namespace drizzled */ |