107
107
but semantically invalid for native functions.
111
Checks if there are named parameters in a parameter list.
112
The syntax to name parameters in a function call is as follow:
113
<code>foo(expr AS named, expr named, expr AS "named", expr "named")</code>
114
@param params The parameter list, can be null
115
@return true if one or more parameter is named
117
static bool has_named_parameters(List<Item>& params)
119
List<Item>::iterator it(params.begin());
120
while (Item* param= it++)
122
if (not param->is_autogenerated_name)
110
128
class Create_native_func : public Create_func
113
virtual Item *create(Session *session, LEX_STRING name, List<Item> *item_list);
131
virtual Item* create(Session* session, LEX_STRING name, List<Item>* item_list)
133
if (item_list && has_named_parameters(*item_list))
135
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
138
return create_native(session, name, item_list);
116
142
Builder method, with no arguments.
249
264
using Create_func_arg1::create;
251
virtual Item *create(Session *session, Item *arg1);
266
virtual Item* create(Session *session, Item *arg1);
253
268
static Create_func_bin s_singleton;
256
271
Create_func_bin() {}
257
virtual ~Create_func_bin() {}
260
274
class Create_func_concat : public Create_native_func
263
virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
277
virtual Item* create_native(Session *session, LEX_STRING name, List<Item> *item_list);
265
279
static Create_func_concat s_singleton;
268
282
Create_func_concat() {}
269
virtual ~Create_func_concat() {}
273
286
class Create_func_concat_ws : public Create_native_func
276
virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
289
virtual Item* create_native(Session *session, LEX_STRING name, List<Item> *item_list);
278
291
static Create_func_concat_ws s_singleton;
281
294
Create_func_concat_ws() {}
282
virtual ~Create_func_concat_ws() {}
289
301
using Create_func_arg3::create;
291
virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
303
virtual Item* create(Session *session, Item *arg1, Item *arg2, Item *arg3)
305
return new (session->mem) Item_func_conv(arg1, arg2, arg3);
293
308
static Create_func_conv s_singleton;
296
310
Create_func_conv() {}
297
virtual ~Create_func_conv() {}
313
Create_func_conv Create_func_conv::s_singleton;
300
315
class Create_func_cot : public Create_func_arg1
303
318
using Create_func_arg1::create;
305
virtual Item *create(Session *session, Item *arg1);
320
virtual Item* create(Session *session, Item *arg1);
307
322
static Create_func_cot s_singleton;
310
325
Create_func_cot() {}
311
virtual ~Create_func_cot() {}
314
328
class Create_func_date_format : public Create_func_arg2
317
331
using Create_func_arg2::create;
319
virtual Item *create(Session *session, Item *arg1, Item *arg2);
333
virtual Item* create(Session *session, Item *arg1, Item *arg2)
335
return new (session->mem) Item_func_date_format(arg1, arg2, 0);
321
338
static Create_func_date_format s_singleton;
324
340
Create_func_date_format() {}
325
virtual ~Create_func_date_format() {}
343
Create_func_date_format Create_func_date_format::s_singleton;
329
345
class Create_func_datediff : public Create_func_arg2
332
348
using Create_func_arg2::create;
334
virtual Item *create(Session *session, Item *arg1, Item *arg2);
350
virtual Item* create(Session *session, Item *arg1, Item *arg2);
336
352
static Create_func_datediff s_singleton;
339
355
Create_func_datediff() {}
340
virtual ~Create_func_datediff() {}
347
362
using Create_func_arg1::create;
349
virtual Item *create(Session *session, Item *arg1);
364
virtual Item* create(Session *session, Item *arg1)
366
return new (session->mem) Item_func_dayname(arg1);
351
369
static Create_func_dayname s_singleton;
354
372
Create_func_dayname() {}
355
virtual ~Create_func_dayname() {}
375
Create_func_dayname Create_func_dayname::s_singleton;
359
377
class Create_func_dayofmonth : public Create_func_arg1
362
380
using Create_func_arg1::create;
364
virtual Item *create(Session *session, Item *arg1);
382
virtual Item* create(Session *session, Item *arg1)
384
return new (session->mem) Item_func_dayofmonth(arg1);
366
387
static Create_func_dayofmonth s_singleton;
369
389
Create_func_dayofmonth() {}
370
virtual ~Create_func_dayofmonth() {}
392
Create_func_dayofmonth Create_func_dayofmonth::s_singleton;
374
394
class Create_func_dayofweek : public Create_func_arg1
377
397
using Create_func_arg1::create;
379
virtual Item *create(Session *session, Item *arg1);
399
virtual Item* create(Session *session, Item *arg1)
401
return new (session->mem) Item_func_weekday(arg1, 1);
381
404
static Create_func_dayofweek s_singleton;
384
406
Create_func_dayofweek() {}
385
virtual ~Create_func_dayofweek() {}
409
Create_func_dayofweek Create_func_dayofweek::s_singleton;
389
411
class Create_func_dayofyear : public Create_func_arg1
392
414
using Create_func_arg1::create;
394
virtual Item *create(Session *session, Item *arg1);
416
virtual Item* create(Session *session, Item *arg1)
418
return new (session->mem) Item_func_dayofyear(arg1);
396
421
static Create_func_dayofyear s_singleton;
399
423
Create_func_dayofyear() {}
400
virtual ~Create_func_dayofyear() {}
426
Create_func_dayofyear Create_func_dayofyear::s_singleton;
404
428
class Create_func_decode : public Create_func_arg2
407
431
using Create_func_arg2::create;
409
virtual Item *create(Session *session, Item *arg1, Item *arg2);
433
virtual Item* create(Session *session, Item *arg1, Item *arg2);
411
435
static Create_func_decode s_singleton;
414
438
Create_func_decode() {}
415
virtual ~Create_func_decode() {}
422
445
using Create_func_arg1::create;
424
virtual Item *create(Session *session, Item *arg1);
447
virtual Item* create(Session *session, Item *arg1)
449
return new (session->mem) Item_func_units("degrees", arg1, 180/M_PI, 0.0);
426
452
static Create_func_degrees s_singleton;
429
454
Create_func_degrees() {}
430
virtual ~Create_func_degrees() {}
457
Create_func_degrees Create_func_degrees::s_singleton;
433
459
class Create_func_export_set : public Create_native_func
437
virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
463
virtual Item* create_native(Session *session, LEX_STRING name, List<Item> *item_list);
439
465
static Create_func_export_set s_singleton;
442
468
Create_func_export_set() {}
443
virtual ~Create_func_export_set() {}
447
472
class Create_func_field : public Create_native_func
450
virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
475
virtual Item* create_native(Session *session, LEX_STRING name, List<Item> *item_list);
452
477
static Create_func_field s_singleton;
455
480
Create_func_field() {}
456
virtual ~Create_func_field() {}
492
514
using Create_func_arg1::create;
494
virtual Item *create(Session *session, Item *arg1);
516
virtual Item* create(Session *session, Item *arg1);
496
518
static Create_func_from_days s_singleton;
499
521
Create_func_from_days() {}
500
virtual ~Create_func_from_days() {}
504
525
class Create_func_from_unixtime : public Create_native_func
507
virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
528
virtual Item* create_native(Session *session, LEX_STRING name, List<Item> *item_list);
509
530
static Create_func_from_unixtime s_singleton;
512
533
Create_func_from_unixtime() {}
513
virtual ~Create_func_from_unixtime() {}
517
537
class Create_func_greatest : public Create_native_func
520
virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
540
virtual Item* create_native(Session *session, LEX_STRING name, List<Item> *item_list);
522
542
static Create_func_greatest s_singleton;
525
545
Create_func_greatest() {}
526
virtual ~Create_func_greatest() {}
661
671
using Create_func_arg3::create;
663
virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
673
virtual Item* create(Session *session, Item *arg1, Item *arg2, Item *arg3)
675
return new (session->mem) Item_func_lpad(*session, arg1, arg2, arg3);
665
678
static Create_func_lpad s_singleton;
668
680
Create_func_lpad() {}
669
virtual ~Create_func_lpad() {}
683
Create_func_lpad Create_func_lpad::s_singleton;
673
685
class Create_func_ltrim : public Create_func_arg1
676
688
using Create_func_arg1::create;
678
virtual Item *create(Session *session, Item *arg1);
690
virtual Item* create(Session *session, Item *arg1)
692
return new (session->mem) Item_func_ltrim(arg1);
680
695
static Create_func_ltrim s_singleton;
683
697
Create_func_ltrim() {}
684
virtual ~Create_func_ltrim() {}
700
Create_func_ltrim Create_func_ltrim::s_singleton;
688
702
class Create_func_makedate : public Create_func_arg2
691
705
using Create_func_arg2::create;
693
virtual Item *create(Session *session, Item *arg1, Item *arg2);
707
virtual Item* create(Session *session, Item *arg1, Item *arg2)
709
return new (session->mem) Item_func_makedate(arg1, arg2);
695
712
static Create_func_makedate s_singleton;
698
714
Create_func_makedate() {}
699
virtual ~Create_func_makedate() {}
717
Create_func_makedate Create_func_makedate::s_singleton;
702
719
class Create_func_make_set : public Create_native_func
705
virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
722
virtual Item* create_native(Session *session, LEX_STRING name, List<Item> *item_list);
707
724
static Create_func_make_set s_singleton;
710
727
Create_func_make_set() {}
711
virtual ~Create_func_make_set() {}
718
734
using Create_func_arg1::create;
720
virtual Item *create(Session *session, Item *arg1);
736
virtual Item* create(Session *session, Item *arg1)
738
return new (session->mem) Item_func_monthname(arg1);
722
741
static Create_func_monthname s_singleton;
725
743
Create_func_monthname() {}
726
virtual ~Create_func_monthname() {}
746
Create_func_monthname Create_func_monthname::s_singleton;
730
748
class Create_func_name_const : public Create_func_arg2
733
751
using Create_func_arg2::create;
735
virtual Item *create(Session *session, Item *arg1, Item *arg2);
753
virtual Item* create(Session *session, Item *arg1, Item *arg2);
737
755
static Create_func_name_const s_singleton;
740
758
Create_func_name_const() {}
741
virtual ~Create_func_name_const() {}
748
765
using Create_func_arg2::create;
750
virtual Item *create(Session *session, Item *arg1, Item *arg2);
767
virtual Item* create(Session *session, Item *arg1, Item *arg2)
769
return new (session->mem) Item_func_nullif(arg1, arg2);
752
772
static Create_func_nullif s_singleton;
755
774
Create_func_nullif() {}
756
virtual ~Create_func_nullif() {}
777
Create_func_nullif Create_func_nullif::s_singleton;
760
779
class Create_func_oct : public Create_func_arg1
763
782
using Create_func_arg1::create;
765
virtual Item *create(Session *session, Item *arg1);
784
virtual Item* create(Session *session, Item *arg1);
767
786
static Create_func_oct s_singleton;
770
789
Create_func_oct() {}
771
virtual ~Create_func_oct() {}
774
792
class Create_func_period_add : public Create_func_arg2
849
860
using Create_func_arg0::create;
851
virtual Item *create(Session *session);
862
virtual Item* create(Session *session)
864
return new (session->mem) Item_func_row_count();
853
867
static Create_func_row_count s_singleton;
856
869
Create_func_row_count() {}
857
virtual ~Create_func_row_count() {}
872
Create_func_row_count Create_func_row_count::s_singleton;
861
874
class Create_func_rpad : public Create_func_arg3
864
877
using Create_func_arg3::create;
866
virtual Item *create(Session *session, Item *arg1, Item *arg2, Item *arg3);
879
virtual Item* create(Session *session, Item *arg1, Item *arg2, Item *arg3)
881
return new (session->mem) Item_func_rpad(*session, arg1, arg2, arg3);
868
884
static Create_func_rpad s_singleton;
871
886
Create_func_rpad() {}
872
virtual ~Create_func_rpad() {}
889
Create_func_rpad Create_func_rpad::s_singleton;
876
891
class Create_func_rtrim : public Create_func_arg1
879
894
using Create_func_arg1::create;
881
virtual Item *create(Session *session, Item *arg1);
896
virtual Item* create(Session *session, Item *arg1)
898
return new (session->mem) Item_func_rtrim(arg1);
883
901
static Create_func_rtrim s_singleton;
886
904
Create_func_rtrim() {}
887
virtual ~Create_func_rtrim() {}
907
Create_func_rtrim Create_func_rtrim::s_singleton;
890
909
class Create_func_sign : public Create_func_arg1
893
912
using Create_func_arg1::create;
895
virtual Item *create(Session *session, Item *arg1);
914
virtual Item* create(Session *session, Item *arg1)
916
return new (session->mem) Item_func_sign(arg1);
897
919
static Create_func_sign s_singleton;
900
921
Create_func_sign() {}
901
virtual ~Create_func_sign() {}
924
Create_func_sign Create_func_sign::s_singleton;
904
926
class Create_func_space : public Create_func_arg1
907
929
using Create_func_arg1::create;
909
virtual Item *create(Session *session, Item *arg1);
931
virtual Item* create(Session *session, Item *arg1);
911
933
static Create_func_space s_singleton;
914
935
Create_func_space() {}
915
virtual ~Create_func_space() {}
918
938
class Create_func_strcmp : public Create_func_arg2
921
941
using Create_func_arg2::create;
923
virtual Item *create(Session *session, Item *arg1, Item *arg2);
943
virtual Item* create(Session *session, Item *arg1, Item *arg2)
945
return new (session->mem) Item_func_strcmp(arg1, arg2);
925
948
static Create_func_strcmp s_singleton;
928
950
Create_func_strcmp() {}
929
virtual ~Create_func_strcmp() {}
953
Create_func_strcmp Create_func_strcmp::s_singleton;
933
955
class Create_func_tan : public Create_func_arg1
936
958
using Create_func_arg1::create;
938
virtual Item *create(Session *session, Item *arg1);
960
virtual Item* create(Session *session, Item *arg1)
962
return new (session->mem) Item_func_tan(arg1);
940
965
static Create_func_tan s_singleton;
943
967
Create_func_tan() {}
944
virtual ~Create_func_tan() {}
970
Create_func_tan Create_func_tan::s_singleton;
948
972
class Create_func_time_format : public Create_func_arg2
951
975
using Create_func_arg2::create;
953
virtual Item *create(Session *session, Item *arg1, Item *arg2);
977
virtual Item* create(Session *session, Item *arg1, Item *arg2)
979
return new (session->mem) Item_func_date_format(arg1, arg2, 1);
955
982
static Create_func_time_format s_singleton;
958
984
Create_func_time_format() {}
959
virtual ~Create_func_time_format() {}
963
class Create_func_time_to_sec : public Create_func_arg1
966
using Create_func_arg1::create;
968
virtual Item *create(Session *session, Item *arg1);
970
static Create_func_time_to_sec s_singleton;
973
Create_func_time_to_sec() {}
974
virtual ~Create_func_time_to_sec() {}
987
Create_func_time_format Create_func_time_format::s_singleton;
978
989
class Create_func_to_days : public Create_func_arg1
981
992
using Create_func_arg1::create;
983
virtual Item *create(Session *session, Item *arg1);
994
virtual Item* create(Session *session, Item *arg1)
996
return new (session->mem) Item_func_to_days(arg1);
985
999
static Create_func_to_days s_singleton;
988
1001
Create_func_to_days() {}
989
virtual ~Create_func_to_days() {}
1004
Create_func_to_days Create_func_to_days::s_singleton;
993
1006
class Create_func_ucase : public Create_func_arg1
996
1009
using Create_func_arg1::create;
998
virtual Item *create(Session *session, Item *arg1);
1011
virtual Item* create(Session *session, Item *arg1)
1013
return new (session->mem) Item_func_ucase(arg1);
1000
1016
static Create_func_ucase s_singleton;
1003
1018
Create_func_ucase() {}
1004
virtual ~Create_func_ucase() {}
1021
Create_func_ucase Create_func_ucase::s_singleton;
1008
1023
class Create_func_unix_timestamp : public Create_native_func
1011
virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1026
virtual Item* create_native(Session *session, LEX_STRING name, List<Item> *item_list);
1013
1028
static Create_func_unix_timestamp s_singleton;
1016
1030
Create_func_unix_timestamp() {}
1017
virtual ~Create_func_unix_timestamp() {}
1024
1037
using Create_func_arg1::create;
1026
virtual Item *create(Session *session, Item *arg1);
1039
virtual Item* create(Session *session, Item *arg1)
1041
return new (session->mem) Item_func_weekday(arg1, 0);
1028
1044
static Create_func_weekday s_singleton;
1031
1046
Create_func_weekday() {}
1032
virtual ~Create_func_weekday() {}
1049
Create_func_weekday Create_func_weekday::s_singleton;
1036
1052
=============================================================================
1038
1054
=============================================================================
1042
Checks if there are named parameters in a parameter list.
1043
The syntax to name parameters in a function call is as follow:
1044
<code>foo(expr AS named, expr named, expr AS "named", expr "named")</code>
1045
@param params The parameter list, can be null
1046
@return true if one or more parameter is named
1048
static bool has_named_parameters(List<Item> *params)
1053
List<Item>::iterator it(params->begin());
1054
while ((param= it++))
1056
if (! param->is_autogenerated_name)
1065
1057
Create_udf_func Create_udf_func::s_singleton;
1068
Create_udf_func::create(Session *session, LEX_STRING name, List<Item> *item_list)
1070
const plugin::Function *udf= plugin::Function::get(std::string(name.str, name.length));
1059
Item* Create_udf_func::create(Session *session, LEX_STRING name, List<Item> *item_list)
1061
return create(session, plugin::Function::get(std::string(name.str, name.length)), item_list);
1064
Item* Create_udf_func::create(Session *session, const plugin::Function *udf, List<Item> *item_list)
1072
return create(session, udf, item_list);
1077
Create_udf_func::create(Session *session, const plugin::Function *udf,
1078
List<Item> *item_list)
1080
Item_func *func= NULL;
1083
if (item_list != NULL)
1084
arg_count= item_list->size();
1086
func= (*udf)(session->mem_root);
1088
if(!func->check_argument_count(arg_count))
1067
int arg_count= item_list ? item_list->size() : 0;
1068
Item_func* func= (*udf)(&session->mem);
1069
if (!func->check_argument_count(arg_count))
1090
1071
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), func->func_name());
1095
1075
func->set_arguments(*item_list);
1102
Create_native_func::create(Session *session, LEX_STRING name, List<Item> *item_list)
1104
if (has_named_parameters(item_list))
1106
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
1110
return create_native(session, name, item_list);
1115
Create_func_arg0::create(Session *session, LEX_STRING name, List<Item> *item_list)
1119
if (item_list != NULL)
1120
arg_count= item_list->size();
1079
Item* Create_func_arg0::create(Session *session, LEX_STRING name, List<Item> *item_list)
1081
if (item_list && item_list->size())
1124
1083
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1128
1086
return create(session);
1133
Create_func_arg1::create(Session *session, LEX_STRING name, List<Item> *item_list)
1089
Item* Create_func_arg1::create(Session *session, LEX_STRING name, List<Item> *item_list)
1138
arg_count= item_list->size();
1091
int arg_count= item_list ? item_list->size() : 0;
1140
1092
if (arg_count != 1)
1142
1094
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1218
1162
Create_func_bin::create(Session *session, Item *arg1)
1220
Item *i10= new (session->mem_root) Item_int((int32_t) 10,2);
1221
Item *i2= new (session->mem_root) Item_int((int32_t) 2,1);
1222
return new (session->mem_root) Item_func_conv(arg1, i10, i2);
1164
Item *i10= new (session->mem) Item_int(10, 2);
1165
Item *i2= new (session->mem) Item_int(2, 1);
1166
return new (session->mem) Item_func_conv(arg1, i10, i2);
1225
1169
Create_func_concat Create_func_concat::s_singleton;
1228
Create_func_concat::create_native(Session *session, LEX_STRING name,
1229
List<Item> *item_list)
1172
Create_func_concat::create_native(Session *session, LEX_STRING name, List<Item> *item_list)
1233
if (item_list != NULL)
1234
arg_count= item_list->size();
1174
int arg_count= item_list ? item_list->size() : 0;
1236
1175
if (arg_count < 1)
1238
1177
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1242
return new (session->mem_root) Item_func_concat(*session, *item_list);
1181
return new (session->mem) Item_func_concat(*session, *item_list);
1279
1205
Create_func_cot::create(Session *session, Item *arg1)
1281
Item *i1= new (session->mem_root) Item_int((char*) "1", 1, 1);
1282
Item *i2= new (session->mem_root) Item_func_tan(arg1);
1283
return new (session->mem_root) Item_func_div(session, i1, i2);
1286
Create_func_date_format Create_func_date_format::s_singleton;
1289
Create_func_date_format::create(Session *session, Item *arg1, Item *arg2)
1291
return new (session->mem_root) Item_func_date_format(arg1, arg2, 0);
1207
Item *i1= new (session->mem) Item_int("1", 1, 1);
1208
Item *i2= new (session->mem) Item_func_tan(arg1);
1209
return new (session->mem) Item_func_div(session, i1, i2);
1295
1212
Create_func_datediff Create_func_datediff::s_singleton;
1298
1215
Create_func_datediff::create(Session *session, Item *arg1, Item *arg2)
1300
Item *i1= new (session->mem_root) Item_func_to_days(arg1);
1301
Item *i2= new (session->mem_root) Item_func_to_days(arg2);
1303
return new (session->mem_root) Item_func_minus(i1, i2);
1307
Create_func_dayname Create_func_dayname::s_singleton;
1310
Create_func_dayname::create(Session *session, Item *arg1)
1312
return new (session->mem_root) Item_func_dayname(arg1);
1316
Create_func_dayofmonth Create_func_dayofmonth::s_singleton;
1319
Create_func_dayofmonth::create(Session *session, Item *arg1)
1321
return new (session->mem_root) Item_func_dayofmonth(arg1);
1325
Create_func_dayofweek Create_func_dayofweek::s_singleton;
1328
Create_func_dayofweek::create(Session *session, Item *arg1)
1330
return new (session->mem_root) Item_func_weekday(arg1, 1);
1334
Create_func_dayofyear Create_func_dayofyear::s_singleton;
1337
Create_func_dayofyear::create(Session *session, Item *arg1)
1339
return new (session->mem_root) Item_func_dayofyear(arg1);
1343
Create_func_degrees Create_func_degrees::s_singleton;
1346
Create_func_degrees::create(Session *session, Item *arg1)
1348
return new (session->mem_root) Item_func_units((char*) "degrees", arg1,
1217
Item *i1= new (session->mem) Item_func_to_days(arg1);
1218
Item *i2= new (session->mem) Item_func_to_days(arg2);
1219
return new (session->mem) Item_func_minus(i1, i2);
1352
1222
Create_func_export_set Create_func_export_set::s_singleton;
1355
Create_func_export_set::create_native(Session *session, LEX_STRING name,
1356
List<Item> *item_list)
1225
Create_func_export_set::create_native(Session *session, LEX_STRING name, List<Item> *item_list)
1361
if (item_list != NULL)
1362
arg_count= item_list->size();
1364
switch (arg_count) {
1227
switch (item_list ? item_list->size() : 0)
1367
Item *param_1= item_list->pop();
1368
Item *param_2= item_list->pop();
1369
Item *param_3= item_list->pop();
1370
func= new (session->mem_root) Item_func_export_set(param_1, param_2, param_3);
1231
Item *param_1= item_list->pop();
1232
Item *param_2= item_list->pop();
1233
Item *param_3= item_list->pop();
1234
return new (session->mem) Item_func_export_set(param_1, param_2, param_3);
1375
Item *param_1= item_list->pop();
1376
Item *param_2= item_list->pop();
1377
Item *param_3= item_list->pop();
1378
Item *param_4= item_list->pop();
1379
func= new (session->mem_root) Item_func_export_set(param_1, param_2, param_3,
1238
Item *param_1= item_list->pop();
1239
Item *param_2= item_list->pop();
1240
Item *param_3= item_list->pop();
1241
Item *param_4= item_list->pop();
1242
return new (session->mem) Item_func_export_set(param_1, param_2, param_3, param_4);
1385
Item *param_1= item_list->pop();
1386
Item *param_2= item_list->pop();
1387
Item *param_3= item_list->pop();
1388
Item *param_4= item_list->pop();
1389
Item *param_5= item_list->pop();
1390
func= new (session->mem_root) Item_func_export_set(param_1, param_2, param_3,
1246
Item *param_1= item_list->pop();
1247
Item *param_2= item_list->pop();
1248
Item *param_3= item_list->pop();
1249
Item *param_4= item_list->pop();
1250
Item *param_5= item_list->pop();
1251
return new (session->mem) Item_func_export_set(param_1, param_2, param_3, param_4, param_5);
1396
1254
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1455
1306
Create_func_from_unixtime::create_native(Session *session, LEX_STRING name,
1456
1307
List<Item> *item_list)
1461
if (item_list != NULL)
1462
arg_count= item_list->size();
1464
switch (arg_count) {
1309
switch (item_list ? item_list->size() : 0)
1467
Item *param_1= item_list->pop();
1468
func= new (session->mem_root) Item_func_from_unixtime(param_1);
1313
Item *param_1= item_list->pop();
1314
return new (session->mem) Item_func_from_unixtime(param_1);
1473
Item *param_1= item_list->pop();
1474
Item *param_2= item_list->pop();
1475
Item *ut= new (session->mem_root) Item_func_from_unixtime(param_1);
1476
func= new (session->mem_root) Item_func_date_format(ut, param_2, 0);
1318
Item *param_1= item_list->pop();
1319
Item *param_2= item_list->pop();
1320
Item *ut= new (session->mem) Item_func_from_unixtime(param_1);
1321
return new (session->mem) Item_func_date_format(ut, param_2, 0);
1481
1324
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1622
1443
Create_func_locate::create_native(Session *session, LEX_STRING name,
1623
1444
List<Item> *item_list)
1628
if (item_list != NULL)
1629
arg_count= item_list->size();
1631
switch (arg_count) {
1446
int arg_count= item_list ? item_list->size() : 0;
1634
Item *param_1= item_list->pop();
1635
Item *param_2= item_list->pop();
1636
/* Yes, parameters in that order : 2, 1 */
1637
func= new (session->mem_root) Item_func_locate(param_2, param_1);
1451
Item *param_1= item_list->pop();
1452
Item *param_2= item_list->pop();
1453
/* Yes, parameters in that order : 2, 1 */
1454
return new (session->mem) Item_func_locate(param_2, param_1);
1642
Item *param_1= item_list->pop();
1643
Item *param_2= item_list->pop();
1644
Item *param_3= item_list->pop();
1645
/* Yes, parameters in that order : 2, 1, 3 */
1646
func= new (session->mem_root) Item_func_locate(param_2, param_1, param_3);
1458
Item *param_1= item_list->pop();
1459
Item *param_2= item_list->pop();
1460
Item *param_3= item_list->pop();
1461
/* Yes, parameters in that order : 2, 1, 3 */
1462
return new (session->mem) Item_func_locate(param_2, param_1, param_3);
1651
1465
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1659
Create_func_lpad Create_func_lpad::s_singleton;
1662
Create_func_lpad::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
1664
return new (session->mem_root) Item_func_lpad(*session, arg1, arg2, arg3);
1668
Create_func_ltrim Create_func_ltrim::s_singleton;
1671
Create_func_ltrim::create(Session *session, Item *arg1)
1673
return new (session->mem_root) Item_func_ltrim(arg1);
1677
Create_func_makedate Create_func_makedate::s_singleton;
1680
Create_func_makedate::create(Session *session, Item *arg1, Item *arg2)
1682
return new (session->mem_root) Item_func_makedate(arg1, arg2);
1686
1470
Create_func_make_set Create_func_make_set::s_singleton;
1703
1483
Item *param_1= item_list->pop();
1704
return new (session_arg->mem_root) Item_func_make_set(*session_arg, param_1, *item_list);
1708
Create_func_monthname Create_func_monthname::s_singleton;
1711
Create_func_monthname::create(Session *session, Item *arg1)
1713
return new (session->mem_root) Item_func_monthname(arg1);
1717
Create_func_nullif Create_func_nullif::s_singleton;
1720
Create_func_nullif::create(Session *session, Item *arg1, Item *arg2)
1722
return new (session->mem_root) Item_func_nullif(arg1, arg2);
1484
return new (session_arg->mem) Item_func_make_set(*session_arg, param_1, *item_list);
1726
1487
Create_func_oct Create_func_oct::s_singleton;
1729
1490
Create_func_oct::create(Session *session, Item *arg1)
1731
Item *i10= new (session->mem_root) Item_int((int32_t) 10,2);
1732
Item *i8= new (session->mem_root) Item_int((int32_t) 8,1);
1733
return new (session->mem_root) Item_func_conv(arg1, i10, i8);
1492
Item *i10= new (session->mem) Item_int((int32_t) 10,2);
1493
Item *i8= new (session->mem) Item_int((int32_t) 8,1);
1494
return new (session->mem) Item_func_conv(arg1, i10, i8);
1736
1497
Create_func_period_add Create_func_period_add::s_singleton;
1765
1526
Create_func_radians::create(Session *session, Item *arg1)
1767
return new (session->mem_root) Item_func_units((char*) "radians", arg1,
1528
return new (session->mem) Item_func_units("radians", arg1,
1768
1529
M_PI/180, 0.0);
1771
1532
Create_func_round Create_func_round::s_singleton;
1774
Create_func_round::create_native(Session *session, LEX_STRING name,
1775
List<Item> *item_list)
1534
Item* Create_func_round::create_native(Session *session, LEX_STRING name, List<Item> *item_list)
1780
if (item_list != NULL)
1781
arg_count= item_list->size();
1783
switch (arg_count) {
1536
switch (item_list ? item_list->size() : 0)
1786
1540
Item *param_1= item_list->pop();
1787
Item *i0 = new (session->mem_root) Item_int((char*)"0", 0, 1);
1788
func= new (session->mem_root) Item_func_round(param_1, i0, 0);
1541
Item *i0 = new (session->mem) Item_int("0", 0, 1);
1542
return new (session->mem) Item_func_round(param_1, i0, 0);
1793
1546
Item *param_1= item_list->pop();
1794
1547
Item *param_2= item_list->pop();
1795
func= new (session->mem_root) Item_func_round(param_1, param_2, 0);
1548
return new (session->mem) Item_func_round(param_1, param_2, 0);
1800
1551
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1809
Create_func_row_count Create_func_row_count::s_singleton;
1812
Create_func_row_count::create(Session *session)
1814
return new (session->mem_root) Item_func_row_count();
1818
Create_func_rpad Create_func_rpad::s_singleton;
1821
Create_func_rpad::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
1823
return new (session->mem_root) Item_func_rpad(*session, arg1, arg2, arg3);
1827
Create_func_rtrim Create_func_rtrim::s_singleton;
1830
Create_func_rtrim::create(Session *session, Item *arg1)
1832
return new (session->mem_root) Item_func_rtrim(arg1);
1836
Create_func_sign Create_func_sign::s_singleton;
1839
Create_func_sign::create(Session *session, Item *arg1)
1841
return new (session->mem_root) Item_func_sign(arg1);
1844
1556
Create_func_space Create_func_space::s_singleton;
1857
1569
if (cs->mbminlen > 1)
1859
sp= new (session->mem_root) Item_string("", 0, cs, DERIVATION_COERCIBLE);
1571
sp= new (session->mem) Item_string("", 0, cs, DERIVATION_COERCIBLE);
1860
1572
sp->str_value.copy(" ", 1, cs);
1864
sp= new (session->mem_root) Item_string(" ", 1, cs, DERIVATION_COERCIBLE);
1576
sp= new (session->mem) Item_string(" ", 1, cs, DERIVATION_COERCIBLE);
1867
return new (session->mem_root) Item_func_repeat(*session, sp, arg1);
1870
Create_func_strcmp Create_func_strcmp::s_singleton;
1873
Create_func_strcmp::create(Session *session, Item *arg1, Item *arg2)
1875
return new (session->mem_root) Item_func_strcmp(arg1, arg2);
1879
Create_func_tan Create_func_tan::s_singleton;
1882
Create_func_tan::create(Session *session, Item *arg1)
1884
return new (session->mem_root) Item_func_tan(arg1);
1888
Create_func_time_format Create_func_time_format::s_singleton;
1891
Create_func_time_format::create(Session *session, Item *arg1, Item *arg2)
1893
return new (session->mem_root) Item_func_date_format(arg1, arg2, 1);
1896
Create_func_to_days Create_func_to_days::s_singleton;
1899
Create_func_to_days::create(Session *session, Item *arg1)
1901
return new (session->mem_root) Item_func_to_days(arg1);
1905
Create_func_ucase Create_func_ucase::s_singleton;
1908
Create_func_ucase::create(Session *session, Item *arg1)
1910
return new (session->mem_root) Item_func_ucase(arg1);
1579
return new (session->mem) Item_func_repeat(*session, sp, arg1);
1913
1582
Create_func_unix_timestamp Create_func_unix_timestamp::s_singleton;
1916
1585
Create_func_unix_timestamp::create_native(Session *session, LEX_STRING name,
1917
1586
List<Item> *item_list)
1922
if (item_list != NULL)
1923
arg_count= item_list->size();
1925
switch (arg_count) {
1588
switch (item_list ? item_list->size() : 0)
1928
func= new (session->mem_root) Item_func_unix_timestamp();
1591
return new (session->mem) Item_func_unix_timestamp();
1933
Item *param_1= item_list->pop();
1934
func= new (session->mem_root) Item_func_unix_timestamp(param_1);
1593
return new (session->mem) Item_func_unix_timestamp(item_list->pop());
1939
1595
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1948
Create_func_weekday Create_func_weekday::s_singleton;
1951
Create_func_weekday::create(Session *session, Item *arg1)
1953
return new (session->mem_root) Item_func_weekday(arg1, 0);
1956
1601
struct Native_func_registry
2048
1693
Item* create_func_char_cast(Session *session, Item *a, int len, const charset_info_st * const cs)
2050
return new (session->mem_root) Item_char_typecast(a, len, cs ? cs : session->variables.getCollation());
1695
return new (session->mem) Item_char_typecast(a, len, cs ? cs : session->variables.getCollation());
2053
Item* create_func_cast(Session *session, Item *a, Cast_target cast_type,
2054
const char *c_len, const char *c_dec,
2055
const charset_info_st * const cs)
1698
Item* create_func_cast(Session *session, Item *a, Cast_target cast_type, const char *c_len, const char *c_dec, const charset_info_st * const cs)
2061
switch (cast_type) {
2062
1702
case ITEM_CAST_SIGNED:
2063
res= new (session->mem_root) function::cast::Signed(a);
1703
return new (session->mem) function::cast::Signed(a);
2066
1704
case ITEM_CAST_UNSIGNED:
2067
res= new (session->mem_root) function::cast::Unsigned(a);
1705
return new (session->mem) function::cast::Unsigned(a);
2070
1706
case ITEM_CAST_BINARY:
2071
res= new (session->mem_root) Item_func_binary(a);
1707
return new (session->mem) Item_func_binary(a);
2074
1708
case ITEM_CAST_BOOLEAN:
2075
res= new (session->mem_root) function::cast::Boolean(a);
1709
return new (session->mem) function::cast::Boolean(a);
2078
1710
case ITEM_CAST_TIME:
2079
res= new (session->mem_root) function::cast::Time(a);
1711
return new (session->mem) function::cast::Time(a);
2082
1712
case ITEM_CAST_DATE:
2083
res= new (session->mem_root) Item_date_typecast(a);
1713
return new (session->mem) Item_date_typecast(a);
2086
1714
case ITEM_CAST_DATETIME:
2087
res= new (session->mem_root) Item_datetime_typecast(a);
1715
return new (session->mem) Item_datetime_typecast(a);
2090
1716
case ITEM_CAST_DECIMAL:
2092
len= c_len ? atoi(c_len) : 0;
2093
dec= c_dec ? atoi(c_dec) : 0;
1718
uint32_t len= c_len ? atoi(c_len) : 0;
1719
uint32_t dec= c_dec ? atoi(c_dec) : 0;
2094
1720
class_decimal_trim(&len, &dec);
2100
1726
if (len > DECIMAL_MAX_PRECISION)
2102
my_error(ER_TOO_BIG_PRECISION, MYF(0), len, a->name,
2103
DECIMAL_MAX_PRECISION);
1728
my_error(ER_TOO_BIG_PRECISION, MYF(0), len, a->name, DECIMAL_MAX_PRECISION);
2106
1731
if (dec > DECIMAL_MAX_SCALE)
2108
my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->name,
1733
my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->name, DECIMAL_MAX_SCALE);
2112
res= new (session->mem_root) Item_decimal_typecast(a, len, dec);
1736
return new (session->mem) Item_decimal_typecast(a, len, dec);
2115
1738
case ITEM_CAST_CHAR:
2117
len= c_len ? atoi(c_len) : -1;
2118
res= create_func_char_cast(session, a, len, cs);
1739
return create_func_char_cast(session, a, c_len ? atoi(c_len) : -1, cs);
2126
1744
} /* namespace drizzled */