~drizzle-trunk/drizzle/development

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
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
16
/**
17
  @file
18
19
  @brief
20
  Functions to create an item. Used by sql_yac.yy
21
*/
22
1241.9.36 by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h.
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>
1 by brian
clean slate
27
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
28
#include <drizzled/function/str/binary.h>
29
#include <drizzled/function/str/concat.h>
30
#include <drizzled/function/str/conv.h>
31
#include <drizzled/function/str/elt.h>
32
#include <drizzled/function/str/export_set.h>
33
#include <drizzled/function/str/format.h>
34
#include <drizzled/function/str/hex.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/substr.h>
41
#include <drizzled/function/str/trim.h>
42
#include <drizzled/function/str/uuid.h>
642.1.12 by Lee
remove drizzled/item/strfunc.h, no longer needed
43
670.1.22 by Monty Taylor
Merged from Lee.
44
#include <drizzled/function/time/date_format.h>
45
#include <drizzled/function/time/dayname.h>
46
#include <drizzled/function/time/dayofmonth.h>
47
#include <drizzled/function/time/dayofyear.h>
48
#include <drizzled/function/time/from_unixtime.h>
49
#include <drizzled/function/time/from_days.h>
50
#include <drizzled/function/time/last_day.h>
51
#include <drizzled/function/time/makedate.h>
52
#include <drizzled/function/time/month.h>
53
#include <drizzled/function/time/period_add.h>
54
#include <drizzled/function/time/period_diff.h>
55
#include <drizzled/function/time/to_days.h>
56
#include <drizzled/function/time/typecast.h>
57
#include <drizzled/function/time/unix_timestamp.h>
58
#include <drizzled/function/time/weekday.h>
642.1.13 by Lee
remove drizzled/item/timefunc.h, no longer needed
59
584.4.7 by Monty Taylor
Removed a big bank of includes from item.h.
60
#include <drizzled/item/cmpfunc.h>
1130.1.12 by Monty Taylor
Moved service stuff into plugin/
61
#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.
62
#include <drizzled/session.h>
584.4.7 by Monty Taylor
Removed a big bank of includes from item.h.
63
648 by Brian Aker
Fix for create to keep its include files (which speeds up recompiles).
64
/* Function declarations */
65
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
66
#include <drizzled/function/func.h>
642.1.30 by Lee
move math functions to drizzled/function/math directory
67
#include <drizzled/function/math/abs.h>
68
#include <drizzled/function/math/acos.h>
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
69
#include <drizzled/function/additive_op.h>
642.1.30 by Lee
move math functions to drizzled/function/math directory
70
#include <drizzled/function/math/asin.h>
71
#include <drizzled/function/math/atan.h>
72
#include <drizzled/function/math/ceiling.h>
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
73
#include <drizzled/function/coercibility.h>
642.1.30 by Lee
move math functions to drizzled/function/math directory
74
#include <drizzled/function/math/cos.h>
75
#include <drizzled/function/math/dec.h>
76
#include <drizzled/function/math/decimal_typecast.h>
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
77
#include <drizzled/function/math/exp.h>
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
78
#include <drizzled/function/field.h>
79
#include <drizzled/function/find_in_set.h>
642.1.30 by Lee
move math functions to drizzled/function/math directory
80
#include <drizzled/function/math/floor.h>
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
81
#include <drizzled/function/found_rows.h>
82
#include <drizzled/function/get_system_var.h>
642.1.30 by Lee
move math functions to drizzled/function/math directory
83
#include <drizzled/function/math/int_val.h>
84
#include <drizzled/function/math/integer.h>
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
85
#include <drizzled/function/last_insert.h>
642.1.30 by Lee
move math functions to drizzled/function/math directory
86
#include <drizzled/function/math/ln.h>
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
87
#include <drizzled/function/locate.h>
642.1.30 by Lee
move math functions to drizzled/function/math directory
88
#include <drizzled/function/math/log.h>
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
89
#include <drizzled/function/min_max.h>
90
#include <drizzled/function/num1.h>
91
#include <drizzled/function/num_op.h>
92
#include <drizzled/function/numhybrid.h>
642.1.30 by Lee
move math functions to drizzled/function/math directory
93
#include <drizzled/function/math/ord.h>
94
#include <drizzled/function/math/pow.h>
95
#include <drizzled/function/math/rand.h>
96
#include <drizzled/function/math/real.h>
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
97
#include <drizzled/function/row_count.h>
98
#include <drizzled/function/set_user_var.h>
99
#include <drizzled/function/sign.h>
642.1.30 by Lee
move math functions to drizzled/function/math directory
100
#include <drizzled/function/math/sin.h>
101
#include <drizzled/function/math/sqrt.h>
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
102
#include <drizzled/function/str/quote.h>
642.1.30 by Lee
move math functions to drizzled/function/math directory
103
#include <drizzled/function/math/tan.h>
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
104
#include <drizzled/function/units.h>
648 by Brian Aker
Fix for create to keep its include files (which speeds up recompiles).
105
873.2.19 by Monty Taylor
Removed another HASH and another set of useless utf8 hashing.
106
#include <map>
107
108
using namespace std;
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
109
110
namespace drizzled
111
{
648 by Brian Aker
Fix for create to keep its include files (which speeds up recompiles).
112
584.4.7 by Monty Taylor
Removed a big bank of includes from item.h.
113
class Item;
114
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.
115
1 by brian
clean slate
116
/*
117
=============================================================================
118
  LOCAL DECLARATIONS
119
=============================================================================
120
*/
121
122
/**
123
  Adapter for native functions with a variable number of arguments.
124
  The main use of this class is to discard the following calls:
125
  <code>foo(expr1 AS name1, expr2 AS name2, ...)</code>
126
  which are syntactically correct (the syntax can refer to a UDF),
127
  but semantically invalid for native functions.
128
*/
129
130
class Create_native_func : public Create_func
131
{
132
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
133
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
134
135
  /**
136
    Builder method, with no arguments.
520.1.22 by Brian Aker
Second pass of thd cleanup
137
    @param session The current thread
1 by brian
clean slate
138
    @param name The native function name
139
    @param item_list The function parameters, none of which are named
140
    @return An item representing the function call
141
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
142
  virtual Item *create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
143
                              List<Item> *item_list) = 0;
144
145
protected:
146
  /** Constructor. */
147
  Create_native_func() {}
148
  /** Destructor. */
149
  virtual ~Create_native_func() {}
150
};
151
152
153
/**
154
  Adapter for functions that takes exactly zero arguments.
155
*/
156
157
class Create_func_arg0 : public Create_func
158
{
159
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
160
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
161
162
  /**
163
    Builder method, with no arguments.
520.1.22 by Brian Aker
Second pass of thd cleanup
164
    @param session The current thread
1 by brian
clean slate
165
    @return An item representing the function call
166
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
167
  virtual Item *create(Session *session) = 0;
1 by brian
clean slate
168
169
protected:
170
  /** Constructor. */
171
  Create_func_arg0() {}
172
  /** Destructor. */
173
  virtual ~Create_func_arg0() {}
174
};
175
176
177
/**
178
  Adapter for functions that takes exactly one argument.
179
*/
180
181
class Create_func_arg1 : public Create_func
182
{
183
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
184
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
185
186
  /**
187
    Builder method, with one argument.
520.1.22 by Brian Aker
Second pass of thd cleanup
188
    @param session The current thread
1 by brian
clean slate
189
    @param arg1 The first argument of the function
190
    @return An item representing the function call
191
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
192
  virtual Item *create(Session *session, Item *arg1) = 0;
1 by brian
clean slate
193
194
protected:
195
  /** Constructor. */
196
  Create_func_arg1() {}
197
  /** Destructor. */
198
  virtual ~Create_func_arg1() {}
199
};
200
201
202
/**
203
  Adapter for functions that takes exactly two arguments.
204
*/
205
206
class Create_func_arg2 : public Create_func
207
{
208
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
209
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
210
211
  /**
212
    Builder method, with two arguments.
520.1.22 by Brian Aker
Second pass of thd cleanup
213
    @param session The current thread
1 by brian
clean slate
214
    @param arg1 The first argument of the function
215
    @param arg2 The second argument of the function
216
    @return An item representing the function call
217
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
218
  virtual Item *create(Session *session, Item *arg1, Item *arg2) = 0;
1 by brian
clean slate
219
220
protected:
221
  /** Constructor. */
222
  Create_func_arg2() {}
223
  /** Destructor. */
224
  virtual ~Create_func_arg2() {}
225
};
226
227
228
/**
229
  Adapter for functions that takes exactly three arguments.
230
*/
231
232
class Create_func_arg3 : public Create_func
233
{
234
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
235
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
236
237
  /**
238
    Builder method, with three arguments.
520.1.22 by Brian Aker
Second pass of thd cleanup
239
    @param session The current thread
1 by brian
clean slate
240
    @param arg1 The first argument of the function
241
    @param arg2 The second argument of the function
242
    @param arg3 The third argument of the function
243
    @return An item representing the function call
244
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
245
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3) = 0;
1 by brian
clean slate
246
247
protected:
248
  /** Constructor. */
249
  Create_func_arg3() {}
250
  /** Destructor. */
251
  virtual ~Create_func_arg3() {}
252
};
253
254
255
/**
256
  Function builder for Stored Functions.
257
*/
258
259
/*
260
  Concrete functions builders (native functions).
261
  Please keep this list sorted in alphabetical order,
262
  it helps to compare code between versions, and helps with merges conflicts.
263
*/
264
265
class Create_func_abs : public Create_func_arg1
266
{
267
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
268
  using Create_func_arg1::create;
269
520.1.22 by Brian Aker
Second pass of thd cleanup
270
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
271
272
  static Create_func_abs s_singleton;
273
274
protected:
275
  Create_func_abs() {}
276
  virtual ~Create_func_abs() {}
277
};
278
279
280
class Create_func_acos : public Create_func_arg1
281
{
282
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
283
  using Create_func_arg1::create;
284
520.1.22 by Brian Aker
Second pass of thd cleanup
285
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
286
287
  static Create_func_acos s_singleton;
288
289
protected:
290
  Create_func_acos() {}
291
  virtual ~Create_func_acos() {}
292
};
293
294
class Create_func_asin : public Create_func_arg1
295
{
296
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
297
  using Create_func_arg1::create;
298
520.1.22 by Brian Aker
Second pass of thd cleanup
299
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
300
301
  static Create_func_asin s_singleton;
302
303
protected:
304
  Create_func_asin() {}
305
  virtual ~Create_func_asin() {}
306
};
307
308
309
class Create_func_atan : public Create_native_func
310
{
311
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
312
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
313
314
  static Create_func_atan s_singleton;
315
316
protected:
317
  Create_func_atan() {}
318
  virtual ~Create_func_atan() {}
319
};
320
321
class Create_func_bin : public Create_func_arg1
322
{
323
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
324
  using Create_func_arg1::create;
325
520.1.22 by Brian Aker
Second pass of thd cleanup
326
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
327
328
  static Create_func_bin s_singleton;
329
330
protected:
331
  Create_func_bin() {}
332
  virtual ~Create_func_bin() {}
333
};
334
335
336
class Create_func_ceiling : public Create_func_arg1
337
{
338
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
339
  using Create_func_arg1::create;
340
520.1.22 by Brian Aker
Second pass of thd cleanup
341
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
342
343
  static Create_func_ceiling s_singleton;
344
345
protected:
346
  Create_func_ceiling() {}
347
  virtual ~Create_func_ceiling() {}
348
};
349
350
351
class Create_func_coercibility : public Create_func_arg1
352
{
353
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
354
  using Create_func_arg1::create;
355
520.1.22 by Brian Aker
Second pass of thd cleanup
356
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
357
358
  static Create_func_coercibility s_singleton;
359
360
protected:
361
  Create_func_coercibility() {}
362
  virtual ~Create_func_coercibility() {}
363
};
364
365
366
class Create_func_concat : public Create_native_func
367
{
368
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
369
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
370
371
  static Create_func_concat s_singleton;
372
373
protected:
374
  Create_func_concat() {}
375
  virtual ~Create_func_concat() {}
376
};
377
378
379
class Create_func_concat_ws : public Create_native_func
380
{
381
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
382
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
383
384
  static Create_func_concat_ws s_singleton;
385
386
protected:
387
  Create_func_concat_ws() {}
388
  virtual ~Create_func_concat_ws() {}
389
};
390
391
392
class Create_func_conv : public Create_func_arg3
393
{
394
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
395
  using Create_func_arg3::create;
396
520.1.22 by Brian Aker
Second pass of thd cleanup
397
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
1 by brian
clean slate
398
399
  static Create_func_conv s_singleton;
400
401
protected:
402
  Create_func_conv() {}
403
  virtual ~Create_func_conv() {}
404
};
405
406
407
class Create_func_cos : public Create_func_arg1
408
{
409
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
410
  using Create_func_arg1::create;
411
520.1.22 by Brian Aker
Second pass of thd cleanup
412
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
413
414
  static Create_func_cos s_singleton;
415
416
protected:
417
  Create_func_cos() {}
418
  virtual ~Create_func_cos() {}
419
};
420
421
422
class Create_func_cot : public Create_func_arg1
423
{
424
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
425
  using Create_func_arg1::create;
426
520.1.22 by Brian Aker
Second pass of thd cleanup
427
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
428
429
  static Create_func_cot s_singleton;
430
431
protected:
432
  Create_func_cot() {}
433
  virtual ~Create_func_cot() {}
434
};
435
436
class Create_func_date_format : public Create_func_arg2
437
{
438
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
439
  using Create_func_arg2::create;
440
520.1.22 by Brian Aker
Second pass of thd cleanup
441
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1 by brian
clean slate
442
443
  static Create_func_date_format s_singleton;
444
445
protected:
446
  Create_func_date_format() {}
447
  virtual ~Create_func_date_format() {}
448
};
449
450
451
class Create_func_datediff : public Create_func_arg2
452
{
453
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
454
  using Create_func_arg2::create;
455
520.1.22 by Brian Aker
Second pass of thd cleanup
456
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1 by brian
clean slate
457
458
  static Create_func_datediff s_singleton;
459
460
protected:
461
  Create_func_datediff() {}
462
  virtual ~Create_func_datediff() {}
463
};
464
465
466
class Create_func_dayname : public Create_func_arg1
467
{
468
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
469
  using Create_func_arg1::create;
470
520.1.22 by Brian Aker
Second pass of thd cleanup
471
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
472
473
  static Create_func_dayname s_singleton;
474
475
protected:
476
  Create_func_dayname() {}
477
  virtual ~Create_func_dayname() {}
478
};
479
480
481
class Create_func_dayofmonth : public Create_func_arg1
482
{
483
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
484
  using Create_func_arg1::create;
485
520.1.22 by Brian Aker
Second pass of thd cleanup
486
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
487
488
  static Create_func_dayofmonth s_singleton;
489
490
protected:
491
  Create_func_dayofmonth() {}
492
  virtual ~Create_func_dayofmonth() {}
493
};
494
495
496
class Create_func_dayofweek : public Create_func_arg1
497
{
498
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
499
  using Create_func_arg1::create;
500
520.1.22 by Brian Aker
Second pass of thd cleanup
501
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
502
503
  static Create_func_dayofweek s_singleton;
504
505
protected:
506
  Create_func_dayofweek() {}
507
  virtual ~Create_func_dayofweek() {}
508
};
509
510
511
class Create_func_dayofyear : public Create_func_arg1
512
{
513
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
514
  using Create_func_arg1::create;
515
520.1.22 by Brian Aker
Second pass of thd cleanup
516
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
517
518
  static Create_func_dayofyear s_singleton;
519
520
protected:
521
  Create_func_dayofyear() {}
522
  virtual ~Create_func_dayofyear() {}
523
};
524
525
526
class Create_func_decode : public Create_func_arg2
527
{
528
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
529
  using Create_func_arg2::create;
530
520.1.22 by Brian Aker
Second pass of thd cleanup
531
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1 by brian
clean slate
532
533
  static Create_func_decode s_singleton;
534
535
protected:
536
  Create_func_decode() {}
537
  virtual ~Create_func_decode() {}
538
};
539
540
541
class Create_func_degrees : public Create_func_arg1
542
{
543
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
544
  using Create_func_arg1::create;
545
520.1.22 by Brian Aker
Second pass of thd cleanup
546
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
547
548
  static Create_func_degrees s_singleton;
549
550
protected:
551
  Create_func_degrees() {}
552
  virtual ~Create_func_degrees() {}
553
};
554
555
556
class Create_func_elt : public Create_native_func
557
{
558
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
559
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
560
561
  static Create_func_elt s_singleton;
562
563
protected:
564
  Create_func_elt() {}
565
  virtual ~Create_func_elt() {}
566
};
567
568
569
class Create_func_exp : public Create_func_arg1
570
{
571
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
572
  using Create_func_arg1::create;
573
520.1.22 by Brian Aker
Second pass of thd cleanup
574
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
575
576
  static Create_func_exp s_singleton;
577
578
protected:
579
  Create_func_exp() {}
580
  virtual ~Create_func_exp() {}
581
};
582
583
584
class Create_func_export_set : public Create_native_func
585
{
586
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
587
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
588
589
  static Create_func_export_set s_singleton;
590
591
protected:
592
  Create_func_export_set() {}
593
  virtual ~Create_func_export_set() {}
594
};
595
596
597
class Create_func_field : public Create_native_func
598
{
599
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
600
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
601
602
  static Create_func_field s_singleton;
603
604
protected:
605
  Create_func_field() {}
606
  virtual ~Create_func_field() {}
607
};
608
609
610
class Create_func_find_in_set : public Create_func_arg2
611
{
612
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
613
  using Create_func_arg2::create;
614
520.1.22 by Brian Aker
Second pass of thd cleanup
615
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1 by brian
clean slate
616
617
  static Create_func_find_in_set s_singleton;
618
619
protected:
620
  Create_func_find_in_set() {}
621
  virtual ~Create_func_find_in_set() {}
622
};
623
624
625
class Create_func_floor : public Create_func_arg1
626
{
627
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
628
  using Create_func_arg1::create;
629
520.1.22 by Brian Aker
Second pass of thd cleanup
630
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
631
632
  static Create_func_floor s_singleton;
633
634
protected:
635
  Create_func_floor() {}
636
  virtual ~Create_func_floor() {}
637
};
638
639
640
class Create_func_format : public Create_func_arg2
641
{
642
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
643
  using Create_func_arg2::create;
644
520.1.22 by Brian Aker
Second pass of thd cleanup
645
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1 by brian
clean slate
646
647
  static Create_func_format s_singleton;
648
649
protected:
650
  Create_func_format() {}
651
  virtual ~Create_func_format() {}
652
};
653
654
655
class Create_func_found_rows : public Create_func_arg0
656
{
657
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
658
  using Create_func_arg0::create;
659
520.1.22 by Brian Aker
Second pass of thd cleanup
660
  virtual Item *create(Session *session);
1 by brian
clean slate
661
662
  static Create_func_found_rows s_singleton;
663
664
protected:
665
  Create_func_found_rows() {}
666
  virtual ~Create_func_found_rows() {}
667
};
668
669
670
class Create_func_from_days : public Create_func_arg1
671
{
672
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
673
  using Create_func_arg1::create;
674
520.1.22 by Brian Aker
Second pass of thd cleanup
675
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
676
677
  static Create_func_from_days s_singleton;
678
679
protected:
680
  Create_func_from_days() {}
681
  virtual ~Create_func_from_days() {}
682
};
683
684
685
class Create_func_from_unixtime : public Create_native_func
686
{
687
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
688
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
689
690
  static Create_func_from_unixtime s_singleton;
691
692
protected:
693
  Create_func_from_unixtime() {}
694
  virtual ~Create_func_from_unixtime() {}
695
};
696
697
698
class Create_func_greatest : public Create_native_func
699
{
700
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
701
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
702
703
  static Create_func_greatest s_singleton;
704
705
protected:
706
  Create_func_greatest() {}
707
  virtual ~Create_func_greatest() {}
708
};
709
710
711
class Create_func_hex : public Create_func_arg1
712
{
713
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
714
  using Create_func_arg1::create;
715
520.1.22 by Brian Aker
Second pass of thd cleanup
716
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
717
718
  static Create_func_hex s_singleton;
719
720
protected:
721
  Create_func_hex() {}
722
  virtual ~Create_func_hex() {}
723
};
724
725
726
class Create_func_ifnull : public Create_func_arg2
727
{
728
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
729
  using Create_func_arg2::create;
730
520.1.22 by Brian Aker
Second pass of thd cleanup
731
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1 by brian
clean slate
732
733
  static Create_func_ifnull s_singleton;
734
735
protected:
736
  Create_func_ifnull() {}
737
  virtual ~Create_func_ifnull() {}
738
};
739
740
741
class Create_func_instr : public Create_func_arg2
742
{
743
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
744
  using Create_func_arg2::create;
745
520.1.22 by Brian Aker
Second pass of thd cleanup
746
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1 by brian
clean slate
747
748
  static Create_func_instr s_singleton;
749
750
protected:
751
  Create_func_instr() {}
752
  virtual ~Create_func_instr() {}
753
};
754
755
756
class Create_func_isnull : public Create_func_arg1
757
{
758
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
759
  using Create_func_arg1::create;
760
520.1.22 by Brian Aker
Second pass of thd cleanup
761
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
762
763
  static Create_func_isnull s_singleton;
764
765
protected:
766
  Create_func_isnull() {}
767
  virtual ~Create_func_isnull() {}
768
};
769
770
771
class Create_func_last_day : public Create_func_arg1
772
{
773
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
774
  using Create_func_arg1::create;
775
520.1.22 by Brian Aker
Second pass of thd cleanup
776
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
777
778
  static Create_func_last_day s_singleton;
779
780
protected:
781
  Create_func_last_day() {}
782
  virtual ~Create_func_last_day() {}
783
};
784
785
786
class Create_func_last_insert_id : public Create_native_func
787
{
788
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
789
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
790
791
  static Create_func_last_insert_id s_singleton;
792
793
protected:
794
  Create_func_last_insert_id() {}
795
  virtual ~Create_func_last_insert_id() {}
796
};
797
798
799
class Create_func_lcase : public Create_func_arg1
800
{
801
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
802
  using Create_func_arg1::create;
803
520.1.22 by Brian Aker
Second pass of thd cleanup
804
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
805
806
  static Create_func_lcase s_singleton;
807
808
protected:
809
  Create_func_lcase() {}
810
  virtual ~Create_func_lcase() {}
811
};
812
813
814
class Create_func_least : public Create_native_func
815
{
816
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
817
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
818
819
  static Create_func_least s_singleton;
820
821
protected:
822
  Create_func_least() {}
823
  virtual ~Create_func_least() {}
824
};
825
826
827
class Create_func_ln : public Create_func_arg1
828
{
829
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
830
  using Create_func_arg1::create;
831
520.1.22 by Brian Aker
Second pass of thd cleanup
832
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
833
834
  static Create_func_ln s_singleton;
835
836
protected:
837
  Create_func_ln() {}
838
  virtual ~Create_func_ln() {}
839
};
840
841
842
class Create_func_load_file : public Create_func_arg1
843
{
844
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
845
  using Create_func_arg1::create;
846
520.1.22 by Brian Aker
Second pass of thd cleanup
847
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
848
849
  static Create_func_load_file s_singleton;
850
851
protected:
852
  Create_func_load_file() {}
853
  virtual ~Create_func_load_file() {}
854
};
855
856
857
class Create_func_locate : public Create_native_func
858
{
859
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
860
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
861
862
  static Create_func_locate s_singleton;
863
864
protected:
865
  Create_func_locate() {}
866
  virtual ~Create_func_locate() {}
867
};
868
869
870
class Create_func_log : public Create_native_func
871
{
872
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
873
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
874
875
  static Create_func_log s_singleton;
876
877
protected:
878
  Create_func_log() {}
879
  virtual ~Create_func_log() {}
880
};
881
882
883
class Create_func_log10 : public Create_func_arg1
884
{
885
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
886
  using Create_func_arg1::create;
887
520.1.22 by Brian Aker
Second pass of thd cleanup
888
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
889
890
  static Create_func_log10 s_singleton;
891
892
protected:
893
  Create_func_log10() {}
894
  virtual ~Create_func_log10() {}
895
};
896
897
898
class Create_func_log2 : public Create_func_arg1
899
{
900
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
901
  using Create_func_arg1::create;
902
520.1.22 by Brian Aker
Second pass of thd cleanup
903
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
904
905
  static Create_func_log2 s_singleton;
906
907
protected:
908
  Create_func_log2() {}
909
  virtual ~Create_func_log2() {}
910
};
911
912
913
class Create_func_lpad : public Create_func_arg3
914
{
915
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
916
  using Create_func_arg3::create;
917
520.1.22 by Brian Aker
Second pass of thd cleanup
918
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
1 by brian
clean slate
919
920
  static Create_func_lpad s_singleton;
921
922
protected:
923
  Create_func_lpad() {}
924
  virtual ~Create_func_lpad() {}
925
};
926
927
928
class Create_func_ltrim : public Create_func_arg1
929
{
930
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
931
  using Create_func_arg1::create;
932
520.1.22 by Brian Aker
Second pass of thd cleanup
933
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
934
935
  static Create_func_ltrim s_singleton;
936
937
protected:
938
  Create_func_ltrim() {}
939
  virtual ~Create_func_ltrim() {}
940
};
941
942
943
class Create_func_makedate : public Create_func_arg2
944
{
945
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
946
  using Create_func_arg2::create;
947
520.1.22 by Brian Aker
Second pass of thd cleanup
948
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1 by brian
clean slate
949
950
  static Create_func_makedate s_singleton;
951
952
protected:
953
  Create_func_makedate() {}
954
  virtual ~Create_func_makedate() {}
955
};
956
957
class Create_func_make_set : public Create_native_func
958
{
959
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
960
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
961
962
  static Create_func_make_set s_singleton;
963
964
protected:
965
  Create_func_make_set() {}
966
  virtual ~Create_func_make_set() {}
967
};
968
969
970
class Create_func_monthname : public Create_func_arg1
971
{
972
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
973
  using Create_func_arg1::create;
974
520.1.22 by Brian Aker
Second pass of thd cleanup
975
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
976
977
  static Create_func_monthname s_singleton;
978
979
protected:
980
  Create_func_monthname() {}
981
  virtual ~Create_func_monthname() {}
982
};
983
984
985
class Create_func_name_const : public Create_func_arg2
986
{
987
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
988
  using Create_func_arg2::create;
989
520.1.22 by Brian Aker
Second pass of thd cleanup
990
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1 by brian
clean slate
991
992
  static Create_func_name_const s_singleton;
993
994
protected:
995
  Create_func_name_const() {}
996
  virtual ~Create_func_name_const() {}
997
};
998
999
1000
class Create_func_nullif : public Create_func_arg2
1001
{
1002
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1003
  using Create_func_arg2::create;
1004
520.1.22 by Brian Aker
Second pass of thd cleanup
1005
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1 by brian
clean slate
1006
1007
  static Create_func_nullif s_singleton;
1008
1009
protected:
1010
  Create_func_nullif() {}
1011
  virtual ~Create_func_nullif() {}
1012
};
1013
1014
1015
class Create_func_oct : public Create_func_arg1
1016
{
1017
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1018
  using Create_func_arg1::create;
1019
520.1.22 by Brian Aker
Second pass of thd cleanup
1020
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
1021
1022
  static Create_func_oct s_singleton;
1023
1024
protected:
1025
  Create_func_oct() {}
1026
  virtual ~Create_func_oct() {}
1027
};
1028
1029
1030
class Create_func_ord : public Create_func_arg1
1031
{
1032
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1033
  using Create_func_arg1::create;
1034
520.1.22 by Brian Aker
Second pass of thd cleanup
1035
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
1036
1037
  static Create_func_ord s_singleton;
1038
1039
protected:
1040
  Create_func_ord() {}
1041
  virtual ~Create_func_ord() {}
1042
};
1043
1044
1045
class Create_func_period_add : public Create_func_arg2
1046
{
1047
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1048
  using Create_func_arg2::create;
1049
520.1.22 by Brian Aker
Second pass of thd cleanup
1050
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1 by brian
clean slate
1051
1052
  static Create_func_period_add s_singleton;
1053
1054
protected:
1055
  Create_func_period_add() {}
1056
  virtual ~Create_func_period_add() {}
1057
};
1058
1059
1060
class Create_func_period_diff : public Create_func_arg2
1061
{
1062
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1063
  using Create_func_arg2::create;
1064
520.1.22 by Brian Aker
Second pass of thd cleanup
1065
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1 by brian
clean slate
1066
1067
  static Create_func_period_diff s_singleton;
1068
1069
protected:
1070
  Create_func_period_diff() {}
1071
  virtual ~Create_func_period_diff() {}
1072
};
1073
1074
1075
class Create_func_pi : public Create_func_arg0
1076
{
1077
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1078
  using Create_func_arg0::create;
1079
520.1.22 by Brian Aker
Second pass of thd cleanup
1080
  virtual Item *create(Session *session);
1 by brian
clean slate
1081
1082
  static Create_func_pi s_singleton;
1083
1084
protected:
1085
  Create_func_pi() {}
1086
  virtual ~Create_func_pi() {}
1087
};
1088
1089
1090
class Create_func_pow : public Create_func_arg2
1091
{
1092
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1093
  using Create_func_arg2::create;
1094
520.1.22 by Brian Aker
Second pass of thd cleanup
1095
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1 by brian
clean slate
1096
1097
  static Create_func_pow s_singleton;
1098
1099
protected:
1100
  Create_func_pow() {}
1101
  virtual ~Create_func_pow() {}
1102
};
1103
1104
1105
class Create_func_quote : public Create_func_arg1
1106
{
1107
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1108
  using Create_func_arg1::create;
1109
520.1.22 by Brian Aker
Second pass of thd cleanup
1110
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
1111
1112
  static Create_func_quote s_singleton;
1113
1114
protected:
1115
  Create_func_quote() {}
1116
  virtual ~Create_func_quote() {}
1117
};
1118
1119
1120
class Create_func_radians : public Create_func_arg1
1121
{
1122
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1123
  using Create_func_arg1::create;
1124
520.1.22 by Brian Aker
Second pass of thd cleanup
1125
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
1126
1127
  static Create_func_radians s_singleton;
1128
1129
protected:
1130
  Create_func_radians() {}
1131
  virtual ~Create_func_radians() {}
1132
};
1133
1134
1135
class Create_func_rand : public Create_native_func
1136
{
1137
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
1138
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
1139
1140
  static Create_func_rand s_singleton;
1141
1142
protected:
1143
  Create_func_rand() {}
1144
  virtual ~Create_func_rand() {}
1145
};
1146
1147
1148
class Create_func_round : public Create_native_func
1149
{
1150
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
1151
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
1152
1153
  static Create_func_round s_singleton;
1154
1155
protected:
1156
  Create_func_round() {}
1157
  virtual ~Create_func_round() {}
1158
};
1159
1160
1161
class Create_func_row_count : public Create_func_arg0
1162
{
1163
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1164
  using Create_func_arg0::create;
1165
520.1.22 by Brian Aker
Second pass of thd cleanup
1166
  virtual Item *create(Session *session);
1 by brian
clean slate
1167
1168
  static Create_func_row_count s_singleton;
1169
1170
protected:
1171
  Create_func_row_count() {}
1172
  virtual ~Create_func_row_count() {}
1173
};
1174
1175
1176
class Create_func_rpad : public Create_func_arg3
1177
{
1178
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1179
  using Create_func_arg3::create;
1180
520.1.22 by Brian Aker
Second pass of thd cleanup
1181
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
1 by brian
clean slate
1182
1183
  static Create_func_rpad s_singleton;
1184
1185
protected:
1186
  Create_func_rpad() {}
1187
  virtual ~Create_func_rpad() {}
1188
};
1189
1190
1191
class Create_func_rtrim : public Create_func_arg1
1192
{
1193
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1194
  using Create_func_arg1::create;
1195
520.1.22 by Brian Aker
Second pass of thd cleanup
1196
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
1197
1198
  static Create_func_rtrim s_singleton;
1199
1200
protected:
1201
  Create_func_rtrim() {}
1202
  virtual ~Create_func_rtrim() {}
1203
};
1204
1205
class Create_func_sign : public Create_func_arg1
1206
{
1207
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1208
  using Create_func_arg1::create;
1209
520.1.22 by Brian Aker
Second pass of thd cleanup
1210
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
1211
1212
  static Create_func_sign s_singleton;
1213
1214
protected:
1215
  Create_func_sign() {}
1216
  virtual ~Create_func_sign() {}
1217
};
1218
1219
1220
class Create_func_sin : public Create_func_arg1
1221
{
1222
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1223
  using Create_func_arg1::create;
1224
520.1.22 by Brian Aker
Second pass of thd cleanup
1225
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
1226
1227
  static Create_func_sin s_singleton;
1228
1229
protected:
1230
  Create_func_sin() {}
1231
  virtual ~Create_func_sin() {}
1232
};
1233
1234
1235
class Create_func_space : public Create_func_arg1
1236
{
1237
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1238
  using Create_func_arg1::create;
1239
520.1.22 by Brian Aker
Second pass of thd cleanup
1240
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
1241
1242
  static Create_func_space s_singleton;
1243
1244
protected:
1245
  Create_func_space() {}
1246
  virtual ~Create_func_space() {}
1247
};
1248
1249
1250
class Create_func_sqrt : public Create_func_arg1
1251
{
1252
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1253
  using Create_func_arg1::create;
1254
520.1.22 by Brian Aker
Second pass of thd cleanup
1255
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
1256
1257
  static Create_func_sqrt s_singleton;
1258
1259
protected:
1260
  Create_func_sqrt() {}
1261
  virtual ~Create_func_sqrt() {}
1262
};
1263
1264
1265
class Create_func_strcmp : public Create_func_arg2
1266
{
1267
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1268
  using Create_func_arg2::create;
1269
520.1.22 by Brian Aker
Second pass of thd cleanup
1270
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1 by brian
clean slate
1271
1272
  static Create_func_strcmp s_singleton;
1273
1274
protected:
1275
  Create_func_strcmp() {}
1276
  virtual ~Create_func_strcmp() {}
1277
};
1278
1279
1280
class Create_func_substr_index : public Create_func_arg3
1281
{
1282
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1283
  using Create_func_arg3::create;
1284
520.1.22 by Brian Aker
Second pass of thd cleanup
1285
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
1 by brian
clean slate
1286
1287
  static Create_func_substr_index s_singleton;
1288
1289
protected:
1290
  Create_func_substr_index() {}
1291
  virtual ~Create_func_substr_index() {}
1292
};
1293
1294
1295
class Create_func_tan : public Create_func_arg1
1296
{
1297
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1298
  using Create_func_arg1::create;
1299
520.1.22 by Brian Aker
Second pass of thd cleanup
1300
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
1301
1302
  static Create_func_tan s_singleton;
1303
1304
protected:
1305
  Create_func_tan() {}
1306
  virtual ~Create_func_tan() {}
1307
};
1308
1309
1310
class Create_func_time_format : public Create_func_arg2
1311
{
1312
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1313
  using Create_func_arg2::create;
1314
520.1.22 by Brian Aker
Second pass of thd cleanup
1315
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1 by brian
clean slate
1316
1317
  static Create_func_time_format s_singleton;
1318
1319
protected:
1320
  Create_func_time_format() {}
1321
  virtual ~Create_func_time_format() {}
1322
};
1323
1324
1325
class Create_func_time_to_sec : public Create_func_arg1
1326
{
1327
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1328
  using Create_func_arg1::create;
1329
520.1.22 by Brian Aker
Second pass of thd cleanup
1330
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
1331
1332
  static Create_func_time_to_sec s_singleton;
1333
1334
protected:
1335
  Create_func_time_to_sec() {}
1336
  virtual ~Create_func_time_to_sec() {}
1337
};
1338
1339
1340
class Create_func_to_days : public Create_func_arg1
1341
{
1342
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1343
  using Create_func_arg1::create;
1344
520.1.22 by Brian Aker
Second pass of thd cleanup
1345
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
1346
1347
  static Create_func_to_days s_singleton;
1348
1349
protected:
1350
  Create_func_to_days() {}
1351
  virtual ~Create_func_to_days() {}
1352
};
1353
1354
1355
class Create_func_ucase : public Create_func_arg1
1356
{
1357
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1358
  using Create_func_arg1::create;
1359
520.1.22 by Brian Aker
Second pass of thd cleanup
1360
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
1361
1362
  static Create_func_ucase s_singleton;
1363
1364
protected:
1365
  Create_func_ucase() {}
1366
  virtual ~Create_func_ucase() {}
1367
};
1368
1369
1370
class Create_func_unhex : public Create_func_arg1
1371
{
1372
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1373
  using Create_func_arg1::create;
1374
520.1.22 by Brian Aker
Second pass of thd cleanup
1375
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
1376
1377
  static Create_func_unhex s_singleton;
1378
1379
protected:
1380
  Create_func_unhex() {}
1381
  virtual ~Create_func_unhex() {}
1382
};
1383
1384
1385
class Create_func_unix_timestamp : public Create_native_func
1386
{
1387
public:
520.1.22 by Brian Aker
Second pass of thd cleanup
1388
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1 by brian
clean slate
1389
1390
  static Create_func_unix_timestamp s_singleton;
1391
1392
protected:
1393
  Create_func_unix_timestamp() {}
1394
  virtual ~Create_func_unix_timestamp() {}
1395
};
1396
1397
1398
class Create_func_uuid : public Create_func_arg0
1399
{
1400
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1401
  using Create_func_arg0::create;
1402
520.1.22 by Brian Aker
Second pass of thd cleanup
1403
  virtual Item *create(Session *session);
1 by brian
clean slate
1404
1405
  static Create_func_uuid s_singleton;
1406
1407
protected:
1408
  Create_func_uuid() {}
1409
  virtual ~Create_func_uuid() {}
1410
};
1411
1412
1413
class Create_func_weekday : public Create_func_arg1
1414
{
1415
public:
892.1.1 by Monty Taylor
Fixed virtual overload warnings.
1416
  using Create_func_arg1::create;
1417
520.1.22 by Brian Aker
Second pass of thd cleanup
1418
  virtual Item *create(Session *session, Item *arg1);
1 by brian
clean slate
1419
1420
  static Create_func_weekday s_singleton;
1421
1422
protected:
1423
  Create_func_weekday() {}
1424
  virtual ~Create_func_weekday() {}
1425
};
1426
1427
/*
1428
=============================================================================
1429
  IMPLEMENTATION
1430
=============================================================================
1431
*/
1432
1433
/**
1434
  Checks if there are named parameters in a parameter list.
1435
  The syntax to name parameters in a function call is as follow:
1436
  <code>foo(expr AS named, expr named, expr AS "named", expr "named")</code>
1437
  @param params The parameter list, can be null
1438
  @return true if one or more parameter is named
1439
*/
1440
static bool has_named_parameters(List<Item> *params)
1441
{
1442
  if (params)
1443
  {
1444
    Item *param;
1445
    List_iterator<Item> it(*params);
1446
    while ((param= it++))
1447
    {
1448
      if (! param->is_autogenerated_name)
1449
        return true;
1450
    }
1451
  }
1452
1453
  return false;
1454
}
1455
1456
1457
Create_udf_func Create_udf_func::s_singleton;
1458
1459
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1460
Create_udf_func::create(Session *session, LEX_STRING name, List<Item> *item_list)
1 by brian
clean slate
1461
{
1130.1.12 by Monty Taylor
Moved service stuff into plugin/
1462
  const plugin::Function *udf= plugin::Function::get(name.str, name.length);
51.1.19 by Jay Pipes
Removed/replace DBUG symbols
1463
  assert(udf);
520.1.22 by Brian Aker
Second pass of thd cleanup
1464
  return create(session, udf, item_list);
1 by brian
clean slate
1465
}
1466
1467
1468
Item*
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
1469
Create_udf_func::create(Session *session, const plugin::Function *udf,
942.1.12 by Monty Taylor
Converted udf_func into a factory.
1470
                        List<Item> *item_list)
1 by brian
clean slate
1471
{
139.1.8 by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot.
1472
  Item_func *func= NULL;
1 by brian
clean slate
1473
  int arg_count= 0;
1474
1475
  if (item_list != NULL)
1476
    arg_count= item_list->elements;
1477
942.1.12 by Monty Taylor
Converted udf_func into a factory.
1478
  func= (*udf)(session->mem_root);
139.1.8 by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot.
1479
997.8.1 by Stewart Smith
Add check for argument numbers for UDFs. Fix crc32 and md5
1480
  if(!func->check_argument_count(arg_count))
1481
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
1482
    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
1483
    return NULL;
1484
  }
1485
1486
  if(item_list)
1487
    func->set_arguments(*item_list);
139.1.8 by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot.
1488
1 by brian
clean slate
1489
  return func;
1490
}
1491
1492
1493
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1494
Create_native_func::create(Session *session, LEX_STRING name, List<Item> *item_list)
1 by brian
clean slate
1495
{
1496
  if (has_named_parameters(item_list))
1497
  {
1498
    my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
1499
    return NULL;
1500
  }
1501
520.1.22 by Brian Aker
Second pass of thd cleanup
1502
  return create_native(session, name, item_list);
1 by brian
clean slate
1503
}
1504
1505
1506
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1507
Create_func_arg0::create(Session *session, LEX_STRING name, List<Item> *item_list)
1 by brian
clean slate
1508
{
1509
  int arg_count= 0;
1510
1511
  if (item_list != NULL)
1512
    arg_count= item_list->elements;
1513
1514
  if (arg_count != 0)
1515
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
1516
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
1517
    return NULL;
1518
  }
1519
520.1.22 by Brian Aker
Second pass of thd cleanup
1520
  return create(session);
1 by brian
clean slate
1521
}
1522
1523
1524
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1525
Create_func_arg1::create(Session *session, LEX_STRING name, List<Item> *item_list)
1 by brian
clean slate
1526
{
1527
  int arg_count= 0;
1528
1529
  if (item_list)
1530
    arg_count= item_list->elements;
1531
1532
  if (arg_count != 1)
1533
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
1534
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
1535
    return NULL;
1536
  }
1537
1538
  Item *param_1= item_list->pop();
1539
1540
  if (! param_1->is_autogenerated_name)
1541
  {
1542
    my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
1543
    return NULL;
1544
  }
1545
520.1.22 by Brian Aker
Second pass of thd cleanup
1546
  return create(session, param_1);
1 by brian
clean slate
1547
}
1548
1549
1550
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1551
Create_func_arg2::create(Session *session, LEX_STRING name, List<Item> *item_list)
1 by brian
clean slate
1552
{
1553
  int arg_count= 0;
1554
1555
  if (item_list)
1556
    arg_count= item_list->elements;
1557
1558
  if (arg_count != 2)
1559
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
1560
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
1561
    return NULL;
1562
  }
1563
1564
  Item *param_1= item_list->pop();
1565
  Item *param_2= item_list->pop();
1566
1567
  if (   (! param_1->is_autogenerated_name)
1568
      || (! param_2->is_autogenerated_name))
1569
  {
1570
    my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
1571
    return NULL;
1572
  }
1573
520.1.22 by Brian Aker
Second pass of thd cleanup
1574
  return create(session, param_1, param_2);
1 by brian
clean slate
1575
}
1576
1577
1578
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1579
Create_func_arg3::create(Session *session, LEX_STRING name, List<Item> *item_list)
1 by brian
clean slate
1580
{
1581
  int arg_count= 0;
1582
1583
  if (item_list)
1584
    arg_count= item_list->elements;
1585
1586
  if (arg_count != 3)
1587
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
1588
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
1589
    return NULL;
1590
  }
1591
1592
  Item *param_1= item_list->pop();
1593
  Item *param_2= item_list->pop();
1594
  Item *param_3= item_list->pop();
1595
1596
  if (   (! param_1->is_autogenerated_name)
1597
      || (! param_2->is_autogenerated_name)
1598
      || (! param_3->is_autogenerated_name))
1599
  {
1600
    my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
1601
    return NULL;
1602
  }
1603
520.1.22 by Brian Aker
Second pass of thd cleanup
1604
  return create(session, param_1, param_2, param_3);
1 by brian
clean slate
1605
}
1606
1607
1608
Create_func_abs Create_func_abs::s_singleton;
1609
1610
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1611
Create_func_abs::create(Session *session, Item *arg1)
1 by brian
clean slate
1612
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1613
  return new (session->mem_root) Item_func_abs(arg1);
1 by brian
clean slate
1614
}
1615
1616
1617
Create_func_acos Create_func_acos::s_singleton;
1618
1619
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1620
Create_func_acos::create(Session *session, Item *arg1)
1 by brian
clean slate
1621
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1622
  return new (session->mem_root) Item_func_acos(arg1);
1 by brian
clean slate
1623
}
1624
1625
Create_func_asin Create_func_asin::s_singleton;
1626
1627
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1628
Create_func_asin::create(Session *session, Item *arg1)
1 by brian
clean slate
1629
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1630
  return new (session->mem_root) Item_func_asin(arg1);
1 by brian
clean slate
1631
}
1632
1633
1634
Create_func_atan Create_func_atan::s_singleton;
1635
1636
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1637
Create_func_atan::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
1638
                                List<Item> *item_list)
1639
{
1640
  Item* func= NULL;
1641
  int arg_count= 0;
1642
1643
  if (item_list != NULL)
1644
    arg_count= item_list->elements;
1645
1646
  switch (arg_count) {
1647
  case 1:
1648
  {
1649
    Item *param_1= item_list->pop();
520.1.22 by Brian Aker
Second pass of thd cleanup
1650
    func= new (session->mem_root) Item_func_atan(param_1);
1 by brian
clean slate
1651
    break;
1652
  }
1653
  case 2:
1654
  {
1655
    Item *param_1= item_list->pop();
1656
    Item *param_2= item_list->pop();
520.1.22 by Brian Aker
Second pass of thd cleanup
1657
    func= new (session->mem_root) Item_func_atan(param_1, param_2);
1 by brian
clean slate
1658
    break;
1659
  }
1660
  default:
1661
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
1662
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
1663
    break;
1664
  }
1665
  }
1666
1667
  return func;
1668
}
1669
1670
Create_func_bin Create_func_bin::s_singleton;
1671
1672
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1673
Create_func_bin::create(Session *session, Item *arg1)
1 by brian
clean slate
1674
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1675
  Item *i10= new (session->mem_root) Item_int((int32_t) 10,2);
1676
  Item *i2= new (session->mem_root) Item_int((int32_t) 2,1);
1677
  return new (session->mem_root) Item_func_conv(arg1, i10, i2);
1 by brian
clean slate
1678
}
1679
1680
1681
Create_func_ceiling Create_func_ceiling::s_singleton;
1682
1683
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1684
Create_func_ceiling::create(Session *session, Item *arg1)
1 by brian
clean slate
1685
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1686
  return new (session->mem_root) Item_func_ceiling(arg1);
1 by brian
clean slate
1687
}
1688
1689
1690
Create_func_coercibility Create_func_coercibility::s_singleton;
1691
1692
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1693
Create_func_coercibility::create(Session *session, Item *arg1)
1 by brian
clean slate
1694
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1695
  return new (session->mem_root) Item_func_coercibility(arg1);
1 by brian
clean slate
1696
}
1697
1698
1699
Create_func_concat Create_func_concat::s_singleton;
1700
1701
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1702
Create_func_concat::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
1703
                                  List<Item> *item_list)
1704
{
1705
  int arg_count= 0;
1706
1707
  if (item_list != NULL)
1708
    arg_count= item_list->elements;
1709
1710
  if (arg_count < 1)
1711
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
1712
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
1713
    return NULL;
1714
  }
1715
520.1.22 by Brian Aker
Second pass of thd cleanup
1716
  return new (session->mem_root) Item_func_concat(*item_list);
