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))
135
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
135
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data());
138
138
return create_native(session, name, item_list);
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
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() {}
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() {}
648
592
class Create_func_lpad : public Create_func_arg3
816
741
using Create_func_arg1::create;
818
virtual Item* create(Session *session, Item *arg1);
743
virtual Item* create(Session *session, Item *arg1)
745
return new (session->mem) Item_func_units("radians", arg1, M_PI/180, 0.0);
820
748
static Create_func_radians s_singleton;
822
Create_func_radians() {}
826
752
class Create_func_round : public Create_native_func
829
virtual Item* create_native(Session *session, lex_string_t name, List<Item> *item_list);
755
virtual Item* create_native(Session *session, str_ref name, List<Item> *item_list);
831
757
static Create_func_round s_singleton;
833
Create_func_round() {}
1037
936
Create_udf_func Create_udf_func::s_singleton;
1039
Item* Create_udf_func::create(Session *session, lex_string_t name, List<Item> *item_list)
938
Item* Create_udf_func::create(Session *session, str_ref name, List<Item> *item_list)
1041
return create(session, plugin::Function::get(std::string(name.str, name.length)), item_list);
940
return create(session, plugin::Function::get(to_string(name)), item_list);
1044
943
Item* Create_udf_func::create(Session *session, const plugin::Function *udf, List<Item> *item_list)
1047
int arg_count= item_list ? item_list->size() : 0;
1048
946
Item_func* func= (*udf)(&session->mem);
1049
if (!func->check_argument_count(arg_count))
947
if (!func->check_argument_count(item_list ? item_list->size() : 0))
1051
949
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), func->func_name());
1059
Item* Create_func_arg0::create(Session *session, lex_string_t name, List<Item> *item_list)
957
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.str);
1066
return create(session);
959
if (not item_list || not item_list->size())
960
return create(session);
961
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)
965
Item* Create_func_arg1::create(Session *session, str_ref name, List<Item> *item_list)
1071
int arg_count= item_list ? item_list->size() : 0;
967
if (not item_list || item_list->size() != 1)
1074
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
969
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1078
973
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.str);
1086
return create(session, param_1);
974
if (param_1->is_autogenerated_name)
975
return create(session, param_1);
976
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)
980
Item* Create_func_arg2::create(Session *session, str_ref name, List<Item> *item_list)
1093
int arg_count= item_list ? item_list->size() : 0;
982
if (not item_list || item_list->size() != 2)
1096
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
984
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1100
988
Item *param_1= item_list->pop();
1101
989
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.str);
991
if (param_1->is_autogenerated_name
992
&& param_2->is_autogenerated_name)
1110
993
return create(session, param_1, param_2);
994
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)
998
Item* Create_func_arg3::create(Session *session, str_ref name, List<Item> *item_list)
1117
int arg_count= item_list ? item_list->size() : 0;
1000
if (not item_list || item_list->size() != 3)
1120
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1002
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1125
1007
Item *param_2= item_list->pop();
1126
1008
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.str);
1136
return create(session, param_1, param_2, param_3);
1010
if (param_1->is_autogenerated_name
1011
&& param_2->is_autogenerated_name
1012
&& param_3->is_autogenerated_name)
1013
return create(session, param_1, param_2, param_3);
1014
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data());
1139
1018
Create_func_bin Create_func_bin::s_singleton;
1142
Create_func_bin::create(Session *session, Item *arg1)
1020
Item* Create_func_bin::create(Session *session, Item *arg1)
1144
1022
Item *i10= new (session->mem) Item_int(10, 2);
1145
1023
Item *i2= new (session->mem) Item_int(2, 1);
1149
1027
Create_func_concat Create_func_concat::s_singleton;
1152
Create_func_concat::create_native(Session *session, lex_string_t name, List<Item> *item_list)
1029
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.str);
1161
return new (session->mem) Item_func_concat(*session, *item_list);
1031
if (item_list && item_list->size() >= 1)
1032
return new (session->mem) Item_func_concat(*session, *item_list);
1033
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1165
1037
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)
1039
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
1041
/* "WS" stands for "With Separator": this function takes 2+ arguments */
1175
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1179
return new (session->mem) Item_func_concat_ws(*session, *item_list);
1042
if (item_list && item_list->size() >= 2)
1043
return new (session->mem) Item_func_concat_ws(*session, *item_list);
1044
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1182
1048
Create_func_cot Create_func_cot::s_singleton;
1230
1096
Item *param_5= item_list->pop();
1231
1097
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.str);
1100
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1240
1105
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)
1107
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.str);
1253
return new (session->mem) Item_func_field(*item_list);
1109
if (item_list && item_list->size() >= 2)
1110
return new (session->mem) Item_func_field(*item_list);
1111
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1257
1115
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
1116
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
1117
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
1118
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)
1120
Item* Create_func_from_unixtime::create_native(Session *session, str_ref name, List<Item> *item_list)
1289
1122
switch (item_list ? item_list->size() : 0)
1300
1133
Item *ut= new (session->mem) Item_func_from_unixtime(param_1);
1301
1134
return new (session->mem) Item_func_date_format(ut, param_2, 0);
1304
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1137
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1310
1141
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)
1143
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.str);
1145
if (item_list && item_list->size() >= 2)
1323
1146
return new (session->mem) Item_func_max(*item_list);
1147
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1326
1151
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
1152
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
1153
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
1154
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
1155
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)
1157
Item* Create_func_last_insert_id::create_native(Session *session, str_ref name, List<Item> *item_list)
1368
1159
int arg_count= item_list ? item_list->size() : 0;
1369
switch (arg_count) {
1372
1164
return new (session->mem) Item_func_last_insert_id();
1376
1168
Item *param_1= item_list->pop();
1377
1169
return new (session->mem) Item_func_last_insert_id(param_1);
1380
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1172
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1386
1176
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
1177
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)
1179
Item* Create_func_least::create_native(Session *session, str_ref name, List<Item> *item_list)
1401
int arg_count= item_list ? item_list->size() : 0;
1404
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1408
return new (session->mem) Item_func_min(*item_list);
1181
if (item_list && item_list->size() >= 2)
1182
return new (session->mem) Item_func_min(*item_list);
1183
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1411
1187
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
1188
Create_func_locate Create_func_locate::s_singleton;
1423
Create_func_locate::create_native(Session *session, lex_string_t name,
1424
List<Item> *item_list)
1190
Item* Create_func_locate::create_native(Session *session, str_ref name, List<Item> *item_list)
1426
int arg_count= item_list ? item_list->size() : 0;
1192
switch (item_list ? item_list->size() : 0)
1441
1206
/* Yes, parameters in that order : 2, 1, 3 */
1442
1207
return new (session->mem) Item_func_locate(param_2, param_1, param_3);
1445
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1210
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1450
1214
Create_func_make_set Create_func_make_set::s_singleton;
1453
Create_func_make_set::create_native(Session *session_arg, lex_string_t name,
1454
List<Item> *item_list)
1216
Item* Create_func_make_set::create_native(Session *session_arg, str_ref name, List<Item> *item_list)
1456
int arg_count= item_list ? item_list->size() : 0;
1218
if (not item_list || item_list->size() < 2)
1459
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1220
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1477
1237
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
1238
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
1239
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
1240
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
1241
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)
1243
Item* Create_func_round::create_native(Session *session, str_ref name, List<Item> *item_list)
1516
1245
switch (item_list ? item_list->size() : 0)
1520
Item *param_1= item_list->pop();
1521
Item *i0 = new (session->mem) Item_int("0", 0, 1);
1522
return new (session->mem) Item_func_round(param_1, i0, 0);
1249
Item *param_1= item_list->pop();
1250
Item *i0 = new (session->mem) Item_int("0", 0, 1);
1251
return new (session->mem) Item_func_round(param_1, i0, 0);
1526
Item *param_1= item_list->pop();
1527
Item *param_2= item_list->pop();
1528
return new (session->mem) Item_func_round(param_1, param_2, 0);
1531
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1255
Item *param_1= item_list->pop();
1256
Item *param_2= item_list->pop();
1257
return new (session->mem) Item_func_round(param_1, param_2, 0);
1260
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1536
1264
Create_func_space Create_func_space::s_singleton;
1539
Create_func_space::create(Session *session, Item *arg1)
1266
Item* Create_func_space::create(Session *session, Item *arg1)
1542
1269
TODO: Fix Bug#23637
1549
1276
if (cs->mbminlen > 1)
1551
sp= new (session->mem) Item_string("", 0, cs, DERIVATION_COERCIBLE);
1278
sp= new (session->mem) Item_string(str_ref(""), cs, DERIVATION_COERCIBLE);
1552
1279
sp->str_value.copy(" ", 1, cs);
1556
sp= new (session->mem) Item_string(" ", 1, cs, DERIVATION_COERCIBLE);
1283
sp= new (session->mem) Item_string(str_ref(" "), cs, DERIVATION_COERCIBLE);
1559
1286
return new (session->mem) Item_func_repeat(*session, sp, arg1);