~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/create.cc

  • Committer: Brian Aker
  • Date: 2009-03-25 22:52:34 UTC
  • mfrom: (934.2.28 small-cleanups)
  • Revision ID: brian@tangent.org-20090325225234-2ewmv7ma3kh858jk
Merge with Jay

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
*/
22
22
 
23
23
#include <drizzled/server_includes.h>
 
24
#include <drizzled/item/create.h>
 
25
#include <drizzled/item/func.h>
 
26
#include <drizzled/error.h>
 
27
#include <drizzled/data_home.h>
 
28
 
 
29
#include <drizzled/function/str/binary.h>
 
30
#include <drizzled/function/str/concat.h>
 
31
#include <drizzled/function/str/conv.h>
 
32
#include <drizzled/function/str/elt.h>
 
33
#include <drizzled/function/str/export_set.h>
 
34
#include <drizzled/function/str/format.h>
 
35
#include <drizzled/function/str/hex.h>
 
36
#include <drizzled/function/str/load_file.h>
 
37
#include <drizzled/function/str/make_set.h>
 
38
#include <drizzled/function/str/pad.h>
 
39
#include <drizzled/function/str/repeat.h>
 
40
#include <drizzled/function/str/str_conv.h>
 
41
#include <drizzled/function/str/substr.h>
 
42
#include <drizzled/function/str/trim.h>
 
43
#include <drizzled/function/str/uuid.h>
 
44
 
 
45
#include <drizzled/function/time/date_format.h>
 
46
#include <drizzled/function/time/dayname.h>
 
47
#include <drizzled/function/time/dayofmonth.h>
 
48
#include <drizzled/function/time/dayofyear.h>
 
49
#include <drizzled/function/time/from_unixtime.h>
 
50
#include <drizzled/function/time/from_days.h>
 
51
#include <drizzled/function/time/last_day.h>
 
52
#include <drizzled/function/time/makedate.h>
 
53
#include <drizzled/function/time/month.h>
 
54
#include <drizzled/function/time/period_add.h>
 
55
#include <drizzled/function/time/period_diff.h>
 
56
#include <drizzled/function/time/to_days.h>
 
57
#include <drizzled/function/time/typecast.h>
 
58
#include <drizzled/function/time/unix_timestamp.h>
 
59
#include <drizzled/function/time/weekday.h>
 
60
 
 
61
#include <drizzled/item/cmpfunc.h>
 
62
#include <drizzled/sql_udf.h>
 
63
#include <drizzled/session.h>
 
64
 
 
65
/* Function declarations */
 
66
 
 
67
#include <drizzled/function/func.h>
 
68
#include <drizzled/function/math/abs.h>
 
69
#include <drizzled/function/math/acos.h>
 
70
#include <drizzled/function/additive_op.h>
 
71
#include <drizzled/function/math/asin.h>
 
72
#include <drizzled/function/math/atan.h>
 
73
#include <drizzled/function/benchmark.h>
 
74
#include <drizzled/function/bit.h>
 
75
#include <drizzled/function/bit_count.h>
 
76
#include <drizzled/function/bit_length.h>
 
77
#include <drizzled/function/math/ceiling.h>
 
78
#include <drizzled/function/char_length.h>
 
79
#include <drizzled/function/coercibility.h>
 
80
#include <drizzled/function/connection_id.h>
 
81
#include <drizzled/function/math/cos.h>
 
82
#include <drizzled/function/math/dec.h>
 
83
#include <drizzled/function/math/decimal_typecast.h>
 
84
#include <drizzled/function/math//exp.h>
 
85
#include <drizzled/function/field.h>
 
86
#include <drizzled/function/find_in_set.h>
 
87
#include <drizzled/function/math/floor.h>
 
88
#include <drizzled/function/found_rows.h>
 
89
#include <drizzled/function/get_system_var.h>
 
90
#include <drizzled/function/get_variable.h>
 
91
#include <drizzled/function/math/int_val.h>
 
92
#include <drizzled/function/math/integer.h>
 
93
#include <drizzled/function/last_insert.h>
 
94
#include <drizzled/function/length.h>
 
95
#include <drizzled/function/math/ln.h>
 
96
#include <drizzled/function/locate.h>
 
97
#include <drizzled/function/math/log.h>
 
98
#include <drizzled/function/min_max.h>
 
99
#include <drizzled/function/num1.h>
 
100
#include <drizzled/function/num_op.h>
 
101
#include <drizzled/function/numhybrid.h>
 
102
#include <drizzled/function/math/ord.h>
 
103
#include <drizzled/function/math/pow.h>
 
104
#include <drizzled/function/math/rand.h>
 
105
#include <drizzled/function/math/real.h>
 
106
#include <drizzled/function/row_count.h>
 
107
#include <drizzled/function/set_user_var.h>
 
108
#include <drizzled/function/sign.h>
 
109
#include <drizzled/function/signed.h>
 
110
#include <drizzled/function/math/sin.h>
 
111
#include <drizzled/function/math/sqrt.h>
 
112
#include <drizzled/function/str/quote.h>
 
113
#include <drizzled/function/math/tan.h>
 
114
#include <drizzled/function/units.h>
 
115
#include <drizzled/function/unsigned.h>
 
116
#include <drizzled/function/update_hash.h>
 
117
 
 
118
#include <map>
 
119
 
 
120
using namespace std;
 
121
 
 
122
class Item;
 
123
 
24
124
 
25
125
/*
26
126
=============================================================================
39
139
class Create_native_func : public Create_func
40
140
{
41
141
public:
42
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
 
142
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
43
143
 
44
144
  /**
45
145
    Builder method, with no arguments.
46
 
    @param thd The current thread
 
146
    @param session The current thread
47
147
    @param name The native function name
48
148
    @param item_list The function parameters, none of which are named
49
149
    @return An item representing the function call
50
150
  */