1 by brian
clean slate
1717
}
1718
1719
1720
Create_func_concat_ws Create_func_concat_ws::s_singleton;
1721
1722
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1723
Create_func_concat_ws::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
1724
                                     List<Item> *item_list)
1725
{
1726
  int arg_count= 0;
1727
1728
  if (item_list != NULL)
1729
    arg_count= item_list->elements;
1730
1731
  /* "WS" stands for "With Separator": this function takes 2+ arguments */
1732
  if (arg_count < 2)
1733
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
1734
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
1735
    return NULL;
1736
  }
1737
520.1.22 by Brian Aker
Second pass of thd cleanup
1738
  return new (session->mem_root) Item_func_concat_ws(*item_list);
1 by brian
clean slate
1739
}
1740
1741
1742
Create_func_conv Create_func_conv::s_singleton;
1743
1744
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1745
Create_func_conv::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
1 by brian
clean slate
1746
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1747
  return new (session->mem_root) Item_func_conv(arg1, arg2, arg3);
1 by brian
clean slate
1748
}
1749
1750
1751
Create_func_cos Create_func_cos::s_singleton;
1752
1753
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1754
Create_func_cos::create(Session *session, Item *arg1)
1 by brian
clean slate
1755
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1756
  return new (session->mem_root) Item_func_cos(arg1);
1 by brian
clean slate
1757
}
1758
1759
1760
Create_func_cot Create_func_cot::s_singleton;
1761
1762
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1763
Create_func_cot::create(Session *session, Item *arg1)
1 by brian
clean slate
1764
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1765
  Item *i1= new (session->mem_root) Item_int((char*) "1", 1, 1);
1766
  Item *i2= new (session->mem_root) Item_func_tan(arg1);
1767
  return new (session->mem_root) Item_func_div(i1, i2);
1 by brian
clean slate
1768
}
1769
1770
Create_func_date_format Create_func_date_format::s_singleton;
1771
1772
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1773
Create_func_date_format::create(Session *session, Item *arg1, Item *arg2)
1 by brian
clean slate
1774
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1775
  return new (session->mem_root) Item_func_date_format(arg1, arg2, 0);
1 by brian
clean slate
1776
}
1777
1778
1779
Create_func_datediff Create_func_datediff::s_singleton;
1780
1781
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1782
Create_func_datediff::create(Session *session, Item *arg1, Item *arg2)
1 by brian
clean slate
1783
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1784
  Item *i1= new (session->mem_root) Item_func_to_days(arg1);
1785
  Item *i2= new (session->mem_root) Item_func_to_days(arg2);
1 by brian
clean slate
1786
520.1.22 by Brian Aker
Second pass of thd cleanup
1787
  return new (session->mem_root) Item_func_minus(i1, i2);
1 by brian
clean slate
1788
}
1789
1790
1791
Create_func_dayname Create_func_dayname::s_singleton;
1792
1793
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1794
Create_func_dayname::create(Session *session, Item *arg1)
1 by brian
clean slate
1795
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1796
  return new (session->mem_root) Item_func_dayname(arg1);
1 by brian
clean slate
1797
}
1798
1799
1800
Create_func_dayofmonth Create_func_dayofmonth::s_singleton;
1801
1802
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1803
Create_func_dayofmonth::create(Session *session, Item *arg1)
1 by brian
clean slate
1804
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1805
  return new (session->mem_root) Item_func_dayofmonth(arg1);
1 by brian
clean slate
1806
}
1807
1808
1809
Create_func_dayofweek Create_func_dayofweek::s_singleton;
1810
1811
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1812
Create_func_dayofweek::create(Session *session, Item *arg1)
1 by brian
clean slate
1813
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1814
  return new (session->mem_root) Item_func_weekday(arg1, 1);
1 by brian
clean slate
1815
}
1816
1817
1818
Create_func_dayofyear Create_func_dayofyear::s_singleton;
1819
1820
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1821
Create_func_dayofyear::create(Session *session, Item *arg1)
1 by brian
clean slate
1822
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1823
  return new (session->mem_root) Item_func_dayofyear(arg1);
1 by brian
clean slate
1824
}
1825
1826
1827
Create_func_degrees Create_func_degrees::s_singleton;
1828
1829
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1830
Create_func_degrees::create(Session *session, Item *arg1)
1 by brian
clean slate
1831
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1832
  return new (session->mem_root) Item_func_units((char*) "degrees", arg1,
1 by brian
clean slate
1833
                                             180/M_PI, 0.0);
1834
}
1835
1836
1837
Create_func_elt Create_func_elt::s_singleton;
1838
1839
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1840
Create_func_elt::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
1841
                               List<Item> *item_list)
1842
{
1843
  int arg_count= 0;
1844
1845
  if (item_list != NULL)
1846
    arg_count= item_list->elements;
1847
1848
  if (arg_count < 2)
1849
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
1850
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
1851
    return NULL;
1852
  }
1853
520.1.22 by Brian Aker
Second pass of thd cleanup
1854
  return new (session->mem_root) Item_func_elt(*item_list);
1 by brian
clean slate
1855
}
1856
1857
1858
Create_func_exp Create_func_exp::s_singleton;
1859
1860
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1861
Create_func_exp::create(Session *session, Item *arg1)
1 by brian
clean slate
1862
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1863
  return new (session->mem_root) Item_func_exp(arg1);
1 by brian
clean slate
1864
}
1865
1866
1867
Create_func_export_set Create_func_export_set::s_singleton;
1868
1869
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1870
Create_func_export_set::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
1871
                                      List<Item> *item_list)
1872
{
1873
  Item *func= NULL;
1874
  int arg_count= 0;
1875
1876
  if (item_list != NULL)
1877
    arg_count= item_list->elements;
1878
1879
  switch (arg_count) {
1880
  case 3:
1881
  {
1882
    Item *param_1= item_list->pop();
1883
    Item *param_2= item_list->pop();
1884
    Item *param_3= item_list->pop();
520.1.22 by Brian Aker
Second pass of thd cleanup
1885
    func= new (session->mem_root) Item_func_export_set(param_1, param_2, param_3);
1 by brian
clean slate
1886
    break;
1887
  }
1888
  case 4:
1889
  {
1890
    Item *param_1= item_list->pop();
1891
    Item *param_2= item_list->pop();
1892
    Item *param_3= item_list->pop();
1893
    Item *param_4= item_list->pop();
520.1.22 by Brian Aker
Second pass of thd cleanup
1894
    func= new (session->mem_root) Item_func_export_set(param_1, param_2, param_3,
1 by brian
clean slate
1895
                                                   param_4);
1896
    break;
1897
  }
1898
  case 5:
1899
  {
1900
    Item *param_1= item_list->pop();
1901
    Item *param_2= item_list->pop();
1902
    Item *param_3= item_list->pop();
1903
    Item *param_4= item_list->pop();
1904
    Item *param_5= item_list->pop();
520.1.22 by Brian Aker
Second pass of thd cleanup
1905
    func= new (session->mem_root) Item_func_export_set(param_1, param_2, param_3,
1 by brian
clean slate
1906
                                                   param_4, param_5);
1907
    break;
1908
  }
1909
  default:
1910
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
1911
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
1912
    break;
1913
  }
1914
  }
1915
1916
  return func;
1917
}
1918
1919
1920
Create_func_field Create_func_field::s_singleton;
1921
1922
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1923
Create_func_field::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
1924
                                 List<Item> *item_list)
1925
{
1926
  int arg_count= 0;
1927
1928
  if (item_list != NULL)
1929
    arg_count= item_list->elements;
1930
1931
  if (arg_count < 2)
1932
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
1933
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
1934
    return NULL;
1935
  }
1936
520.1.22 by Brian Aker
Second pass of thd cleanup
1937
  return new (session->mem_root) Item_func_field(*item_list);
1 by brian
clean slate
1938
}
1939
1940
1941
Create_func_find_in_set Create_func_find_in_set::s_singleton;
1942
1943
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1944
Create_func_find_in_set::create(Session *session, Item *arg1, Item *arg2)
1 by brian
clean slate
1945
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1946
  return new (session->mem_root) Item_func_find_in_set(arg1, arg2);
1 by brian
clean slate
1947
}
1948
1949
1950
Create_func_floor Create_func_floor::s_singleton;
1951
1952
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1953
Create_func_floor::create(Session *session, Item *arg1)
1 by brian
clean slate
1954
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1955
  return new (session->mem_root) Item_func_floor(arg1);
1 by brian
clean slate
1956
}
1957
1958
1959
Create_func_format Create_func_format::s_singleton;
1960
1961
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1962
Create_func_format::create(Session *session, Item *arg1, Item *arg2)
1 by brian
clean slate
1963
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1964
  return new (session->mem_root) Item_func_format(arg1, arg2);
1 by brian
clean slate
1965
}
1966
1967
1968
Create_func_found_rows Create_func_found_rows::s_singleton;
1969
1970
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1971
Create_func_found_rows::create(Session *session)
1 by brian
clean slate
1972
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1973
  return new (session->mem_root) Item_func_found_rows();
1 by brian
clean slate
1974
}
1975
1976
1977
Create_func_from_days Create_func_from_days::s_singleton;
1978
1979
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1980
Create_func_from_days::create(Session *session, Item *arg1)
1 by brian
clean slate
1981
{
520.1.22 by Brian Aker
Second pass of thd cleanup
1982
  return new (session->mem_root) Item_func_from_days(arg1);
1 by brian
clean slate
1983
}
1984
1985
1986
Create_func_from_unixtime Create_func_from_unixtime::s_singleton;
1987
1988
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
1989
Create_func_from_unixtime::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
1990
                                         List<Item> *item_list)
1991
{
1992
  Item *func= NULL;
1993
  int arg_count= 0;
1994
1995
  if (item_list != NULL)
1996
    arg_count= item_list->elements;
1997
1998
  switch (arg_count) {
1999
  case 1:
2000
  {
2001
    Item *param_1= item_list->pop();
520.1.22 by Brian Aker
Second pass of thd cleanup
2002
    func= new (session->mem_root) Item_func_from_unixtime(param_1);
1 by brian
clean slate
2003
    break;
2004
  }
2005
  case 2:
2006
  {
2007
    Item *param_1= item_list->pop();
2008
    Item *param_2= item_list->pop();
520.1.22 by Brian Aker
Second pass of thd cleanup
2009
    Item *ut= new (session->mem_root) Item_func_from_unixtime(param_1);
2010
    func= new (session->mem_root) Item_func_date_format(ut, param_2, 0);
1 by brian
clean slate
2011
    break;
2012
  }
2013
  default:
2014
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
2015
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
2016
    break;
2017
  }
2018
  }
2019
2020
  return func;
2021
}
2022
2023
2024
Create_func_greatest Create_func_greatest::s_singleton;
2025
2026
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2027
Create_func_greatest::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
2028
                                    List<Item> *item_list)
2029
{
2030
  int arg_count= 0;
2031
2032
  if (item_list != NULL)
2033
    arg_count= item_list->elements;
2034
2035
  if (arg_count < 2)
2036
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
2037
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
2038
    return NULL;
2039
  }
2040
520.1.22 by Brian Aker
Second pass of thd cleanup
2041
  return new (session->mem_root) Item_func_max(*item_list);
1 by brian
clean slate
2042
}
2043
2044
2045
Create_func_hex Create_func_hex::s_singleton;
2046
2047
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2048
Create_func_hex::create(Session *session, Item *arg1)
1 by brian
clean slate
2049
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2050
  return new (session->mem_root) Item_func_hex(arg1);
1 by brian
clean slate
2051
}
2052
2053
2054
Create_func_ifnull Create_func_ifnull::s_singleton;
2055
2056
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2057
Create_func_ifnull::create(Session *session, Item *arg1, Item *arg2)
1 by brian
clean slate
2058
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2059
  return new (session->mem_root) Item_func_ifnull(arg1, arg2);
1 by brian
clean slate
2060
}
2061
2062
2063
Create_func_instr Create_func_instr::s_singleton;
2064
2065
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2066
Create_func_instr::create(Session *session, Item *arg1, Item *arg2)
1 by brian
clean slate
2067
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2068
  return new (session->mem_root) Item_func_locate(arg1, arg2);
1 by brian
clean slate
2069
}
2070
2071
2072
Create_func_isnull Create_func_isnull::s_singleton;
2073
2074
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2075
Create_func_isnull::create(Session *session, Item *arg1)
1 by brian
clean slate
2076
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2077
  return new (session->mem_root) Item_func_isnull(arg1);
1 by brian
clean slate
2078
}
2079
2080
2081
Create_func_last_day Create_func_last_day::s_singleton;
2082
2083
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2084
Create_func_last_day::create(Session *session, Item *arg1)
1 by brian
clean slate
2085
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2086
  return new (session->mem_root) Item_func_last_day(arg1);
1 by brian
clean slate
2087
}
2088
2089
2090
Create_func_last_insert_id Create_func_last_insert_id::s_singleton;
2091
2092
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2093
Create_func_last_insert_id::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
2094
                                          List<Item> *item_list)
2095
{
2096
  Item *func= NULL;
2097
  int arg_count= 0;
2098
2099
  if (item_list != NULL)
2100
    arg_count= item_list->elements;
2101
2102
  switch (arg_count) {
2103
  case 0:
2104
  {
520.1.22 by Brian Aker
Second pass of thd cleanup
2105
    func= new (session->mem_root) Item_func_last_insert_id();
1 by brian
clean slate
2106
    break;
2107
  }
2108
  case 1:
2109
  {
2110
    Item *param_1= item_list->pop();
520.1.22 by Brian Aker
Second pass of thd cleanup
2111
    func= new (session->mem_root) Item_func_last_insert_id(param_1);
1 by brian
clean slate
2112
    break;
2113
  }
2114
  default:
2115
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
2116
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
2117
    break;
2118
  }
2119
  }
2120
2121
  return func;
2122
}
2123
2124
2125
Create_func_lcase Create_func_lcase::s_singleton;
2126
2127
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2128
Create_func_lcase::create(Session *session, Item *arg1)
1 by brian
clean slate
2129
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2130
  return new (session->mem_root) Item_func_lcase(arg1);
1 by brian
clean slate
2131
}
2132
2133
2134
Create_func_least Create_func_least::s_singleton;
2135
2136
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2137
Create_func_least::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
2138
                                 List<Item> *item_list)
2139
{
2140
  int arg_count= 0;
2141
2142
  if (item_list != NULL)
2143
    arg_count= item_list->elements;
2144
2145
  if (arg_count < 2)
2146
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
2147
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
2148
    return NULL;
2149
  }
2150
520.1.22 by Brian Aker
Second pass of thd cleanup
2151
  return new (session->mem_root) Item_func_min(*item_list);
1 by brian
clean slate
2152
}
2153
2154
2155
Create_func_ln Create_func_ln::s_singleton;
2156
2157
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2158
Create_func_ln::create(Session *session, Item *arg1)
1 by brian
clean slate
2159
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2160
  return new (session->mem_root) Item_func_ln(arg1);
1 by brian
clean slate
2161
}
2162
2163
2164
Create_func_load_file Create_func_load_file::s_singleton;
2165
2166
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2167
Create_func_load_file::create(Session *session, Item *arg1)
1 by brian
clean slate
2168
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2169
  return new (session->mem_root) Item_load_file(arg1);
1 by brian
clean slate
2170
}
2171
2172
2173
Create_func_locate Create_func_locate::s_singleton;
2174
2175
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2176
Create_func_locate::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
2177
                                  List<Item> *item_list)
2178
{
2179
  Item *func= NULL;
2180
  int arg_count= 0;
2181
2182
  if (item_list != NULL)
2183
    arg_count= item_list->elements;
2184
2185
  switch (arg_count) {
2186
  case 2:
2187
  {
2188
    Item *param_1= item_list->pop();
2189
    Item *param_2= item_list->pop();
2190
    /* Yes, parameters in that order : 2, 1 */
520.1.22 by Brian Aker
Second pass of thd cleanup
2191
    func= new (session->mem_root) Item_func_locate(param_2, param_1);
1 by brian
clean slate
2192
    break;
2193
  }
2194
  case 3:
2195
  {
2196
    Item *param_1= item_list->pop();
2197
    Item *param_2= item_list->pop();
2198
    Item *param_3= item_list->pop();
2199
    /* Yes, parameters in that order : 2, 1, 3 */
520.1.22 by Brian Aker
Second pass of thd cleanup
2200
    func= new (session->mem_root) Item_func_locate(param_2, param_1, param_3);
1 by brian
clean slate
2201
    break;
2202
  }
2203
  default:
2204
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
2205
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
2206
    break;
2207
  }
2208
  }
2209
2210
  return func;
2211
}
2212
2213
2214
Create_func_log Create_func_log::s_singleton;
2215
2216
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2217
Create_func_log::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
2218
                               List<Item> *item_list)
2219
{
2220
  Item *func= NULL;
2221
  int arg_count= 0;
2222
2223
  if (item_list != NULL)
2224
    arg_count= item_list->elements;
2225
2226
  switch (arg_count) {
2227
  case 1:
2228
  {
2229
    Item *param_1= item_list->pop();
520.1.22 by Brian Aker
Second pass of thd cleanup
2230
    func= new (session->mem_root) Item_func_log(param_1);
1 by brian
clean slate
2231
    break;
2232
  }
2233
  case 2:
2234
  {
2235
    Item *param_1= item_list->pop();
2236
    Item *param_2= item_list->pop();
520.1.22 by Brian Aker
Second pass of thd cleanup
2237
    func= new (session->mem_root) Item_func_log(param_1, param_2);
1 by brian
clean slate
2238
    break;
2239
  }
2240
  default:
2241
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
2242
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
2243
    break;
2244
  }
2245
  }
2246
2247
  return func;
2248
}
2249
2250
2251
Create_func_log10 Create_func_log10::s_singleton;
2252
2253
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2254
Create_func_log10::create(Session *session, Item *arg1)
1 by brian
clean slate
2255
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2256
  return new (session->mem_root) Item_func_log10(arg1);
1 by brian
clean slate
2257
}
2258
2259
2260
Create_func_log2 Create_func_log2::s_singleton;
2261
2262
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2263
Create_func_log2::create(Session *session, Item *arg1)
1 by brian
clean slate
2264
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2265
  return new (session->mem_root) Item_func_log2(arg1);
1 by brian
clean slate
2266
}
2267
2268
2269
Create_func_lpad Create_func_lpad::s_singleton;
2270
2271
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2272
Create_func_lpad::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
1 by brian
clean slate
2273
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2274
  return new (session->mem_root) Item_func_lpad(arg1, arg2, arg3);
1 by brian
clean slate
2275
}
2276
2277
2278
Create_func_ltrim Create_func_ltrim::s_singleton;
2279
2280
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2281
Create_func_ltrim::create(Session *session, Item *arg1)
1 by brian
clean slate
2282
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2283
  return new (session->mem_root) Item_func_ltrim(arg1);
1 by brian
clean slate
2284
}
2285
2286
2287
Create_func_makedate Create_func_makedate::s_singleton;
2288
2289
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2290
Create_func_makedate::create(Session *session, Item *arg1, Item *arg2)
1 by brian
clean slate
2291
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2292
  return new (session->mem_root) Item_func_makedate(arg1, arg2);
1 by brian
clean slate
2293
}
2294
2295
2296
Create_func_make_set Create_func_make_set::s_singleton;
2297
2298
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2299
Create_func_make_set::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
2300
                                    List<Item> *item_list)
2301
{
2302
  int arg_count= 0;
2303
2304
  if (item_list != NULL)
2305
    arg_count= item_list->elements;
2306
2307
  if (arg_count < 2)
2308
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
2309
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
2310
    return NULL;
2311
  }
2312
2313
  Item *param_1= item_list->pop();
520.1.22 by Brian Aker
Second pass of thd cleanup
2314
  return new (session->mem_root) Item_func_make_set(param_1, *item_list);
1 by brian
clean slate
2315
}
2316
2317
2318
Create_func_monthname Create_func_monthname::s_singleton;
2319
2320
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2321
Create_func_monthname::create(Session *session, Item *arg1)
1 by brian
clean slate
2322
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2323
  return new (session->mem_root) Item_func_monthname(arg1);
1 by brian
clean slate
2324
}
2325
2326
2327
Create_func_nullif Create_func_nullif::s_singleton;
2328
2329
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2330
Create_func_nullif::create(Session *session, Item *arg1, Item *arg2)
1 by brian
clean slate
2331
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2332
  return new (session->mem_root) Item_func_nullif(arg1, arg2);
1 by brian
clean slate
2333
}
2334
2335
2336
Create_func_oct Create_func_oct::s_singleton;
2337
2338
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2339
Create_func_oct::create(Session *session, Item *arg1)
1 by brian
clean slate
2340
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2341
  Item *i10= new (session->mem_root) Item_int((int32_t) 10,2);
2342
  Item *i8= new (session->mem_root) Item_int((int32_t) 8,1);
2343
  return new (session->mem_root) Item_func_conv(arg1, i10, i8);
1 by brian
clean slate
2344
}
2345
2346
2347
Create_func_ord Create_func_ord::s_singleton;
2348
2349
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2350
Create_func_ord::create(Session *session, Item *arg1)
1 by brian
clean slate
2351
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2352
  return new (session->mem_root) Item_func_ord(arg1);
1 by brian
clean slate
2353
}
2354
2355
2356
Create_func_period_add Create_func_period_add::s_singleton;
2357
2358
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2359
Create_func_period_add::create(Session *session, Item *arg1, Item *arg2)
1 by brian
clean slate
2360
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2361
  return new (session->mem_root) Item_func_period_add(arg1, arg2);
1 by brian
clean slate
2362
}
2363
2364
2365
Create_func_period_diff Create_func_period_diff::s_singleton;
2366
2367
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2368
Create_func_period_diff::create(Session *session, Item *arg1, Item *arg2)
1 by brian
clean slate
2369
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2370
  return new (session->mem_root) Item_func_period_diff(arg1, arg2);
1 by brian
clean slate
2371
}
2372
2373
2374
Create_func_pi Create_func_pi::s_singleton;
2375
2376
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2377
Create_func_pi::create(Session *session)
1 by brian
clean slate
2378
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2379
  return new (session->mem_root) Item_static_float_func("pi()", M_PI, 6, 8);
1 by brian
clean slate
2380
}
2381
2382
2383
Create_func_pow Create_func_pow::s_singleton;
2384
2385
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2386
Create_func_pow::create(Session *session, Item *arg1, Item *arg2)
1 by brian
clean slate
2387
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2388
  return new (session->mem_root) Item_func_pow(arg1, arg2);
1 by brian
clean slate
2389
}
2390
2391
2392
Create_func_quote Create_func_quote::s_singleton;
2393
2394
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2395
Create_func_quote::create(Session *session, Item *arg1)
1 by brian
clean slate
2396
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2397
  return new (session->mem_root) Item_func_quote(arg1);
1 by brian
clean slate
2398
}
2399
2400
2401
Create_func_radians Create_func_radians::s_singleton;
2402
2403
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2404
Create_func_radians::create(Session *session, Item *arg1)
1 by brian
clean slate
2405
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2406
  return new (session->mem_root) Item_func_units((char*) "radians", arg1,
1 by brian
clean slate
2407
                                             M_PI/180, 0.0);
2408
}
2409
2410
2411
Create_func_rand Create_func_rand::s_singleton;
2412
2413
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2414
Create_func_rand::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
2415
                                List<Item> *item_list)
2416
{
2417
  Item *func= NULL;
2418
  int arg_count= 0;
2419
2420
  if (item_list != NULL)
2421
    arg_count= item_list->elements;
2422
2423
  switch (arg_count) {
2424
  case 0:
2425
  {
520.1.22 by Brian Aker
Second pass of thd cleanup
2426
    func= new (session->mem_root) Item_func_rand();
1 by brian
clean slate
2427
    break;
2428
  }
2429
  case 1:
2430
  {
2431
    Item *param_1= item_list->pop();
520.1.22 by Brian Aker
Second pass of thd cleanup
2432
    func= new (session->mem_root) Item_func_rand(param_1);
1 by brian
clean slate
2433
    break;
2434
  }
2435
  default:
2436
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
2437
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
2438
    break;
2439
  }
2440
  }
2441
2442
  return func;
2443
}
2444
2445
2446
Create_func_round Create_func_round::s_singleton;
2447
2448
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2449
Create_func_round::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
2450
                                 List<Item> *item_list)
2451
{
2452
  Item *func= NULL;
2453
  int arg_count= 0;
2454
2455
  if (item_list != NULL)
2456
    arg_count= item_list->elements;
2457
2458
  switch (arg_count) {
2459
  case 1:
2460
  {
2461
    Item *param_1= item_list->pop();
520.1.22 by Brian Aker
Second pass of thd cleanup
2462
    Item *i0 = new (session->mem_root) Item_int((char*)"0", 0, 1);
2463
    func= new (session->mem_root) Item_func_round(param_1, i0, 0);
1 by brian
clean slate
2464
    break;
2465
  }
2466
  case 2:
2467
  {
2468
    Item *param_1= item_list->pop();
2469
    Item *param_2= item_list->pop();
520.1.22 by Brian Aker
Second pass of thd cleanup
2470
    func= new (session->mem_root) Item_func_round(param_1, param_2, 0);
1 by brian
clean slate
2471
    break;
2472
  }
2473
  default:
2474
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
2475
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
2476
    break;
2477
  }
2478
  }
2479
2480
  return func;
2481
}
2482
2483
2484
Create_func_row_count Create_func_row_count::s_singleton;
2485
2486
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2487
Create_func_row_count::create(Session *session)
1 by brian
clean slate
2488
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2489
  return new (session->mem_root) Item_func_row_count();
1 by brian
clean slate
2490
}
2491
2492
2493
Create_func_rpad Create_func_rpad::s_singleton;
2494
2495
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2496
Create_func_rpad::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
1 by brian
clean slate
2497
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2498
  return new (session->mem_root) Item_func_rpad(arg1, arg2, arg3);
1 by brian
clean slate
2499
}
2500
2501
2502
Create_func_rtrim Create_func_rtrim::s_singleton;
2503
2504
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2505
Create_func_rtrim::create(Session *session, Item *arg1)
1 by brian
clean slate
2506
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2507
  return new (session->mem_root) Item_func_rtrim(arg1);
1 by brian
clean slate
2508
}
2509
2510
2511
Create_func_sign Create_func_sign::s_singleton;
2512
2513
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2514
Create_func_sign::create(Session *session, Item *arg1)
1 by brian
clean slate
2515
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2516
  return new (session->mem_root) Item_func_sign(arg1);
1 by brian
clean slate
2517
}
2518
2519
2520
Create_func_sin Create_func_sin::s_singleton;
2521
2522
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2523
Create_func_sin::create(Session *session, Item *arg1)
1 by brian
clean slate
2524
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2525
  return new (session->mem_root) Item_func_sin(arg1);
1 by brian
clean slate
2526
}
2527
2528
2529
Create_func_space Create_func_space::s_singleton;
2530
2531
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2532
Create_func_space::create(Session *session, Item *arg1)
1 by brian
clean slate
2533
{
2534
  /**
2535
    TODO: Fix Bug#23637
2536
    The parsed item tree should not depend on
520.1.22 by Brian Aker
Second pass of thd cleanup
2537
    <code>session->variables.collation_connection</code>.
1 by brian
clean slate
2538
  */
748 by Brian Aker
Removal of client side collation.
2539
  const CHARSET_INFO * const cs= session->variables.getCollation();
1 by brian
clean slate
2540
  Item *sp;
2541
2542
  if (cs->mbminlen > 1)
2543
  {
482 by Brian Aker
Remove uint.
2544
    uint32_t dummy_errors;
1022.1.3 by Brian Aker
Force UTF8 (remove the bits for looking for ascii).
2545
    sp= new (session->mem_root) Item_string("", 0, cs, DERIVATION_COERCIBLE);
383.1.12 by Brian Aker
Much closer toward UTF8 being around all the time...
2546
    sp->str_value.copy(" ", 1, &my_charset_utf8_general_ci, cs, &dummy_errors);
1 by brian
clean slate
2547
  }
2548
  else
2549
  {
1022.1.3 by Brian Aker
Force UTF8 (remove the bits for looking for ascii).
2550
    sp= new (session->mem_root) Item_string(" ", 1, cs, DERIVATION_COERCIBLE);
1 by brian
clean slate
2551
  }
2552
520.1.22 by Brian Aker
Second pass of thd cleanup
2553
  return new (session->mem_root) Item_func_repeat(sp, arg1);
1 by brian
clean slate
2554
}
2555
2556
2557
Create_func_sqrt Create_func_sqrt::s_singleton;
2558
2559
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2560
Create_func_sqrt::create(Session *session, Item *arg1)
1 by brian
clean slate
2561
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2562
  return new (session->mem_root) Item_func_sqrt(arg1);
1 by brian
clean slate
2563
}
2564
2565
2566
Create_func_strcmp Create_func_strcmp::s_singleton;
2567
2568
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2569
Create_func_strcmp::create(Session *session, Item *arg1, Item *arg2)
1 by brian
clean slate
2570
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2571
  return new (session->mem_root) Item_func_strcmp(arg1, arg2);
1 by brian
clean slate
2572
}
2573
2574
2575
Create_func_substr_index Create_func_substr_index::s_singleton;
2576
2577
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2578
Create_func_substr_index::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
1 by brian
clean slate
2579
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2580
  return new (session->mem_root) Item_func_substr_index(arg1, arg2, arg3);
1 by brian
clean slate
2581
}
2582
2583
Create_func_tan Create_func_tan::s_singleton;
2584
2585
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2586
Create_func_tan::create(Session *session, Item *arg1)
1 by brian
clean slate
2587
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2588
  return new (session->mem_root) Item_func_tan(arg1);
1 by brian
clean slate
2589
}
2590
2591
2592
Create_func_time_format Create_func_time_format::s_singleton;
2593
2594
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2595
Create_func_time_format::create(Session *session, Item *arg1, Item *arg2)
1 by brian
clean slate
2596
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2597
  return new (session->mem_root) Item_func_date_format(arg1, arg2, 1);
1 by brian
clean slate
2598
}
2599
2600
Create_func_to_days Create_func_to_days::s_singleton;
2601
2602
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2603
Create_func_to_days::create(Session *session, Item *arg1)
1 by brian
clean slate
2604
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2605
  return new (session->mem_root) Item_func_to_days(arg1);
1 by brian
clean slate
2606
}
2607
2608
2609
Create_func_ucase Create_func_ucase::s_singleton;
2610
2611
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2612
Create_func_ucase::create(Session *session, Item *arg1)
1 by brian
clean slate
2613
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2614
  return new (session->mem_root) Item_func_ucase(arg1);
1 by brian
clean slate
2615
}
2616
2617
2618
Create_func_unhex Create_func_unhex::s_singleton;
2619
2620
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2621
Create_func_unhex::create(Session *session, Item *arg1)
1 by brian
clean slate
2622
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2623
  return new (session->mem_root) Item_func_unhex(arg1);
1 by brian
clean slate
2624
}
2625
2626
2627
Create_func_unix_timestamp Create_func_unix_timestamp::s_singleton;
2628
2629
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2630
Create_func_unix_timestamp::create_native(Session *session, LEX_STRING name,
1 by brian
clean slate
2631
                                          List<Item> *item_list)
2632
{
2633
  Item *func= NULL;
2634
  int arg_count= 0;
2635
2636
  if (item_list != NULL)
2637
    arg_count= item_list->elements;
2638
2639
  switch (arg_count) {
2640
  case 0:
2641
  {
520.1.22 by Brian Aker
Second pass of thd cleanup
2642
    func= new (session->mem_root) Item_func_unix_timestamp();
1 by brian
clean slate
2643
    break;
2644
  }
2645
  case 1:
2646
  {
2647
    Item *param_1= item_list->pop();
520.1.22 by Brian Aker
Second pass of thd cleanup
2648
    func= new (session->mem_root) Item_func_unix_timestamp(param_1);
1 by brian
clean slate
2649
    break;
2650
  }
2651
  default:
2652
  {
1124.3.2 by Diego Medina
Renamed ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT to ER_WRONG_PARAMCOUNT_TO_FUNCTION
2653
    my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1 by brian
clean slate
2654
    break;
2655
  }
2656
  }
2657
2658
  return func;
2659
}
2660
2661
2662
Create_func_uuid Create_func_uuid::s_singleton;
2663
2664
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2665
Create_func_uuid::create(Session *session)
1 by brian
clean slate
2666
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2667
  return new (session->mem_root) Item_func_uuid();
1 by brian
clean slate
2668
}
2669
2670
2671
Create_func_weekday Create_func_weekday::s_singleton;
2672
2673
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2674
Create_func_weekday::create(Session *session, Item *arg1)
1 by brian
clean slate
2675
{
520.1.22 by Brian Aker
Second pass of thd cleanup
2676
  return new (session->mem_root) Item_func_weekday(arg1, 0);
1 by brian
clean slate
2677
}
2678
2679
struct Native_func_registry
2680
{
2681
  LEX_STRING name;
2682
  Create_func *builder;
2683
};
2684
2685
#define BUILDER(F) & F::s_singleton
2686
2687
/*
2688
  MySQL native functions.
2689
  MAINTAINER:
2690
  - Keep sorted for human lookup. At runtime, a hash table is used.
2691
  - keep 1 line per entry, it makes grep | sort easier
2692
*/
2693
2694
static Native_func_registry func_array[] =
2695
{
2696
  { { C_STRING_WITH_LEN("ABS") }, BUILDER(Create_func_abs)},
2697
  { { C_STRING_WITH_LEN("ACOS") }, BUILDER(Create_func_acos)},
2698
  { { C_STRING_WITH_LEN("ASIN") }, BUILDER(Create_func_asin)},
2699
  { { C_STRING_WITH_LEN("ATAN") }, BUILDER(Create_func_atan)},
2700
  { { C_STRING_WITH_LEN("ATAN2") }, BUILDER(Create_func_atan)},
2701
  { { C_STRING_WITH_LEN("BIN") }, BUILDER(Create_func_bin)},
2702
  { { C_STRING_WITH_LEN("CEIL") }, BUILDER(Create_func_ceiling)},
2703
  { { C_STRING_WITH_LEN("CEILING") }, BUILDER(Create_func_ceiling)},
2704
  { { C_STRING_WITH_LEN("COERCIBILITY") }, BUILDER(Create_func_coercibility)},
2705
  { { C_STRING_WITH_LEN("CONCAT") }, BUILDER(Create_func_concat)},
2706
  { { C_STRING_WITH_LEN("CONCAT_WS") }, BUILDER(Create_func_concat_ws)},
2707
  { { C_STRING_WITH_LEN("CONV") }, BUILDER(Create_func_conv)},
2708
  { { C_STRING_WITH_LEN("COS") }, BUILDER(Create_func_cos)},
2709
  { { C_STRING_WITH_LEN("COT") }, BUILDER(Create_func_cot)},
2710
  { { C_STRING_WITH_LEN("DATEDIFF") }, BUILDER(Create_func_datediff)},
2711
  { { C_STRING_WITH_LEN("DATE_FORMAT") }, BUILDER(Create_func_date_format)},
2712
  { { C_STRING_WITH_LEN("DAYNAME") }, BUILDER(Create_func_dayname)},
2713
  { { C_STRING_WITH_LEN("DAYOFMONTH") }, BUILDER(Create_func_dayofmonth)},
2714
  { { C_STRING_WITH_LEN("DAYOFWEEK") }, BUILDER(Create_func_dayofweek)},
2715
  { { C_STRING_WITH_LEN("DAYOFYEAR") }, BUILDER(Create_func_dayofyear)},
2716
  { { C_STRING_WITH_LEN("DEGREES") }, BUILDER(Create_func_degrees)},
2717
  { { C_STRING_WITH_LEN("ELT") }, BUILDER(Create_func_elt)},
2718
  { { C_STRING_WITH_LEN("EXP") }, BUILDER(Create_func_exp)},
2719
  { { C_STRING_WITH_LEN("EXPORT_SET") }, BUILDER(Create_func_export_set)},
2720
  { { C_STRING_WITH_LEN("FIELD") }, BUILDER(Create_func_field)},
2721
  { { C_STRING_WITH_LEN("FIND_IN_SET") }, BUILDER(Create_func_find_in_set)},
2722
  { { C_STRING_WITH_LEN("FLOOR") }, BUILDER(Create_func_floor)},
2723
  { { C_STRING_WITH_LEN("FORMAT") }, BUILDER(Create_func_format)},
2724
  { { C_STRING_WITH_LEN("FOUND_ROWS") }, BUILDER(Create_func_found_rows)},
2725
  { { C_STRING_WITH_LEN("FROM_DAYS") }, BUILDER(Create_func_from_days)},
2726
  { { C_STRING_WITH_LEN("FROM_UNIXTIME") }, BUILDER(Create_func_from_unixtime)},
2727
  { { C_STRING_WITH_LEN("GREATEST") }, BUILDER(Create_func_greatest)},
2728
  { { C_STRING_WITH_LEN("HEX") }, BUILDER(Create_func_hex)},
2729
  { { C_STRING_WITH_LEN("IFNULL") }, BUILDER(Create_func_ifnull)},
2730
  { { C_STRING_WITH_LEN("INSTR") }, BUILDER(Create_func_instr)},
2731
  { { C_STRING_WITH_LEN("ISNULL") }, BUILDER(Create_func_isnull)},
2732
  { { C_STRING_WITH_LEN("LAST_DAY") }, BUILDER(Create_func_last_day)},
2733
  { { C_STRING_WITH_LEN("LAST_INSERT_ID") }, BUILDER(Create_func_last_insert_id)},
2734
  { { C_STRING_WITH_LEN("LCASE") }, BUILDER(Create_func_lcase)},
2735
  { { C_STRING_WITH_LEN("LEAST") }, BUILDER(Create_func_least)},
2736
  { { C_STRING_WITH_LEN("LN") }, BUILDER(Create_func_ln)},
2737
  { { C_STRING_WITH_LEN("LOAD_FILE") }, BUILDER(Create_func_load_file)},
2738
  { { C_STRING_WITH_LEN("LOCATE") }, BUILDER(Create_func_locate)},
2739
  { { C_STRING_WITH_LEN("LOG") }, BUILDER(Create_func_log)},
2740
  { { C_STRING_WITH_LEN("LOG10") }, BUILDER(Create_func_log10)},
2741
  { { C_STRING_WITH_LEN("LOG2") }, BUILDER(Create_func_log2)},
2742
  { { C_STRING_WITH_LEN("LOWER") }, BUILDER(Create_func_lcase)},
2743
  { { C_STRING_WITH_LEN("LPAD") }, BUILDER(Create_func_lpad)},
2744
  { { C_STRING_WITH_LEN("LTRIM") }, BUILDER(Create_func_ltrim)},
2745
  { { C_STRING_WITH_LEN("MAKEDATE") }, BUILDER(Create_func_makedate)},
2746
  { { C_STRING_WITH_LEN("MAKE_SET") }, BUILDER(Create_func_make_set)},
2747
  { { C_STRING_WITH_LEN("MONTHNAME") }, BUILDER(Create_func_monthname)},
2748
  { { C_STRING_WITH_LEN("NULLIF") }, BUILDER(Create_func_nullif)},
2749
  { { C_STRING_WITH_LEN("OCT") }, BUILDER(Create_func_oct)},
2750
  { { C_STRING_WITH_LEN("ORD") }, BUILDER(Create_func_ord)},
2751
  { { C_STRING_WITH_LEN("PERIOD_ADD") }, BUILDER(Create_func_period_add)},
2752
  { { C_STRING_WITH_LEN("PERIOD_DIFF") }, BUILDER(Create_func_period_diff)},
2753
  { { C_STRING_WITH_LEN("PI") }, BUILDER(Create_func_pi)},
2754
  { { C_STRING_WITH_LEN("POW") }, BUILDER(Create_func_pow)},
2755
  { { C_STRING_WITH_LEN("POWER") }, BUILDER(Create_func_pow)},
2756
  { { C_STRING_WITH_LEN("QUOTE") }, BUILDER(Create_func_quote)},
2757
  { { C_STRING_WITH_LEN("RADIANS") }, BUILDER(Create_func_radians)},
2758
  { { C_STRING_WITH_LEN("RAND") }, BUILDER(Create_func_rand)},
2759
  { { C_STRING_WITH_LEN("ROUND") }, BUILDER(Create_func_round)},
2760
  { { C_STRING_WITH_LEN("ROW_COUNT") }, BUILDER(Create_func_row_count)},
2761
  { { C_STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad)},
2762
  { { C_STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim)},
2763
  { { C_STRING_WITH_LEN("SIGN") }, BUILDER(Create_func_sign)},
2764
  { { C_STRING_WITH_LEN("SIN") }, BUILDER(Create_func_sin)},
2765
  { { C_STRING_WITH_LEN("SPACE") }, BUILDER(Create_func_space)},
2766
  { { C_STRING_WITH_LEN("SQRT") }, BUILDER(Create_func_sqrt)},
2767
  { { C_STRING_WITH_LEN("STRCMP") }, BUILDER(Create_func_strcmp)},
2768
  { { C_STRING_WITH_LEN("SUBSTRING_INDEX") }, BUILDER(Create_func_substr_index)},
2769
  { { C_STRING_WITH_LEN("TAN") }, BUILDER(Create_func_tan)},
2770
  { { C_STRING_WITH_LEN("TIME_FORMAT") }, BUILDER(Create_func_time_format)},
2771
  { { C_STRING_WITH_LEN("TO_DAYS") }, BUILDER(Create_func_to_days)},
2772
  { { C_STRING_WITH_LEN("UCASE") }, BUILDER(Create_func_ucase)},
2773
  { { C_STRING_WITH_LEN("UNHEX") }, BUILDER(Create_func_unhex)},
2774
  { { C_STRING_WITH_LEN("UNIX_TIMESTAMP") }, BUILDER(Create_func_unix_timestamp)},
2775
  { { C_STRING_WITH_LEN("UPPER") }, BUILDER(Create_func_ucase)},
2776
  { { C_STRING_WITH_LEN("UUID") }, BUILDER(Create_func_uuid)},
2777
  { { C_STRING_WITH_LEN("WEEKDAY") }, BUILDER(Create_func_weekday)},
2778
2779
  { {0, 0}, NULL}
2780
};
2781
873.2.19 by Monty Taylor
Removed another HASH and another set of useless utf8 hashing.
2782
static map<string, Native_func_registry *> native_functions_map;
1 by brian
clean slate
2783
2784
/*
2785
  Load the hash table for native functions.
2786
  Note: this code is not thread safe, and is intended to be used at server
2787
  startup only (before going multi-threaded)
2788
*/
2789
2790
int item_create_init()
2791
{
873.2.19 by Monty Taylor
Removed another HASH and another set of useless utf8 hashing.
2792
  string func_name;
2793
1 by brian
clean slate
2794
  Native_func_registry *func;
2795
  for (func= func_array; func->builder != NULL; func++)
2796
  {
873.2.19 by Monty Taylor
Removed another HASH and another set of useless utf8 hashing.
2797
    func_name.assign(func->name.str, func->name.length);
2798
    transform(func_name.begin(), func_name.end(), func_name.begin(), ::tolower);
2799
2800
    native_functions_map[func_name]= func;
51.1.19 by Jay Pipes
Removed/replace DBUG symbols
2801
  }
2802
873.2.19 by Monty Taylor
Removed another HASH and another set of useless utf8 hashing.
2803
  return 0;
2804
}
2805
1 by brian
clean slate
2806
2807
Create_func *
873.2.19 by Monty Taylor
Removed another HASH and another set of useless utf8 hashing.
2808
find_native_function_builder(LEX_STRING name)
1 by brian
clean slate
2809
{
2810
  Native_func_registry *func;
2811
  Create_func *builder= NULL;
2812
873.2.19 by Monty Taylor
Removed another HASH and another set of useless utf8 hashing.
2813
  string func_name(name.str, name.length);
2814
  transform(func_name.begin(), func_name.end(), func_name.begin(), ::tolower);
2815
2816
  map<string, Native_func_registry *>::iterator func_iter=
2817
    native_functions_map.find(func_name);
2818
2819
  if (func_iter != native_functions_map.end())
1 by brian
clean slate
2820
  {
873.2.19 by Monty Taylor
Removed another HASH and another set of useless utf8 hashing.
2821
    func= (*func_iter).second;
1 by brian
clean slate
2822
    builder= func->builder;
2823
  }
2824
2825
  return builder;
2826
}
2827
2828
2829
Item*
520.1.22 by Brian Aker
Second pass of thd cleanup
2830
create_func_char_cast(Session *session, Item *a, int len, const CHARSET_INFO * const cs)
1 by brian
clean slate
2831
{
748 by Brian Aker
Removal of client side collation.
2832
  const CHARSET_INFO * const real_cs= (cs ? cs : session->variables.getCollation());
520.1.22 by Brian Aker
Second pass of thd cleanup
2833
  return new (session->mem_root) Item_char_typecast(a, len, real_cs);
1 by brian
clean slate
2834
}
2835
2836
2837
Item *
520.1.22 by Brian Aker
Second pass of thd cleanup
2838
create_func_cast(Session *session, Item *a, Cast_target cast_type,
1 by brian
clean slate
2839
                 const char *c_len, const char *c_dec,
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
2840
                 const CHARSET_INFO * const cs)
1 by brian
clean slate
2841
{
2842
  Item *res;
290 by Brian Aker
Update for ulong change over.
2843
  uint32_t len;
482 by Brian Aker
Remove uint.
2844
  uint32_t dec;
1 by brian
clean slate
2845
2846
  switch (cast_type) {
2847
  case ITEM_CAST_BINARY:
520.1.22 by Brian Aker
Second pass of thd cleanup
2848
    res= new (session->mem_root) Item_func_binary(a);
1 by brian
clean slate
2849
    break;
2850
  case ITEM_CAST_DATE:
520.1.22 by Brian Aker
Second pass of thd cleanup
2851
    res= new (session->mem_root) Item_date_typecast(a);
1 by brian
clean slate
2852
    break;
2853
  case ITEM_CAST_DATETIME:
520.1.22 by Brian Aker
Second pass of thd cleanup
2854
    res= new (session->mem_root) Item_datetime_typecast(a);
1 by brian
clean slate
2855
    break;
2856
  case ITEM_CAST_DECIMAL:
2857
  {
2858
    len= c_len ? atoi(c_len) : 0;
2859
    dec= c_dec ? atoi(c_dec) : 0;
2860
    my_decimal_trim(&len, &dec);
2861
    if (len < dec)
2862
    {
2863
      my_error(ER_M_BIGGER_THAN_D, MYF(0), "");
2864
      return 0;
2865
    }
2866
    if (len > DECIMAL_MAX_PRECISION)
2867
    {
2868
      my_error(ER_TOO_BIG_PRECISION, MYF(0), len, a->name,
2869
               DECIMAL_MAX_PRECISION);
2870
      return 0;
2871
    }
2872
    if (dec > DECIMAL_MAX_SCALE)
2873
    {
2874
      my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->name,
2875
               DECIMAL_MAX_SCALE);
2876
      return 0;
2877
    }
520.1.22 by Brian Aker
Second pass of thd cleanup
2878
    res= new (session->mem_root) Item_decimal_typecast(a, len, dec);
1 by brian
clean slate
2879
    break;
2880
  }
2881
  case ITEM_CAST_CHAR:
2882
  {
2883
    len= c_len ? atoi(c_len) : -1;
520.1.22 by Brian Aker
Second pass of thd cleanup
2884
    res= create_func_char_cast(session, a, len, cs);
1 by brian
clean slate
2885
    break;
2886
  }
2887
  default:
2888
  {
51.1.19 by Jay Pipes
Removed/replace DBUG symbols
2889
    assert(0);
1 by brian
clean slate
2890
    res= 0;
2891
    break;
2892
  }
2893
  }
2894
  return res;
2895
}
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
2896
2897
} /* namespace drizzled */