~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_create.cc

  • Committer: Monty Taylor
  • Date: 2008-10-23 23:53:49 UTC
  • mto: This revision was merged to the branch mainline in revision 557.
  • Revision ID: monty@inaugust.com-20081023235349-317wgwqwgccuacmq
SplitĀ outĀ nested_join.h.

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/error.h>
24
25
 
25
26
/*
26
27
=============================================================================
39
40
class Create_native_func : public Create_func
40
41
{
41
42
public:
42
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
 
43
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
43
44
 
44
45
  /**
45
46
    Builder method, with no arguments.
46
 
    @param thd The current thread
 
47
    @param session The current thread
47
48
    @param name The native function name
48
49
    @param item_list The function parameters, none of which are named
49
50
    @return An item representing the function call
50
51
  */
51
 
  virtual Item *create_native(THD *thd, LEX_STRING name,
 
52
  virtual Item *create_native(Session *session, LEX_STRING name,
52
53
                              List<Item> *item_list) = 0;
53
54
 
54
55
protected:
66
67
class Create_func_arg0 : public Create_func
67
68
{
68
69
public:
69
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
 
70
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
70
71
 
71
72
  /**
72
73
    Builder method, with no arguments.
73
 
    @param thd The current thread
 
74
    @param session The current thread
74
75
    @return An item representing the function call
75
76
  */
76
 
  virtual Item *create(THD *thd) = 0;
 
77
  virtual Item *create(Session *session) = 0;
77
78
 
78
79
protected:
79
80
  /** Constructor. */
90
91
class Create_func_arg1 : public Create_func
91
92
{
92
93
public:
93
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
 
94
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
94
95
 
95
96
  /**
96
97
    Builder method, with one argument.
97
 
    @param thd The current thread
 
98
    @param session The current thread
98
99
    @param arg1 The first argument of the function
99
100
    @return An item representing the function call
100
101
  */
101
 
  virtual Item *create(THD *thd, Item *arg1) = 0;
 
102
  virtual Item *create(Session *session, Item *arg1) = 0;
102
103
 
103
104
protected:
104
105
  /** Constructor. */
115
116
class Create_func_arg2 : public Create_func
116
117
{
117
118
public:
118
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
 
119
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
119
120
 
120
121
  /**
121
122
    Builder method, with two arguments.
122
 
    @param thd The current thread
 
123
    @param session The current thread
123
124
    @param arg1 The first argument of the function
124
125
    @param arg2 The second argument of the function
125
126
    @return An item representing the function call
126
127
  */
127
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2) = 0;
 
128
  virtual Item *create(Session *session, Item *arg1, Item *arg2) = 0;
128
129
 
129
130
protected:
130
131
  /** Constructor. */
141
142
class Create_func_arg3 : public Create_func
142
143
{
143
144
public:
144
 
  virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
 
145
  virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
145
146
 
146
147
  /**
147
148
    Builder method, with three arguments.
148
 
    @param thd The current thread
 
149
    @param session The current thread
149
150
    @param arg1 The first argument of the function
150
151
    @param arg2 The second argument of the function
151
152
    @param arg3 The third argument of the function
152
153
    @return An item representing the function call
153
154
  */
154
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3) = 0;
 
155
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3) = 0;
155
156
 
156
157
protected:
157
158
  /** Constructor. */
174
175
class Create_func_abs : public Create_func_arg1
175
176
{
176
177
public:
177
 
  virtual Item *create(THD *thd, Item *arg1);
 
178
  virtual Item *create(Session *session, Item *arg1);
178
179
 
179
180
  static Create_func_abs s_singleton;
180
181
 
187
188
class Create_func_acos : public Create_func_arg1
188
189
{
189
190
public:
190
 
  virtual Item *create(THD *thd, Item *arg1);
 
191
  virtual Item *create(Session *session, Item *arg1);
191
192
 
192
193
  static Create_func_acos s_singleton;
193
194
 
200
201
class Create_func_addtime : public Create_func_arg2
201
202
{
202
203
public:
203
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
204
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
204
205
 
205
206
  static Create_func_addtime s_singleton;
206
207
 
213
214
class Create_func_asin : public Create_func_arg1
214
215
{
215
216
public:
216
 
  virtual Item *create(THD *thd, Item *arg1);
 
217
  virtual Item *create(Session *session, Item *arg1);
217
218
 
218
219
  static Create_func_asin s_singleton;
219
220
 
226
227
class Create_func_atan : public Create_native_func
227
228
{
228
229
public:
229
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
230
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
230
231
 
231
232
  static Create_func_atan s_singleton;
232
233
 
239
240
class Create_func_benchmark : public Create_func_arg2
240
241
{
241
242
public:
242
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
243
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
243
244
 
244
245
  static Create_func_benchmark s_singleton;
245
246
 
252
253
class Create_func_bin : public Create_func_arg1
253
254
{
254
255
public:
255
 
  virtual Item *create(THD *thd, Item *arg1);
 
256
  virtual Item *create(Session *session, Item *arg1);
256
257
 
257
258
  static Create_func_bin s_singleton;
258
259
 
265
266
class Create_func_bit_count : public Create_func_arg1
266
267
{
267
268
public:
268
 
  virtual Item *create(THD *thd, Item *arg1);
 
269
  virtual Item *create(Session *session, Item *arg1);
269
270
 
270
271
  static Create_func_bit_count s_singleton;
271
272
 
278
279
class Create_func_bit_length : public Create_func_arg1
279
280
{
280
281
public:
281
 
  virtual Item *create(THD *thd, Item *arg1);
 
282
  virtual Item *create(Session *session, Item *arg1);
282
283
 
283
284
  static Create_func_bit_length s_singleton;
284
285
 
291
292
class Create_func_ceiling : public Create_func_arg1
292
293
{
293
294
public:
294
 
  virtual Item *create(THD *thd, Item *arg1);
 
295
  virtual Item *create(Session *session, Item *arg1);
295
296
 
296
297
  static Create_func_ceiling s_singleton;
297
298
 
304
305
class Create_func_char_length : public Create_func_arg1
305
306
{
306
307
public:
307
 
  virtual Item *create(THD *thd, Item *arg1);
 
308
  virtual Item *create(Session *session, Item *arg1);
308
309
 
309
310
  static Create_func_char_length s_singleton;
310
311
 
317
318
class Create_func_coercibility : public Create_func_arg1
318
319
{
319
320
public:
320
 
  virtual Item *create(THD *thd, Item *arg1);
 
321
  virtual Item *create(Session *session, Item *arg1);
321
322
 
322
323
  static Create_func_coercibility s_singleton;
323
324
 
330
331
class Create_func_concat : public Create_native_func
331
332
{
332
333
public:
333
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
334
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
334
335
 
335
336
  static Create_func_concat s_singleton;
336
337
 
343
344
class Create_func_concat_ws : public Create_native_func
344
345
{
345
346
public:
346
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
347
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
347
348
 
348
349
  static Create_func_concat_ws s_singleton;
349
350
 
356
357
class Create_func_connection_id : public Create_func_arg0
357
358
{
358
359
public:
359
 
  virtual Item *create(THD *thd);
 
360
  virtual Item *create(Session *session);
360
361
 
361
362
  static Create_func_connection_id s_singleton;
362
363
 
369
370
class Create_func_conv : public Create_func_arg3
370
371
{
371
372
public:
372
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
 
373
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
373
374
 
374
375
  static Create_func_conv s_singleton;
375
376
 
382
383
class Create_func_cos : public Create_func_arg1
383
384
{
384
385
public:
385
 
  virtual Item *create(THD *thd, Item *arg1);
 
386
  virtual Item *create(Session *session, Item *arg1);
386
387
 
387
388
  static Create_func_cos s_singleton;
388
389
 
395
396
class Create_func_cot : public Create_func_arg1
396
397
{
397
398
public:
398
 
  virtual Item *create(THD *thd, Item *arg1);
 
399
  virtual Item *create(Session *session, Item *arg1);
399
400
 
400
401
  static Create_func_cot s_singleton;
401
402
 
407
408
class Create_func_date_format : public Create_func_arg2
408
409
{
409
410
public:
410
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
411
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
411
412
 
412
413
  static Create_func_date_format s_singleton;
413
414
 
420
421
class Create_func_datediff : public Create_func_arg2
421
422
{
422
423
public:
423
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
424
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
424
425
 
425
426
  static Create_func_datediff s_singleton;
426
427
 
433
434
class Create_func_dayname : public Create_func_arg1
434
435
{
435
436
public:
436
 
  virtual Item *create(THD *thd, Item *arg1);
 
437
  virtual Item *create(Session *session, Item *arg1);
437
438
 
438
439
  static Create_func_dayname s_singleton;
439
440
 
446
447
class Create_func_dayofmonth : public Create_func_arg1
447
448
{
448
449
public:
449
 
  virtual Item *create(THD *thd, Item *arg1);
 
450
  virtual Item *create(Session *session, Item *arg1);
450
451
 
451
452
  static Create_func_dayofmonth s_singleton;
452
453
 
459
460
class Create_func_dayofweek : public Create_func_arg1
460
461
{
461
462
public:
462
 
  virtual Item *create(THD *thd, Item *arg1);
 
463
  virtual Item *create(Session *session, Item *arg1);
463
464
 
464
465
  static Create_func_dayofweek s_singleton;
465
466
 
472
473
class Create_func_dayofyear : public Create_func_arg1
473
474
{
474
475
public:
475
 
  virtual Item *create(THD *thd, Item *arg1);
 
476
  virtual Item *create(Session *session, Item *arg1);
476
477
 
477
478
  static Create_func_dayofyear s_singleton;
478
479
 
485
486
class Create_func_decode : public Create_func_arg2
486
487
{
487
488
public:
488
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
489
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
489
490
 
490
491
  static Create_func_decode s_singleton;
491
492
 
498
499
class Create_func_degrees : public Create_func_arg1
499
500
{
500
501
public:
501
 
  virtual Item *create(THD *thd, Item *arg1);
 
502
  virtual Item *create(Session *session, Item *arg1);
502
503
 
503
504
  static Create_func_degrees s_singleton;
504
505
 
511
512
class Create_func_elt : public Create_native_func
512
513
{
513
514
public:
514
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
515
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
515
516
 
516
517
  static Create_func_elt s_singleton;
517
518
 
524
525
class Create_func_exp : public Create_func_arg1
525
526
{
526
527
public:
527
 
  virtual Item *create(THD *thd, Item *arg1);
 
528
  virtual Item *create(Session *session, Item *arg1);
528
529
 
529
530
  static Create_func_exp s_singleton;
530
531
 
537
538
class Create_func_export_set : public Create_native_func
538
539
{
539
540
public:
540
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
541
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
541
542
 
542
543
  static Create_func_export_set s_singleton;
543
544
 
550
551
class Create_func_field : public Create_native_func
551
552
{
552
553
public:
553
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
554
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
554
555
 
555
556
  static Create_func_field s_singleton;
556
557
 
563
564
class Create_func_find_in_set : public Create_func_arg2
564
565
{
565
566
public:
566
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
567
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
567
568
 
568
569
  static Create_func_find_in_set s_singleton;
569
570
 
576
577
class Create_func_floor : public Create_func_arg1
577
578
{
578
579
public:
579
 
  virtual Item *create(THD *thd, Item *arg1);
 
580
  virtual Item *create(Session *session, Item *arg1);
580
581
 
581
582
  static Create_func_floor s_singleton;
582
583
 
589
590
class Create_func_format : public Create_func_arg2
590
591
{
591
592
public:
592
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
593
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
593
594
 
594
595
  static Create_func_format s_singleton;
595
596
 
602
603
class Create_func_found_rows : public Create_func_arg0
603
604
{
604
605
public:
605
 
  virtual Item *create(THD *thd);
 
606
  virtual Item *create(Session *session);
606
607
 
607
608
  static Create_func_found_rows s_singleton;
608
609
 
615
616
class Create_func_from_days : public Create_func_arg1
616
617
{
617
618
public:
618
 
  virtual Item *create(THD *thd, Item *arg1);
 
619
  virtual Item *create(Session *session, Item *arg1);
619
620
 
620
621
  static Create_func_from_days s_singleton;
621
622
 
628
629
class Create_func_from_unixtime : public Create_native_func
629
630
{
630
631
public:
631
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
632
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
632
633
 
633
634
  static Create_func_from_unixtime s_singleton;
634
635
 
641
642
class Create_func_greatest : public Create_native_func
642
643
{
643
644
public:
644
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
645
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
645
646
 
646
647
  static Create_func_greatest s_singleton;
647
648
 
654
655
class Create_func_hex : public Create_func_arg1
655
656
{
656
657
public:
657
 
  virtual Item *create(THD *thd, Item *arg1);
 
658
  virtual Item *create(Session *session, Item *arg1);
658
659
 
659
660
  static Create_func_hex s_singleton;
660
661
 
667
668
class Create_func_ifnull : public Create_func_arg2
668
669
{
669
670
public:
670
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
671
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
671
672
 
672
673
  static Create_func_ifnull s_singleton;
673
674
 
680
681
class Create_func_instr : public Create_func_arg2
681
682
{
682
683
public:
683
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
684
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
684
685
 
685
686
  static Create_func_instr s_singleton;
686
687
 
693
694
class Create_func_isnull : public Create_func_arg1
694
695
{
695
696
public:
696
 
  virtual Item *create(THD *thd, Item *arg1);
 
697
  virtual Item *create(Session *session, Item *arg1);
697
698
 
698
699
  static Create_func_isnull s_singleton;
699
700
 
706
707
class Create_func_last_day : public Create_func_arg1
707
708
{
708
709
public:
709
 
  virtual Item *create(THD *thd, Item *arg1);
 
710
  virtual Item *create(Session *session, Item *arg1);
710
711
 
711
712
  static Create_func_last_day s_singleton;
712
713
 
719
720
class Create_func_last_insert_id : public Create_native_func
720
721
{
721
722
public:
722
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
723
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
723
724
 
724
725
  static Create_func_last_insert_id s_singleton;
725
726
 
732
733
class Create_func_lcase : public Create_func_arg1
733
734
{
734
735
public:
735
 
  virtual Item *create(THD *thd, Item *arg1);
 
736
  virtual Item *create(Session *session, Item *arg1);
736
737
 
737
738
  static Create_func_lcase s_singleton;
738
739
 
745
746
class Create_func_least : public Create_native_func
746
747
{
747
748
public:
748
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
749
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
749
750
 
750
751
  static Create_func_least s_singleton;
751
752
 
758
759
class Create_func_length : public Create_func_arg1
759
760
{
760
761
public:
761
 
  virtual Item *create(THD *thd, Item *arg1);
 
762
  virtual Item *create(Session *session, Item *arg1);
762
763
 
763
764
  static Create_func_length s_singleton;
764
765
 
771
772
class Create_func_ln : public Create_func_arg1
772
773
{
773
774
public:
774
 
  virtual Item *create(THD *thd, Item *arg1);
 
775
  virtual Item *create(Session *session, Item *arg1);
775
776
 
776
777
  static Create_func_ln s_singleton;
777
778
 
784
785
class Create_func_load_file : public Create_func_arg1
785
786
{
786
787
public:
787
 
  virtual Item *create(THD *thd, Item *arg1);
 
788
  virtual Item *create(Session *session, Item *arg1);
788
789
 
789
790
  static Create_func_load_file s_singleton;
790
791
 
797
798
class Create_func_locate : public Create_native_func
798
799
{
799
800
public:
800
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
801
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
801
802
 
802
803
  static Create_func_locate s_singleton;
803
804
 
810
811
class Create_func_log : public Create_native_func
811
812
{
812
813
public:
813
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
814
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
814
815
 
815
816
  static Create_func_log s_singleton;
816
817
 
823
824
class Create_func_log10 : public Create_func_arg1
824
825
{
825
826
public:
826
 
  virtual Item *create(THD *thd, Item *arg1);
 
827
  virtual Item *create(Session *session, Item *arg1);
827
828
 
828
829
  static Create_func_log10 s_singleton;
829
830
 
836
837
class Create_func_log2 : public Create_func_arg1
837
838
{
838
839
public:
839
 
  virtual Item *create(THD *thd, Item *arg1);
 
840
  virtual Item *create(Session *session, Item *arg1);
840
841
 
841
842
  static Create_func_log2 s_singleton;
842
843
 
849
850
class Create_func_lpad : public Create_func_arg3
850
851
{
851
852
public:
852
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
 
853
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
853
854
 
854
855
  static Create_func_lpad s_singleton;
855
856
 
862
863
class Create_func_ltrim : public Create_func_arg1
863
864
{
864
865
public:
865
 
  virtual Item *create(THD *thd, Item *arg1);
 
866
  virtual Item *create(Session *session, Item *arg1);
866
867
 
867
868
  static Create_func_ltrim s_singleton;
868
869
 
875
876
class Create_func_makedate : public Create_func_arg2
876
877
{
877
878
public:
878
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
879
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
879
880
 
880
881
  static Create_func_makedate s_singleton;
881
882
 
888
889
class Create_func_maketime : public Create_func_arg3
889
890
{
890
891
public:
891
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
 
892
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
892
893
 
893
894
  static Create_func_maketime s_singleton;
894
895
 
901
902
class Create_func_make_set : public Create_native_func
902
903
{
903
904
public:
904
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
905
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
905
906
 
906
907
  static Create_func_make_set s_singleton;
907
908
 
914
915
class Create_func_master_pos_wait : public Create_native_func
915
916
{
916
917
public:
917
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
918
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
918
919
 
919
920
  static Create_func_master_pos_wait s_singleton;
920
921
 
926
927
class Create_func_monthname : public Create_func_arg1
927
928
{
928
929
public:
929
 
  virtual Item *create(THD *thd, Item *arg1);
 
930
  virtual Item *create(Session *session, Item *arg1);
930
931
 
931
932
  static Create_func_monthname s_singleton;
932
933
 
939
940
class Create_func_name_const : public Create_func_arg2
940
941
{
941
942
public:
942
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
943
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
943
944
 
944
945
  static Create_func_name_const s_singleton;
945
946
 
952
953
class Create_func_nullif : public Create_func_arg2
953
954
{
954
955
public:
955
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
956
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
956
957
 
957
958
  static Create_func_nullif s_singleton;
958
959
 
965
966
class Create_func_oct : public Create_func_arg1
966
967
{
967
968
public:
968
 
  virtual Item *create(THD *thd, Item *arg1);
 
969
  virtual Item *create(Session *session, Item *arg1);
969
970
 
970
971
  static Create_func_oct s_singleton;
971
972
 
978
979
class Create_func_ord : public Create_func_arg1
979
980
{
980
981
public:
981
 
  virtual Item *create(THD *thd, Item *arg1);
 
982
  virtual Item *create(Session *session, Item *arg1);
982
983
 
983
984
  static Create_func_ord s_singleton;
984
985
 
991
992
class Create_func_period_add : public Create_func_arg2
992
993
{
993
994
public:
994
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
995
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
995
996
 
996
997
  static Create_func_period_add s_singleton;
997
998
 
1004
1005
class Create_func_period_diff : public Create_func_arg2
1005
1006
{
1006
1007
public:
1007
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
1008
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1008
1009
 
1009
1010
  static Create_func_period_diff s_singleton;
1010
1011
 
1017
1018
class Create_func_pi : public Create_func_arg0
1018
1019
{
1019
1020
public:
1020
 
  virtual Item *create(THD *thd);
 
1021
  virtual Item *create(Session *session);
1021
1022
 
1022
1023
  static Create_func_pi s_singleton;
1023
1024
 
1030
1031
class Create_func_pow : public Create_func_arg2
1031
1032
{
1032
1033
public:
1033
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
1034
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1034
1035
 
1035
1036
  static Create_func_pow s_singleton;
1036
1037
 
1043
1044
class Create_func_quote : public Create_func_arg1
1044
1045
{
1045
1046
public:
1046
 
  virtual Item *create(THD *thd, Item *arg1);
 
1047
  virtual Item *create(Session *session, Item *arg1);
1047
1048
 
1048
1049
  static Create_func_quote s_singleton;
1049
1050
 
1056
1057
class Create_func_radians : public Create_func_arg1
1057
1058
{
1058
1059
public:
1059
 
  virtual Item *create(THD *thd, Item *arg1);
 
1060
  virtual Item *create(Session *session, Item *arg1);
1060
1061
 
1061
1062
  static Create_func_radians s_singleton;
1062
1063
 
1069
1070
class Create_func_rand : public Create_native_func
1070
1071
{
1071
1072
public:
1072
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
1073
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1073
1074
 
1074
1075
  static Create_func_rand s_singleton;
1075
1076
 
1082
1083
class Create_func_round : public Create_native_func
1083
1084
{
1084
1085
public:
1085
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
1086
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1086
1087
 
1087
1088
  static Create_func_round s_singleton;
1088
1089
 
1095
1096
class Create_func_row_count : public Create_func_arg0
1096
1097
{
1097
1098
public:
1098
 
  virtual Item *create(THD *thd);
 
1099
  virtual Item *create(Session *session);
1099
1100
 
1100
1101
  static Create_func_row_count s_singleton;
1101
1102
 
1108
1109
class Create_func_rpad : public Create_func_arg3
1109
1110
{
1110
1111
public:
1111
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
 
1112
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
1112
1113
 
1113
1114
  static Create_func_rpad s_singleton;
1114
1115
 
1121
1122
class Create_func_rtrim : public Create_func_arg1
1122
1123
{
1123
1124
public:
1124
 
  virtual Item *create(THD *thd, Item *arg1);
 
1125
  virtual Item *create(Session *session, Item *arg1);
1125
1126
 
1126
1127
  static Create_func_rtrim s_singleton;
1127
1128
 
1134
1135
class Create_func_sec_to_time : public Create_func_arg1
1135
1136
{
1136
1137
public:
1137
 
  virtual Item *create(THD *thd, Item *arg1);
 
1138
  virtual Item *create(Session *session, Item *arg1);
1138
1139
 
1139
1140
  static Create_func_sec_to_time s_singleton;
1140
1141
 
1147
1148
class Create_func_sign : public Create_func_arg1
1148
1149
{
1149
1150
public:
1150
 
  virtual Item *create(THD *thd, Item *arg1);
 
1151
  virtual Item *create(Session *session, Item *arg1);
1151
1152
 
1152
1153
  static Create_func_sign s_singleton;
1153
1154
 
1160
1161
class Create_func_sin : public Create_func_arg1
1161
1162
{
1162
1163
public:
1163
 
  virtual Item *create(THD *thd, Item *arg1);
 
1164
  virtual Item *create(Session *session, Item *arg1);
1164
1165
 
1165
1166
  static Create_func_sin s_singleton;
1166
1167
 
1173
1174
class Create_func_space : public Create_func_arg1
1174
1175
{
1175
1176
public:
1176
 
  virtual Item *create(THD *thd, Item *arg1);
 
1177
  virtual Item *create(Session *session, Item *arg1);
1177
1178
 
1178
1179
  static Create_func_space s_singleton;
1179
1180
 
1186
1187
class Create_func_sqrt : public Create_func_arg1
1187
1188
{
1188
1189
public:
1189
 
  virtual Item *create(THD *thd, Item *arg1);
 
1190
  virtual Item *create(Session *session, Item *arg1);
1190
1191
 
1191
1192
  static Create_func_sqrt s_singleton;
1192
1193
 
1199
1200
class Create_func_str_to_date : public Create_func_arg2
1200
1201
{
1201
1202
public:
1202
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
1203
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1203
1204
 
1204
1205
  static Create_func_str_to_date s_singleton;
1205
1206
 
1212
1213
class Create_func_strcmp : public Create_func_arg2
1213
1214
{
1214
1215
public:
1215
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
1216
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1216
1217
 
1217
1218
  static Create_func_strcmp s_singleton;
1218
1219
 
1225
1226
class Create_func_substr_index : public Create_func_arg3
1226
1227
{
1227
1228
public:
1228
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
 
1229
  virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
1229
1230
 
1230
1231
  static Create_func_substr_index s_singleton;
1231
1232
 
1238
1239
class Create_func_subtime : public Create_func_arg2
1239
1240
{
1240
1241
public:
1241
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
1242
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1242
1243
 
1243
1244
  static Create_func_subtime s_singleton;
1244
1245
 
1251
1252
class Create_func_tan : public Create_func_arg1
1252
1253
{
1253
1254
public:
1254
 
  virtual Item *create(THD *thd, Item *arg1);
 
1255
  virtual Item *create(Session *session, Item *arg1);
1255
1256
 
1256
1257
  static Create_func_tan s_singleton;
1257
1258
 
1264
1265
class Create_func_time_format : public Create_func_arg2
1265
1266
{
1266
1267
public:
1267
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
1268
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1268
1269
 
1269
1270
  static Create_func_time_format s_singleton;
1270
1271
 
1277
1278
class Create_func_time_to_sec : public Create_func_arg1
1278
1279
{
1279
1280
public:
1280
 
  virtual Item *create(THD *thd, Item *arg1);
 
1281
  virtual Item *create(Session *session, Item *arg1);
1281
1282
 
1282
1283
  static Create_func_time_to_sec s_singleton;
1283
1284
 
1290
1291
class Create_func_timediff : public Create_func_arg2
1291
1292
{
1292
1293
public:
1293
 
  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
 
1294
  virtual Item *create(Session *session, Item *arg1, Item *arg2);
1294
1295
 
1295
1296
  static Create_func_timediff s_singleton;
1296
1297
 
1303
1304
class Create_func_to_days : public Create_func_arg1
1304
1305
{
1305
1306
public:
1306
 
  virtual Item *create(THD *thd, Item *arg1);
 
1307
  virtual Item *create(Session *session, Item *arg1);
1307
1308
 
1308
1309
  static Create_func_to_days s_singleton;
1309
1310
 
1316
1317
class Create_func_ucase : public Create_func_arg1
1317
1318
{
1318
1319
public:
1319
 
  virtual Item *create(THD *thd, Item *arg1);
 
1320
  virtual Item *create(Session *session, Item *arg1);
1320
1321
 
1321
1322
  static Create_func_ucase s_singleton;
1322
1323
 
1329
1330
class Create_func_unhex : public Create_func_arg1
1330
1331
{
1331
1332
public:
1332
 
  virtual Item *create(THD *thd, Item *arg1);
 
1333
  virtual Item *create(Session *session, Item *arg1);
1333
1334
 
1334
1335
  static Create_func_unhex s_singleton;
1335
1336
 
1342
1343
class Create_func_unix_timestamp : public Create_native_func
1343
1344
{
1344
1345
public:
1345
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
1346
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1346
1347
 
1347
1348
  static Create_func_unix_timestamp s_singleton;
1348
1349
 
1355
1356
class Create_func_uuid : public Create_func_arg0
1356
1357
{
1357
1358
public:
1358
 
  virtual Item *create(THD *thd);
 
1359
  virtual Item *create(Session *session);
1359
1360
 
1360
1361
  static Create_func_uuid s_singleton;
1361
1362
 
1368
1369
class Create_func_version : public Create_func_arg0
1369
1370
{
1370
1371
public:
1371
 
  virtual Item *create(THD *thd);
 
1372
  virtual Item *create(Session *session);
1372
1373
 
1373
1374
  static Create_func_version s_singleton;
1374
1375
 
1381
1382
class Create_func_weekday : public Create_func_arg1
1382
1383
{
1383
1384
public:
1384
 
  virtual Item *create(THD *thd, Item *arg1);
 
1385
  virtual Item *create(Session *session, Item *arg1);
1385
1386
 
1386
1387
  static Create_func_weekday s_singleton;
1387
1388
 
1394
1395
class Create_func_weekofyear : public Create_func_arg1
1395
1396
{
1396
1397
public:
1397
 
  virtual Item *create(THD *thd, Item *arg1);
 
1398
  virtual Item *create(Session *session, Item *arg1);
1398
1399
 
1399
1400
  static Create_func_weekofyear s_singleton;
1400
1401
 
1407
1408
class Create_func_year_week : public Create_native_func
1408
1409
{
1409
1410
public:
1410
 
  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
 
1411
  virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1411
1412
 
1412
1413
  static Create_func_year_week s_singleton;
1413
1414
 
1450
1451
Create_udf_func Create_udf_func::s_singleton;
1451
1452
 
1452
1453
Item*
1453
 
Create_udf_func::create(THD *thd, LEX_STRING name, List<Item> *item_list)
 
1454
Create_udf_func::create(Session *session, LEX_STRING name, List<Item> *item_list)
1454
1455
{
1455
1456
  udf_func *udf= find_udf(name.str, name.length);
1456
1457
  assert(udf);
1457
 
  return create(thd, udf, item_list);
 
1458
  return create(session, udf, item_list);
1458
1459
}
1459
1460
 
1460
1461
 
1461
1462
Item*
1462
 
Create_udf_func::create(THD *thd, udf_func *udf, List<Item> *item_list)
 
1463
Create_udf_func::create(Session *session, udf_func *udf, List<Item> *item_list)
1463
1464
{
1464
1465
  Item_func *func= NULL;
1465
1466
  int arg_count= 0;
1467
1468
  if (item_list != NULL)
1468
1469
    arg_count= item_list->elements;
1469
1470
 
1470
 
  thd->lex->set_stmt_unsafe();
 
1471
  session->lex->set_stmt_unsafe();
1471
1472
 
1472
 
  func= udf->create_func(thd->mem_root);
 
1473
  func= udf->create_func(session->mem_root);
1473
1474
 
1474
1475
  func->set_arguments(*item_list);
1475
1476
 
1478
1479
 
1479
1480
 
1480
1481
Item*
1481
 
Create_native_func::create(THD *thd, LEX_STRING name, List<Item> *item_list)
 
1482
Create_native_func::create(Session *session, LEX_STRING name, List<Item> *item_list)
1482
1483
{
1483
1484
  if (has_named_parameters(item_list))
1484
1485
  {
1486
1487
    return NULL;
1487
1488
  }
1488
1489
 
1489
 
  return create_native(thd, name, item_list);
 
1490
  return create_native(session, name, item_list);
1490
1491
}
1491
1492
 
1492
1493
 
1493
1494
Item*
1494
 
Create_func_arg0::create(THD *thd, LEX_STRING name, List<Item> *item_list)
 
1495
Create_func_arg0::create(Session *session, LEX_STRING name, List<Item> *item_list)
1495
1496
{
1496
1497
  int arg_count= 0;
1497
1498
 
1504
1505
    return NULL;
1505
1506
  }
1506
1507
 
1507
 
  return create(thd);
 
1508
  return create(session);
1508
1509
}
1509
1510
 
1510
1511
 
1511
1512
Item*
1512
 
Create_func_arg1::create(THD *thd, LEX_STRING name, List<Item> *item_list)
 
1513
Create_func_arg1::create(Session *session, LEX_STRING name, List<Item> *item_list)
1513
1514
{
1514
1515
  int arg_count= 0;
1515
1516
 
1530
1531
    return NULL;
1531
1532
  }
1532
1533
 
1533
 
  return create(thd, param_1);
 
1534
  return create(session, param_1);
1534
1535
}
1535
1536
 
1536
1537
 
1537
1538
Item*
1538
 
Create_func_arg2::create(THD *thd, LEX_STRING name, List<Item> *item_list)
 
1539
Create_func_arg2::create(Session *session, LEX_STRING name, List<Item> *item_list)
1539
1540
{
1540
1541
  int arg_count= 0;
1541
1542
 
1558
1559
    return NULL;
1559
1560
  }
1560
1561
 
1561
 
  return create(thd, param_1, param_2);
 
1562
  return create(session, param_1, param_2);
1562
1563
}
1563
1564
 
1564
1565
 
1565
1566
Item*
1566
 
Create_func_arg3::create(THD *thd, LEX_STRING name, List<Item> *item_list)
 
1567
Create_func_arg3::create(Session *session, LEX_STRING name, List<Item> *item_list)
1567
1568
{
1568
1569
  int arg_count= 0;
1569
1570
 
1588
1589
    return NULL;
1589
1590
  }
1590
1591
 
1591
 
  return create(thd, param_1, param_2, param_3);
 
1592
  return create(session, param_1, param_2, param_3);
1592
1593
}
1593
1594
 
1594
1595
 
1595
1596
Create_func_abs Create_func_abs::s_singleton;
1596
1597
 
1597
1598
Item*
1598
 
Create_func_abs::create(THD *thd, Item *arg1)
 
1599
Create_func_abs::create(Session *session, Item *arg1)
1599
1600
{
1600
 
  return new (thd->mem_root) Item_func_abs(arg1);
 
1601
  return new (session->mem_root) Item_func_abs(arg1);
1601
1602
}
1602
1603
 
1603
1604
 
1604
1605
Create_func_acos Create_func_acos::s_singleton;
1605
1606
 
1606
1607
Item*
1607
 
Create_func_acos::create(THD *thd, Item *arg1)
 
1608
Create_func_acos::create(Session *session, Item *arg1)
1608
1609
{
1609
 
  return new (thd->mem_root) Item_func_acos(arg1);
 
1610
  return new (session->mem_root) Item_func_acos(arg1);
1610
1611
}
1611
1612
 
1612
1613
 
1613
1614
Create_func_addtime Create_func_addtime::s_singleton;
1614
1615
 
1615
1616
Item*
1616
 
Create_func_addtime::create(THD *thd, Item *arg1, Item *arg2)
 
1617
Create_func_addtime::create(Session *session, Item *arg1, Item *arg2)
1617
1618
{
1618
 
  return new (thd->mem_root) Item_func_add_time(arg1, arg2, 0, 0);
 
1619
  return new (session->mem_root) Item_func_add_time(arg1, arg2, 0, 0);
1619
1620
}
1620
1621
 
1621
1622
 
1622
1623
Create_func_asin Create_func_asin::s_singleton;
1623
1624
 
1624
1625
Item*
1625
 
Create_func_asin::create(THD *thd, Item *arg1)
 
1626
Create_func_asin::create(Session *session, Item *arg1)
1626
1627
{
1627
 
  return new (thd->mem_root) Item_func_asin(arg1);
 
1628
  return new (session->mem_root) Item_func_asin(arg1);
1628
1629
}
1629
1630
 
1630
1631
 
1631
1632
Create_func_atan Create_func_atan::s_singleton;
1632
1633
 
1633
1634
Item*
1634
 
Create_func_atan::create_native(THD *thd, LEX_STRING name,
 
1635
Create_func_atan::create_native(Session *session, LEX_STRING name,
1635
1636
                                List<Item> *item_list)
1636
1637
{
1637
1638
  Item* func= NULL;
1644
1645
  case 1:
1645
1646
  {
1646
1647
    Item *param_1= item_list->pop();
1647
 
    func= new (thd->mem_root) Item_func_atan(param_1);
 
1648
    func= new (session->mem_root) Item_func_atan(param_1);
1648
1649
    break;
1649
1650
  }
1650
1651
  case 2:
1651
1652
  {
1652
1653
    Item *param_1= item_list->pop();
1653
1654
    Item *param_2= item_list->pop();
1654
 
    func= new (thd->mem_root) Item_func_atan(param_1, param_2);
 
1655
    func= new (session->mem_root) Item_func_atan(param_1, param_2);
1655
1656
    break;
1656
1657
  }
1657
1658
  default:
1668
1669
Create_func_benchmark Create_func_benchmark::s_singleton;
1669
1670
 
1670
1671
Item*
1671
 
Create_func_benchmark::create(THD *thd, Item *arg1, Item *arg2)
 
1672
Create_func_benchmark::create(Session *session, Item *arg1, Item *arg2)
1672
1673
{
1673
 
  return new (thd->mem_root) Item_func_benchmark(arg1, arg2);
 
1674
  return new (session->mem_root) Item_func_benchmark(arg1, arg2);
1674
1675
}
1675
1676
 
1676
1677
 
1677
1678
Create_func_bin Create_func_bin::s_singleton;
1678
1679
 
1679
1680
Item*
1680
 
Create_func_bin::create(THD *thd, Item *arg1)
 
1681
Create_func_bin::create(Session *session, Item *arg1)
1681
1682
{
1682
 
  Item *i10= new (thd->mem_root) Item_int((int32_t) 10,2);
1683
 
  Item *i2= new (thd->mem_root) Item_int((int32_t) 2,1);
1684
 
  return new (thd->mem_root) Item_func_conv(arg1, i10, i2);
 
1683
  Item *i10= new (session->mem_root) Item_int((int32_t) 10,2);
 
1684
  Item *i2= new (session->mem_root) Item_int((int32_t) 2,1);
 
1685
  return new (session->mem_root) Item_func_conv(arg1, i10, i2);
1685
1686
}
1686
1687
 
1687
1688
 
1688
1689
Create_func_bit_count Create_func_bit_count::s_singleton;
1689
1690
 
1690
1691
Item*
1691
 
Create_func_bit_count::create(THD *thd, Item *arg1)
 
1692
Create_func_bit_count::create(Session *session, Item *arg1)
1692
1693
{
1693
 
  return new (thd->mem_root) Item_func_bit_count(arg1);
 
1694
  return new (session->mem_root) Item_func_bit_count(arg1);
1694
1695
}
1695
1696
 
1696
1697
 
1697
1698
Create_func_bit_length Create_func_bit_length::s_singleton;
1698
1699
 
1699
1700
Item*
1700
 
Create_func_bit_length::create(THD *thd, Item *arg1)
 
1701
Create_func_bit_length::create(Session *session, Item *arg1)
1701
1702
{
1702
 
  return new (thd->mem_root) Item_func_bit_length(arg1);
 
1703
  return new (session->mem_root) Item_func_bit_length(arg1);
1703
1704
}
1704
1705
 
1705
1706
 
1706
1707
Create_func_ceiling Create_func_ceiling::s_singleton;
1707
1708
 
1708
1709
Item*
1709
 
Create_func_ceiling::create(THD *thd, Item *arg1)
 
1710
Create_func_ceiling::create(Session *session, Item *arg1)
1710
1711
{
1711
 
  return new (thd->mem_root) Item_func_ceiling(arg1);
 
1712
  return new (session->mem_root) Item_func_ceiling(arg1);
1712
1713
}
1713
1714
 
1714
1715
 
1715
1716
Create_func_char_length Create_func_char_length::s_singleton;
1716
1717
 
1717
1718
Item*
1718
 
Create_func_char_length::create(THD *thd, Item *arg1)
 
1719
Create_func_char_length::create(Session *session, Item *arg1)
1719
1720
{
1720
 
  return new (thd->mem_root) Item_func_char_length(arg1);
 
1721
  return new (session->mem_root) Item_func_char_length(arg1);
1721
1722
}
1722
1723
 
1723
1724
 
1724
1725
Create_func_coercibility Create_func_coercibility::s_singleton;
1725
1726
 
1726
1727
Item*
1727
 
Create_func_coercibility::create(THD *thd, Item *arg1)
 
1728
Create_func_coercibility::create(Session *session, Item *arg1)
1728
1729
{
1729
 
  return new (thd->mem_root) Item_func_coercibility(arg1);
 
1730
  return new (session->mem_root) Item_func_coercibility(arg1);
1730
1731
}
1731
1732
 
1732
1733
 
1733
1734
Create_func_concat Create_func_concat::s_singleton;
1734
1735
 
1735
1736
Item*
1736
 
Create_func_concat::create_native(THD *thd, LEX_STRING name,
 
1737
Create_func_concat::create_native(Session *session, LEX_STRING name,
1737
1738
                                  List<Item> *item_list)
1738
1739
{
1739
1740
  int arg_count= 0;
1747
1748
    return NULL;
1748
1749
  }
1749
1750
 
1750
 
  return new (thd->mem_root) Item_func_concat(*item_list);
 
1751
  return new (session->mem_root) Item_func_concat(*item_list);
1751
1752
}
1752
1753
 
1753
1754
 
1754
1755
Create_func_concat_ws Create_func_concat_ws::s_singleton;
1755
1756
 
1756
1757
Item*
1757
 
Create_func_concat_ws::create_native(THD *thd, LEX_STRING name,
 
1758
Create_func_concat_ws::create_native(Session *session, LEX_STRING name,
1758
1759
                                     List<Item> *item_list)
1759
1760
{
1760
1761
  int arg_count= 0;
1769
1770
    return NULL;
1770
1771
  }
1771
1772
 
1772
 
  return new (thd->mem_root) Item_func_concat_ws(*item_list);
 
1773
  return new (session->mem_root) Item_func_concat_ws(*item_list);
1773
1774
}
1774
1775
 
1775
1776
 
1776
1777
Create_func_connection_id Create_func_connection_id::s_singleton;
1777
1778
 
1778
1779
Item*
1779
 
Create_func_connection_id::create(THD *thd)
 
1780
Create_func_connection_id::create(Session *session)
1780
1781
{
1781
 
  return new (thd->mem_root) Item_func_connection_id();
 
1782
  return new (session->mem_root) Item_func_connection_id();
1782
1783
}
1783
1784
 
1784
1785
 
1785
1786
Create_func_conv Create_func_conv::s_singleton;
1786
1787
 
1787
1788
Item*
1788
 
Create_func_conv::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
 
1789
Create_func_conv::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
1789
1790
{
1790
 
  return new (thd->mem_root) Item_func_conv(arg1, arg2, arg3);
 
1791
  return new (session->mem_root) Item_func_conv(arg1, arg2, arg3);
1791
1792
}
1792
1793
 
1793
1794
 
1794
1795
Create_func_cos Create_func_cos::s_singleton;
1795
1796
 
1796
1797
Item*
1797
 
Create_func_cos::create(THD *thd, Item *arg1)
 
1798
Create_func_cos::create(Session *session, Item *arg1)
1798
1799
{
1799
 
  return new (thd->mem_root) Item_func_cos(arg1);
 
1800
  return new (session->mem_root) Item_func_cos(arg1);
1800
1801
}
1801
1802
 
1802
1803
 
1803
1804
Create_func_cot Create_func_cot::s_singleton;
1804
1805
 
1805
1806
Item*
1806
 
Create_func_cot::create(THD *thd, Item *arg1)
 
1807
Create_func_cot::create(Session *session, Item *arg1)
1807
1808
{
1808
 
  Item *i1= new (thd->mem_root) Item_int((char*) "1", 1, 1);
1809
 
  Item *i2= new (thd->mem_root) Item_func_tan(arg1);
1810
 
  return new (thd->mem_root) Item_func_div(i1, i2);
 
1809
  Item *i1= new (session->mem_root) Item_int((char*) "1", 1, 1);
 
1810
  Item *i2= new (session->mem_root) Item_func_tan(arg1);
 
1811
  return new (session->mem_root) Item_func_div(i1, i2);
1811
1812
}
1812
1813
 
1813
1814
Create_func_date_format Create_func_date_format::s_singleton;
1814
1815
 
1815
1816
Item*
1816
 
Create_func_date_format::create(THD *thd, Item *arg1, Item *arg2)
 
1817
Create_func_date_format::create(Session *session, Item *arg1, Item *arg2)
1817
1818
{
1818
 
  return new (thd->mem_root) Item_func_date_format(arg1, arg2, 0);
 
1819
  return new (session->mem_root) Item_func_date_format(arg1, arg2, 0);
1819
1820
}
1820
1821
 
1821
1822
 
1822
1823
Create_func_datediff Create_func_datediff::s_singleton;
1823
1824
 
1824
1825
Item*
1825
 
Create_func_datediff::create(THD *thd, Item *arg1, Item *arg2)
 
1826
Create_func_datediff::create(Session *session, Item *arg1, Item *arg2)
1826
1827
{
1827
 
  Item *i1= new (thd->mem_root) Item_func_to_days(arg1);
1828
 
  Item *i2= new (thd->mem_root) Item_func_to_days(arg2);
 
1828
  Item *i1= new (session->mem_root) Item_func_to_days(arg1);
 
1829
  Item *i2= new (session->mem_root) Item_func_to_days(arg2);
1829
1830
 
1830
 
  return new (thd->mem_root) Item_func_minus(i1, i2);
 
1831
  return new (session->mem_root) Item_func_minus(i1, i2);
1831
1832
}
1832
1833
 
1833
1834
 
1834
1835
Create_func_dayname Create_func_dayname::s_singleton;
1835
1836
 
1836
1837
Item*
1837
 
Create_func_dayname::create(THD *thd, Item *arg1)
 
1838
Create_func_dayname::create(Session *session, Item *arg1)
1838
1839
{
1839
 
  return new (thd->mem_root) Item_func_dayname(arg1);
 
1840
  return new (session->mem_root) Item_func_dayname(arg1);
1840
1841
}
1841
1842
 
1842
1843
 
1843
1844
Create_func_dayofmonth Create_func_dayofmonth::s_singleton;
1844
1845
 
1845
1846
Item*
1846
 
Create_func_dayofmonth::create(THD *thd, Item *arg1)
 
1847
Create_func_dayofmonth::create(Session *session, Item *arg1)
1847
1848
{
1848
 
  return new (thd->mem_root) Item_func_dayofmonth(arg1);
 
1849
  return new (session->mem_root) Item_func_dayofmonth(arg1);
1849
1850
}
1850
1851
 
1851
1852
 
1852
1853
Create_func_dayofweek Create_func_dayofweek::s_singleton;
1853
1854
 
1854
1855
Item*
1855
 
Create_func_dayofweek::create(THD *thd, Item *arg1)
 
1856
Create_func_dayofweek::create(Session *session, Item *arg1)
1856
1857
{
1857
 
  return new (thd->mem_root) Item_func_weekday(arg1, 1);
 
1858
  return new (session->mem_root) Item_func_weekday(arg1, 1);
1858
1859
}
1859
1860
 
1860
1861
 
1861
1862
Create_func_dayofyear Create_func_dayofyear::s_singleton;
1862
1863
 
1863
1864
Item*
1864
 
Create_func_dayofyear::create(THD *thd, Item *arg1)
 
1865
Create_func_dayofyear::create(Session *session, Item *arg1)
1865
1866
{
1866
 
  return new (thd->mem_root) Item_func_dayofyear(arg1);
 
1867
  return new (session->mem_root) Item_func_dayofyear(arg1);
1867
1868
}
1868
1869
 
1869
1870
 
1870
1871
Create_func_degrees Create_func_degrees::s_singleton;
1871
1872
 
1872
1873
Item*
1873
 
Create_func_degrees::create(THD *thd, Item *arg1)
 
1874
Create_func_degrees::create(Session *session, Item *arg1)
1874
1875
{
1875
 
  return new (thd->mem_root) Item_func_units((char*) "degrees", arg1,
 
1876
  return new (session->mem_root) Item_func_units((char*) "degrees", arg1,
1876
1877
                                             180/M_PI, 0.0);
1877
1878
}
1878
1879
 
1880
1881
Create_func_elt Create_func_elt::s_singleton;
1881
1882
 
1882
1883
Item*
1883
 
Create_func_elt::create_native(THD *thd, LEX_STRING name,
 
1884
Create_func_elt::create_native(Session *session, LEX_STRING name,
1884
1885
                               List<Item> *item_list)
1885
1886
{
1886
1887
  int arg_count= 0;
1894
1895
    return NULL;
1895
1896
  }
1896
1897
 
1897
 
  return new (thd->mem_root) Item_func_elt(*item_list);
 
1898
  return new (session->mem_root) Item_func_elt(*item_list);
1898
1899
}
1899
1900
 
1900
1901
 
1901
1902
Create_func_exp Create_func_exp::s_singleton;
1902
1903
 
1903
1904
Item*
1904
 
Create_func_exp::create(THD *thd, Item *arg1)
 
1905
Create_func_exp::create(Session *session, Item *arg1)
1905
1906
{
1906
 
  return new (thd->mem_root) Item_func_exp(arg1);
 
1907
  return new (session->mem_root) Item_func_exp(arg1);
1907
1908
}
1908
1909
 
1909
1910
 
1910
1911
Create_func_export_set Create_func_export_set::s_singleton;
1911
1912
 
1912
1913
Item*
1913
 
Create_func_export_set::create_native(THD *thd, LEX_STRING name,
 
1914
Create_func_export_set::create_native(Session *session, LEX_STRING name,
1914
1915
                                      List<Item> *item_list)
1915
1916
{
1916
1917
  Item *func= NULL;
1925
1926
    Item *param_1= item_list->pop();
1926
1927
    Item *param_2= item_list->pop();
1927
1928
    Item *param_3= item_list->pop();
1928
 
    func= new (thd->mem_root) Item_func_export_set(param_1, param_2, param_3);
 
1929
    func= new (session->mem_root) Item_func_export_set(param_1, param_2, param_3);
1929
1930
    break;
1930
1931
  }
1931
1932
  case 4:
1934
1935
    Item *param_2= item_list->pop();
1935
1936
    Item *param_3= item_list->pop();
1936
1937
    Item *param_4= item_list->pop();
1937
 
    func= new (thd->mem_root) Item_func_export_set(param_1, param_2, param_3,
 
1938
    func= new (session->mem_root) Item_func_export_set(param_1, param_2, param_3,
1938
1939
                                                   param_4);
1939
1940
    break;
1940
1941
  }
1945
1946
    Item *param_3= item_list->pop();
1946
1947
    Item *param_4= item_list->pop();
1947
1948
    Item *param_5= item_list->pop();
1948
 
    func= new (thd->mem_root) Item_func_export_set(param_1, param_2, param_3,
 
1949
    func= new (session->mem_root) Item_func_export_set(param_1, param_2, param_3,
1949
1950
                                                   param_4, param_5);
1950
1951
    break;
1951
1952
  }
1963
1964
Create_func_field Create_func_field::s_singleton;
1964
1965
 
1965
1966
Item*
1966
 
Create_func_field::create_native(THD *thd, LEX_STRING name,
 
1967
Create_func_field::create_native(Session *session, LEX_STRING name,
1967
1968
                                 List<Item> *item_list)
1968
1969
{
1969
1970
  int arg_count= 0;
1977
1978
    return NULL;
1978
1979
  }
1979
1980
 
1980
 
  return new (thd->mem_root) Item_func_field(*item_list);
 
1981
  return new (session->mem_root) Item_func_field(*item_list);
1981
1982
}
1982
1983
 
1983
1984
 
1984
1985
Create_func_find_in_set Create_func_find_in_set::s_singleton;
1985
1986
 
1986
1987
Item*
1987
 
Create_func_find_in_set::create(THD *thd, Item *arg1, Item *arg2)
 
1988
Create_func_find_in_set::create(Session *session, Item *arg1, Item *arg2)
1988
1989
{
1989
 
  return new (thd->mem_root) Item_func_find_in_set(arg1, arg2);
 
1990
  return new (session->mem_root) Item_func_find_in_set(arg1, arg2);
1990
1991
}
1991
1992
 
1992
1993
 
1993
1994
Create_func_floor Create_func_floor::s_singleton;
1994
1995
 
1995
1996
Item*
1996
 
Create_func_floor::create(THD *thd, Item *arg1)
 
1997
Create_func_floor::create(Session *session, Item *arg1)
1997
1998
{
1998
 
  return new (thd->mem_root) Item_func_floor(arg1);
 
1999
  return new (session->mem_root) Item_func_floor(arg1);
1999
2000
}
2000
2001
 
2001
2002
 
2002
2003
Create_func_format Create_func_format::s_singleton;
2003
2004
 
2004
2005
Item*
2005
 
Create_func_format::create(THD *thd, Item *arg1, Item *arg2)
 
2006
Create_func_format::create(Session *session, Item *arg1, Item *arg2)
2006
2007
{
2007
 
  return new (thd->mem_root) Item_func_format(arg1, arg2);
 
2008
  return new (session->mem_root) Item_func_format(arg1, arg2);
2008
2009
}
2009
2010
 
2010
2011
 
2011
2012
Create_func_found_rows Create_func_found_rows::s_singleton;
2012
2013
 
2013
2014
Item*
2014
 
Create_func_found_rows::create(THD *thd)
 
2015
Create_func_found_rows::create(Session *session)
2015
2016
{
2016
 
  thd->lex->set_stmt_unsafe();
2017
 
  return new (thd->mem_root) Item_func_found_rows();
 
2017
  session->lex->set_stmt_unsafe();
 
2018
  return new (session->mem_root) Item_func_found_rows();
2018
2019
}
2019
2020
 
2020
2021
 
2021
2022
Create_func_from_days Create_func_from_days::s_singleton;
2022
2023
 
2023
2024
Item*
2024
 
Create_func_from_days::create(THD *thd, Item *arg1)
 
2025
Create_func_from_days::create(Session *session, Item *arg1)
2025
2026
{
2026
 
  return new (thd->mem_root) Item_func_from_days(arg1);
 
2027
  return new (session->mem_root) Item_func_from_days(arg1);
2027
2028
}
2028
2029
 
2029
2030
 
2030
2031
Create_func_from_unixtime Create_func_from_unixtime::s_singleton;
2031
2032
 
2032
2033
Item*
2033
 
Create_func_from_unixtime::create_native(THD *thd, LEX_STRING name,
 
2034
Create_func_from_unixtime::create_native(Session *session, LEX_STRING name,
2034
2035
                                         List<Item> *item_list)
2035
2036
{
2036
2037
  Item *func= NULL;
2043
2044
  case 1:
2044
2045
  {
2045
2046
    Item *param_1= item_list->pop();
2046
 
    func= new (thd->mem_root) Item_func_from_unixtime(param_1);
 
2047
    func= new (session->mem_root) Item_func_from_unixtime(param_1);
2047
2048
    break;
2048
2049
  }
2049
2050
  case 2:
2050
2051
  {
2051
2052
    Item *param_1= item_list->pop();
2052
2053
    Item *param_2= item_list->pop();
2053
 
    Item *ut= new (thd->mem_root) Item_func_from_unixtime(param_1);
2054
 
    func= new (thd->mem_root) Item_func_date_format(ut, param_2, 0);
 
2054
    Item *ut= new (session->mem_root) Item_func_from_unixtime(param_1);
 
2055
    func= new (session->mem_root) Item_func_date_format(ut, param_2, 0);
2055
2056
    break;
2056
2057
  }
2057
2058
  default:
2068
2069
Create_func_greatest Create_func_greatest::s_singleton;
2069
2070
 
2070
2071
Item*
2071
 
Create_func_greatest::create_native(THD *thd, LEX_STRING name,
 
2072
Create_func_greatest::create_native(Session *session, LEX_STRING name,
2072
2073
                                    List<Item> *item_list)
2073
2074
{
2074
2075
  int arg_count= 0;
2082
2083
    return NULL;
2083
2084
  }
2084
2085
 
2085
 
  return new (thd->mem_root) Item_func_max(*item_list);
 
2086
  return new (session->mem_root) Item_func_max(*item_list);
2086
2087
}
2087
2088
 
2088
2089
 
2089
2090
Create_func_hex Create_func_hex::s_singleton;
2090
2091
 
2091
2092
Item*
2092
 
Create_func_hex::create(THD *thd, Item *arg1)
 
2093
Create_func_hex::create(Session *session, Item *arg1)
2093
2094
{
2094
 
  return new (thd->mem_root) Item_func_hex(arg1);
 
2095
  return new (session->mem_root) Item_func_hex(arg1);
2095
2096
}
2096
2097
 
2097
2098
 
2098
2099
Create_func_ifnull Create_func_ifnull::s_singleton;
2099
2100
 
2100
2101
Item*
2101
 
Create_func_ifnull::create(THD *thd, Item *arg1, Item *arg2)
 
2102
Create_func_ifnull::create(Session *session, Item *arg1, Item *arg2)
2102
2103
{
2103
 
  return new (thd->mem_root) Item_func_ifnull(arg1, arg2);
 
2104
  return new (session->mem_root) Item_func_ifnull(arg1, arg2);
2104
2105
}
2105
2106
 
2106
2107
 
2107
2108
Create_func_instr Create_func_instr::s_singleton;
2108
2109
 
2109
2110
Item*
2110
 
Create_func_instr::create(THD *thd, Item *arg1, Item *arg2)
 
2111
Create_func_instr::create(Session *session, Item *arg1, Item *arg2)
2111
2112
{
2112
 
  return new (thd->mem_root) Item_func_locate(arg1, arg2);
 
2113
  return new (session->mem_root) Item_func_locate(arg1, arg2);
2113
2114
}
2114
2115
 
2115
2116
 
2116
2117
Create_func_isnull Create_func_isnull::s_singleton;
2117
2118
 
2118
2119
Item*
2119
 
Create_func_isnull::create(THD *thd, Item *arg1)
 
2120
Create_func_isnull::create(Session *session, Item *arg1)
2120
2121
{
2121
 
  return new (thd->mem_root) Item_func_isnull(arg1);
 
2122
  return new (session->mem_root) Item_func_isnull(arg1);
2122
2123
}
2123
2124
 
2124
2125
 
2125
2126
Create_func_last_day Create_func_last_day::s_singleton;
2126
2127
 
2127
2128
Item*
2128
 
Create_func_last_day::create(THD *thd, Item *arg1)
 
2129
Create_func_last_day::create(Session *session, Item *arg1)
2129
2130
{
2130
 
  return new (thd->mem_root) Item_func_last_day(arg1);
 
2131
  return new (session->mem_root) Item_func_last_day(arg1);
2131
2132
}
2132
2133
 
2133
2134
 
2134
2135
Create_func_last_insert_id Create_func_last_insert_id::s_singleton;
2135
2136
 
2136
2137
Item*
2137
 
Create_func_last_insert_id::create_native(THD *thd, LEX_STRING name,
 
2138
Create_func_last_insert_id::create_native(Session *session, LEX_STRING name,
2138
2139
                                          List<Item> *item_list)
2139
2140
{
2140
2141
  Item *func= NULL;
2146
2147
  switch (arg_count) {
2147
2148
  case 0:
2148
2149
  {
2149
 
    func= new (thd->mem_root) Item_func_last_insert_id();
 
2150
    func= new (session->mem_root) Item_func_last_insert_id();
2150
2151
    break;
2151
2152
  }
2152
2153
  case 1:
2153
2154
  {
2154
2155
    Item *param_1= item_list->pop();
2155
 
    func= new (thd->mem_root) Item_func_last_insert_id(param_1);
 
2156
    func= new (session->mem_root) Item_func_last_insert_id(param_1);
2156
2157
    break;
2157
2158
  }
2158
2159
  default:
2169
2170
Create_func_lcase Create_func_lcase::s_singleton;
2170
2171
 
2171
2172
Item*
2172
 
Create_func_lcase::create(THD *thd, Item *arg1)
 
2173
Create_func_lcase::create(Session *session, Item *arg1)
2173
2174
{
2174
 
  return new (thd->mem_root) Item_func_lcase(arg1);
 
2175
  return new (session->mem_root) Item_func_lcase(arg1);
2175
2176
}
2176
2177
 
2177
2178
 
2178
2179
Create_func_least Create_func_least::s_singleton;
2179
2180
 
2180
2181
Item*
2181
 
Create_func_least::create_native(THD *thd, LEX_STRING name,
 
2182
Create_func_least::create_native(Session *session, LEX_STRING name,
2182
2183
                                 List<Item> *item_list)
2183
2184
{
2184
2185
  int arg_count= 0;
2192
2193
    return NULL;
2193
2194
  }
2194
2195
 
2195
 
  return new (thd->mem_root) Item_func_min(*item_list);
 
2196
  return new (session->mem_root) Item_func_min(*item_list);
2196
2197
}
2197
2198
 
2198
2199
 
2199
2200
Create_func_length Create_func_length::s_singleton;
2200
2201
 
2201
2202
Item*
2202
 
Create_func_length::create(THD *thd, Item *arg1)
 
2203
Create_func_length::create(Session *session, Item *arg1)
2203
2204
{
2204
 
  return new (thd->mem_root) Item_func_length(arg1);
 
2205
  return new (session->mem_root) Item_func_length(arg1);
2205
2206
}
2206
2207
 
2207
2208
 
2208
2209
Create_func_ln Create_func_ln::s_singleton;
2209
2210
 
2210
2211
Item*
2211
 
Create_func_ln::create(THD *thd, Item *arg1)
 
2212
Create_func_ln::create(Session *session, Item *arg1)
2212
2213
{
2213
 
  return new (thd->mem_root) Item_func_ln(arg1);
 
2214
  return new (session->mem_root) Item_func_ln(arg1);
2214
2215
}
2215
2216
 
2216
2217
 
2217
2218
Create_func_load_file Create_func_load_file::s_singleton;
2218
2219
 
2219
2220
Item*
2220
 
Create_func_load_file::create(THD *thd, Item *arg1)
 
2221
Create_func_load_file::create(Session *session, Item *arg1)
2221
2222
{
2222
 
  return new (thd->mem_root) Item_load_file(arg1);
 
2223
  return new (session->mem_root) Item_load_file(arg1);
2223
2224
}
2224
2225
 
2225
2226
 
2226
2227
Create_func_locate Create_func_locate::s_singleton;
2227
2228
 
2228
2229
Item*
2229
 
Create_func_locate::create_native(THD *thd, LEX_STRING name,
 
2230
Create_func_locate::create_native(Session *session, LEX_STRING name,
2230
2231
                                  List<Item> *item_list)
2231
2232
{
2232
2233
  Item *func= NULL;
2241
2242
    Item *param_1= item_list->pop();
2242
2243
    Item *param_2= item_list->pop();
2243
2244
    /* Yes, parameters in that order : 2, 1 */
2244
 
    func= new (thd->mem_root) Item_func_locate(param_2, param_1);
 
2245
    func= new (session->mem_root) Item_func_locate(param_2, param_1);
2245
2246
    break;
2246
2247
  }
2247
2248
  case 3:
2250
2251
    Item *param_2= item_list->pop();
2251
2252
    Item *param_3= item_list->pop();
2252
2253
    /* Yes, parameters in that order : 2, 1, 3 */
2253
 
    func= new (thd->mem_root) Item_func_locate(param_2, param_1, param_3);
 
2254
    func= new (session->mem_root) Item_func_locate(param_2, param_1, param_3);
2254
2255
    break;
2255
2256
  }
2256
2257
  default:
2267
2268
Create_func_log Create_func_log::s_singleton;
2268
2269
 
2269
2270
Item*
2270
 
Create_func_log::create_native(THD *thd, LEX_STRING name,
 
2271
Create_func_log::create_native(Session *session, LEX_STRING name,
2271
2272
                               List<Item> *item_list)
2272
2273
{
2273
2274
  Item *func= NULL;
2280
2281
  case 1:
2281
2282
  {
2282
2283
    Item *param_1= item_list->pop();
2283
 
    func= new (thd->mem_root) Item_func_log(param_1);
 
2284
    func= new (session->mem_root) Item_func_log(param_1);
2284
2285
    break;
2285
2286
  }
2286
2287
  case 2:
2287
2288
  {
2288
2289
    Item *param_1= item_list->pop();
2289
2290
    Item *param_2= item_list->pop();
2290
 
    func= new (thd->mem_root) Item_func_log(param_1, param_2);
 
2291
    func= new (session->mem_root) Item_func_log(param_1, param_2);
2291
2292
    break;
2292
2293
  }
2293
2294
  default:
2304
2305
Create_func_log10 Create_func_log10::s_singleton;
2305
2306
 
2306
2307
Item*
2307
 
Create_func_log10::create(THD *thd, Item *arg1)
 
2308
Create_func_log10::create(Session *session, Item *arg1)
2308
2309
{
2309
 
  return new (thd->mem_root) Item_func_log10(arg1);
 
2310
  return new (session->mem_root) Item_func_log10(arg1);
2310
2311
}
2311
2312
 
2312
2313
 
2313
2314
Create_func_log2 Create_func_log2::s_singleton;
2314
2315
 
2315
2316
Item*
2316
 
Create_func_log2::create(THD *thd, Item *arg1)
 
2317
Create_func_log2::create(Session *session, Item *arg1)
2317
2318
{
2318
 
  return new (thd->mem_root) Item_func_log2(arg1);
 
2319
  return new (session->mem_root) Item_func_log2(arg1);
2319
2320
}
2320
2321
 
2321
2322
 
2322
2323
Create_func_lpad Create_func_lpad::s_singleton;
2323
2324
 
2324
2325
Item*
2325
 
Create_func_lpad::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
 
2326
Create_func_lpad::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
2326
2327
{
2327
 
  return new (thd->mem_root) Item_func_lpad(arg1, arg2, arg3);
 
2328
  return new (session->mem_root) Item_func_lpad(arg1, arg2, arg3);
2328
2329
}
2329
2330
 
2330
2331
 
2331
2332
Create_func_ltrim Create_func_ltrim::s_singleton;
2332
2333
 
2333
2334
Item*
2334
 
Create_func_ltrim::create(THD *thd, Item *arg1)
 
2335
Create_func_ltrim::create(Session *session, Item *arg1)
2335
2336
{
2336
 
  return new (thd->mem_root) Item_func_ltrim(arg1);
 
2337
  return new (session->mem_root) Item_func_ltrim(arg1);
2337
2338
}
2338
2339
 
2339
2340
 
2340
2341
Create_func_makedate Create_func_makedate::s_singleton;
2341
2342
 
2342
2343
Item*
2343
 
Create_func_makedate::create(THD *thd, Item *arg1, Item *arg2)
 
2344
Create_func_makedate::create(Session *session, Item *arg1, Item *arg2)
2344
2345
{
2345
 
  return new (thd->mem_root) Item_func_makedate(arg1, arg2);
 
2346
  return new (session->mem_root) Item_func_makedate(arg1, arg2);
2346
2347
}
2347
2348
 
2348
2349
 
2349
2350
Create_func_maketime Create_func_maketime::s_singleton;
2350
2351
 
2351
2352
Item*
2352
 
Create_func_maketime::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
 
2353
Create_func_maketime::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
2353
2354
{
2354
 
  return new (thd->mem_root) Item_func_maketime(arg1, arg2, arg3);
 
2355
  return new (session->mem_root) Item_func_maketime(arg1, arg2, arg3);
2355
2356
}
2356
2357
 
2357
2358
 
2358
2359
Create_func_make_set Create_func_make_set::s_singleton;
2359
2360
 
2360
2361
Item*
2361
 
Create_func_make_set::create_native(THD *thd, LEX_STRING name,
 
2362
Create_func_make_set::create_native(Session *session, LEX_STRING name,
2362
2363
                                    List<Item> *item_list)
2363
2364
{
2364
2365
  int arg_count= 0;
2373
2374
  }
2374
2375
 
2375
2376
  Item *param_1= item_list->pop();
2376
 
  return new (thd->mem_root) Item_func_make_set(param_1, *item_list);
 
2377
  return new (session->mem_root) Item_func_make_set(param_1, *item_list);
2377
2378
}
2378
2379
 
2379
2380
 
2380
2381
Create_func_master_pos_wait Create_func_master_pos_wait::s_singleton;
2381
2382
 
2382
2383
Item*
2383
 
Create_func_master_pos_wait::create_native(THD *thd, LEX_STRING name,
 
2384
Create_func_master_pos_wait::create_native(Session *session, LEX_STRING name,
2384
2385
                                           List<Item> *item_list)
2385
2386
 
2386
2387
{
2395
2396
  {
2396
2397
    Item *param_1= item_list->pop();
2397
2398
    Item *param_2= item_list->pop();
2398
 
    func= new (thd->mem_root) Item_master_pos_wait(param_1, param_2);
 
2399
    func= new (session->mem_root) Item_master_pos_wait(param_1, param_2);
2399
2400
    break;
2400
2401
  }
2401
2402
  case 3:
2403
2404
    Item *param_1= item_list->pop();
2404
2405
    Item *param_2= item_list->pop();
2405
2406
    Item *param_3= item_list->pop();
2406
 
    func= new (thd->mem_root) Item_master_pos_wait(param_1, param_2, param_3);
 
2407
    func= new (session->mem_root) Item_master_pos_wait(param_1, param_2, param_3);
2407
2408
    break;
2408
2409
  }
2409
2410
  default:
2420
2421
Create_func_monthname Create_func_monthname::s_singleton;
2421
2422
 
2422
2423
Item*
2423
 
Create_func_monthname::create(THD *thd, Item *arg1)
 
2424
Create_func_monthname::create(Session *session, Item *arg1)
2424
2425
{
2425
 
  return new (thd->mem_root) Item_func_monthname(arg1);
 
2426
  return new (session->mem_root) Item_func_monthname(arg1);
2426
2427
}
2427
2428
 
2428
2429
 
2429
2430
Create_func_nullif Create_func_nullif::s_singleton;
2430
2431
 
2431
2432
Item*
2432
 
Create_func_nullif::create(THD *thd, Item *arg1, Item *arg2)
 
2433
Create_func_nullif::create(Session *session, Item *arg1, Item *arg2)
2433
2434
{
2434
 
  return new (thd->mem_root) Item_func_nullif(arg1, arg2);
 
2435
  return new (session->mem_root) Item_func_nullif(arg1, arg2);
2435
2436
}
2436
2437
 
2437
2438
 
2438
2439
Create_func_oct Create_func_oct::s_singleton;
2439
2440
 
2440
2441
Item*
2441
 
Create_func_oct::create(THD *thd, Item *arg1)
 
2442
Create_func_oct::create(Session *session, Item *arg1)
2442
2443
{
2443
 
  Item *i10= new (thd->mem_root) Item_int((int32_t) 10,2);
2444
 
  Item *i8= new (thd->mem_root) Item_int((int32_t) 8,1);
2445
 
  return new (thd->mem_root) Item_func_conv(arg1, i10, i8);
 
2444
  Item *i10= new (session->mem_root) Item_int((int32_t) 10,2);
 
2445
  Item *i8= new (session->mem_root) Item_int((int32_t) 8,1);
 
2446
  return new (session->mem_root) Item_func_conv(arg1, i10, i8);
2446
2447
}
2447
2448
 
2448
2449
 
2449
2450
Create_func_ord Create_func_ord::s_singleton;
2450
2451
 
2451
2452
Item*
2452
 
Create_func_ord::create(THD *thd, Item *arg1)
 
2453
Create_func_ord::create(Session *session, Item *arg1)
2453
2454
{
2454
 
  return new (thd->mem_root) Item_func_ord(arg1);
 
2455
  return new (session->mem_root) Item_func_ord(arg1);
2455
2456
}
2456
2457
 
2457
2458
 
2458
2459
Create_func_period_add Create_func_period_add::s_singleton;
2459
2460
 
2460
2461
Item*
2461
 
Create_func_period_add::create(THD *thd, Item *arg1, Item *arg2)
 
2462
Create_func_period_add::create(Session *session, Item *arg1, Item *arg2)
2462
2463
{
2463
 
  return new (thd->mem_root) Item_func_period_add(arg1, arg2);
 
2464
  return new (session->mem_root) Item_func_period_add(arg1, arg2);
2464
2465
}
2465
2466
 
2466
2467
 
2467
2468
Create_func_period_diff Create_func_period_diff::s_singleton;
2468
2469
 
2469
2470
Item*
2470
 
Create_func_period_diff::create(THD *thd, Item *arg1, Item *arg2)
 
2471
Create_func_period_diff::create(Session *session, Item *arg1, Item *arg2)
2471
2472
{
2472
 
  return new (thd->mem_root) Item_func_period_diff(arg1, arg2);
 
2473
  return new (session->mem_root) Item_func_period_diff(arg1, arg2);
2473
2474
}
2474
2475
 
2475
2476
 
2476
2477
Create_func_pi Create_func_pi::s_singleton;
2477
2478
 
2478
2479
Item*
2479
 
Create_func_pi::create(THD *thd)
 
2480
Create_func_pi::create(Session *session)
2480
2481
{
2481
 
  return new (thd->mem_root) Item_static_float_func("pi()", M_PI, 6, 8);
 
2482
  return new (session->mem_root) Item_static_float_func("pi()", M_PI, 6, 8);
2482
2483
}
2483
2484
 
2484
2485
 
2485
2486
Create_func_pow Create_func_pow::s_singleton;
2486
2487
 
2487
2488
Item*
2488
 
Create_func_pow::create(THD *thd, Item *arg1, Item *arg2)
 
2489
Create_func_pow::create(Session *session, Item *arg1, Item *arg2)
2489
2490
{
2490
 
  return new (thd->mem_root) Item_func_pow(arg1, arg2);
 
2491
  return new (session->mem_root) Item_func_pow(arg1, arg2);
2491
2492
}
2492
2493
 
2493
2494
 
2494
2495
Create_func_quote Create_func_quote::s_singleton;
2495
2496
 
2496
2497
Item*
2497
 
Create_func_quote::create(THD *thd, Item *arg1)
 
2498
Create_func_quote::create(Session *session, Item *arg1)
2498
2499
{
2499
 
  return new (thd->mem_root) Item_func_quote(arg1);
 
2500
  return new (session->mem_root) Item_func_quote(arg1);
2500
2501
}
2501
2502
 
2502
2503
 
2503
2504
Create_func_radians Create_func_radians::s_singleton;
2504
2505
 
2505
2506
Item*
2506
 
Create_func_radians::create(THD *thd, Item *arg1)
 
2507
Create_func_radians::create(Session *session, Item *arg1)
2507
2508
{
2508
 
  return new (thd->mem_root) Item_func_units((char*) "radians", arg1,
 
2509
  return new (session->mem_root) Item_func_units((char*) "radians", arg1,
2509
2510
                                             M_PI/180, 0.0);
2510
2511
}
2511
2512
 
2513
2514
Create_func_rand Create_func_rand::s_singleton;
2514
2515
 
2515
2516
Item*
2516
 
Create_func_rand::create_native(THD *thd, LEX_STRING name,
 
2517
Create_func_rand::create_native(Session *session, LEX_STRING name,
2517
2518
                                List<Item> *item_list)
2518
2519
{
2519
2520
  Item *func= NULL;
2525
2526
  switch (arg_count) {
2526
2527
  case 0:
2527
2528
  {
2528
 
    func= new (thd->mem_root) Item_func_rand();
 
2529
    func= new (session->mem_root) Item_func_rand();
2529
2530
    break;
2530
2531
  }
2531
2532
  case 1:
2532
2533
  {
2533
2534
    Item *param_1= item_list->pop();
2534
 
    func= new (thd->mem_root) Item_func_rand(param_1);
 
2535
    func= new (session->mem_root) Item_func_rand(param_1);
2535
2536
    break;
2536
2537
  }
2537
2538
  default:
2548
2549
Create_func_round Create_func_round::s_singleton;
2549
2550
 
2550
2551
Item*
2551
 
Create_func_round::create_native(THD *thd, LEX_STRING name,
 
2552
Create_func_round::create_native(Session *session, LEX_STRING name,
2552
2553
                                 List<Item> *item_list)
2553
2554
{
2554
2555
  Item *func= NULL;
2561
2562
  case 1:
2562
2563
  {
2563
2564
    Item *param_1= item_list->pop();
2564
 
    Item *i0 = new (thd->mem_root) Item_int((char*)"0", 0, 1);
2565
 
    func= new (thd->mem_root) Item_func_round(param_1, i0, 0);
 
2565
    Item *i0 = new (session->mem_root) Item_int((char*)"0", 0, 1);
 
2566
    func= new (session->mem_root) Item_func_round(param_1, i0, 0);
2566
2567
    break;
2567
2568
  }
2568
2569
  case 2:
2569
2570
  {
2570
2571
    Item *param_1= item_list->pop();
2571
2572
    Item *param_2= item_list->pop();
2572
 
    func= new (thd->mem_root) Item_func_round(param_1, param_2, 0);
 
2573
    func= new (session->mem_root) Item_func_round(param_1, param_2, 0);
2573
2574
    break;
2574
2575
  }
2575
2576
  default:
2586
2587
Create_func_row_count Create_func_row_count::s_singleton;
2587
2588
 
2588
2589
Item*
2589
 
Create_func_row_count::create(THD *thd)
 
2590
Create_func_row_count::create(Session *session)
2590
2591
{
2591
 
  thd->lex->set_stmt_unsafe();
2592
 
  return new (thd->mem_root) Item_func_row_count();
 
2592
  session->lex->set_stmt_unsafe();
 
2593
  return new (session->mem_root) Item_func_row_count();
2593
2594
}
2594
2595
 
2595
2596
 
2596
2597
Create_func_rpad Create_func_rpad::s_singleton;
2597
2598
 
2598
2599
Item*
2599
 
Create_func_rpad::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
 
2600
Create_func_rpad::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
2600
2601
{
2601
 
  return new (thd->mem_root) Item_func_rpad(arg1, arg2, arg3);
 
2602
  return new (session->mem_root) Item_func_rpad(arg1, arg2, arg3);
2602
2603
}
2603
2604
 
2604
2605
 
2605
2606
Create_func_rtrim Create_func_rtrim::s_singleton;
2606
2607
 
2607
2608
Item*
2608
 
Create_func_rtrim::create(THD *thd, Item *arg1)
 
2609
Create_func_rtrim::create(Session *session, Item *arg1)
2609
2610
{
2610
 
  return new (thd->mem_root) Item_func_rtrim(arg1);
 
2611
  return new (session->mem_root) Item_func_rtrim(arg1);
2611
2612
}
2612
2613
 
2613
2614
 
2614
2615
Create_func_sec_to_time Create_func_sec_to_time::s_singleton;
2615
2616
 
2616
2617
Item*
2617
 
Create_func_sec_to_time::create(THD *thd, Item *arg1)
 
2618
Create_func_sec_to_time::create(Session *session, Item *arg1)
2618
2619
{
2619
 
  return new (thd->mem_root) Item_func_sec_to_time(arg1);
 
2620
  return new (session->mem_root) Item_func_sec_to_time(arg1);
2620
2621
}
2621
2622
 
2622
2623
 
2623
2624
Create_func_sign Create_func_sign::s_singleton;
2624
2625
 
2625
2626
Item*
2626
 
Create_func_sign::create(THD *thd, Item *arg1)
 
2627
Create_func_sign::create(Session *session, Item *arg1)
2627
2628
{
2628
 
  return new (thd->mem_root) Item_func_sign(arg1);
 
2629
  return new (session->mem_root) Item_func_sign(arg1);
2629
2630
}
2630
2631
 
2631
2632
 
2632
2633
Create_func_sin Create_func_sin::s_singleton;
2633
2634
 
2634
2635
Item*
2635
 
Create_func_sin::create(THD *thd, Item *arg1)
 
2636
Create_func_sin::create(Session *session, Item *arg1)
2636
2637
{
2637
 
  return new (thd->mem_root) Item_func_sin(arg1);
 
2638
  return new (session->mem_root) Item_func_sin(arg1);
2638
2639
}
2639
2640
 
2640
2641
 
2641
2642
Create_func_space Create_func_space::s_singleton;
2642
2643
 
2643
2644
Item*
2644
 
Create_func_space::create(THD *thd, Item *arg1)
 
2645
Create_func_space::create(Session *session, Item *arg1)
2645
2646
{
2646
2647
  /**
2647
2648
    TODO: Fix Bug#23637
2648
2649
    The parsed item tree should not depend on
2649
 
    <code>thd->variables.collation_connection</code>.
 
2650
    <code>session->variables.collation_connection</code>.
2650
2651
  */
2651
 
  const CHARSET_INFO * const cs= thd->variables.collation_connection;
 
2652
  const CHARSET_INFO * const cs= session->variables.collation_connection;
2652
2653
  Item *sp;
2653
2654
 
2654
2655
  if (cs->mbminlen > 1)
2655
2656
  {
2656
2657
    uint32_t dummy_errors;
2657
 
    sp= new (thd->mem_root) Item_string("", 0, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
 
2658
    sp= new (session->mem_root) Item_string("", 0, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
2658
2659
    sp->str_value.copy(" ", 1, &my_charset_utf8_general_ci, cs, &dummy_errors);
2659
2660
  }
2660
2661
  else
2661
2662
  {
2662
 
    sp= new (thd->mem_root) Item_string(" ", 1, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
 
2663
    sp= new (session->mem_root) Item_string(" ", 1, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
2663
2664
  }
2664
2665
 
2665
 
  return new (thd->mem_root) Item_func_repeat(sp, arg1);
 
2666
  return new (session->mem_root) Item_func_repeat(sp, arg1);
2666
2667
}
2667
2668
 
2668
2669
 
2669
2670
Create_func_sqrt Create_func_sqrt::s_singleton;
2670
2671
 
2671
2672
Item*
2672
 
Create_func_sqrt::create(THD *thd, Item *arg1)
 
2673
Create_func_sqrt::create(Session *session, Item *arg1)
2673
2674
{
2674
 
  return new (thd->mem_root) Item_func_sqrt(arg1);
 
2675
  return new (session->mem_root) Item_func_sqrt(arg1);
2675
2676
}
2676
2677
 
2677
2678
 
2678
2679
Create_func_str_to_date Create_func_str_to_date::s_singleton;
2679
2680
 
2680
2681
Item*
2681
 
Create_func_str_to_date::create(THD *thd, Item *arg1, Item *arg2)
 
2682
Create_func_str_to_date::create(Session *session, Item *arg1, Item *arg2)
2682
2683
{
2683
 
  return new (thd->mem_root) Item_func_str_to_date(arg1, arg2);
 
2684
  return new (session->mem_root) Item_func_str_to_date(arg1, arg2);
2684
2685
}
2685
2686
 
2686
2687
 
2687
2688
Create_func_strcmp Create_func_strcmp::s_singleton;
2688
2689
 
2689
2690
Item*
2690
 
Create_func_strcmp::create(THD *thd, Item *arg1, Item *arg2)
 
2691
Create_func_strcmp::create(Session *session, Item *arg1, Item *arg2)
2691
2692
{
2692
 
  return new (thd->mem_root) Item_func_strcmp(arg1, arg2);
 
2693
  return new (session->mem_root) Item_func_strcmp(arg1, arg2);
2693
2694
}
2694
2695
 
2695
2696
 
2696
2697
Create_func_substr_index Create_func_substr_index::s_singleton;
2697
2698
 
2698
2699
Item*
2699
 
Create_func_substr_index::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
 
2700
Create_func_substr_index::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
2700
2701
{
2701
 
  return new (thd->mem_root) Item_func_substr_index(arg1, arg2, arg3);
 
2702
  return new (session->mem_root) Item_func_substr_index(arg1, arg2, arg3);
2702
2703
}
2703
2704
 
2704
2705
 
2705
2706
Create_func_subtime Create_func_subtime::s_singleton;
2706
2707
 
2707
2708
Item*
2708
 
Create_func_subtime::create(THD *thd, Item *arg1, Item *arg2)
 
2709
Create_func_subtime::create(Session *session, Item *arg1, Item *arg2)
2709
2710
{
2710
 
  return new (thd->mem_root) Item_func_add_time(arg1, arg2, 0, 1);
 
2711
  return new (session->mem_root) Item_func_add_time(arg1, arg2, 0, 1);
2711
2712
}
2712
2713
 
2713
2714
 
2714
2715
Create_func_tan Create_func_tan::s_singleton;
2715
2716
 
2716
2717
Item*
2717
 
Create_func_tan::create(THD *thd, Item *arg1)
 
2718
Create_func_tan::create(Session *session, Item *arg1)
2718
2719
{
2719
 
  return new (thd->mem_root) Item_func_tan(arg1);
 
2720
  return new (session->mem_root) Item_func_tan(arg1);
2720
2721
}
2721
2722
 
2722
2723
 
2723
2724
Create_func_time_format Create_func_time_format::s_singleton;
2724
2725
 
2725
2726
Item*
2726
 
Create_func_time_format::create(THD *thd, Item *arg1, Item *arg2)
 
2727
Create_func_time_format::create(Session *session, Item *arg1, Item *arg2)
2727
2728
{
2728
 
  return new (thd->mem_root) Item_func_date_format(arg1, arg2, 1);
 
2729
  return new (session->mem_root) Item_func_date_format(arg1, arg2, 1);
2729
2730
}
2730
2731
 
2731
2732
 
2732
2733
Create_func_time_to_sec Create_func_time_to_sec::s_singleton;
2733
2734
 
2734
2735
Item*
2735
 
Create_func_time_to_sec::create(THD *thd, Item *arg1)
 
2736
Create_func_time_to_sec::create(Session *session, Item *arg1)
2736
2737
{
2737
 
  return new (thd->mem_root) Item_func_time_to_sec(arg1);
 
2738
  return new (session->mem_root) Item_func_time_to_sec(arg1);
2738
2739
}
2739
2740
 
2740
2741
 
2741
2742
Create_func_timediff Create_func_timediff::s_singleton;
2742
2743
 
2743
2744
Item*
2744
 
Create_func_timediff::create(THD *thd, Item *arg1, Item *arg2)
 
2745
Create_func_timediff::create(Session *session, Item *arg1, Item *arg2)
2745
2746
{
2746
 
  return new (thd->mem_root) Item_func_timediff(arg1, arg2);
 
2747
  return new (session->mem_root) Item_func_timediff(arg1, arg2);
2747
2748
}
2748
2749
 
2749
2750
 
2750
2751
Create_func_to_days Create_func_to_days::s_singleton;
2751
2752
 
2752
2753
Item*
2753
 
Create_func_to_days::create(THD *thd, Item *arg1)
 
2754
Create_func_to_days::create(Session *session, Item *arg1)
2754
2755
{
2755
 
  return new (thd->mem_root) Item_func_to_days(arg1);
 
2756
  return new (session->mem_root) Item_func_to_days(arg1);
2756
2757
}
2757
2758
 
2758
2759
 
2759
2760
Create_func_ucase Create_func_ucase::s_singleton;
2760
2761
 
2761
2762
Item*
2762
 
Create_func_ucase::create(THD *thd, Item *arg1)
 
2763
Create_func_ucase::create(Session *session, Item *arg1)
2763
2764
{
2764
 
  return new (thd->mem_root) Item_func_ucase(arg1);
 
2765
  return new (session->mem_root) Item_func_ucase(arg1);
2765
2766
}
2766
2767
 
2767
2768
 
2768
2769
Create_func_unhex Create_func_unhex::s_singleton;
2769
2770
 
2770
2771
Item*
2771
 
Create_func_unhex::create(THD *thd, Item *arg1)
 
2772
Create_func_unhex::create(Session *session, Item *arg1)
2772
2773
{
2773
 
  return new (thd->mem_root) Item_func_unhex(arg1);
 
2774
  return new (session->mem_root) Item_func_unhex(arg1);
2774
2775
}
2775
2776
 
2776
2777
 
2777
2778
Create_func_unix_timestamp Create_func_unix_timestamp::s_singleton;
2778
2779
 
2779
2780
Item*
2780
 
Create_func_unix_timestamp::create_native(THD *thd, LEX_STRING name,
 
2781
Create_func_unix_timestamp::create_native(Session *session, LEX_STRING name,
2781
2782
                                          List<Item> *item_list)
2782
2783
{
2783
2784
  Item *func= NULL;
2789
2790
  switch (arg_count) {
2790
2791
  case 0:
2791
2792
  {
2792
 
    func= new (thd->mem_root) Item_func_unix_timestamp();
 
2793
    func= new (session->mem_root) Item_func_unix_timestamp();
2793
2794
    break;
2794
2795
  }
2795
2796
  case 1:
2796
2797
  {
2797
2798
    Item *param_1= item_list->pop();
2798
 
    func= new (thd->mem_root) Item_func_unix_timestamp(param_1);
 
2799
    func= new (session->mem_root) Item_func_unix_timestamp(param_1);
2799
2800
    break;
2800
2801
  }
2801
2802
  default:
2812
2813
Create_func_uuid Create_func_uuid::s_singleton;
2813
2814
 
2814
2815
Item*
2815
 
Create_func_uuid::create(THD *thd)
 
2816
Create_func_uuid::create(Session *session)
2816
2817
{
2817
 
  thd->lex->set_stmt_unsafe();
2818
 
  return new (thd->mem_root) Item_func_uuid();
 
2818
  session->lex->set_stmt_unsafe();
 
2819
  return new (session->mem_root) Item_func_uuid();
2819
2820
}
2820
2821
 
2821
2822
 
2822
2823
Create_func_version Create_func_version::s_singleton;
2823
2824
 
2824
2825
Item*
2825
 
Create_func_version::create(THD *thd)
 
2826
Create_func_version::create(Session *session)
2826
2827
{
2827
 
  return new (thd->mem_root) Item_static_string_func("version()",
 
2828
  return new (session->mem_root) Item_static_string_func("version()",
2828
2829
                                                     server_version,
2829
2830
                                                     (uint) strlen(server_version),
2830
2831
                                                     system_charset_info,
2835
2836
Create_func_weekday Create_func_weekday::s_singleton;
2836
2837
 
2837
2838
Item*
2838
 
Create_func_weekday::create(THD *thd, Item *arg1)
 
2839
Create_func_weekday::create(Session *session, Item *arg1)
2839
2840
{
2840
 
  return new (thd->mem_root) Item_func_weekday(arg1, 0);
 
2841
  return new (session->mem_root) Item_func_weekday(arg1, 0);
2841
2842
}
2842
2843
 
2843
2844
 
2844
2845
Create_func_weekofyear Create_func_weekofyear::s_singleton;
2845
2846
 
2846
2847
Item*
2847
 
Create_func_weekofyear::create(THD *thd, Item *arg1)
 
2848
Create_func_weekofyear::create(Session *session, Item *arg1)
2848
2849
{
2849
 
  Item *i1= new (thd->mem_root) Item_int((char*) "0", 3, 1);
2850
 
  return new (thd->mem_root) Item_func_week(arg1, i1);
 
2850
  Item *i1= new (session->mem_root) Item_int((char*) "0", 3, 1);
 
2851
  return new (session->mem_root) Item_func_week(arg1, i1);
2851
2852
}
2852
2853
 
2853
2854
 
2854
2855
Create_func_year_week Create_func_year_week::s_singleton;
2855
2856
 
2856
2857
Item*
2857
 
Create_func_year_week::create_native(THD *thd, LEX_STRING name,
 
2858
Create_func_year_week::create_native(Session *session, LEX_STRING name,
2858
2859
                                     List<Item> *item_list)
2859
2860
{
2860
2861
  Item *func= NULL;
2867
2868
  case 1:
2868
2869
  {
2869
2870
    Item *param_1= item_list->pop();
2870
 
    Item *i0= new (thd->mem_root) Item_int((char*) "0", 0, 1);
2871
 
    func= new (thd->mem_root) Item_func_yearweek(param_1, i0);
 
2871
    Item *i0= new (session->mem_root) Item_int((char*) "0", 0, 1);
 
2872
    func= new (session->mem_root) Item_func_yearweek(param_1, i0);
2872
2873
    break;
2873
2874
  }
2874
2875
  case 2:
2875
2876
  {
2876
2877
    Item *param_1= item_list->pop();
2877
2878
    Item *param_2= item_list->pop();
2878
 
    func= new (thd->mem_root) Item_func_yearweek(param_1, param_2);
 
2879
    func= new (session->mem_root) Item_func_yearweek(param_1, param_2);
2879
2880
    break;
2880
2881
  }
2881
2882
  default:
3064
3065
}
3065
3066
 
3066
3067
Create_func *
3067
 
find_native_function_builder(THD *thd __attribute__((unused)),
 
3068
find_native_function_builder(Session *session __attribute__((unused)),
3068
3069
                             LEX_STRING name)
3069
3070
{
3070
3071
  Native_func_registry *func;
3085
3086
 
3086
3087
 
3087
3088
Item*
3088
 
create_func_char_cast(THD *thd, Item *a, int len, const CHARSET_INFO * const cs)
 
3089
create_func_char_cast(Session *session, Item *a, int len, const CHARSET_INFO * const cs)
3089
3090
{
3090
 
  const CHARSET_INFO * const real_cs= (cs ? cs : thd->variables.collation_connection);
3091
 
  return new (thd->mem_root) Item_char_typecast(a, len, real_cs);
 
3091
  const CHARSET_INFO * const real_cs= (cs ? cs : session->variables.collation_connection);
 
3092
  return new (session->mem_root) Item_char_typecast(a, len, real_cs);
3092
3093
}
3093
3094
 
3094
3095
 
3095
3096
Item *
3096
 
create_func_cast(THD *thd, Item *a, Cast_target cast_type,
 
3097
create_func_cast(Session *session, Item *a, Cast_target cast_type,
3097
3098
                 const char *c_len, const char *c_dec,
3098
3099
                 const CHARSET_INFO * const cs)
3099
3100
{
3103
3104
 
3104
3105
  switch (cast_type) {
3105
3106
  case ITEM_CAST_BINARY:
3106
 
    res= new (thd->mem_root) Item_func_binary(a);
 
3107
    res= new (session->mem_root) Item_func_binary(a);
3107
3108
    break;
3108
3109
  case ITEM_CAST_SIGNED_INT:
3109
 
    res= new (thd->mem_root) Item_func_signed(a);
 
3110
    res= new (session->mem_root) Item_func_signed(a);
3110
3111
    break;
3111
3112
  case ITEM_CAST_UNSIGNED_INT:
3112
 
    res= new (thd->mem_root) Item_func_unsigned(a);
 
3113
    res= new (session->mem_root) Item_func_unsigned(a);
3113
3114
    break;
3114
3115
  case ITEM_CAST_DATE:
3115
 
    res= new (thd->mem_root) Item_date_typecast(a);
 
3116
    res= new (session->mem_root) Item_date_typecast(a);
3116
3117
    break;
3117
3118
  case ITEM_CAST_TIME:
3118
 
    res= new (thd->mem_root) Item_time_typecast(a);
 
3119
    res= new (session->mem_root) Item_time_typecast(a);
3119
3120
    break;
3120
3121
  case ITEM_CAST_DATETIME:
3121
 
    res= new (thd->mem_root) Item_datetime_typecast(a);
 
3122
    res= new (session->mem_root) Item_datetime_typecast(a);
3122
3123
    break;
3123
3124
  case ITEM_CAST_DECIMAL:
3124
3125
  {
3142
3143
               DECIMAL_MAX_SCALE);
3143
3144
      return 0;
3144
3145
    }
3145
 
    res= new (thd->mem_root) Item_decimal_typecast(a, len, dec);
 
3146
    res= new (session->mem_root) Item_decimal_typecast(a, len, dec);
3146
3147
    break;
3147
3148
  }
3148
3149
  case ITEM_CAST_CHAR:
3149
3150
  {
3150
3151
    len= c_len ? atoi(c_len) : -1;
3151
 
    res= create_func_char_cast(thd, a, len, cs);
 
3152
    res= create_func_char_cast(session, a, len, cs);
3152
3153
    break;
3153
3154
  }
3154
3155
  default: