128
128
class Create_native_func : public Create_func
131
virtual Item* create(Session* session, lex_string_t name, List<Item>* item_list)
131
virtual Item* create(Session* session, str_ref name, List<Item>* item_list)
133
133
if (item_list && has_named_parameters(*item_list))
145
145
@param item_list The function parameters, none of which are named
146
146
@return An item representing the function call
148
virtual Item* create_native(Session*, lex_string_t name, List<Item>*) = 0;
148
virtual Item* create_native(Session*, str_ref name, List<Item>*) = 0;
156
156
class Create_func_arg0 : public Create_func
159
virtual Item* create(Session *session, lex_string_t name, List<Item> *item_list);
159
virtual Item* create(Session *session, str_ref name, List<Item> *item_list);
162
162
Builder method, with no arguments.
174
174
class Create_func_arg1 : public Create_func
177
virtual Item* create(Session *session, lex_string_t name, List<Item> *item_list);
177
virtual Item* create(Session *session, str_ref name, List<Item> *item_list);
180
180
Builder method, with one argument.
193
193
class Create_func_arg2 : public Create_func
196
virtual Item* create(Session *session, lex_string_t name, List<Item> *item_list);
196
virtual Item* create(Session *session, str_ref name, List<Item> *item_list);
199
199
Builder method, with two arguments.
213
213
class Create_func_arg3 : public Create_func
216
virtual Item* create(Session *session, lex_string_t name, List<Item> *item_list);
216
virtual Item* create(Session *session, str_ref name, List<Item> *item_list);
219
219
Builder method, with three arguments.
246
246
virtual Item* create(Session *session, Item *arg1);
248
248
static Create_func_bin s_singleton;
254
251
class Create_func_concat : public Create_native_func
257
virtual Item* create_native(Session *session, lex_string_t name, List<Item> *item_list);
254
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list);
259
256
static Create_func_concat s_singleton;
262
Create_func_concat() {}
266
260
class Create_func_concat_ws : public Create_native_func
269
virtual Item* create_native(Session *session, lex_string_t name, List<Item> *item_list);
263
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list);
271
265
static Create_func_concat_ws s_singleton;
274
Create_func_concat_ws() {}
443
virtual Item* create_native(Session *session, lex_string_t name, List<Item> *item_list);
410
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list);
445
412
static Create_func_export_set s_singleton;
448
Create_func_export_set() {}
452
416
class Create_func_field : public Create_native_func
455
virtual Item* create_native(Session *session, lex_string_t name, List<Item> *item_list);
419
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list);
457
421
static Create_func_field s_singleton;
460
Create_func_field() {}
467
428
using Create_func_arg2::create;
469
virtual Item* create(Session *session, Item *arg1, Item *arg2);
430
virtual Item* create(Session *session, Item *arg1, Item *arg2)
432
return new (session->mem) Item_func_find_in_set(arg1, arg2);
471
435
static Create_func_find_in_set s_singleton;
474
Create_func_find_in_set() {}
477
438
class Create_func_found_rows : public Create_func_arg0
480
441
using Create_func_arg0::create;
482
virtual Item* create(Session *session);
443
virtual Item* create(Session *session)
445
return new (session->mem) Item_func_found_rows();
484
448
static Create_func_found_rows s_singleton;
487
Create_func_found_rows() {}
494
455
using Create_func_arg1::create;
496
virtual Item* create(Session *session, Item *arg1);
457
virtual Item* create(Session *session, Item *arg1)
459
return new (session->mem) Item_func_from_days(arg1);
498
462
static Create_func_from_days s_singleton;
501
Create_func_from_days() {}
505
466
class Create_func_from_unixtime : public Create_native_func
508
virtual Item* create_native(Session *session, lex_string_t name, List<Item> *item_list);
469
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list);
510
471
static Create_func_from_unixtime s_singleton;
513
Create_func_from_unixtime() {}
517
475
class Create_func_greatest : public Create_native_func
520
virtual Item* create_native(Session *session, lex_string_t name, List<Item> *item_list);
478
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list);
522
480
static Create_func_greatest s_singleton;
525
Create_func_greatest() {}
532
487
using Create_func_arg2::create;
534
virtual Item* create(Session *session, Item *arg1, Item *arg2);
489
virtual Item* create(Session *session, Item *arg1, Item *arg2)
491
return new (session->mem) Item_func_ifnull(arg1, arg2);
536
494
static Create_func_ifnull s_singleton;
539
Create_func_ifnull() {}
546
501
using Create_func_arg2::create;
548
virtual Item* create(Session *session, Item *arg1, Item *arg2);
503
virtual Item* create(Session *session, Item *arg1, Item *arg2)
505
return new (session->mem) Item_func_locate(arg1, arg2);
550
508
static Create_func_instr s_singleton;
553
Create_func_instr() {}
560
515
using Create_func_arg1::create;
562
virtual Item* create(Session *session, Item *arg1);
517
virtual Item* create(Session *session, Item *arg1)
519
return new (session->mem) Item_func_isnull(arg1);
564
522
static Create_func_isnull s_singleton;
567
Create_func_isnull() {}
574
529
using Create_func_arg1::create;
576
virtual Item* create(Session *session, Item *arg1);
531
virtual Item* create(Session *session, Item *arg1)
533
return new (session->mem) Item_func_last_day(arg1);
578
536
static Create_func_last_day s_singleton;
581
Create_func_last_day() {}
585
540
class Create_func_last_insert_id : public Create_native_func
588
virtual Item* create_native(Session *session, lex_string_t name, List<Item> *item_list);
543
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list);
590
545
static Create_func_last_insert_id s_singleton;
593
Create_func_last_insert_id() {}
600
552
using Create_func_arg1::create;
602
virtual Item* create(Session *session, Item *arg1);
554
virtual Item* create(Session *session, Item *arg1)
556
return new (session->mem) Item_func_lcase(arg1);
604
559
static Create_func_lcase s_singleton;
607
Create_func_lcase() {}
611
563
class Create_func_least : public Create_native_func
614
virtual Item* create_native(Session *session, lex_string_t name, List<Item> *item_list);
566
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list);
616
568
static Create_func_least s_singleton;
619
Create_func_least() {}
622
571
class Create_func_load_file : public Create_func_arg1
625
574
using Create_func_arg1::create;
627
virtual Item* create(Session *session, Item *arg1);
576
virtual Item* create(Session *session, Item *arg1)
578
return new (session->mem) Item_load_file(*session, arg1);
629
581
static Create_func_load_file s_singleton;
632
Create_func_load_file() {}
636
584
class Create_func_locate : public Create_native_func
639
virtual Item* create_native(Session *session, lex_string_t name, List<Item> *item_list);
587
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list);
641
589
static Create_func_locate s_singleton;
644
Create_func_locate() {}
699
638
class Create_func_make_set : public Create_native_func
702
virtual Item* create_native(Session *session, lex_string_t name, List<Item> *item_list);
641
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list);
704
643
static Create_func_make_set s_singleton;
707
Create_func_make_set() {}
775
701
using Create_func_arg2::create;
777
virtual Item* create(Session *session, Item *arg1, Item *arg2);
703
virtual Item* create(Session *session, Item *arg1, Item *arg2)
705
return new (session->mem) Item_func_period_add(arg1, arg2);
779
708
static Create_func_period_add s_singleton;
782
Create_func_period_add() {}
789
715
using Create_func_arg2::create;
791
virtual Item* create(Session *session, Item *arg1, Item *arg2);
717
virtual Item* create(Session *session, Item *arg1, Item *arg2)
719
return new (session->mem) Item_func_period_diff(arg1, arg2);
793
722
static Create_func_period_diff s_singleton;
796
Create_func_period_diff() {}
803
729
using Create_func_arg0::create;
805
virtual Item* create(Session *session);
731
virtual Item* create(Session *session)
733
return new (session->mem) Item_static_float_func("pi()", M_PI, 6, 8);
807
736
static Create_func_pi s_singleton;
813
739
class Create_func_radians : public Create_func_arg1
816
742
using Create_func_arg1::create;
818
virtual Item* create(Session *session, Item *arg1);
744
virtual Item* create(Session *session, Item *arg1)
746
return new (session->mem) Item_func_units("radians", arg1, M_PI/180, 0.0);
820
749
static Create_func_radians s_singleton;
822
Create_func_radians() {}
826
753
class Create_func_round : public Create_native_func
829
virtual Item* create_native(Session *session, lex_string_t name, List<Item> *item_list);
756
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list);
831
758
static Create_func_round s_singleton;
833
Create_func_round() {}
1003
907
class Create_func_unix_timestamp : public Create_native_func
1006
virtual Item* create_native(Session *session, lex_string_t name, List<Item> *item_list);
910
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list);
1008
912
static Create_func_unix_timestamp s_singleton;
1010
Create_func_unix_timestamp() {}
1037
937
Create_udf_func Create_udf_func::s_singleton;
1039
Item* Create_udf_func::create(Session *session, lex_string_t name, List<Item> *item_list)
939
Item* Create_udf_func::create(Session *session, str_ref name, List<Item> *item_list)
1041
941
return create(session, plugin::Function::get(to_string(name)), item_list);
1059
Item* Create_func_arg0::create(Session *session, lex_string_t name, List<Item> *item_list)
959
Item* Create_func_arg0::create(Session *session, str_ref name, List<Item> *item_list)
1061
if (item_list && item_list->size())
1063
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1066
return create(session);
961
if (not item_list || not item_list->size())
962
return create(session);
963
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1069
Item* Create_func_arg1::create(Session *session, lex_string_t name, List<Item> *item_list)
967
Item* Create_func_arg1::create(Session *session, str_ref name, List<Item> *item_list)
1071
int arg_count= item_list ? item_list->size() : 0;
969
if (not item_list || item_list->size() != 1)
1074
971
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1078
975
Item *param_1= item_list->pop();
1080
if (! param_1->is_autogenerated_name)
1082
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data());
1086
return create(session, param_1);
976
if (param_1->is_autogenerated_name)
977
return create(session, param_1);
978
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data());
1091
Create_func_arg2::create(Session *session, lex_string_t name, List<Item> *item_list)
982
Item* Create_func_arg2::create(Session *session, str_ref name, List<Item> *item_list)
1093
int arg_count= item_list ? item_list->size() : 0;
984
if (not item_list || item_list->size() != 2)
1096
986
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1100
990
Item *param_1= item_list->pop();
1101
991
Item *param_2= item_list->pop();
1103
if ( (! param_1->is_autogenerated_name)
1104
|| (! param_2->is_autogenerated_name))
1106
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data());
993
if (param_1->is_autogenerated_name
994
&& param_2->is_autogenerated_name)
1110
995
return create(session, param_1, param_2);
996
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data());
1115
Create_func_arg3::create(Session *session, lex_string_t name, List<Item> *item_list)
1000
Item* Create_func_arg3::create(Session *session, str_ref name, List<Item> *item_list)
1117
int arg_count= item_list ? item_list->size() : 0;
1002
if (not item_list || item_list->size() != 3)
1120
1004
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1125
1009
Item *param_2= item_list->pop();
1126
1010
Item *param_3= item_list->pop();
1128
if ( (! param_1->is_autogenerated_name)
1129
|| (! param_2->is_autogenerated_name)
1130
|| (! param_3->is_autogenerated_name))
1132
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data());
1136
return create(session, param_1, param_2, param_3);
1012
if (param_1->is_autogenerated_name
1013
&& param_2->is_autogenerated_name
1014
&& param_3->is_autogenerated_name)
1015
return create(session, param_1, param_2, param_3);
1016
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data());
1139
1020
Create_func_bin Create_func_bin::s_singleton;
1142
Create_func_bin::create(Session *session, Item *arg1)
1022
Item* Create_func_bin::create(Session *session, Item *arg1)
1144
1024
Item *i10= new (session->mem) Item_int(10, 2);
1145
1025
Item *i2= new (session->mem) Item_int(2, 1);
1149
1029
Create_func_concat Create_func_concat::s_singleton;
1152
Create_func_concat::create_native(Session *session, lex_string_t name, List<Item> *item_list)
1031
Item* Create_func_concat::create_native(Session *session, str_ref name, List<Item> *item_list)
1154
int arg_count= item_list ? item_list->size() : 0;
1157
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1161
return new (session->mem) Item_func_concat(*session, *item_list);
1033
if (item_list && item_list->size() >= 1)
1034
return new (session->mem) Item_func_concat(*session, *item_list);
1035
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1165
1039
Create_func_concat_ws Create_func_concat_ws::s_singleton;
1168
Create_func_concat_ws::create_native(Session *session, lex_string_t name,
1169
List<Item> *item_list)
1041
Item* Create_func_concat_ws::create_native(Session *session, str_ref name, List<Item> *item_list)
1171
int arg_count= item_list ? item_list->size() : 0;
1172
1043
/* "WS" stands for "With Separator": this function takes 2+ arguments */
1175
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1179
return new (session->mem) Item_func_concat_ws(*session, *item_list);
1044
if (item_list && item_list->size() >= 2)
1045
return new (session->mem) Item_func_concat_ws(*session, *item_list);
1046
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1182
1050
Create_func_cot Create_func_cot::s_singleton;
1202
1070
Create_func_export_set Create_func_export_set::s_singleton;
1205
Create_func_export_set::create_native(Session *session, lex_string_t name, List<Item> *item_list)
1073
Create_func_export_set::create_native(Session *session, str_ref name, List<Item> *item_list)
1207
1075
switch (item_list ? item_list->size() : 0)
1230
1098
Item *param_5= item_list->pop();
1231
1099
return new (session->mem) Item_func_export_set(param_1, param_2, param_3, param_4, param_5);
1234
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1102
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1240
1107
Create_func_field Create_func_field::s_singleton;
1243
Create_func_field::create_native(Session *session, lex_string_t name,
1244
List<Item> *item_list)
1109
Item* Create_func_field::create_native(Session *session, str_ref name, List<Item> *item_list)
1246
int arg_count= item_list ? item_list->size() : 0;
1249
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1253
return new (session->mem) Item_func_field(*item_list);
1111
if (item_list && item_list->size() >= 2)
1112
return new (session->mem) Item_func_field(*item_list);
1113
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1257
1117
Create_func_find_in_set Create_func_find_in_set::s_singleton;
1260
Create_func_find_in_set::create(Session *session, Item *arg1, Item *arg2)
1262
return new (session->mem) Item_func_find_in_set(arg1, arg2);
1265
1118
Create_func_found_rows Create_func_found_rows::s_singleton;
1268
Create_func_found_rows::create(Session *session)
1270
return new (session->mem) Item_func_found_rows();
1274
1119
Create_func_from_days Create_func_from_days::s_singleton;
1277
Create_func_from_days::create(Session *session, Item *arg1)
1279
return new (session->mem) Item_func_from_days(arg1);
1283
1120
Create_func_from_unixtime Create_func_from_unixtime::s_singleton;
1286
Create_func_from_unixtime::create_native(Session *session, lex_string_t name,
1287
List<Item> *item_list)
1122
Item* Create_func_from_unixtime::create_native(Session *session, str_ref name, List<Item> *item_list)
1289
1124
switch (item_list ? item_list->size() : 0)
1300
1135
Item *ut= new (session->mem) Item_func_from_unixtime(param_1);
1301
1136
return new (session->mem) Item_func_date_format(ut, param_2, 0);
1304
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1139
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1310
1143
Create_func_greatest Create_func_greatest::s_singleton;
1313
Create_func_greatest::create_native(Session *session, lex_string_t name,
1314
List<Item> *item_list)
1145
Item* Create_func_greatest::create_native(Session *session, str_ref name, List<Item> *item_list)
1316
int arg_count= item_list ? item_list->size() : 0;
1319
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1147
if (item_list && item_list->size() >= 2)
1323
1148
return new (session->mem) Item_func_max(*item_list);
1149
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1326
1153
Create_func_ifnull Create_func_ifnull::s_singleton;
1329
Create_func_ifnull::create(Session *session, Item *arg1, Item *arg2)
1331
return new (session->mem) Item_func_ifnull(arg1, arg2);
1335
1154
Create_func_instr Create_func_instr::s_singleton;
1338
Create_func_instr::create(Session *session, Item *arg1, Item *arg2)
1340
return new (session->mem) Item_func_locate(arg1, arg2);
1344
1155
Create_func_isnull Create_func_isnull::s_singleton;
1347
Create_func_isnull::create(Session *session, Item *arg1)
1349
return new (session->mem) Item_func_isnull(arg1);
1353
1156
Create_func_last_day Create_func_last_day::s_singleton;
1356
Create_func_last_day::create(Session *session, Item *arg1)
1358
return new (session->mem) Item_func_last_day(arg1);
1362
1157
Create_func_last_insert_id Create_func_last_insert_id::s_singleton;
1365
Create_func_last_insert_id::create_native(Session *session, lex_string_t name,
1366
List<Item> *item_list)
1159
Item* Create_func_last_insert_id::create_native(Session *session, str_ref name, List<Item> *item_list)
1368
1161
int arg_count= item_list ? item_list->size() : 0;
1369
1162
switch (arg_count) {
1386
1179
Create_func_lcase Create_func_lcase::s_singleton;
1389
Create_func_lcase::create(Session *session, Item *arg1)
1391
return new (session->mem) Item_func_lcase(arg1);
1395
1180
Create_func_least Create_func_least::s_singleton;
1398
Create_func_least::create_native(Session *session, lex_string_t name,
1399
List<Item> *item_list)
1182
Item* Create_func_least::create_native(Session *session, str_ref name, List<Item> *item_list)
1401
1184
int arg_count= item_list ? item_list->size() : 0;
1402
1185
if (arg_count < 2)
1411
1194
Create_func_load_file Create_func_load_file::s_singleton;
1414
Create_func_load_file::create(Session *session, Item *arg1)
1416
return new (session->mem) Item_load_file(*session, arg1);
1420
1195
Create_func_locate Create_func_locate::s_singleton;
1423
Create_func_locate::create_native(Session *session, lex_string_t name,
1198
Create_func_locate::create_native(Session *session, str_ref name,
1424
1199
List<Item> *item_list)
1426
1201
int arg_count= item_list ? item_list->size() : 0;
1450
1225
Create_func_make_set Create_func_make_set::s_singleton;
1453
Create_func_make_set::create_native(Session *session_arg, lex_string_t name,
1228
Create_func_make_set::create_native(Session *session_arg, str_ref name,
1454
1229
List<Item> *item_list)
1456
1231
int arg_count= item_list ? item_list->size() : 0;
1477
1252
Create_func_period_add Create_func_period_add::s_singleton;
1480
Create_func_period_add::create(Session *session, Item *arg1, Item *arg2)
1482
return new (session->mem) Item_func_period_add(arg1, arg2);
1486
1253
Create_func_period_diff Create_func_period_diff::s_singleton;
1489
Create_func_period_diff::create(Session *session, Item *arg1, Item *arg2)
1491
return new (session->mem) Item_func_period_diff(arg1, arg2);
1495
1254
Create_func_pi Create_func_pi::s_singleton;
1498
Create_func_pi::create(Session *session)
1500
return new (session->mem) Item_static_float_func("pi()", M_PI, 6, 8);
1503
1255
Create_func_radians Create_func_radians::s_singleton;
1506
Create_func_radians::create(Session *session, Item *arg1)
1508
return new (session->mem) Item_func_units("radians", arg1,
1512
1256
Create_func_round Create_func_round::s_singleton;
1514
Item* Create_func_round::create_native(Session *session, lex_string_t name, List<Item> *item_list)
1258
Item* Create_func_round::create_native(Session *session, str_ref name, List<Item> *item_list)
1516
1260
switch (item_list ? item_list->size() : 0)
1562
1306
Create_func_unix_timestamp Create_func_unix_timestamp::s_singleton;
1565
Create_func_unix_timestamp::create_native(Session *session, lex_string_t name,
1566
List<Item> *item_list)
1308
Item* Create_func_unix_timestamp::create_native(Session *session, str_ref name, List<Item> *item_list)
1568
1310
switch (item_list ? item_list->size() : 0)