24#include <drizzled/item/create.h>
25#include <drizzled/item/func.h>
26#include <drizzled/error.h>
27#include <drizzled/system_variables.h>
29#include <drizzled/function_container.h>
31#include <drizzled/function/str/binary.h>
32#include <drizzled/function/str/concat.h>
33#include <drizzled/function/str/conv.h>
34#include <drizzled/function/str/export_set.h>
35#include <drizzled/function/str/load_file.h>
36#include <drizzled/function/str/make_set.h>
37#include <drizzled/function/str/pad.h>
38#include <drizzled/function/str/repeat.h>
39#include <drizzled/function/str/str_conv.h>
40#include <drizzled/function/str/trim.h>
42#include <drizzled/function/time/date_format.h>
43#include <drizzled/function/time/dayname.h>
44#include <drizzled/function/time/dayofmonth.h>
45#include <drizzled/function/time/dayofyear.h>
46#include <drizzled/function/time/from_unixtime.h>
47#include <drizzled/function/time/from_days.h>
48#include <drizzled/function/time/last_day.h>
49#include <drizzled/function/time/makedate.h>
50#include <drizzled/function/time/month.h>
51#include <drizzled/function/time/period_add.h>
52#include <drizzled/function/time/period_diff.h>
53#include <drizzled/function/time/to_days.h>
54#include <drizzled/function/time/typecast.h>
55#include <drizzled/function/time/unix_timestamp.h>
56#include <drizzled/function/time/weekday.h>
58#include <drizzled/item/cmpfunc.h>
59#include <drizzled/plugin/function.h>
60#include <drizzled/session.h>
64#include <drizzled/function/func.h>
65#include <drizzled/function/additive_op.h>
66#include <drizzled/function/math/dec.h>
67#include <drizzled/function/math/decimal_typecast.h>
68#include <drizzled/function/field.h>
69#include <drizzled/function/find_in_set.h>
70#include <drizzled/function/found_rows.h>
71#include <drizzled/function/get_system_var.h>
72#include <drizzled/function/math/int_val.h>
73#include <drizzled/function/math/integer.h>
74#include <drizzled/function/last_insert.h>
75#include <drizzled/function/locate.h>
76#include <drizzled/function/min_max.h>
77#include <drizzled/function/num1.h>
78#include <drizzled/function/num_op.h>
79#include <drizzled/function/numhybrid.h>
80#include <drizzled/function/math/real.h>
81#include <drizzled/function/row_count.h>
82#include <drizzled/function/set_user_var.h>
83#include <drizzled/function/sign.h>
84#include <drizzled/function/math/tan.h>
85#include <drizzled/function/units.h>
87#include <drizzled/function/cast/boolean.h>
88#include <drizzled/function/cast/signed.h>
89#include <drizzled/function/cast/time.h>
90#include <drizzled/function/cast/unsigned.h>
119 List<Item>::iterator it(params.begin());
120 while (
Item* param= it++)
122 if (not param->is_autogenerated_name)
135 my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data());
282Create_func_conv Create_func_conv::s_singleton;
307Create_func_date_format Create_func_date_format::s_singleton;
333Create_func_dayname Create_func_dayname::s_singleton;
348Create_func_dayofmonth Create_func_dayofmonth::s_singleton;
363Create_func_dayofweek Create_func_dayofweek::s_singleton;
378Create_func_dayofyear Create_func_dayofyear::s_singleton;
398 return new (session->mem)
Item_func_units(
"degrees", arg1, 180/M_PI, 0.0);
404Create_func_degrees Create_func_degrees::s_singleton;
599 return new (session->mem)
Item_func_lpad(*session, arg1, arg2, arg3);
605Create_func_lpad Create_func_lpad::s_singleton;
620Create_func_ltrim Create_func_ltrim::s_singleton;
635Create_func_makedate Create_func_makedate::s_singleton;
659Create_func_monthname Create_func_monthname::s_singleton;
685Create_func_nullif Create_func_nullif::s_singleton;
745 return new (session->mem)
Item_func_units(
"radians", arg1, M_PI/180, 0.0);
774Create_func_row_count Create_func_row_count::s_singleton;
783 return new (session->mem)
Item_func_rpad(*session, arg1, arg2, arg3);
789Create_func_rpad Create_func_rpad::s_singleton;
804Create_func_rtrim Create_func_rtrim::s_singleton;
819Create_func_sign Create_func_sign::s_singleton;
844Create_func_strcmp Create_func_strcmp::s_singleton;
859Create_func_tan Create_func_tan::s_singleton;
874Create_func_time_format Create_func_time_format::s_singleton;
889Create_func_to_days Create_func_to_days::s_singleton;
904Create_func_ucase Create_func_ucase::s_singleton;
928Create_func_weekday Create_func_weekday::s_singleton;
940 return create(session, plugin::Function::get(to_string(name)), item_list);
949 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), func->func_name());
953 func->set_arguments(*item_list);
959 if (not item_list || not item_list->size())
961 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
967 if (not item_list || item_list->size() != 1)
969 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
973 Item *param_1= item_list->pop();
975 return create(session, param_1);
976 my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data());
982 if (not item_list || item_list->size() != 2)
984 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
988 Item *param_1= item_list->pop();
989 Item *param_2= item_list->pop();
993 return create(session, param_1, param_2);
994 my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data());
1000 if (not item_list || item_list->size() != 3)
1002 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1006 Item *param_1= item_list->pop();
1007 Item *param_2= item_list->pop();
1008 Item *param_3= item_list->pop();
1013 return create(session, param_1, param_2, param_3);
1014 my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.data());
1031 if (item_list && item_list->size() >= 1)
1033 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1042 if (item_list && item_list->size() >= 2)
1044 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1073 switch (item_list ? item_list->size() : 0)
1077 Item *param_1= item_list->pop();
1078 Item *param_2= item_list->pop();
1079 Item *param_3= item_list->pop();
1084 Item *param_1= item_list->pop();
1085 Item *param_2= item_list->pop();
1086 Item *param_3= item_list->pop();
1087 Item *param_4= item_list->pop();
1092 Item *param_1= item_list->pop();
1093 Item *param_2= item_list->pop();
1094 Item *param_3= item_list->pop();
1095 Item *param_4= item_list->pop();
1096 Item *param_5= item_list->pop();
1100 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1109 if (item_list && item_list->size() >= 2)
1111 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1122 switch (item_list ? item_list->size() : 0)
1126 Item *param_1= item_list->pop();
1131 Item *param_1= item_list->pop();
1132 Item *param_2= item_list->pop();
1137 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1145 if (item_list && item_list->size() >= 2)
1147 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1159 int arg_count= item_list ? item_list->size() : 0;
1168 Item *param_1= item_list->pop();
1172 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1181 if (item_list && item_list->size() >= 2)
1183 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1192 switch (item_list ? item_list->size() : 0)
1196 Item *param_1= item_list->pop();
1197 Item *param_2= item_list->pop();
1203 Item *param_1= item_list->pop();
1204 Item *param_2= item_list->pop();
1205 Item *param_3= item_list->pop();
1210 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1218 if (not item_list || item_list->size() < 2)
1220 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1224 Item *param_1= item_list->pop();
1232 Item *i10=
new (session->mem)
Item_int((int32_t) 10,2);
1245 switch (item_list ? item_list->size() : 0)
1249 Item *param_1= item_list->pop();
1255 Item *param_1= item_list->pop();
1256 Item *param_2= item_list->pop();
1260 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1276 if (cs->mbminlen > 1)
1278 sp=
new (session->mem)
Item_string(str_ref(
""), cs, DERIVATION_COERCIBLE);
1283 sp=
new (session->mem)
Item_string(str_ref(
" "), cs, DERIVATION_COERCIBLE);
1293 switch (item_list ? item_list->size() : 0)
1300 my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.data());
1311#define BUILDER(F) & F::s_singleton
1323 {
"CONCAT", BUILDER(Create_func_concat)},
1385void item_create_init()
1388 FunctionContainer::getMutableMap()[func->name]= func->builder;
1393 return find_ptr2(FunctionContainer::getMap(), name.data());
1396Item* create_func_char_cast(Session *session, Item *a,
int len,
const charset_info_st* cs)
1398 return new (session->mem) Item_char_typecast(a, len, cs ? cs : session->variables.getCollation());
1405 case ITEM_CAST_SIGNED:
1407 case ITEM_CAST_UNSIGNED:
1409 case ITEM_CAST_BINARY:
1411 case ITEM_CAST_BOOLEAN:
1413 case ITEM_CAST_TIME:
1415 case ITEM_CAST_DATE:
1417 case ITEM_CAST_DATETIME:
1419 case ITEM_CAST_DECIMAL:
1421 uint32_t len= c_len ? atoi(c_len) : 0;
1422 uint32_t dec= c_dec ? atoi(c_dec) : 0;
1423 class_decimal_trim(&len, &dec);
1426 my_error(ER_M_BIGGER_THAN_D, MYF(0),
"");
1429 if (len > DECIMAL_MAX_PRECISION)
1431 my_error(ER_TOO_BIG_PRECISION, MYF(0), len, a->
name, DECIMAL_MAX_PRECISION);
1434 if (dec > DECIMAL_MAX_SCALE)
1436 my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->
name, DECIMAL_MAX_SCALE);
1441 case ITEM_CAST_CHAR:
1442 return create_func_char_cast(session, a, c_len ? atoi(c_len) : -1, cs);
virtual Item * create(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create(Session *session)=0
virtual Item * create(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create(Session *session, Item *arg1)=0
virtual Item * create(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create(Session *session, Item *arg1, Item *arg2)=0
virtual Item * create(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create(Session *session, Item *arg1, Item *arg2, Item *arg3)=0
virtual Item * create(Session *session, Item *arg1)
virtual Item * create_native(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create_native(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create(Session *session, Item *arg1, Item *arg2, Item *arg3)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create(Session *session, Item *arg1, Item *arg2)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create(Session *session, Item *arg1, Item *arg2)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create_native(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create_native(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create(Session *session, Item *arg1, Item *arg2)
virtual Item * create(Session *session)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create_native(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create_native(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create(Session *session, Item *arg1, Item *arg2)
virtual Item * create(Session *session, Item *arg1, Item *arg2)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create_native(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create_native(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create_native(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create(Session *session, Item *arg1, Item *arg2, Item *arg3)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create_native(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create(Session *session, Item *arg1, Item *arg2)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create(Session *session, Item *arg1, Item *arg2)
virtual Item * create(Session *session, Item *arg1, Item *arg2)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create(Session *session, Item *arg1, Item *arg2)
virtual Item * create(Session *session, Item *arg1, Item *arg2)
virtual Item * create(Session *session)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create_native(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create(Session *session)
virtual Item * create(Session *session, Item *arg1, Item *arg2, Item *arg3)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create(Session *session, Item *arg1, Item *arg2)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create_native(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create(Session *session, Item *arg1)
virtual Item * create(Session *session, str_ref name, List< Item > *item_list)
virtual Item * create_native(Session *, str_ref name, List< Item > *)=0
virtual Item * create(Session *, str_ref name, List< Item > *item_list)
static Create_udf_func s_singleton
virtual bool check_argument_count(int)
bool is_autogenerated_name
TODO: Rename this file - func.h is stupid.
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)
static bool has_named_parameters(List< Item > ¶ms)
Create_func * find_native_function_builder(str_ref name)