~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_create.cc

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

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