51
 
  virtual Item *create_native(THD *thd, LEX_STRING name,
 
151
  virtual Item *create_native(Session *session, LEX_STRING name,
52
152
                              List<Item> *item_list) = 0;
53
153
 
54
154
protected:
66
166
class Create_func_arg0 : public Create_func
67
167
{
68
168
public:
69
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
 
169
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
70
170
 
71
171
  /**
72
172
    Builder method, with no arguments.
73
 
    @param thd The current thread
 
173
    @param session The current thread
74
174
    @return An item representing the function call
75
175
  */
76
 
  virtual Item *create(THD *thd) = 0;
 
176
  virtual Item *create(Session *session) = 0;
77
177
 
78
178
protected:
79
179
  /** Constructor. */
90
190
class Create_func_arg1 : public Create_func
91
191
{
92
192
public:
93
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
 
193
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
94
194
 
95
195
  /**
96
196
    Builder method, with one argument.
97
 
    @param thd The current thread
 
197
    @param session The current thread
98
198
    @param arg1 The first argument of the function
99
199
    @return An item representing the function call
100
200
  */
101
 
  virtual Item *create(THD *thd, Item *arg1) = 0;
 
201
  virtual Item *create(Session *session, Item *arg1) = 0;
102
202
 
103
203
protected:
104
204
  /** Constructor. */
115
215
class Create_func_arg2 : public Create_func
116
216
{
117
217
public:
118
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
 
218
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
119
219
 
120
220
  /**
121
221
    Builder method, with two arguments.
122
 
    @param thd The current thread
 
222
    @param session The current thread
123
223
    @param arg1 The first argument of the function
124
224
    @param arg2 The second argument of the function
125
225
    @return An item representing the function call
126
226
  */
127
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2) = 0;
 
227
  virtual Item *create(Session *session, Item *arg1, Item *arg2) = 0;
128
228
 
129
229
protected:
130
230
  /** Constructor. */
141
241
class Create_func_arg3 : public Create_func
142
242
{
143
243
public:
144
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
 
244
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
145
245
 
146
246
  /**
147
247
    Builder method, with three arguments.
148
 
    @param thd The current thread
 
248
    @param session The current thread
149
249
    @param arg1 The first argument of the function
150
250
    @param arg2 The second argument of the function
151
251
    @param arg3 The third argument of the function
152
252
    @return An item representing the function call
153
253
  */
154
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3) = 0;
 
254
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3) = 0;
155
255
 
156
256
protected:
157
257
  /** Constructor. */
174
274
class Create_func_abs : public Create_func_arg1
175
275
{
176
276
public:
177
 
  virtual Item *create(THD *thd, Item *arg1);
 
277
  using Create_func_arg1::create;
 
278
 
 
279
  virtual Item *create(Session *session, Item *arg1);
178
280
 
179
281
  static Create_func_abs s_singleton;
180
282
 
187
289
class Create_func_acos : public Create_func_arg1
188
290
{
189
291
public:
190
 
  virtual Item *create(THD *thd, Item *arg1);
 
292
  using Create_func_arg1::create;
 
293
 
 
294
  virtual Item *create(Session *session, Item *arg1);
191
295
 
192
296
  static Create_func_acos s_singleton;
193
297
 
196
300
  virtual ~Create_func_acos() {}
197
301
};
198
302
 
199
 
 
200
 
class Create_func_addtime : public Create_func_arg2
201
 
{
202
 
public:
203
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
204
 
 
205
 
  static Create_func_addtime s_singleton;
206
 
 
207
 
protected:
208
 
  Create_func_addtime() {}
209
 
  virtual ~Create_func_addtime() {}
210
 
};
211
 
 
212
 
 
213
303
class Create_func_asin : public Create_func_arg1
214
304
{
215
305
public:
216
 
  virtual Item *create(THD *thd, Item *arg1);
 
306
  using Create_func_arg1::create;
 
307
 
 
308
  virtual Item *create(Session *session, Item *arg1);
217
309
 
218
310
  static Create_func_asin s_singleton;
219
311
 
226
318
class Create_func_atan : public Create_native_func
227
319
{
228
320
public:
229
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
321
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
230
322
 
231
323
  static Create_func_atan s_singleton;
232
324
 
239
331
class Create_func_benchmark : public Create_func_arg2
240
332
{
241
333
public:
242
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
334
  using Create_func_arg2::create;
 
335
 
 
336
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
243
337
 
244
338
  static Create_func_benchmark s_singleton;
245
339
 
252
346
class Create_func_bin : public Create_func_arg1
253
347
{
254
348
public:
255
 
  virtual Item *create(THD *thd, Item *arg1);
 
349
  using Create_func_arg1::create;
 
350
 
 
351
  virtual Item *create(Session *session, Item *arg1);
256
352
 
257
353
  static Create_func_bin s_singleton;
258
354
 
265
361
class Create_func_bit_count : public Create_func_arg1
266
362
{
267
363
public:
268
 
  virtual Item *create(THD *thd, Item *arg1);
 
364
  using Create_func_arg1::create;
 
365
 
 
366
  virtual Item *create(Session *session, Item *arg1);
269
367
 
270
368
  static Create_func_bit_count s_singleton;
271
369
 
278
376
class Create_func_bit_length : public Create_func_arg1
279
377
{
280
378
public:
281
 
  virtual Item *create(THD *thd, Item *arg1);
 
379
  using Create_func_arg1::create;
 
380
 
 
381
  virtual Item *create(Session *session, Item *arg1);
282
382
 
283
383
  static Create_func_bit_length s_singleton;
284
384
 
291
391
class Create_func_ceiling : public Create_func_arg1
292
392
{
293
393
public:
294
 
  virtual Item *create(THD *thd, Item *arg1);
 
394
  using Create_func_arg1::create;
 
395
 
 
396
  virtual Item *create(Session *session, Item *arg1);
295
397
 
296
398
  static Create_func_ceiling s_singleton;
297
399
 
304
406
class Create_func_char_length : public Create_func_arg1
305
407
{
306
408
public:
307
 
  virtual Item *create(THD *thd, Item *arg1);
 
409
  using Create_func_arg1::create;
 
410
 
 
411
  virtual Item *create(Session *session, Item *arg1);
308
412
 
309
413
  static Create_func_char_length s_singleton;
310
414
 
317
421
class Create_func_coercibility : public Create_func_arg1
318
422
{
319
423
public:
320
 
  virtual Item *create(THD *thd, Item *arg1);
 
424
  using Create_func_arg1::create;
 
425
 
 
426
  virtual Item *create(Session *session, Item *arg1);
321
427
 
322
428
  static Create_func_coercibility s_singleton;
323
429
 
330
436
class Create_func_concat : public Create_native_func
331
437
{
332
438
public:
333
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
439
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
334
440
 
335
441
  static Create_func_concat s_singleton;
336
442
 
343
449
class Create_func_concat_ws : public Create_native_func
344
450
{
345
451
public:
346
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
452
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
347
453
 
348
454
  static Create_func_concat_ws s_singleton;
349
455
 
356
462
class Create_func_connection_id : public Create_func_arg0
357
463
{
358
464
public:
359
 
  virtual Item *create(THD *thd);
 
465
  using Create_func_arg0::create;
 
466
 
 
467
  virtual Item *create(Session *session);
360
468
 
361
469
  static Create_func_connection_id s_singleton;
362
470
 
369
477
class Create_func_conv : public Create_func_arg3
370
478
{
371
479
public:
372
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
 
480
  using Create_func_arg3::create;
 
481
 
 
482
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
373
483
 
374
484
  static Create_func_conv s_singleton;
375
485
 
382
492
class Create_func_cos : public Create_func_arg1
383
493
{
384
494
public:
385
 
  virtual Item *create(THD *thd, Item *arg1);
 
495
  using Create_func_arg1::create;
 
496
 
 
497
  virtual Item *create(Session *session, Item *arg1);
386
498
 
387
499
  static Create_func_cos s_singleton;
388
500
 
395
507
class Create_func_cot : public Create_func_arg1
396
508
{
397
509
public:
398
 
  virtual Item *create(THD *thd, Item *arg1);
 
510
  using Create_func_arg1::create;
 
511
 
 
512
  virtual Item *create(Session *session, Item *arg1);
399
513
 
400
514
  static Create_func_cot s_singleton;
401
515
 
407
521
class Create_func_date_format : public Create_func_arg2
408
522
{
409
523
public:
410
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
524
  using Create_func_arg2::create;
 
525
 
 
526
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
411
527
 
412
528
  static Create_func_date_format s_singleton;
413
529
 
420
536
class Create_func_datediff : public Create_func_arg2
421
537
{
422
538
public:
423
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
539
  using Create_func_arg2::create;
 
540
 
 
541
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
424
542
 
425
543
  static Create_func_datediff s_singleton;
426
544
 
433
551
class Create_func_dayname : public Create_func_arg1
434
552
{
435
553
public:
436
 
  virtual Item *create(THD *thd, Item *arg1);
 
554
  using Create_func_arg1::create;
 
555
 
 
556
  virtual Item *create(Session *session, Item *arg1);
437
557
 
438
558
  static Create_func_dayname s_singleton;
439
559
 
446
566
class Create_func_dayofmonth : public Create_func_arg1
447
567
{
448
568
public:
449
 
  virtual Item *create(THD *thd, Item *arg1);
 
569
  using Create_func_arg1::create;
 
570
 
 
571
  virtual Item *create(Session *session, Item *arg1);
450
572
 
451
573
  static Create_func_dayofmonth s_singleton;
452
574
 
459
581
class Create_func_dayofweek : public Create_func_arg1
460
582
{
461
583
public:
462
 
  virtual Item *create(THD *thd, Item *arg1);
 
584
  using Create_func_arg1::create;
 
585
 
 
586
  virtual Item *create(Session *session, Item *arg1);
463
587
 
464
588
  static Create_func_dayofweek s_singleton;
465
589
 
472
596
class Create_func_dayofyear : public Create_func_arg1
473
597
{
474
598
public:
475
 
  virtual Item *create(THD *thd, Item *arg1);
 
599
  using Create_func_arg1::create;
 
600
 
 
601
  virtual Item *create(Session *session, Item *arg1);
476
602
 
477
603
  static Create_func_dayofyear s_singleton;
478
604
 
485
611
class Create_func_decode : public Create_func_arg2
486
612
{
487
613
public:
488
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
614
  using Create_func_arg2::create;
 
615
 
 
616
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
489
617
 
490
618
  static Create_func_decode s_singleton;
491
619
 
498
626
class Create_func_degrees : public Create_func_arg1
499
627
{
500
628
public:
501
 
  virtual Item *create(THD *thd, Item *arg1);
 
629
  using Create_func_arg1::create;
 
630
 
 
631
  virtual Item *create(Session *session, Item *arg1);
502
632
 
503
633
  static Create_func_degrees s_singleton;
504
634
 
511
641
class Create_func_elt : public Create_native_func
512
642
{
513
643
public:
514
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
644
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
515
645
 
516
646
  static Create_func_elt s_singleton;
517
647
 
524
654
class Create_func_exp : public Create_func_arg1
525
655
{
526
656
public:
527
 
  virtual Item *create(THD *thd, Item *arg1);
 
657
  using Create_func_arg1::create;
 
658
 
 
659
  virtual Item *create(Session *session, Item *arg1);
528
660
 
529
661
  static Create_func_exp s_singleton;
530
662
 
537
669
class Create_func_export_set : public Create_native_func
538
670
{
539
671
public:
540
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
672
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
541
673
 
542
674
  static Create_func_export_set s_singleton;
543
675
 
550
682
class Create_func_field : public Create_native_func
551
683
{
552
684
public:
553
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
685
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
554
686
 
555
687
  static Create_func_field s_singleton;
556
688
 
563
695
class Create_func_find_in_set : public Create_func_arg2
564
696
{
565
697
public:
566
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
698
  using Create_func_arg2::create;
 
699
 
 
700
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
567
701
 
568
702
  static Create_func_find_in_set s_singleton;
569
703
 
576
710
class Create_func_floor : public Create_func_arg1
577
711
{
578
712
public:
579
 
  virtual Item *create(THD *thd, Item *arg1);
 
713
  using Create_func_arg1::create;
 
714
 
 
715
  virtual Item *create(Session *session, Item *arg1);
580
716
 
581
717
  static Create_func_floor s_singleton;
582
718
 
589
725
class Create_func_format : public Create_func_arg2
590
726
{
591
727
public:
592
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
728
  using Create_func_arg2::create;
 
729
 
 
730
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
593
731
 
594
732
  static Create_func_format s_singleton;
595
733
 
602
740
class Create_func_found_rows : public Create_func_arg0
603
741
{
604
742
public:
605
 
  virtual Item *create(THD *thd);
 
743
  using Create_func_arg0::create;
 
744
 
 
745
  virtual Item *create(Session *session);
606
746
 
607
747
  static Create_func_found_rows s_singleton;
608
748
 
615
755
class Create_func_from_days : public Create_func_arg1
616
756
{
617
757
public:
618
 
  virtual Item *create(THD *thd, Item *arg1);
 
758
  using Create_func_arg1::create;
 
759
 
 
760
  virtual Item *create(Session *session, Item *arg1);
619
761
 
620
762
  static Create_func_from_days s_singleton;
621
763
 
628
770
class Create_func_from_unixtime : public Create_native_func
629
771
{
630
772
public:
631
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
773
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
632
774
 
633
775
  static Create_func_from_unixtime s_singleton;
634
776
 
641
783
class Create_func_greatest : public Create_native_func
642
784
{
643
785
public:
644
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
786
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
645
787
 
646
788
  static Create_func_greatest s_singleton;
647
789
 
654
796
class Create_func_hex : public Create_func_arg1
655
797
{
656
798
public:
657
 
  virtual Item *create(THD *thd, Item *arg1);
 
799
  using Create_func_arg1::create;
 
800
 
 
801
  virtual Item *create(Session *session, Item *arg1);
658
802
 
659
803
  static Create_func_hex s_singleton;
660
804
 
667
811
class Create_func_ifnull : public Create_func_arg2
668
812
{
669
813
public:
670
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
814
  using Create_func_arg2::create;
 
815
 
 
816
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
671
817
 
672
818
  static Create_func_ifnull s_singleton;
673
819
 
680
826
class Create_func_instr : public Create_func_arg2
681
827
{
682
828
public:
683
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
829
  using Create_func_arg2::create;
 
830
 
 
831
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
684
832
 
685
833
  static Create_func_instr s_singleton;
686
834
 
693
841
class Create_func_isnull : public Create_func_arg1
694
842
{
695
843
public:
696
 
  virtual Item *create(THD *thd, Item *arg1);
 
844
  using Create_func_arg1::create;
 
845
 
 
846
  virtual Item *create(Session *session, Item *arg1);
697
847
 
698
848
  static Create_func_isnull s_singleton;
699
849
 
706
856
class Create_func_last_day : public Create_func_arg1
707
857
{
708
858
public:
709
 
  virtual Item *create(THD *thd, Item *arg1);
 
859
  using Create_func_arg1::create;
 
860
 
 
861
  virtual Item *create(Session *session, Item *arg1);
710
862
 
711
863
  static Create_func_last_day s_singleton;
712
864
 
719
871
class Create_func_last_insert_id : public Create_native_func
720
872
{
721
873
public:
722
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
874
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
723
875
 
724
876
  static Create_func_last_insert_id s_singleton;
725
877
 
732
884
class Create_func_lcase : public Create_func_arg1
733
885
{
734
886
public:
735
 
  virtual Item *create(THD *thd, Item *arg1);
 
887
  using Create_func_arg1::create;
 
888
 
 
889
  virtual Item *create(Session *session, Item *arg1);
736
890
 
737
891
  static Create_func_lcase s_singleton;
738
892
 
745
899
class Create_func_least : public Create_native_func
746
900
{
747
901
public:
748
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
902
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
749
903
 
750
904
  static Create_func_least s_singleton;
751
905
 
758
912
class Create_func_length : public Create_func_arg1
759
913
{
760
914
public:
761
 
  virtual Item *create(THD *thd, Item *arg1);
 
915
  using Create_func_arg1::create;
 
916
 
 
917
  virtual Item *create(Session *session, Item *arg1);
762
918
 
763
919
  static Create_func_length s_singleton;
764
920
 
771
927
class Create_func_ln : public Create_func_arg1
772
928
{
773
929
public:
774
 
  virtual Item *create(THD *thd, Item *arg1);
 
930
  using Create_func_arg1::create;
 
931
 
 
932
  virtual Item *create(Session *session, Item *arg1);
775
933
 
776
934
  static Create_func_ln s_singleton;
777
935
 
784
942
class Create_func_load_file : public Create_func_arg1
785
943
{
786
944
public:
787
 
  virtual Item *create(THD *thd, Item *arg1);
 
945
  using Create_func_arg1::create;
 
946
 
 
947
  virtual Item *create(Session *session, Item *arg1);
788
948
 
789
949
  static Create_func_load_file s_singleton;
790
950
 
797
957
class Create_func_locate : public Create_native_func
798
958
{
799
959
public:
800
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
960
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
801
961
 
802
962
  static Create_func_locate s_singleton;
803
963
 
810
970
class Create_func_log : public Create_native_func
811
971
{
812
972
public:
813
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
973
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
814
974
 
815
975
  static Create_func_log s_singleton;
816
976
 
823
983
class Create_func_log10 : public Create_func_arg1
824
984
{
825
985
public:
826
 
  virtual Item *create(THD *thd, Item *arg1);
 
986
  using Create_func_arg1::create;
 
987
 
 
988
  virtual Item *create(Session *session, Item *arg1);
827
989
 
828
990
  static Create_func_log10 s_singleton;
829
991
 
836
998
class Create_func_log2 : public Create_func_arg1
837
999
{
838
1000
public:
839
 
  virtual Item *create(THD *thd, Item *arg1);
 
1001
  using Create_func_arg1::create;
 
1002
 
 
1003
  virtual Item *create(Session *session, Item *arg1);
840
1004
 
841
1005
  static Create_func_log2 s_singleton;
842
1006
 
849
1013
class Create_func_lpad : public Create_func_arg3
850
1014
{
851
1015
public:
852
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
 
1016
  using Create_func_arg3::create;
 
1017
 
 
1018
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
853
1019
 
854
1020
  static Create_func_lpad s_singleton;
855
1021
 
862
1028
class Create_func_ltrim : public Create_func_arg1
863
1029
{
864
1030
public:
865
 
  virtual Item *create(THD *thd, Item *arg1);
 
1031
  using Create_func_arg1::create;
 
1032
 
 
1033
  virtual Item *create(Session *session, Item *arg1);
866
1034
 
867
1035
  static Create_func_ltrim s_singleton;
868
1036
 
875
1043
class Create_func_makedate : public Create_func_arg2
876
1044
{
877
1045
public:
878
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
1046
  using Create_func_arg2::create;
 
1047
 
 
1048
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
879
1049
 
880
1050
  static Create_func_makedate s_singleton;
881
1051
 
884
1054
  virtual ~Create_func_makedate() {}
885
1055
};
886
1056
 
887
 
 
888
 
class Create_func_maketime : public Create_func_arg3
889
 
{
890
 
public:
891
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
892
 
 
893
 
  static Create_func_maketime s_singleton;
894
 
 
895
 
protected:
896
 
  Create_func_maketime() {}
897
 
  virtual ~Create_func_maketime() {}
898
 
};
899
 
 
900
 
 
901
1057
class Create_func_make_set : public Create_native_func
902
1058
{
903
1059
public:
904
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
1060
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
905
1061
 
906
1062
  static Create_func_make_set s_singleton;
907
1063
 
911
1067
};
912
1068
 
913
1069
 
914
 
class Create_func_master_pos_wait : public Create_native_func
915
 
{
916
 
public:
917
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
918
 
 
919
 
  static Create_func_master_pos_wait s_singleton;
920
 
 
921
 
protected:
922
 
  Create_func_master_pos_wait() {}
923
 
  virtual ~Create_func_master_pos_wait() {}
924
 
};
925
 
 
926
1070
class Create_func_monthname : public Create_func_arg1
927
1071
{
928
1072
public:
929
 
  virtual Item *create(THD *thd, Item *arg1);
 
1073
  using Create_func_arg1::create;
 
1074
 
 
1075
  virtual Item *create(Session *session, Item *arg1);
930
1076
 
931
1077
  static Create_func_monthname s_singleton;
932
1078
 
939
1085
class Create_func_name_const : public Create_func_arg2
940
1086
{
941
1087
public:
942
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
1088
  using Create_func_arg2::create;
 
1089
 
 
1090
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
943
1091
 
944
1092
  static Create_func_name_const s_singleton;
945
1093
 
952
1100
class Create_func_nullif : public Create_func_arg2
953
1101
{
954
1102
public:
955
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
1103
  using Create_func_arg2::create;
 
1104
 
 
1105
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
956
1106
 
957
1107
  static Create_func_nullif s_singleton;
958
1108
 
965
1115
class Create_func_oct : public Create_func_arg1
966
1116
{
967
1117
public:
968
 
  virtual Item *create(THD *thd, Item *arg1);
 
1118
  using Create_func_arg1::create;
 
1119
 
 
1120
  virtual Item *create(Session *session, Item *arg1);
969
1121
 
970
1122
  static Create_func_oct s_singleton;
971
1123
 
978
1130
class Create_func_ord : public Create_func_arg1
979
1131
{
980
1132
public:
981
 
  virtual Item *create(THD *thd, Item *arg1);
 
1133
  using Create_func_arg1::create;
 
1134
 
 
1135
  virtual Item *create(Session *session, Item *arg1);
982
1136
 
983
1137
  static Create_func_ord s_singleton;
984
1138
 
991
1145
class Create_func_period_add : public Create_func_arg2
992
1146
{
993
1147
public:
994
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
1148
  using Create_func_arg2::create;
 
1149
 
 
1150
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
995
1151
 
996
1152
  static Create_func_period_add s_singleton;
997
1153
 
1004
1160
class Create_func_period_diff : public Create_func_arg2
1005
1161
{
1006
1162
public:
1007
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
1163
  using Create_func_arg2::create;
 
1164
 
 
1165
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1008
1166
 
1009
1167
  static Create_func_period_diff s_singleton;
1010
1168
 
1017
1175
class Create_func_pi : public Create_func_arg0
1018
1176
{
1019
1177
public:
1020
 
  virtual Item *create(THD *thd);
 
1178
  using Create_func_arg0::create;
 
1179
 
 
1180
  virtual Item *create(Session *session);
1021
1181
 
1022
1182
  static Create_func_pi s_singleton;
1023
1183
 
1030
1190
class Create_func_pow : public Create_func_arg2
1031
1191
{
1032
1192
public:
1033
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
1193
  using Create_func_arg2::create;
 
1194
 
 
1195
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1034
1196
 
1035
1197
  static Create_func_pow s_singleton;
1036
1198
 
1043
1205
class Create_func_quote : public Create_func_arg1
1044
1206
{
1045
1207
public:
1046
 
  virtual Item *create(THD *thd, Item *arg1);
 
1208
  using Create_func_arg1::create;
 
1209
 
 
1210
  virtual Item *create(Session *session, Item *arg1);
1047
1211
 
1048
1212
  static Create_func_quote s_singleton;
1049
1213
 
1056
1220
class Create_func_radians : public Create_func_arg1
1057
1221
{
1058
1222
public:
1059
 
  virtual Item *create(THD *thd, Item *arg1);
 
1223
  using Create_func_arg1::create;
 
1224
 
 
1225
  virtual Item *create(Session *session, Item *arg1);
1060
1226
 
1061
1227
  static Create_func_radians s_singleton;
1062
1228
 
1069
1235
class Create_func_rand : public Create_native_func
1070
1236
{
1071
1237
public:
1072
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
1238
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1073
1239
 
1074
1240
  static Create_func_rand s_singleton;
1075
1241
 
1082
1248
class Create_func_round : public Create_native_func
1083
1249
{
1084
1250
public:
1085
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
1251
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1086
1252
 
1087
1253
  static Create_func_round s_singleton;
1088
1254
 
1095
1261
class Create_func_row_count : public Create_func_arg0
1096
1262
{
1097
1263
public:
1098
 
  virtual Item *create(THD *thd);
 
1264
  using Create_func_arg0::create;
 
1265
 
 
1266
  virtual Item *create(Session *session);
1099
1267
 
1100
1268
  static Create_func_row_count s_singleton;
1101
1269
 
1108
1276
class Create_func_rpad : public Create_func_arg3
1109
1277
{
1110
1278
public:
1111
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
 
1279
  using Create_func_arg3::create;
 
1280
 
 
1281
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
1112
1282
 
1113
1283
  static Create_func_rpad s_singleton;
1114
1284
 
1121
1291
class Create_func_rtrim : public Create_func_arg1
1122
1292
{
1123
1293
public:
1124
 
  virtual Item *create(THD *thd, Item *arg1);
 
1294
  using Create_func_arg1::create;
 
1295
 
 
1296
  virtual Item *create(Session *session, Item *arg1);
1125
1297
 
1126
1298
  static Create_func_rtrim s_singleton;
1127
1299
 
1130
1302
  virtual ~Create_func_rtrim() {}
1131
1303
};
1132
1304
 
1133
 
 
1134
 
class Create_func_sec_to_time : public Create_func_arg1
1135
 
{
1136
 
public:
1137
 
  virtual Item *create(THD *thd, Item *arg1);
1138
 
 
1139
 
  static Create_func_sec_to_time s_singleton;
1140
 
 
1141
 
protected:
1142
 
  Create_func_sec_to_time() {}
1143
 
  virtual ~Create_func_sec_to_time() {}
1144
 
};
1145
 
 
1146
 
 
1147
1305
class Create_func_sign : public Create_func_arg1
1148
1306
{
1149
1307
public:
1150
 
  virtual Item *create(THD *thd, Item *arg1);
 
1308
  using Create_func_arg1::create;
 
1309
 
 
1310
  virtual Item *create(Session *session, Item *arg1);
1151
1311
 
1152
1312
  static Create_func_sign s_singleton;
1153
1313
 
1160
1320
class Create_func_sin : public Create_func_arg1
1161
1321
{
1162
1322
public:
1163
 
  virtual Item *create(THD *thd, Item *arg1);
 
1323
  using Create_func_arg1::create;
 
1324
 
 
1325
  virtual Item *create(Session *session, Item *arg1);
1164
1326
 
1165
1327
  static Create_func_sin s_singleton;
1166
1328
 
1173
1335
class Create_func_space : public Create_func_arg1
1174
1336
{
1175
1337
public:
1176
 
  virtual Item *create(THD *thd, Item *arg1);
 
1338
  using Create_func_arg1::create;
 
1339
 
 
1340
  virtual Item *create(Session *session, Item *arg1);
1177
1341
 
1178
1342
  static Create_func_space s_singleton;
1179
1343
 
1186
1350
class Create_func_sqrt : public Create_func_arg1
1187
1351
{
1188
1352
public:
1189
 
  virtual Item *create(THD *thd, Item *arg1);
 
1353
  using Create_func_arg1::create;
 
1354
 
 
1355
  virtual Item *create(Session *session, Item *arg1);
1190
1356
 
1191
1357
  static Create_func_sqrt s_singleton;
1192
1358
 
1196
1362
};
1197
1363
 
1198
1364
 
1199
 
class Create_func_str_to_date : public Create_func_arg2
1200
 
{
1201
 
public:
1202
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1203
 
 
1204
 
  static Create_func_str_to_date s_singleton;
1205
 
 
1206
 
protected:
1207
 
  Create_func_str_to_date() {}
1208
 
  virtual ~Create_func_str_to_date() {}
1209
 
};
1210
 
 
1211
 
 
1212
1365
class Create_func_strcmp : public Create_func_arg2
1213
1366
{
1214
1367
public:
1215
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
1368
  using Create_func_arg2::create;
 
1369
 
 
1370
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1216
1371
 
1217
1372
  static Create_func_strcmp s_singleton;
1218
1373
 
1225
1380
class Create_func_substr_index : public Create_func_arg3
1226
1381
{
1227
1382
public:
1228
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
 
1383
  using Create_func_arg3::create;
 
1384
 
 
1385
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
1229
1386
 
1230
1387
  static Create_func_substr_index s_singleton;
1231
1388
 
1235
1392
};
1236
1393
 
1237
1394
 
1238
 
class Create_func_subtime : public Create_func_arg2
1239
 
{
1240
 
public:
1241
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1242
 
 
1243
 
  static Create_func_subtime s_singleton;
1244
 
 
1245
 
protected:
1246
 
  Create_func_subtime() {}
1247
 
  virtual ~Create_func_subtime() {}
1248
 
};
1249
 
 
1250
 
 
1251
1395
class Create_func_tan : public Create_func_arg1
1252
1396
{
1253
1397
public:
1254
 
  virtual Item *create(THD *thd, Item *arg1);
 
1398
  using Create_func_arg1::create;
 
1399
 
 
1400
  virtual Item *create(Session *session, Item *arg1);
1255
1401
 
1256
1402
  static Create_func_tan s_singleton;
1257
1403
 
1264
1410
class Create_func_time_format : public Create_func_arg2
1265
1411
{
1266
1412
public:
1267
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
1413
  using Create_func_arg2::create;
 
1414
 
 
1415
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1268
1416
 
1269
1417
  static Create_func_time_format s_singleton;
1270
1418
 
1277
1425
class Create_func_time_to_sec : public Create_func_arg1
1278
1426
{
1279
1427
public:
1280
 
  virtual Item *create(THD *thd, Item *arg1);
 
1428
  using Create_func_arg1::create;
 
1429
 
 
1430
  virtual Item *create(Session *session, Item *arg1);
1281
1431
 
1282
1432
  static Create_func_time_to_sec s_singleton;
1283
1433
 
1287
1437
};
1288
1438
 
1289
1439
 
1290
 
class Create_func_timediff : public Create_func_arg2
1291
 
{
1292
 
public:
1293
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1294
 
 
1295
 
  static Create_func_timediff s_singleton;
1296
 
 
1297
 
protected:
1298
 
  Create_func_timediff() {}
1299
 
  virtual ~Create_func_timediff() {}
1300
 
};
1301
 
 
1302
 
 
1303
1440
class Create_func_to_days : public Create_func_arg1
1304
1441
{
1305
1442
public:
1306
 
  virtual Item *create(THD *thd, Item *arg1);
 
1443
  using Create_func_arg1::create;
 
1444
 
 
1445
  virtual Item *create(Session *session, Item *arg1);
1307
1446
 
1308
1447
  static Create_func_to_days s_singleton;
1309
1448
 
1316
1455
class Create_func_ucase : public Create_func_arg1
1317
1456
{
1318
1457
public:
1319
 
  virtual Item *create(THD *thd, Item *arg1);
 
1458
  using Create_func_arg1::create;
 
1459
 
 
1460
  virtual Item *create(Session *session, Item *arg1);
1320
1461
 
1321
1462
  static Create_func_ucase s_singleton;
1322
1463
 
1329
1470
class Create_func_unhex : public Create_func_arg1
1330
1471
{
1331
1472
public:
1332
 
  virtual Item *create(THD *thd, Item *arg1);
 
1473
  using Create_func_arg1::create;
 
1474
 
 
1475
  virtual Item *create(Session *session, Item *arg1);
1333
1476
 
1334
1477
  static Create_func_unhex s_singleton;
1335
1478
 
1342
1485
class Create_func_unix_timestamp : public Create_native_func
1343
1486
{
1344
1487
public:
1345
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
1488
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1346
1489
 
1347
1490
  static Create_func_unix_timestamp s_singleton;
1348
1491
 
1355
1498
class Create_func_uuid : public Create_func_arg0
1356
1499
{
1357
1500
public:
1358
 
  virtual Item *create(THD *thd);
 
1501
  using Create_func_arg0::create;
 
1502
 
 
1503
  virtual Item *create(Session *session);
1359
1504
 
1360
1505
  static Create_func_uuid s_singleton;
1361
1506
 
1368
1513
class Create_func_version : public Create_func_arg0
1369
1514
{
1370
1515
public:
1371
 
  virtual Item *create(THD *thd);
 
1516
  using Create_func_arg0::create;
 
1517
 
 
1518
  virtual Item *create(Session *session);
1372
1519
 
1373
1520
  static Create_func_version s_singleton;
1374
1521
 
1381
1528
class Create_func_weekday : public Create_func_arg1
1382
1529
{
1383
1530
public:
1384
 
  virtual Item *create(THD *thd, Item *arg1);
 
1531
  using Create_func_arg1::create;
 
1532
 
 
1533
  virtual Item *create(Session *session, Item *arg1);
1385
1534
 
1386
1535
  static Create_func_weekday s_singleton;
1387
1536
 
1390
1539
  virtual ~Create_func_weekday() {}
1391
1540
};
1392
1541
 
1393
 
 
1394
 
class Create_func_weekofyear : public Create_func_arg1
1395
 
{
1396
 
public:
1397
 
  virtual Item *create(THD *thd, Item *arg1);
1398
 
 
1399
 
  static Create_func_weekofyear s_singleton;
1400
 
 
1401
 
protected:
1402
 
  Create_func_weekofyear() {}
1403
 
  virtual ~Create_func_weekofyear() {}
1404
 
};
1405
 
 
1406
 
 
1407
 
class Create_func_year_week : public Create_native_func
1408
 
{
1409
 
public:
1410
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1411
 
 
1412
 
  static Create_func_year_week s_singleton;
1413
 
 
1414
 
protected:
1415
 
  Create_func_year_week() {}
1416
 
  virtual ~Create_func_year_week() {}
1417
 
};
1418
 
 
1419
 
 
1420
1542
/*
1421
1543
=============================================================================
1422
1544
  IMPLEMENTATION
1450
1572
Create_udf_func Create_udf_func::s_singleton;
1451
1573
 
1452
1574
Item*
1453
 
Create_udf_func::create(THD *thd, LEX_STRING name, List<Item> *item_list)
 
1575
Create_udf_func::create(Session *session, LEX_STRING name, List<Item> *item_list)
1454
1576
{
1455
 
  udf_func *udf= find_udf(name.str, name.length);
 
1577
  Function_builder *udf= find_udf(name.str, name.length);
1456
1578
  assert(udf);
1457
 
  return create(thd, udf, item_list);
 
1579
  return create(session, udf, item_list);
1458
1580
}
1459
1581
 
1460
1582
 
1461
1583
Item*
1462
 
Create_udf_func::create(THD *thd, udf_func *udf, List<Item> *item_list)
 
1584
Create_udf_func::create(Session *session, Function_builder *udf,
 
1585
                        List<Item> *item_list)
1463
1586
{
1464
 
  Item *func= NULL;
 
1587
  Item_func *func= NULL;
1465
1588
  int arg_count= 0;
1466
1589
 
1467
1590
  if (item_list != NULL)
1468
1591
    arg_count= item_list->elements;
1469
1592
 
1470
 
  thd->lex->set_stmt_unsafe();
1471
 
 
1472
 
  assert(   (udf->type == UDFTYPE_FUNCTION)
1473
 
              || (udf->type == UDFTYPE_AGGREGATE));
1474
 
 
1475
 
  switch(udf->returns) {
1476
 
  case STRING_RESULT:
1477
 
  {
1478
 
    if (udf->type == UDFTYPE_FUNCTION)
1479
 
    {
1480
 
      if (arg_count)
1481
 
        func= new (thd->mem_root) Item_func_udf_str(udf, *item_list);
1482
 
      else
1483
 
        func= new (thd->mem_root) Item_func_udf_str(udf);
1484
 
    }
1485
 
    else
1486
 
    {
1487
 
      if (arg_count)
1488
 
        func= new (thd->mem_root) Item_sum_udf_str(udf, *item_list);
1489
 
      else
1490
 
        func= new (thd->mem_root) Item_sum_udf_str(udf);
1491
 
    }
1492
 
    break;
1493
 
  }
1494
 
  case REAL_RESULT:
1495
 
  {
1496
 
    if (udf->type == UDFTYPE_FUNCTION)
1497
 
    {
1498
 
      if (arg_count)
1499
 
        func= new (thd->mem_root) Item_func_udf_float(udf, *item_list);
1500
 
      else
1501
 
        func= new (thd->mem_root) Item_func_udf_float(udf);
1502
 
    }
1503
 
    else
1504
 
    {
1505
 
      if (arg_count)
1506
 
        func= new (thd->mem_root) Item_sum_udf_float(udf, *item_list);
1507
 
      else
1508
 
        func= new (thd->mem_root) Item_sum_udf_float(udf);
1509
 
    }
1510
 
    break;
1511
 
  }
1512
 
  case INT_RESULT:
1513
 
  {
1514
 
    if (udf->type == UDFTYPE_FUNCTION)
1515
 
    {
1516
 
      if (arg_count)
1517
 
        func= new (thd->mem_root) Item_func_udf_int(udf, *item_list);
1518
 
      else
1519
 
        func= new (thd->mem_root) Item_func_udf_int(udf);
1520
 
    }
1521
 
    else
1522
 
    {
1523
 
      if (arg_count)
1524
 
        func= new (thd->mem_root) Item_sum_udf_int(udf, *item_list);
1525
 
      else
1526
 
        func= new (thd->mem_root) Item_sum_udf_int(udf);
1527
 
    }
1528
 
    break;
1529
 
  }
1530
 
  case DECIMAL_RESULT:
1531
 
  {
1532
 
    if (udf->type == UDFTYPE_FUNCTION)
1533
 
    {
1534
 
      if (arg_count)
1535
 
        func= new (thd->mem_root) Item_func_udf_decimal(udf, *item_list);
1536
 
      else
1537
 
        func= new (thd->mem_root) Item_func_udf_decimal(udf);
1538
 
    }
1539
 
    else
1540
 
    {
1541
 
      if (arg_count)
1542
 
        func= new (thd->mem_root) Item_sum_udf_decimal(udf, *item_list);
1543
 
      else
1544
 
        func= new (thd->mem_root) Item_sum_udf_decimal(udf);
1545
 
    }
1546
 
    break;
1547
 
  }
1548
 
  default:
1549
 
  {
1550
 
    my_error(ER_NOT_SUPPORTED_YET, MYF(0), "UDF return type");
1551
 
  }
1552
 
  }
 
1593
  func= (*udf)(session->mem_root);
 
1594
 
 
1595
  func->set_arguments(*item_list);
 
1596
 
1553
1597
  return func;
1554
1598
}
1555
1599
 
1556
1600
 
1557
1601
Item*
1558
 
Create_native_func::create(THD *thd, LEX_STRING name, List<Item> *item_list)
 
1602
Create_native_func::create(Session *session, LEX_STRING name, List<Item> *item_list)
1559
1603
{
1560
1604
  if (has_named_parameters(item_list))
1561
1605
  {
1563
1607
    return NULL;
1564
1608
  }
1565
1609
 
1566
 
  return create_native(thd, name, item_list);
 
1610
  return create_native(session, name, item_list);
1567
1611
}
1568
1612
 
1569
1613
 
1570
1614
Item*
1571
 
Create_func_arg0::create(THD *thd, LEX_STRING name, List<Item> *item_list)
 
1615
Create_func_arg0::create(Session *session, LEX_STRING name, List<Item> *item_list)
1572
1616
{
1573
1617
  int arg_count= 0;
1574
1618
 
1581
1625
    return NULL;
1582
1626
  }
1583
1627
 
1584
 
  return create(thd);
 
1628
  return create(session);
1585
1629
}
1586
1630
 
1587
1631
 
1588
1632
Item*
1589
 
Create_func_arg1::create(THD *thd, LEX_STRING name, List<Item> *item_list)
 
1633
Create_func_arg1::create(Session *session, LEX_STRING name, List<Item> *item_list)
1590
1634
{
1591
1635
  int arg_count= 0;
1592
1636
 
1607
1651
    return NULL;
1608
1652
  }
1609
1653
 
1610
 
  return create(thd, param_1);
 
1654
  return create(session, param_1);
1611
1655
}
1612
1656
 
1613
1657
 
1614
1658
Item*
1615
 
Create_func_arg2::create(THD *thd, LEX_STRING name, List<Item> *item_list)
 
1659
Create_func_arg2::create(Session *session, LEX_STRING name, List<Item> *item_list)
1616
1660
{
1617
1661
  int arg_count= 0;
1618
1662
 
1635
1679
    return NULL;
1636
1680
  }
1637
1681
 
1638
 
  return create(thd, param_1, param_2);
 
1682
  return create(session, param_1, param_2);
1639
1683
}
1640
1684
 
1641
1685
 
1642
1686
Item*
1643
 
Create_func_arg3::create(THD *thd, LEX_STRING name, List<Item> *item_list)
 
1687
Create_func_arg3::create(Session *session, LEX_STRING name, List<Item> *item_list)
1644
1688
{
1645
1689
  int arg_count= 0;
1646
1690
 
1665
1709
    return NULL;
1666
1710
  }
1667
1711
 
1668
 
  return create(thd, param_1, param_2, param_3);
 
1712
  return create(session, param_1, param_2, param_3);
1669
1713
}
1670
1714
 
1671
1715
 
1672
1716
Create_func_abs Create_func_abs::s_singleton;
1673
1717
 
1674
1718
Item*
1675
 
Create_func_abs::create(THD *thd, Item *arg1)
 
1719
Create_func_abs::create(Session *session, Item *arg1)
1676
1720
{
1677
 
  return new (thd->mem_root) Item_func_abs(arg1);
 
1721
  return new (session->mem_root) Item_func_abs(arg1);
1678
1722
}
1679
1723
 
1680
1724
 
1681
1725
Create_func_acos Create_func_acos::s_singleton;
1682
1726
 
1683
1727
Item*
1684
 
Create_func_acos::create(THD *thd, Item *arg1)
1685
 
{
1686
 
  return new (thd->mem_root) Item_func_acos(arg1);
1687
 
}
1688
 
 
1689
 
 
1690
 
Create_func_addtime Create_func_addtime::s_singleton;
1691
 
 
1692
 
Item*
1693
 
Create_func_addtime::create(THD *thd, Item *arg1, Item *arg2)
1694
 
{
1695
 
  return new (thd->mem_root) Item_func_add_time(arg1, arg2, 0, 0);
1696
 
}
1697
 
 
 
1728
Create_func_acos::create(Session *session, Item *arg1)
 
1729
{
 
1730
  return new (session->mem_root) Item_func_acos(arg1);
 
1731
}
1698
1732
 
1699
1733
Create_func_asin Create_func_asin::s_singleton;
1700
1734
 
1701
1735
Item*
1702
 
Create_func_asin::create(THD *thd, Item *arg1)
 
1736
Create_func_asin::create(Session *session, Item *arg1)
1703
1737
{
1704
 
  return new (thd->mem_root) Item_func_asin(arg1);
 
1738
  return new (session->mem_root) Item_func_asin(arg1);
1705
1739
}
1706
1740
 
1707
1741
 
1708
1742
Create_func_atan Create_func_atan::s_singleton;
1709
1743
 
1710
1744
Item*
1711
 
Create_func_atan::create_native(THD *thd, LEX_STRING name,
 
1745
Create_func_atan::create_native(Session *session, LEX_STRING name,
1712
1746
                                List<Item> *item_list)
1713
1747
{
1714
1748
  Item* func= NULL;
1721
1755
  case 1:
1722
1756
  {
1723
1757
    Item *param_1= item_list->pop();
1724
 
    func= new (thd->mem_root) Item_func_atan(param_1);
 
1758
    func= new (session->mem_root) Item_func_atan(param_1);
1725
1759
    break;
1726
1760
  }
1727
1761
  case 2:
1728
1762
  {
1729
1763
    Item *param_1= item_list->pop();
1730
1764
    Item *param_2= item_list->pop();
1731
 
    func= new (thd->mem_root) Item_func_atan(param_1, param_2);
 
1765
    func= new (session->mem_root) Item_func_atan(param_1, param_2);
1732
1766
    break;
1733
1767
  }
1734
1768
  default:
1745
1779
Create_func_benchmark Create_func_benchmark::s_singleton;
1746
1780
 
1747
1781
Item*
1748
 
Create_func_benchmark::create(THD *thd, Item *arg1, Item *arg2)
 
1782
Create_func_benchmark::create(Session *session, Item *arg1, Item *arg2)
1749
1783
{
1750
 
  return new (thd->mem_root) Item_func_benchmark(arg1, arg2);
 
1784
  return new (session->mem_root) Item_func_benchmark(arg1, arg2);
1751
1785
}
1752
1786
 
1753
1787
 
1754
1788
Create_func_bin Create_func_bin::s_singleton;
1755
1789
 
1756
1790
Item*
1757
 
Create_func_bin::create(THD *thd, Item *arg1)
 
1791
Create_func_bin::create(Session *session, Item *arg1)
1758
1792
{
1759
 
  Item *i10= new (thd->mem_root) Item_int((int32_t) 10,2);
1760
 
  Item *i2= new (thd->mem_root) Item_int((int32_t) 2,1);
1761
 
  return new (thd->mem_root) Item_func_conv(arg1, i10, i2);
 
1793
  Item *i10= new (session->mem_root) Item_int((int32_t) 10,2);
 
1794
  Item *i2= new (session->mem_root) Item_int((int32_t) 2,1);
 
1795
  return new (session->mem_root) Item_func_conv(arg1, i10, i2);
1762
1796
}
1763
1797
 
1764
1798
 
1765
1799
Create_func_bit_count Create_func_bit_count::s_singleton;
1766
1800
 
1767
1801
Item*
1768
 
Create_func_bit_count::create(THD *thd, Item *arg1)
 
1802
Create_func_bit_count::create(Session *session, Item *arg1)
1769
1803
{
1770
 
  return new (thd->mem_root) Item_func_bit_count(arg1);
 
1804
  return new (session->mem_root) Item_func_bit_count(arg1);
1771
1805
}
1772
1806
 
1773
1807
 
1774
1808
Create_func_bit_length Create_func_bit_length::s_singleton;
1775
1809
 
1776
1810
Item*
1777
 
Create_func_bit_length::create(THD *thd, Item *arg1)
 
1811
Create_func_bit_length::create(Session *session, Item *arg1)
1778
1812
{
1779
 
  return new (thd->mem_root) Item_func_bit_length(arg1);
 
1813
  return new (session->mem_root) Item_func_bit_length(arg1);
1780
1814
}
1781
1815
 
1782
1816
 
1783
1817
Create_func_ceiling Create_func_ceiling::s_singleton;
1784
1818
 
1785
1819
Item*
1786
 
Create_func_ceiling::create(THD *thd, Item *arg1)
 
1820
Create_func_ceiling::create(Session *session, Item *arg1)
1787
1821
{
1788
 
  return new (thd->mem_root) Item_func_ceiling(arg1);
 
1822
  return new (session->mem_root) Item_func_ceiling(arg1);
1789
1823
}
1790
1824
 
1791
1825
 
1792
1826
Create_func_char_length Create_func_char_length::s_singleton;
1793
1827
 
1794
1828
Item*
1795
 
Create_func_char_length::create(THD *thd, Item *arg1)
 
1829
Create_func_char_length::create(Session *session, Item *arg1)
1796
1830
{
1797
 
  return new (thd->mem_root) Item_func_char_length(arg1);
 
1831
  return new (session->mem_root) Item_func_char_length(arg1);
1798
1832
}
1799
1833
 
1800
1834
 
1801
1835
Create_func_coercibility Create_func_coercibility::s_singleton;
1802
1836
 
1803
1837
Item*
1804
 
Create_func_coercibility::create(THD *thd, Item *arg1)
 
1838
Create_func_coercibility::create(Session *session, Item *arg1)
1805
1839
{
1806
 
  return new (thd->mem_root) Item_func_coercibility(arg1);
 
1840
  return new (session->mem_root) Item_func_coercibility(arg1);
1807
1841
}
1808
1842
 
1809
1843
 
1810
1844
Create_func_concat Create_func_concat::s_singleton;
1811
1845
 
1812
1846
Item*
1813
 
Create_func_concat::create_native(THD *thd, LEX_STRING name,
 
1847
Create_func_concat::create_native(Session *session, LEX_STRING name,
1814
1848
                                  List<Item> *item_list)
1815
1849
{
1816
1850
  int arg_count= 0;
1824
1858
    return NULL;
1825
1859
  }
1826
1860
 
1827
 
  return new (thd->mem_root) Item_func_concat(*item_list);
 
1861
  return new (session->mem_root) Item_func_concat(*item_list);
1828
1862
}
1829
1863
 
1830
1864
 
1831
1865
Create_func_concat_ws Create_func_concat_ws::s_singleton;
1832
1866
 
1833
1867
Item*
1834
 
Create_func_concat_ws::create_native(THD *thd, LEX_STRING name,
 
1868
Create_func_concat_ws::create_native(Session *session, LEX_STRING name,
1835
1869
                                     List<Item> *item_list)
1836
1870
{
1837
1871
  int arg_count= 0;
1846
1880
    return NULL;
1847
1881
  }
1848
1882
 
1849
 
  return new (thd->mem_root) Item_func_concat_ws(*item_list);
 
1883
  return new (session->mem_root) Item_func_concat_ws(*item_list);
1850
1884
}
1851
1885
 
1852
1886
 
1853
1887
Create_func_connection_id Create_func_connection_id::s_singleton;
1854
1888
 
1855
1889
Item*
1856
 
Create_func_connection_id::create(THD *thd)
 
1890
Create_func_connection_id::create(Session *session)
1857
1891
{
1858
 
  return new (thd->mem_root) Item_func_connection_id();
 
1892
  return new (session->mem_root) Item_func_connection_id();
1859
1893
}
1860
1894
 
1861
1895
 
1862
1896
Create_func_conv Create_func_conv::s_singleton;
1863
1897
 
1864
1898
Item*
1865
 
Create_func_conv::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
 
1899
Create_func_conv::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
1866
1900
{
1867
 
  return new (thd->mem_root) Item_func_conv(arg1, arg2, arg3);
 
1901
  return new (session->mem_root) Item_func_conv(arg1, arg2, arg3);
1868
1902
}
1869
1903
 
1870
1904
 
1871
1905
Create_func_cos Create_func_cos::s_singleton;
1872
1906
 
1873
1907
Item*
1874
 
Create_func_cos::create(THD *thd, Item *arg1)
 
1908
Create_func_cos::create(Session *session, Item *arg1)
1875
1909
{
1876
 
  return new (thd->mem_root) Item_func_cos(arg1);
 
1910
  return new (session->mem_root) Item_func_cos(arg1);
1877
1911
}
1878
1912
 
1879
1913
 
1880
1914
Create_func_cot Create_func_cot::s_singleton;
1881
1915
 
1882
1916
Item*
1883
 
Create_func_cot::create(THD *thd, Item *arg1)
 
1917
Create_func_cot::create(Session *session, Item *arg1)
1884
1918
{
1885
 
  Item *i1= new (thd->mem_root) Item_int((char*) "1", 1, 1);
1886
 
  Item *i2= new (thd->mem_root) Item_func_tan(arg1);
1887
 
  return new (thd->mem_root) Item_func_div(i1, i2);
 
1919
  Item *i1= new (session->mem_root) Item_int((char*) "1", 1, 1);
 
1920
  Item *i2= new (session->mem_root) Item_func_tan(arg1);
 
1921
  return new (session->mem_root) Item_func_div(i1, i2);
1888
1922
}
1889
1923
 
1890
1924
Create_func_date_format Create_func_date_format::s_singleton;
1891
1925
 
1892
1926
Item*
1893
 
Create_func_date_format::create(THD *thd, Item *arg1, Item *arg2)
 
1927
Create_func_date_format::create(Session *session, Item *arg1, Item *arg2)
1894
1928
{
1895
 
  return new (thd->mem_root) Item_func_date_format(arg1, arg2, 0);
 
1929
  return new (session->mem_root) Item_func_date_format(arg1, arg2, 0);
1896
1930
}
1897
1931
 
1898
1932
 
1899
1933
Create_func_datediff Create_func_datediff::s_singleton;
1900
1934
 
1901
1935
Item*
1902
 
Create_func_datediff::create(THD *thd, Item *arg1, Item *arg2)
 
1936
Create_func_datediff::create(Session *session, Item *arg1, Item *arg2)
1903
1937
{
1904
 
  Item *i1= new (thd->mem_root) Item_func_to_days(arg1);
1905
 
  Item *i2= new (thd->mem_root) Item_func_to_days(arg2);
 
1938
  Item *i1= new (session->mem_root) Item_func_to_days(arg1);
 
1939
  Item *i2= new (session->mem_root) Item_func_to_days(arg2);
1906
1940
 
1907
 
  return new (thd->mem_root) Item_func_minus(i1, i2);
 
1941
  return new (session->mem_root) Item_func_minus(i1, i2);
1908
1942
}
1909
1943
 
1910
1944
 
1911
1945
Create_func_dayname Create_func_dayname::s_singleton;
1912
1946
 
1913
1947
Item*
1914
 
Create_func_dayname::create(THD *thd, Item *arg1)
 
1948
Create_func_dayname::create(Session *session, Item *arg1)
1915
1949
{
1916
 
  return new (thd->mem_root) Item_func_dayname(arg1);
 
1950
  return new (session->mem_root) Item_func_dayname(arg1);
1917
1951
}
1918
1952
 
1919
1953
 
1920
1954
Create_func_dayofmonth Create_func_dayofmonth::s_singleton;
1921
1955
 
1922
1956
Item*
1923
 
Create_func_dayofmonth::create(THD *thd, Item *arg1)
 
1957
Create_func_dayofmonth::create(Session *session, Item *arg1)
1924
1958
{
1925
 
  return new (thd->mem_root) Item_func_dayofmonth(arg1);
 
1959
  return new (session->mem_root) Item_func_dayofmonth(arg1);
1926
1960
}
1927
1961
 
1928
1962
 
1929
1963
Create_func_dayofweek Create_func_dayofweek::s_singleton;
1930
1964
 
1931
1965
Item*
1932
 
Create_func_dayofweek::create(THD *thd, Item *arg1)
 
1966
Create_func_dayofweek::create(Session *session, Item *arg1)
1933
1967
{
1934
 
  return new (thd->mem_root) Item_func_weekday(arg1, 1);
 
1968
  return new (session->mem_root) Item_func_weekday(arg1, 1);
1935
1969
}
1936
1970
 
1937
1971
 
1938
1972
Create_func_dayofyear Create_func_dayofyear::s_singleton;
1939
1973
 
1940
1974
Item*
1941
 
Create_func_dayofyear::create(THD *thd, Item *arg1)
 
1975
Create_func_dayofyear::create(Session *session, Item *arg1)
1942
1976
{
1943
 
  return new (thd->mem_root) Item_func_dayofyear(arg1);
 
1977
  return new (session->mem_root) Item_func_dayofyear(arg1);
1944
1978
}
1945
1979
 
1946
1980
 
1947
1981
Create_func_degrees Create_func_degrees::s_singleton;
1948
1982
 
1949
1983
Item*
1950
 
Create_func_degrees::create(THD *thd, Item *arg1)
 
1984
Create_func_degrees::create(Session *session, Item *arg1)
1951
1985
{
1952
 
  return new (thd->mem_root) Item_func_units((char*) "degrees", arg1,
 
1986
  return new (session->mem_root) Item_func_units((char*) "degrees", arg1,
1953
1987
                                             180/M_PI, 0.0);
1954
1988
}
1955
1989
 
1957
1991
Create_func_elt Create_func_elt::s_singleton;
1958
1992
 
1959
1993
Item*
1960
 
Create_func_elt::create_native(THD *thd, LEX_STRING name,
 
1994
Create_func_elt::create_native(Session *session, LEX_STRING name,
1961
1995
                               List<Item> *item_list)
1962
1996
{
1963
1997
  int arg_count= 0;
1971
2005
    return NULL;
1972
2006
  }
1973
2007
 
1974
 
  return new (thd->mem_root) Item_func_elt(*item_list);
 
2008
  return new (session->mem_root) Item_func_elt(*item_list);
1975
2009
}
1976
2010
 
1977
2011
 
1978
2012
Create_func_exp Create_func_exp::s_singleton;
1979
2013
 
1980
2014
Item*
1981
 
Create_func_exp::create(THD *thd, Item *arg1)
 
2015
Create_func_exp::create(Session *session, Item *arg1)
1982
2016
{
1983
 
  return new (thd->mem_root) Item_func_exp(arg1);
 
2017
  return new (session->mem_root) Item_func_exp(arg1);
1984
2018
}
1985
2019
 
1986
2020
 
1987
2021
Create_func_export_set Create_func_export_set::s_singleton;
1988
2022
 
1989
2023
Item*
1990
 
Create_func_export_set::create_native(THD *thd, LEX_STRING name,
 
2024
Create_func_export_set::create_native(Session *session, LEX_STRING name,
1991
2025
                                      List<Item> *item_list)
1992
2026
{
1993
2027
  Item *func= NULL;
2002
2036
    Item *param_1= item_list->pop();
2003
2037
    Item *param_2= item_list->pop();
2004
2038
    Item *param_3= item_list->pop();
2005
 
    func= new (thd->mem_root) Item_func_export_set(param_1, param_2, param_3);
 
2039
    func= new (session->mem_root) Item_func_export_set(param_1, param_2, param_3);
2006
2040
    break;
2007
2041
  }
2008
2042
  case 4:
2011
2045
    Item *param_2= item_list->pop();
2012
2046
    Item *param_3= item_list->pop();
2013
2047
    Item *param_4= item_list->pop();
2014
 
    func= new (thd->mem_root) Item_func_export_set(param_1, param_2, param_3,
 
2048
    func= new (session->mem_root) Item_func_export_set(param_1, param_2, param_3,
2015
2049
                                                   param_4);
2016
2050
    break;
2017
2051
  }
2022
2056
    Item *param_3= item_list->pop();
2023
2057
    Item *param_4= item_list->pop();
2024
2058
    Item *param_5= item_list->pop();
2025
 
    func= new (thd->mem_root) Item_func_export_set(param_1, param_2, param_3,
 
2059
    func= new (session->mem_root) Item_func_export_set(param_1, param_2, param_3,
2026
2060
                                                   param_4, param_5);
2027
2061
    break;
2028
2062
  }
2040
2074
Create_func_field Create_func_field::s_singleton;
2041
2075
 
2042
2076
Item*
2043
 
Create_func_field::create_native(THD *thd, LEX_STRING name,
 
2077
Create_func_field::create_native(Session *session, LEX_STRING name,
2044
2078
                                 List<Item> *item_list)
2045
2079
{
2046
2080
  int arg_count= 0;
2054
2088
    return NULL;
2055
2089
  }
2056
2090
 
2057
 
  return new (thd->mem_root) Item_func_field(*item_list);
 
2091
  return new (session->mem_root) Item_func_field(*item_list);
2058
2092
}
2059
2093
 
2060
2094
 
2061
2095
Create_func_find_in_set Create_func_find_in_set::s_singleton;
2062
2096
 
2063
2097
Item*
2064
 
Create_func_find_in_set::create(THD *thd, Item *arg1, Item *arg2)
 
2098
Create_func_find_in_set::create(Session *session, Item *arg1, Item *arg2)
2065
2099
{
2066
 
  return new (thd->mem_root) Item_func_find_in_set(arg1, arg2);
 
2100
  return new (session->mem_root) Item_func_find_in_set(arg1, arg2);
2067
2101
}
2068
2102
 
2069
2103
 
2070
2104
Create_func_floor Create_func_floor::s_singleton;
2071
2105
 
2072
2106
Item*
2073
 
Create_func_floor::create(THD *thd, Item *arg1)
 
2107
Create_func_floor::create(Session *session, Item *arg1)
2074
2108
{
2075
 
  return new (thd->mem_root) Item_func_floor(arg1);
 
2109
  return new (session->mem_root) Item_func_floor(arg1);
2076
2110
}
2077
2111
 
2078
2112
 
2079
2113
Create_func_format Create_func_format::s_singleton;
2080
2114
 
2081
2115
Item*
2082
 
Create_func_format::create(THD *thd, Item *arg1, Item *arg2)
 
2116
Create_func_format::create(Session *session, Item *arg1, Item *arg2)
2083
2117
{
2084
 
  return new (thd->mem_root) Item_func_format(arg1, arg2);
 
2118
  return new (session->mem_root) Item_func_format(arg1, arg2);
2085
2119
}
2086
2120
 
2087
2121
 
2088
2122
Create_func_found_rows Create_func_found_rows::s_singleton;
2089
2123
 
2090
2124
Item*
2091
 
Create_func_found_rows::create(THD *thd)
 
2125
Create_func_found_rows::create(Session *session)
2092
2126
{
2093
 
  thd->lex->set_stmt_unsafe();
2094
 
  return new (thd->mem_root) Item_func_found_rows();
 
2127
  return new (session->mem_root) Item_func_found_rows();
2095
2128
}
2096
2129
 
2097
2130
 
2098
2131
Create_func_from_days Create_func_from_days::s_singleton;
2099
2132
 
2100
2133
Item*
2101
 
Create_func_from_days::create(THD *thd, Item *arg1)
 
2134
Create_func_from_days::create(Session *session, Item *arg1)
2102
2135
{
2103
 
  return new (thd->mem_root) Item_func_from_days(arg1);
 
2136
  return new (session->mem_root) Item_func_from_days(arg1);
2104
2137
}
2105
2138
 
2106
2139
 
2107
2140
Create_func_from_unixtime Create_func_from_unixtime::s_singleton;
2108
2141
 
2109
2142
Item*
2110
 
Create_func_from_unixtime::create_native(THD *thd, LEX_STRING name,
 
2143
Create_func_from_unixtime::create_native(Session *session, LEX_STRING name,
2111
2144
                                         List<Item> *item_list)
2112
2145
{
2113
2146
  Item *func= NULL;
2120
2153
  case 1:
2121
2154
  {
2122
2155
    Item *param_1= item_list->pop();
2123
 
    func= new (thd->mem_root) Item_func_from_unixtime(param_1);
 
2156
    func= new (session->mem_root) Item_func_from_unixtime(param_1);
2124
2157
    break;
2125
2158
  }
2126
2159
  case 2:
2127
2160
  {
2128
2161
    Item *param_1= item_list->pop();
2129
2162
    Item *param_2= item_list->pop();
2130
 
    Item *ut= new (thd->mem_root) Item_func_from_unixtime(param_1);
2131
 
    func= new (thd->mem_root) Item_func_date_format(ut, param_2, 0);
 
2163
    Item *ut= new (session->mem_root) Item_func_from_unixtime(param_1);
 
2164
    func= new (session->mem_root) Item_func_date_format(ut, param_2, 0);
2132
2165
    break;
2133
2166
  }
2134
2167
  default:
2145
2178
Create_func_greatest Create_func_greatest::s_singleton;
2146
2179
 
2147
2180
Item*
2148
 
Create_func_greatest::create_native(THD *thd, LEX_STRING name,
 
2181
Create_func_greatest::create_native(Session *session, LEX_STRING name,
2149
2182
                                    List<Item> *item_list)
2150
2183
{
2151
2184
  int arg_count= 0;
2159
2192
    return NULL;
2160
2193
  }
2161
2194
 
2162
 
  return new (thd->mem_root) Item_func_max(*item_list);
 
2195
  return new (session->mem_root) Item_func_max(*item_list);
2163
2196
}
2164
2197
 
2165
2198
 
2166
2199
Create_func_hex Create_func_hex::s_singleton;
2167
2200
 
2168
2201
Item*
2169
 
Create_func_hex::create(THD *thd, Item *arg1)
 
2202
Create_func_hex::create(Session *session, Item *arg1)
2170
2203
{
2171
 
  return new (thd->mem_root) Item_func_hex(arg1);
 
2204
  return new (session->mem_root) Item_func_hex(arg1);
2172
2205
}
2173
2206
 
2174
2207
 
2175
2208
Create_func_ifnull Create_func_ifnull::s_singleton;
2176
2209
 
2177
2210
Item*
2178
 
Create_func_ifnull::create(THD *thd, Item *arg1, Item *arg2)
 
2211
Create_func_ifnull::create(Session *session, Item *arg1, Item *arg2)
2179
2212
{
2180
 
  return new (thd->mem_root) Item_func_ifnull(arg1, arg2);
 
2213
  return new (session->mem_root) Item_func_ifnull(arg1, arg2);
2181
2214
}
2182
2215
 
2183
2216
 
2184
2217
Create_func_instr Create_func_instr::s_singleton;
2185
2218
 
2186
2219
Item*
2187
 
Create_func_instr::create(THD *thd, Item *arg1, Item *arg2)
 
2220
Create_func_instr::create(Session *session, Item *arg1, Item *arg2)
2188
2221
{
2189
 
  return new (thd->mem_root) Item_func_locate(arg1, arg2);
 
2222
  return new (session->mem_root) Item_func_locate(arg1, arg2);
2190
2223
}
2191
2224
 
2192
2225
 
2193
2226
Create_func_isnull Create_func_isnull::s_singleton;
2194
2227
 
2195
2228
Item*
2196
 
Create_func_isnull::create(THD *thd, Item *arg1)
 
2229
Create_func_isnull::create(Session *session, Item *arg1)
2197
2230
{
2198
 
  return new (thd->mem_root) Item_func_isnull(arg1);
 
2231
  return new (session->mem_root) Item_func_isnull(arg1);
2199
2232
}
2200
2233
 
2201
2234
 
2202
2235
Create_func_last_day Create_func_last_day::s_singleton;
2203
2236
 
2204
2237
Item*
2205
 
Create_func_last_day::create(THD *thd, Item *arg1)
 
2238
Create_func_last_day::create(Session *session, Item *arg1)
2206
2239
{
2207
 
  return new (thd->mem_root) Item_func_last_day(arg1);
 
2240
  return new (session->mem_root) Item_func_last_day(arg1);
2208
2241
}
2209
2242
 
2210
2243
 
2211
2244
Create_func_last_insert_id Create_func_last_insert_id::s_singleton;
2212
2245
 
2213
2246
Item*
2214
 
Create_func_last_insert_id::create_native(THD *thd, LEX_STRING name,
 
2247
Create_func_last_insert_id::create_native(Session *session, LEX_STRING name,
2215
2248
                                          List<Item> *item_list)
2216
2249
{
2217
2250
  Item *func= NULL;
2223
2256
  switch (arg_count) {
2224
2257
  case 0:
2225
2258
  {
2226
 
    func= new (thd->mem_root) Item_func_last_insert_id();
 
2259
    func= new (session->mem_root) Item_func_last_insert_id();
2227
2260
    break;
2228
2261
  }
2229
2262
  case 1:
2230
2263
  {
2231
2264
    Item *param_1= item_list->pop();
2232
 
    func= new (thd->mem_root) Item_func_last_insert_id(param_1);
 
2265
    func= new (session->mem_root) Item_func_last_insert_id(param_1);
2233
2266
    break;
2234
2267
  }
2235
2268
  default:
2246
2279
Create_func_lcase Create_func_lcase::s_singleton;
2247
2280
 
2248
2281
Item*
2249
 
Create_func_lcase::create(THD *thd, Item *arg1)
 
2282
Create_func_lcase::create(Session *session, Item *arg1)
2250
2283
{
2251
 
  return new (thd->mem_root) Item_func_lcase(arg1);
 
2284
  return new (session->mem_root) Item_func_lcase(arg1);
2252
2285
}
2253
2286
 
2254
2287
 
2255
2288
Create_func_least Create_func_least::s_singleton;
2256
2289
 
2257
2290
Item*
2258
 
Create_func_least::create_native(THD *thd, LEX_STRING name,
 
2291
Create_func_least::create_native(Session *session, LEX_STRING name,
2259
2292
                                 List<Item> *item_list)
2260
2293
{
2261
2294
  int arg_count= 0;
2269
2302
    return NULL;
2270
2303
  }
2271
2304
 
2272
 
  return new (thd->mem_root) Item_func_min(*item_list);
 
2305
  return new (session->mem_root) Item_func_min(*item_list);
2273
2306
}
2274
2307
 
2275
2308
 
2276
2309
Create_func_length Create_func_length::s_singleton;
2277
2310
 
2278
2311
Item*
2279
 
Create_func_length::create(THD *thd, Item *arg1)
 
2312
Create_func_length::create(Session *session, Item *arg1)
2280
2313
{
2281
 
  return new (thd->mem_root) Item_func_length(arg1);
 
2314
  return new (session->mem_root) Item_func_length(arg1);
2282
2315
}
2283
2316
 
2284
2317
 
2285
2318
Create_func_ln Create_func_ln::s_singleton;
2286
2319
 
2287
2320
Item*
2288
 
Create_func_ln::create(THD *thd, Item *arg1)
 
2321
Create_func_ln::create(Session *session, Item *arg1)
2289
2322
{
2290
 
  return new (thd->mem_root) Item_func_ln(arg1);
 
2323
  return new (session->mem_root) Item_func_ln(arg1);
2291
2324
}
2292
2325
 
2293
2326
 
2294
2327
Create_func_load_file Create_func_load_file::s_singleton;
2295
2328
 
2296
2329
Item*
2297
 
Create_func_load_file::create(THD *thd, Item *arg1)
 
2330
Create_func_load_file::create(Session *session, Item *arg1)
2298
2331
{
2299
 
  return new (thd->mem_root) Item_load_file(arg1);
 
2332
  return new (session->mem_root) Item_load_file(arg1);
2300
2333
}
2301
2334
 
2302
2335
 
2303
2336
Create_func_locate Create_func_locate::s_singleton;
2304
2337
 
2305
2338
Item*
2306
 
Create_func_locate::create_native(THD *thd, LEX_STRING name,
 
2339
Create_func_locate::create_native(Session *session, LEX_STRING name,
2307
2340
                                  List<Item> *item_list)
2308
2341
{
2309
2342
  Item *func= NULL;
2318
2351
    Item *param_1= item_list->pop();
2319
2352
    Item *param_2= item_list->pop();
2320
2353
    /* Yes, parameters in that order : 2, 1 */
2321
 
    func= new (thd->mem_root) Item_func_locate(param_2, param_1);
 
2354
    func= new (session->mem_root) Item_func_locate(param_2, param_1);
2322
2355
    break;
2323
2356
  }
2324
2357
  case 3:
2327
2360
    Item *param_2= item_list->pop();
2328
2361
    Item *param_3= item_list->pop();
2329
2362
    /* Yes, parameters in that order : 2, 1, 3 */
2330
 
    func= new (thd->mem_root) Item_func_locate(param_2, param_1, param_3);
 
2363
    func= new (session->mem_root) Item_func_locate(param_2, param_1, param_3);
2331
2364
    break;
2332
2365
  }
2333
2366
  default:
2344
2377
Create_func_log Create_func_log::s_singleton;
2345
2378
 
2346
2379
Item*
2347
 
Create_func_log::create_native(THD *thd, LEX_STRING name,
 
2380
Create_func_log::create_native(Session *session, LEX_STRING name,
2348
2381
                               List<Item> *item_list)
2349
2382
{
2350
2383
  Item *func= NULL;
2357
2390
  case 1:
2358
2391
  {
2359
2392
    Item *param_1= item_list->pop();
2360
 
    func= new (thd->mem_root) Item_func_log(param_1);
 
2393
    func= new (session->mem_root) Item_func_log(param_1);
2361
2394
    break;
2362
2395
  }
2363
2396
  case 2:
2364
2397
  {
2365
2398
    Item *param_1= item_list->pop();
2366
2399
    Item *param_2= item_list->pop();
2367
 
    func= new (thd->mem_root) Item_func_log(param_1, param_2);
 
2400
    func= new (session->mem_root) Item_func_log(param_1, param_2);
2368
2401
    break;
2369
2402
  }
2370
2403
  default:
2381
2414
Create_func_log10 Create_func_log10::s_singleton;
2382
2415
 
2383
2416
Item*
2384
 
Create_func_log10::create(THD *thd, Item *arg1)
 
2417
Create_func_log10::create(Session *session, Item *arg1)
2385
2418
{
2386
 
  return new (thd->mem_root) Item_func_log10(arg1);
 
2419
  return new (session->mem_root) Item_func_log10(arg1);
2387
2420
}
2388
2421
 
2389
2422
 
2390
2423
Create_func_log2 Create_func_log2::s_singleton;
2391
2424
 
2392
2425
Item*
2393
 
Create_func_log2::create(THD *thd, Item *arg1)
 
2426
Create_func_log2::create(Session *session, Item *arg1)
2394
2427
{
2395
 
  return new (thd->mem_root) Item_func_log2(arg1);
 
2428
  return new (session->mem_root) Item_func_log2(arg1);
2396
2429
}
2397
2430
 
2398
2431
 
2399
2432
Create_func_lpad Create_func_lpad::s_singleton;
2400
2433
 
2401
2434
Item*
2402
 
Create_func_lpad::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
 
2435
Create_func_lpad::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
2403
2436
{
2404
 
  return new (thd->mem_root) Item_func_lpad(arg1, arg2, arg3);
 
2437
  return new (session->mem_root) Item_func_lpad(arg1, arg2, arg3);
2405
2438
}
2406
2439
 
2407
2440
 
2408
2441
Create_func_ltrim Create_func_ltrim::s_singleton;
2409
2442
 
2410
2443
Item*
2411
 
Create_func_ltrim::create(THD *thd, Item *arg1)
 
2444
Create_func_ltrim::create(Session *session, Item *arg1)
2412
2445
{
2413
 
  return new (thd->mem_root) Item_func_ltrim(arg1);
 
2446
  return new (session->mem_root) Item_func_ltrim(arg1);
2414
2447
}
2415
2448
 
2416
2449
 
2417
2450
Create_func_makedate Create_func_makedate::s_singleton;
2418
2451
 
2419
2452
Item*
2420
 
Create_func_makedate::create(THD *thd, Item *arg1, Item *arg2)
2421
 
{
2422
 
  return new (thd->mem_root) Item_func_makedate(arg1, arg2);
2423
 
}
2424
 
 
2425
 
 
2426
 
Create_func_maketime Create_func_maketime::s_singleton;
2427
 
 
2428
 
Item*
2429
 
Create_func_maketime::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
2430
 
{
2431
 
  return new (thd->mem_root) Item_func_maketime(arg1, arg2, arg3);
 
2453
Create_func_makedate::create(Session *session, Item *arg1, Item *arg2)
 
2454
{
 
2455
  return new (session->mem_root) Item_func_makedate(arg1, arg2);
2432
2456
}
2433
2457
 
2434
2458
 
2435
2459
Create_func_make_set Create_func_make_set::s_singleton;
2436
2460
 
2437
2461
Item*
2438
 
Create_func_make_set::create_native(THD *thd, LEX_STRING name,
 
2462
Create_func_make_set::create_native(Session *session, LEX_STRING name,
2439
2463
                                    List<Item> *item_list)
2440
2464
{
2441
2465
  int arg_count= 0;
2450
2474
  }
2451
2475
 
2452
2476
  Item *param_1= item_list->pop();
2453
 
  return new (thd->mem_root) Item_func_make_set(param_1, *item_list);
2454
 
}
2455
 
 
2456
 
 
2457
 
Create_func_master_pos_wait Create_func_master_pos_wait::s_singleton;
2458
 
 
2459
 
Item*
2460
 
Create_func_master_pos_wait::create_native(THD *thd, LEX_STRING name,
2461
 
                                           List<Item> *item_list)
2462
 
 
2463
 
{
2464
 
  Item *func= NULL;
2465
 
  int arg_count= 0;
2466
 
 
2467
 
  if (item_list != NULL)
2468
 
    arg_count= item_list->elements;
2469
 
 
2470
 
  switch (arg_count) {
2471
 
  case 2:
2472
 
  {
2473
 
    Item *param_1= item_list->pop();
2474
 
    Item *param_2= item_list->pop();
2475
 
    func= new (thd->mem_root) Item_master_pos_wait(param_1, param_2);
2476
 
    break;
2477
 
  }
2478
 
  case 3:
2479
 
  {
2480
 
    Item *param_1= item_list->pop();
2481
 
    Item *param_2= item_list->pop();
2482
 
    Item *param_3= item_list->pop();
2483
 
    func= new (thd->mem_root) Item_master_pos_wait(param_1, param_2, param_3);
2484
 
    break;
2485
 
  }
2486
 
  default:
2487
 
  {
2488
 
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2489
 
    break;
2490
 
  }
2491
 
  }
2492
 
 
2493
 
  return func;
 
2477
  return new (session->mem_root) Item_func_make_set(param_1, *item_list);
2494
2478
}
2495
2479
 
2496
2480
 
2497
2481
Create_func_monthname Create_func_monthname::s_singleton;
2498
2482
 
2499
2483
Item*
2500
 
Create_func_monthname::create(THD *thd, Item *arg1)
 
2484
Create_func_monthname::create(Session *session, Item *arg1)
2501
2485
{
2502
 
  return new (thd->mem_root) Item_func_monthname(arg1);
 
2486
  return new (session->mem_root) Item_func_monthname(arg1);
2503
2487
}
2504
2488
 
2505
2489
 
2506
2490
Create_func_nullif Create_func_nullif::s_singleton;
2507
2491
 
2508
2492
Item*
2509
 
Create_func_nullif::create(THD *thd, Item *arg1, Item *arg2)
 
2493
Create_func_nullif::create(Session *session, Item *arg1, Item *arg2)
2510
2494
{
2511
 
  return new (thd->mem_root) Item_func_nullif(arg1, arg2);
 
2495
  return new (session->mem_root) Item_func_nullif(arg1, arg2);
2512
2496
}
2513
2497
 
2514
2498
 
2515
2499
Create_func_oct Create_func_oct::s_singleton;
2516
2500
 
2517
2501
Item*
2518
 
Create_func_oct::create(THD *thd, Item *arg1)
 
2502
Create_func_oct::create(Session *session, Item *arg1)
2519
2503
{
2520
 
  Item *i10= new (thd->mem_root) Item_int((int32_t) 10,2);
2521
 
  Item *i8= new (thd->mem_root) Item_int((int32_t) 8,1);
2522
 
  return new (thd->mem_root) Item_func_conv(arg1, i10, i8);
 
2504
  Item *i10= new (session->mem_root) Item_int((int32_t) 10,2);
 
2505
  Item *i8= new (session->mem_root) Item_int((int32_t) 8,1);
 
2506
  return new (session->mem_root) Item_func_conv(arg1, i10, i8);
2523
2507
}
2524
2508
 
2525
2509
 
2526
2510
Create_func_ord Create_func_ord::s_singleton;
2527
2511
 
2528
2512
Item*
2529
 
Create_func_ord::create(THD *thd, Item *arg1)
 
2513
Create_func_ord::create(Session *session, Item *arg1)
2530
2514
{
2531
 
  return new (thd->mem_root) Item_func_ord(arg1);
 
2515
  return new (session->mem_root) Item_func_ord(arg1);
2532
2516
}
2533
2517
 
2534
2518
 
2535
2519
Create_func_period_add Create_func_period_add::s_singleton;
2536
2520
 
2537
2521
Item*
2538
 
Create_func_period_add::create(THD *thd, Item *arg1, Item *arg2)
 
2522
Create_func_period_add::create(Session *session, Item *arg1, Item *arg2)
2539
2523
{
2540
 
  return new (thd->mem_root) Item_func_period_add(arg1, arg2);
 
2524
  return new (session->mem_root) Item_func_period_add(arg1, arg2);
2541
2525
}
2542
2526
 
2543
2527
 
2544
2528
Create_func_period_diff Create_func_period_diff::s_singleton;
2545
2529
 
2546
2530
Item*
2547
 
Create_func_period_diff::create(THD *thd, Item *arg1, Item *arg2)
 
2531
Create_func_period_diff::create(Session *session, Item *arg1, Item *arg2)
2548
2532
{
2549
 
  return new (thd->mem_root) Item_func_period_diff(arg1, arg2);
 
2533
  return new (session->mem_root) Item_func_period_diff(arg1, arg2);
2550
2534
}
2551
2535
 
2552
2536
 
2553
2537
Create_func_pi Create_func_pi::s_singleton;
2554
2538
 
2555
2539
Item*
2556
 
Create_func_pi::create(THD *thd)
 
2540
Create_func_pi::create(Session *session)
2557
2541
{
2558
 
  return new (thd->mem_root) Item_static_float_func("pi()", M_PI, 6, 8);
 
2542
  return new (session->mem_root) Item_static_float_func("pi()", M_PI, 6, 8);
2559
2543
}
2560
2544
 
2561
2545
 
2562
2546
Create_func_pow Create_func_pow::s_singleton;
2563
2547
 
2564
2548
Item*
2565
 
Create_func_pow::create(THD *thd, Item *arg1, Item *arg2)
 
2549
Create_func_pow::create(Session *session, Item *arg1, Item *arg2)
2566
2550
{
2567
 
  return new (thd->mem_root) Item_func_pow(arg1, arg2);
 
2551
  return new (session->mem_root) Item_func_pow(arg1, arg2);
2568
2552
}
2569
2553
 
2570
2554
 
2571
2555
Create_func_quote Create_func_quote::s_singleton;
2572
2556
 
2573
2557
Item*
2574
 
Create_func_quote::create(THD *thd, Item *arg1)
 
2558
Create_func_quote::create(Session *session, Item *arg1)
2575
2559
{
2576
 
  return new (thd->mem_root) Item_func_quote(arg1);
 
2560
  return new (session->mem_root) Item_func_quote(arg1);
2577
2561
}
2578
2562
 
2579
2563
 
2580
2564
Create_func_radians Create_func_radians::s_singleton;
2581
2565
 
2582
2566
Item*
2583
 
Create_func_radians::create(THD *thd, Item *arg1)
 
2567
Create_func_radians::create(Session *session, Item *arg1)
2584
2568
{
2585
 
  return new (thd->mem_root) Item_func_units((char*) "radians", arg1,
 
2569
  return new (session->mem_root) Item_func_units((char*) "radians", arg1,
2586
2570
                                             M_PI/180, 0.0);
2587
2571
}
2588
2572
 
2590
2574
Create_func_rand Create_func_rand::s_singleton;
2591
2575
 
2592
2576
Item*
2593
 
Create_func_rand::create_native(THD *thd, LEX_STRING name,
 
2577
Create_func_rand::create_native(Session *session, LEX_STRING name,
2594
2578
                                List<Item> *item_list)
2595
2579
{
2596
2580
  Item *func= NULL;
2602
2586
  switch (arg_count) {
2603
2587
  case 0:
2604
2588
  {
2605
 
    func= new (thd->mem_root) Item_func_rand();
 
2589
    func= new (session->mem_root) Item_func_rand();
2606
2590
    break;
2607
2591
  }
2608
2592
  case 1:
2609
2593
  {
2610
2594
    Item *param_1= item_list->pop();
2611
 
    func= new (thd->mem_root) Item_func_rand(param_1);
 
2595
    func= new (session->mem_root) Item_func_rand(param_1);
2612
2596
    break;
2613
2597
  }
2614
2598
  default:
2625
2609
Create_func_round Create_func_round::s_singleton;
2626
2610
 
2627
2611
Item*
2628
 
Create_func_round::create_native(THD *thd, LEX_STRING name,
 
2612
Create_func_round::create_native(Session *session, LEX_STRING name,
2629
2613
                                 List<Item> *item_list)
2630
2614
{
2631
2615
  Item *func= NULL;
2638
2622
  case 1:
2639
2623
  {
2640
2624
    Item *param_1= item_list->pop();
2641
 
    Item *i0 = new (thd->mem_root) Item_int((char*)"0", 0, 1);
2642
 
    func= new (thd->mem_root) Item_func_round(param_1, i0, 0);
 
2625
    Item *i0 = new (session->mem_root) Item_int((char*)"0", 0, 1);
 
2626
    func= new (session->mem_root) Item_func_round(param_1, i0, 0);
2643
2627
    break;
2644
2628
  }
2645
2629
  case 2:
2646
2630
  {
2647
2631
    Item *param_1= item_list->pop();
2648
2632
    Item *param_2= item_list->pop();
2649
 
    func= new (thd->mem_root) Item_func_round(param_1, param_2, 0);
 
2633
    func= new (session->mem_root) Item_func_round(param_1, param_2, 0);
2650
2634
    break;
2651
2635
  }
2652
2636
  default:
2663
2647
Create_func_row_count Create_func_row_count::s_singleton;
2664
2648
 
2665
2649
Item*
2666
 
Create_func_row_count::create(THD *thd)
 
2650
Create_func_row_count::create(Session *session)
2667
2651
{
2668
 
  thd->lex->set_stmt_unsafe();
2669
 
  return new (thd->mem_root) Item_func_row_count();
 
2652
  return new (session->mem_root) Item_func_row_count();
2670
2653
}
2671
2654
 
2672
2655
 
2673
2656
Create_func_rpad Create_func_rpad::s_singleton;
2674
2657
 
2675
2658
Item*
2676
 
Create_func_rpad::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
 
2659
Create_func_rpad::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
2677
2660
{
2678
 
  return new (thd->mem_root) Item_func_rpad(arg1, arg2, arg3);
 
2661
  return new (session->mem_root) Item_func_rpad(arg1, arg2, arg3);
2679
2662
}
2680
2663
 
2681
2664
 
2682
2665
Create_func_rtrim Create_func_rtrim::s_singleton;
2683
2666
 
2684
2667
Item*
2685
 
Create_func_rtrim::create(THD *thd, Item *arg1)
2686
 
{
2687
 
  return new (thd->mem_root) Item_func_rtrim(arg1);
2688
 
}
2689
 
 
2690
 
 
2691
 
Create_func_sec_to_time Create_func_sec_to_time::s_singleton;
2692
 
 
2693
 
Item*
2694
 
Create_func_sec_to_time::create(THD *thd, Item *arg1)
2695
 
{
2696
 
  return new (thd->mem_root) Item_func_sec_to_time(arg1);
 
2668
Create_func_rtrim::create(Session *session, Item *arg1)
 
2669
{
 
2670
  return new (session->mem_root) Item_func_rtrim(arg1);
2697
2671
}
2698
2672
 
2699
2673
 
2700
2674
Create_func_sign Create_func_sign::s_singleton;
2701
2675
 
2702
2676
Item*
2703
 
Create_func_sign::create(THD *thd, Item *arg1)
 
2677
Create_func_sign::create(Session *session, Item *arg1)
2704
2678
{
2705
 
  return new (thd->mem_root) Item_func_sign(arg1);
 
2679
  return new (session->mem_root) Item_func_sign(arg1);
2706
2680
}
2707
2681
 
2708
2682
 
2709
2683
Create_func_sin Create_func_sin::s_singleton;
2710
2684
 
2711
2685
Item*
2712
 
Create_func_sin::create(THD *thd, Item *arg1)
 
2686
Create_func_sin::create(Session *session, Item *arg1)
2713
2687
{
2714
 
  return new (thd->mem_root) Item_func_sin(arg1);
 
2688
  return new (session->mem_root) Item_func_sin(arg1);
2715
2689
}
2716
2690
 
2717
2691
 
2718
2692
Create_func_space Create_func_space::s_singleton;
2719
2693
 
2720
2694
Item*
2721
 
Create_func_space::create(THD *thd, Item *arg1)
 
2695
Create_func_space::create(Session *session, Item *arg1)
2722
2696
{
2723
2697
  /**
2724
2698
    TODO: Fix Bug#23637
2725
2699
    The parsed item tree should not depend on
2726
 
    <code>thd->variables.collation_connection</code>.
 
2700
    <code>session->variables.collation_connection</code>.
2727
2701
  */
2728
 
  const CHARSET_INFO * const cs= thd->variables.collation_connection;
 
2702
  const CHARSET_INFO * const cs= session->variables.getCollation();
2729
2703
  Item *sp;
2730
2704
 
2731
2705
  if (cs->mbminlen > 1)
2732
2706
  {
2733
 
    uint dummy_errors;
2734
 
    sp= new (thd->mem_root) Item_string("", 0, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
 
2707
    uint32_t dummy_errors;
 
2708
    sp= new (session->mem_root) Item_string("", 0, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
2735
2709
    sp->str_value.copy(" ", 1, &my_charset_utf8_general_ci, cs, &dummy_errors);
2736
2710
  }
2737
2711
  else
2738
2712
  {
2739
 
    sp= new (thd->mem_root) Item_string(" ", 1, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
 
2713
    sp= new (session->mem_root) Item_string(" ", 1, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
2740
2714
  }
2741
2715
 
2742
 
  return new (thd->mem_root) Item_func_repeat(sp, arg1);
 
2716
  return new (session->mem_root) Item_func_repeat(sp, arg1);
2743
2717
}
2744
2718
 
2745
2719
 
2746
2720
Create_func_sqrt Create_func_sqrt::s_singleton;
2747
2721
 
2748
2722
Item*
2749
 
Create_func_sqrt::create(THD *thd, Item *arg1)
2750
 
{
2751
 
  return new (thd->mem_root) Item_func_sqrt(arg1);
2752
 
}
2753
 
 
2754
 
 
2755
 
Create_func_str_to_date Create_func_str_to_date::s_singleton;
2756
 
 
2757
 
Item*
2758
 
Create_func_str_to_date::create(THD *thd, Item *arg1, Item *arg2)
2759
 
{
2760
 
  return new (thd->mem_root) Item_func_str_to_date(arg1, arg2);
 
2723
Create_func_sqrt::create(Session *session, Item *arg1)
 
2724
{
 
2725
  return new (session->mem_root) Item_func_sqrt(arg1);
2761
2726
}
2762
2727
 
2763
2728
 
2764
2729
Create_func_strcmp Create_func_strcmp::s_singleton;
2765
2730
 
2766
2731
Item*
2767
 
Create_func_strcmp::create(THD *thd, Item *arg1, Item *arg2)
 
2732
Create_func_strcmp::create(Session *session, Item *arg1, Item *arg2)
2768
2733
{
2769
 
  return new (thd->mem_root) Item_func_strcmp(arg1, arg2);
 
2734
  return new (session->mem_root) Item_func_strcmp(arg1, arg2);
2770
2735
}
2771
2736
 
2772
2737
 
2773
2738
Create_func_substr_index Create_func_substr_index::s_singleton;
2774
2739
 
2775
2740
Item*
2776
 
Create_func_substr_index::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
2777
 
{
2778
 
  return new (thd->mem_root) Item_func_substr_index(arg1, arg2, arg3);
2779
 
}
2780
 
 
2781
 
 
2782
 
Create_func_subtime Create_func_subtime::s_singleton;
2783
 
 
2784
 
Item*
2785
 
Create_func_subtime::create(THD *thd, Item *arg1, Item *arg2)
2786
 
{
2787
 
  return new (thd->mem_root) Item_func_add_time(arg1, arg2, 0, 1);
2788
 
}
2789
 
 
 
2741
Create_func_substr_index::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
 
2742
{
 
2743
  return new (session->mem_root) Item_func_substr_index(arg1, arg2, arg3);
 
2744
}
2790
2745
 
2791
2746
Create_func_tan Create_func_tan::s_singleton;
2792
2747
 
2793
2748
Item*
2794
 
Create_func_tan::create(THD *thd, Item *arg1)
 
2749
Create_func_tan::create(Session *session, Item *arg1)
2795
2750
{
2796
 
  return new (thd->mem_root) Item_func_tan(arg1);
 
2751
  return new (session->mem_root) Item_func_tan(arg1);
2797
2752
}
2798
2753
 
2799
2754
 
2800
2755
Create_func_time_format Create_func_time_format::s_singleton;
2801
2756
 
2802
2757
Item*
2803
 
Create_func_time_format::create(THD *thd, Item *arg1, Item *arg2)
2804
 
{
2805
 
  return new (thd->mem_root) Item_func_date_format(arg1, arg2, 1);
2806
 
}
2807
 
 
2808
 
 
2809
 
Create_func_time_to_sec Create_func_time_to_sec::s_singleton;
2810
 
 
2811
 
Item*
2812
 
Create_func_time_to_sec::create(THD *thd, Item *arg1)
2813
 
{
2814
 
  return new (thd->mem_root) Item_func_time_to_sec(arg1);
2815
 
}
2816
 
 
2817
 
 
2818
 
Create_func_timediff Create_func_timediff::s_singleton;
2819
 
 
2820
 
Item*
2821
 
Create_func_timediff::create(THD *thd, Item *arg1, Item *arg2)
2822
 
{
2823
 
  return new (thd->mem_root) Item_func_timediff(arg1, arg2);
2824
 
}
2825
 
 
 
2758
Create_func_time_format::create(Session *session, Item *arg1, Item *arg2)
 
2759
{
 
2760
  return new (session->mem_root) Item_func_date_format(arg1, arg2, 1);
 
2761
}
2826
2762
 
2827
2763
Create_func_to_days Create_func_to_days::s_singleton;
2828
2764
 
2829
2765
Item*
2830
 
Create_func_to_days::create(THD *thd, Item *arg1)
 
2766
Create_func_to_days::create(Session *session, Item *arg1)
2831
2767
{
2832
 
  return new (thd->mem_root) Item_func_to_days(arg1);
 
2768
  return new (session->mem_root) Item_func_to_days(arg1);
2833
2769
}
2834
2770
 
2835
2771
 
2836
2772
Create_func_ucase Create_func_ucase::s_singleton;
2837
2773
 
2838
2774
Item*
2839
 
Create_func_ucase::create(THD *thd, Item *arg1)
 
2775
Create_func_ucase::create(Session *session, Item *arg1)
2840
2776
{
2841
 
  return new (thd->mem_root) Item_func_ucase(arg1);
 
2777
  return new (session->mem_root) Item_func_ucase(arg1);
2842
2778
}
2843
2779
 
2844
2780
 
2845
2781
Create_func_unhex Create_func_unhex::s_singleton;
2846
2782
 
2847
2783
Item*
2848
 
Create_func_unhex::create(THD *thd, Item *arg1)
 
2784
Create_func_unhex::create(Session *session, Item *arg1)
2849
2785
{
2850
 
  return new (thd->mem_root) Item_func_unhex(arg1);
 
2786
  return new (session->mem_root) Item_func_unhex(arg1);
2851
2787
}
2852
2788
 
2853
2789
 
2854
2790
Create_func_unix_timestamp Create_func_unix_timestamp::s_singleton;
2855
2791
 
2856
2792
Item*
2857
 
Create_func_unix_timestamp::create_native(THD *thd, LEX_STRING name,
 
2793
Create_func_unix_timestamp::create_native(Session *session, LEX_STRING name,
2858
2794
                                          List<Item> *item_list)
2859
2795
{
2860
2796
  Item *func= NULL;
2866
2802
  switch (arg_count) {
2867
2803
  case 0:
2868
2804
  {
2869
 
    func= new (thd->mem_root) Item_func_unix_timestamp();
 
2805
    func= new (session->mem_root) Item_func_unix_timestamp();
2870
2806
    break;
2871
2807
  }
2872
2808
  case 1:
2873
2809
  {
2874
2810
    Item *param_1= item_list->pop();
2875
 
    func= new (thd->mem_root) Item_func_unix_timestamp(param_1);
 
2811
    func= new (session->mem_root) Item_func_unix_timestamp(param_1);
2876
2812
    break;
2877
2813
  }
2878
2814
  default:
2889
2825
Create_func_uuid Create_func_uuid::s_singleton;
2890
2826
 
2891
2827
Item*
2892
 
Create_func_uuid::create(THD *thd)
 
2828
Create_func_uuid::create(Session *session)
2893
2829
{
2894
 
  thd->lex->set_stmt_unsafe();
2895
 
  return new (thd->mem_root) Item_func_uuid();
 
2830
  return new (session->mem_root) Item_func_uuid();
2896
2831
}
2897
2832
 
2898
2833
 
2899
2834
Create_func_version Create_func_version::s_singleton;
2900
2835
 
2901
2836
Item*
2902
 
Create_func_version::create(THD *thd)
 
2837
Create_func_version::create(Session *session)
2903
2838
{
2904
 
  return new (thd->mem_root) Item_static_string_func("version()",
2905
 
                                                     server_version,
2906
 
                                                     (uint) strlen(server_version),
2907
 
                                                     system_charset_info,
2908
 
                                                     DERIVATION_SYSCONST);
 
2839
  return new (session->mem_root) Item_static_string_func("version()",
 
2840
                                                         server_version,
 
2841
                                                         (uint32_t) strlen(server_version),
 
2842
                                                         system_charset_info,
 
2843
                                                         DERIVATION_SYSCONST);
2909
2844
}
2910
2845
 
2911
2846
 
2912
2847
Create_func_weekday Create_func_weekday::s_singleton;
2913
2848
 
2914
2849
Item*
2915
 
Create_func_weekday::create(THD *thd, Item *arg1)
2916
 
{
2917
 
  return new (thd->mem_root) Item_func_weekday(arg1, 0);
2918
 
}
2919
 
 
2920
 
 
2921
 
Create_func_weekofyear Create_func_weekofyear::s_singleton;
2922
 
 
2923
 
Item*
2924
 
Create_func_weekofyear::create(THD *thd, Item *arg1)
2925
 
{
2926
 
  Item *i1= new (thd->mem_root) Item_int((char*) "0", 3, 1);
2927
 
  return new (thd->mem_root) Item_func_week(arg1, i1);
2928
 
}
2929
 
 
2930
 
 
2931
 
Create_func_year_week Create_func_year_week::s_singleton;
2932
 
 
2933
 
Item*
2934
 
Create_func_year_week::create_native(THD *thd, LEX_STRING name,
2935
 
                                     List<Item> *item_list)
2936
 
{
2937
 
  Item *func= NULL;
2938
 
  int arg_count= 0;
2939
 
 
2940
 
  if (item_list != NULL)
2941
 
    arg_count= item_list->elements;
2942
 
 
2943
 
  switch (arg_count) {
2944
 
  case 1:
2945
 
  {
2946
 
    Item *param_1= item_list->pop();
2947
 
    Item *i0= new (thd->mem_root) Item_int((char*) "0", 0, 1);
2948
 
    func= new (thd->mem_root) Item_func_yearweek(param_1, i0);
2949
 
    break;
2950
 
  }
2951
 
  case 2:
2952
 
  {
2953
 
    Item *param_1= item_list->pop();
2954
 
    Item *param_2= item_list->pop();
2955
 
    func= new (thd->mem_root) Item_func_yearweek(param_1, param_2);
2956
 
    break;
2957
 
  }
2958
 
  default:
2959
 
  {
2960
 
    my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2961
 
    break;
2962
 
  }
2963
 
  }
2964
 
 
2965
 
  return func;
2966
 
}
2967
 
 
 
2850
Create_func_weekday::create(Session *session, Item *arg1)
 
2851
{
 
2852
  return new (session->mem_root) Item_func_weekday(arg1, 0);
 
2853
}
2968
2854
 
2969
2855
struct Native_func_registry
2970
2856
{
2985
2871
{
2986
2872
  { { C_STRING_WITH_LEN("ABS") }, BUILDER(Create_func_abs)},
2987
2873
  { { C_STRING_WITH_LEN("ACOS") }, BUILDER(Create_func_acos)},
2988
 
  { { C_STRING_WITH_LEN("ADDTIME") }, BUILDER(Create_func_addtime)},
2989
2874
  { { C_STRING_WITH_LEN("ASIN") }, BUILDER(Create_func_asin)},
2990
2875
  { { C_STRING_WITH_LEN("ATAN") }, BUILDER(Create_func_atan)},
2991
2876
  { { C_STRING_WITH_LEN("ATAN2") }, BUILDER(Create_func_atan)},
3041
2926
  { { C_STRING_WITH_LEN("LPAD") }, BUILDER(Create_func_lpad)},
3042
2927
  { { C_STRING_WITH_LEN("LTRIM") }, BUILDER(Create_func_ltrim)},
3043
2928
  { { C_STRING_WITH_LEN("MAKEDATE") }, BUILDER(Create_func_makedate)},
3044
 
  { { C_STRING_WITH_LEN("MAKETIME") }, BUILDER(Create_func_maketime)},
3045
2929
  { { C_STRING_WITH_LEN("MAKE_SET") }, BUILDER(Create_func_make_set)},
3046
 
  { { C_STRING_WITH_LEN("MASTER_POS_WAIT") }, BUILDER(Create_func_master_pos_wait)},
3047
2930
  { { C_STRING_WITH_LEN("MONTHNAME") }, BUILDER(Create_func_monthname)},
3048
2931
  { { C_STRING_WITH_LEN("NULLIF") }, BUILDER(Create_func_nullif)},
3049
2932
  { { C_STRING_WITH_LEN("OCT") }, BUILDER(Create_func_oct)},
3061
2944
  { { C_STRING_WITH_LEN("ROW_COUNT") }, BUILDER(Create_func_row_count)},
3062
2945
  { { C_STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad)},
3063
2946
  { { C_STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim)},
3064
 
  { { C_STRING_WITH_LEN("SEC_TO_TIME") }, BUILDER(Create_func_sec_to_time)},
3065
2947
  { { C_STRING_WITH_LEN("SIGN") }, BUILDER(Create_func_sign)},
3066
2948
  { { C_STRING_WITH_LEN("SIN") }, BUILDER(Create_func_sin)},
3067
2949
  { { C_STRING_WITH_LEN("SPACE") }, BUILDER(Create_func_space)},
3068
2950
  { { C_STRING_WITH_LEN("SQRT") }, BUILDER(Create_func_sqrt)},
3069
2951
  { { C_STRING_WITH_LEN("STRCMP") }, BUILDER(Create_func_strcmp)},
3070
 
  { { C_STRING_WITH_LEN("STR_TO_DATE") }, BUILDER(Create_func_str_to_date)},
3071
2952
  { { C_STRING_WITH_LEN("SUBSTRING_INDEX") }, BUILDER(Create_func_substr_index)},
3072
 
  { { C_STRING_WITH_LEN("SUBTIME") }, BUILDER(Create_func_subtime)},
3073
2953
  { { C_STRING_WITH_LEN("TAN") }, BUILDER(Create_func_tan)},
3074
 
  { { C_STRING_WITH_LEN("TIMEDIFF") }, BUILDER(Create_func_timediff)},
3075
2954
  { { C_STRING_WITH_LEN("TIME_FORMAT") }, BUILDER(Create_func_time_format)},
3076
 
  { { C_STRING_WITH_LEN("TIME_TO_SEC") }, BUILDER(Create_func_time_to_sec)},
3077
2955
  { { C_STRING_WITH_LEN("TO_DAYS") }, BUILDER(Create_func_to_days)},
3078
2956
  { { C_STRING_WITH_LEN("UCASE") }, BUILDER(Create_func_ucase)},
3079
2957
  { { C_STRING_WITH_LEN("UNHEX") }, BUILDER(Create_func_unhex)},
3082
2960
  { { C_STRING_WITH_LEN("UUID") }, BUILDER(Create_func_uuid)},
3083
2961
  { { C_STRING_WITH_LEN("VERSION") }, BUILDER(Create_func_version)},
3084
2962
  { { C_STRING_WITH_LEN("WEEKDAY") }, BUILDER(Create_func_weekday)},
3085
 
  { { C_STRING_WITH_LEN("WEEKOFYEAR") }, BUILDER(Create_func_weekofyear)},
3086
 
  { { C_STRING_WITH_LEN("YEARWEEK") }, BUILDER(Create_func_year_week)},
3087
2963
 
3088
2964
  { {0, 0}, NULL}
3089
2965
};
3090
2966
 
3091
 
static HASH native_functions_hash;
3092
 
 
3093
 
extern "C" uchar*
3094
 
get_native_fct_hash_key(const uchar *buff, size_t *length,
3095
 
                        bool /* unused */)
3096
 
{
3097
 
  Native_func_registry *func= (Native_func_registry*) buff;
3098
 
  *length= func->name.length;
3099
 
  return (uchar*) func->name.str;
3100
 
}
 
2967
static map<string, Native_func_registry *> native_functions_map;
3101
2968
 
3102
2969
/*
3103
2970
  Load the hash table for native functions.
3107
2974
 
3108
2975
int item_create_init()
3109
2976
{
 
2977
  string func_name;
 
2978
 
3110
2979
  Native_func_registry *func;
3111
 
 
3112
 
  if (hash_init(& native_functions_hash,
3113
 
                system_charset_info,
3114
 
                array_elements(func_array),
3115
 
                0,
3116
 
                0,
3117
 
                (hash_get_key) get_native_fct_hash_key,
3118
 
                NULL,                          /* Nothing to free */
3119
 
                MYF(0)))
3120
 
    return(1);
3121
 
 
3122
2980
  for (func= func_array; func->builder != NULL; func++)
3123
2981
  {
3124
 
    if (my_hash_insert(& native_functions_hash, (uchar*) func))
3125
 
      return(1);
 
2982
    func_name.assign(func->name.str, func->name.length);
 
2983
    transform(func_name.begin(), func_name.end(), func_name.begin(), ::tolower);
 
2984
 
 
2985
    native_functions_map[func_name]= func;
3126
2986
  }
3127
2987
 
3128
 
  return(0);
3129
 
}
3130
 
 
3131
 
/*
3132
 
  Empty the hash table for native functions.
3133
 
  Note: this code is not thread safe, and is intended to be used at server
3134
 
  shutdown only (after thread requests have been executed).
3135
 
*/
3136
 
 
3137
 
void item_create_cleanup()
3138
 
{
3139
 
  hash_free(& native_functions_hash);
3140
 
  return;
3141
 
}
 
2988
  return 0;
 
2989
}
 
2990
 
3142
2991
 
3143
2992
Create_func *
3144
 
find_native_function_builder(THD *thd __attribute__((unused)),
3145
 
                             LEX_STRING name)
 
2993
find_native_function_builder(LEX_STRING name)
3146
2994
{
3147
2995
  Native_func_registry *func;
3148
2996
  Create_func *builder= NULL;
3149
2997
 
3150
 
  /* Thread safe */
3151
 
  func= (Native_func_registry*) hash_search(& native_functions_hash,
3152
 
                                            (uchar*) name.str,
3153
 
                                             name.length);
3154
 
 
3155
 
  if (func)
 
2998
  string func_name(name.str, name.length);
 
2999
  transform(func_name.begin(), func_name.end(), func_name.begin(), ::tolower);
 
3000
 
 
3001
  map<string, Native_func_registry *>::iterator func_iter=
 
3002
    native_functions_map.find(func_name);
 
3003
 
 
3004
  if (func_iter != native_functions_map.end())
3156
3005
  {
 
3006
    func= (*func_iter).second;
3157
3007
    builder= func->builder;
3158
3008
  }
3159
3009
 
3162
3012
 
3163
3013
 
3164
3014
Item*
3165
 
create_func_char_cast(THD *thd, Item *a, int len, const CHARSET_INFO * const cs)
 
3015
create_func_char_cast(Session *session, Item *a, int len, const CHARSET_INFO * const cs)
3166
3016
{
3167
 
  const CHARSET_INFO * const real_cs= (cs ? cs : thd->variables.collation_connection);
3168
 
  return new (thd->mem_root) Item_char_typecast(a, len, real_cs);
 
3017
  const CHARSET_INFO * const real_cs= (cs ? cs : session->variables.getCollation());
 
3018
  return new (session->mem_root) Item_char_typecast(a, len, real_cs);
3169
3019
}
3170
3020
 
3171
3021
 
3172
3022
Item *
3173
 
create_func_cast(THD *thd, Item *a, Cast_target cast_type,
 
3023
create_func_cast(Session *session, Item *a, Cast_target cast_type,
3174
3024
                 const char *c_len, const char *c_dec,
3175
3025
                 const CHARSET_INFO * const cs)
3176
3026
{
3177
3027
  Item *res;
3178
3028
  uint32_t len;
3179
 
  uint dec;
 
3029
  uint32_t dec;
3180
3030
 
3181
3031
  switch (cast_type) {
3182
3032
  case ITEM_CAST_BINARY:
3183
 
    res= new (thd->mem_root) Item_func_binary(a);
 
3033
    res= new (session->mem_root) Item_func_binary(a);
3184
3034
    break;
3185
3035
  case ITEM_CAST_SIGNED_INT:
3186
 
    res= new (thd->mem_root) Item_func_signed(a);
 
3036
    res= new (session->mem_root) Item_func_signed(a);
3187
3037
    break;
3188
3038
  case ITEM_CAST_UNSIGNED_INT:
3189
 
    res= new (thd->mem_root) Item_func_unsigned(a);
 
3039
    res= new (session->mem_root) Item_func_unsigned(a);
3190
3040
    break;
3191
3041
  case ITEM_CAST_DATE:
3192
 
    res= new (thd->mem_root) Item_date_typecast(a);
3193
 
    break;
3194
 
  case ITEM_CAST_TIME:
3195
 
    res= new (thd->mem_root) Item_time_typecast(a);
 
3042
    res= new (session->mem_root) Item_date_typecast(a);
3196
3043
    break;
3197
3044
  case ITEM_CAST_DATETIME:
3198
 
    res= new (thd->mem_root) Item_datetime_typecast(a);
 
3045
    res= new (session->mem_root) Item_datetime_typecast(a);
3199
3046
    break;
3200
3047
  case ITEM_CAST_DECIMAL:
3201
3048
  {
3219
3066
               DECIMAL_MAX_SCALE);
3220
3067
      return 0;
3221
3068
    }
3222
 
    res= new (thd->mem_root) Item_decimal_typecast(a, len, dec);
 
3069
    res= new (session->mem_root) Item_decimal_typecast(a, len, dec);
3223
3070
    break;
3224
3071
  }
3225
3072
  case ITEM_CAST_CHAR:
3226
3073
  {
3227
3074
    len= c_len ? atoi(c_len) : -1;
3228
 
    res= create_func_char_cast(thd, a, len, cs);
 
3075
    res= create_func_char_cast(session, a, len, cs);
3229
3076
    break;
3230
3077
  }
3231
3078
  default: