404
405
virtual ~Create_func_cot() {}
409
class Create_func_crc32 : public Create_func_arg1
412
virtual Item *create(THD *thd, Item *arg1);
414
static Create_func_crc32 s_singleton;
417
Create_func_crc32() {}
418
virtual ~Create_func_crc32() {}
407
422
class Create_func_date_format : public Create_func_arg2
539
class Create_func_encode : public Create_func_arg2
542
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
544
static Create_func_encode s_singleton;
547
Create_func_encode() {}
548
virtual ~Create_func_encode() {}
552
class Create_func_encrypt : public Create_native_func
555
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
557
static Create_func_encrypt s_singleton;
560
Create_func_encrypt() {}
561
virtual ~Create_func_encrypt() {}
524
565
class Create_func_exp : public Create_func_arg1
923
964
virtual ~Create_func_master_pos_wait() {}
968
class Create_func_md5 : public Create_func_arg1
971
virtual Item *create(THD *thd, Item *arg1);
973
static Create_func_md5 s_singleton;
977
virtual ~Create_func_md5() {}
926
981
class Create_func_monthname : public Create_func_arg1
1470
1526
thd->lex->set_stmt_unsafe();
1472
func= udf->create_func(thd->mem_root);
1474
func->set_arguments(*item_list);
1528
assert( (udf->type == UDFTYPE_FUNCTION)
1529
|| (udf->type == UDFTYPE_AGGREGATE));
1531
switch(udf->returns) {
1534
if (udf->type == UDFTYPE_FUNCTION)
1537
func= new (thd->mem_root) Item_func_udf_str(udf, *item_list);
1539
func= new (thd->mem_root) Item_func_udf_str(udf);
1544
func= new (thd->mem_root) Item_sum_udf_str(udf, *item_list);
1546
func= new (thd->mem_root) Item_sum_udf_str(udf);
1552
if (udf->type == UDFTYPE_FUNCTION)
1555
func= new (thd->mem_root) Item_func_udf_float(udf, *item_list);
1557
func= new (thd->mem_root) Item_func_udf_float(udf);
1562
func= new (thd->mem_root) Item_sum_udf_float(udf, *item_list);
1564
func= new (thd->mem_root) Item_sum_udf_float(udf);
1570
if (udf->type == UDFTYPE_FUNCTION)
1573
func= new (thd->mem_root) Item_func_udf_int(udf, *item_list);
1575
func= new (thd->mem_root) Item_func_udf_int(udf);
1580
func= new (thd->mem_root) Item_sum_udf_int(udf, *item_list);
1582
func= new (thd->mem_root) Item_sum_udf_int(udf);
1586
case DECIMAL_RESULT:
1588
if (udf->type == UDFTYPE_FUNCTION)
1591
func= new (thd->mem_root) Item_func_udf_decimal(udf, *item_list);
1593
func= new (thd->mem_root) Item_func_udf_decimal(udf);
1598
func= new (thd->mem_root) Item_sum_udf_decimal(udf, *item_list);
1600
func= new (thd->mem_root) Item_sum_udf_decimal(udf);
1606
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "UDF return type");
1680
1814
Create_func_bin::create(THD *thd, Item *arg1)
1682
Item *i10= new (thd->mem_root) Item_int((int32_t) 10,2);
1683
Item *i2= new (thd->mem_root) Item_int((int32_t) 2,1);
1816
Item *i10= new (thd->mem_root) Item_int((int32) 10,2);
1817
Item *i2= new (thd->mem_root) Item_int((int32) 2,1);
1684
1818
return new (thd->mem_root) Item_func_conv(arg1, i10, i2);
1810
1944
return new (thd->mem_root) Item_func_div(i1, i2);
1948
Create_func_crc32 Create_func_crc32::s_singleton;
1951
Create_func_crc32::create(THD *thd, Item *arg1)
1953
return new (thd->mem_root) Item_func_crc32(arg1);
1813
1957
Create_func_date_format Create_func_date_format::s_singleton;
2014
Create_func_decode Create_func_decode::s_singleton;
2017
Create_func_decode::create(THD *thd, Item *arg1, Item *arg2)
2019
return new (thd->mem_root) Item_func_decode(arg1, arg2);
1870
2023
Create_func_degrees Create_func_degrees::s_singleton;
2054
Create_func_encode Create_func_encode::s_singleton;
2057
Create_func_encode::create(THD *thd, Item *arg1, Item *arg2)
2059
return new (thd->mem_root) Item_func_encode(arg1, arg2);
2063
Create_func_encrypt Create_func_encrypt::s_singleton;
2066
Create_func_encrypt::create_native(THD *thd, LEX_STRING name,
2067
List<Item> *item_list)
2072
if (item_list != NULL)
2073
arg_count= item_list->elements;
2075
switch (arg_count) {
2078
Item *param_1= item_list->pop();
2079
func= new (thd->mem_root) Item_func_encrypt(param_1);
2084
Item *param_1= item_list->pop();
2085
Item *param_2= item_list->pop();
2086
func= new (thd->mem_root) Item_func_encrypt(param_1, param_2);
2091
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1901
2100
Create_func_exp Create_func_exp::s_singleton;
2619
Create_func_md5 Create_func_md5::s_singleton;
2622
Create_func_md5::create(THD *thd, Item *arg1)
2624
return new (thd->mem_root) Item_func_md5(arg1);
2420
2628
Create_func_monthname Create_func_monthname::s_singleton;
2441
2649
Create_func_oct::create(THD *thd, Item *arg1)
2443
Item *i10= new (thd->mem_root) Item_int((int32_t) 10,2);
2444
Item *i8= new (thd->mem_root) Item_int((int32_t) 8,1);
2651
Item *i10= new (thd->mem_root) Item_int((int32) 10,2);
2652
Item *i8= new (thd->mem_root) Item_int((int32) 8,1);
2445
2653
return new (thd->mem_root) Item_func_conv(arg1, i10, i8);
2648
2856
The parsed item tree should not depend on
2649
2857
<code>thd->variables.collation_connection</code>.
2651
const CHARSET_INFO * const cs= thd->variables.collation_connection;
2859
CHARSET_INFO *cs= thd->variables.collation_connection;
2654
2862
if (cs->mbminlen > 1)
2656
uint32_t dummy_errors;
2657
2865
sp= new (thd->mem_root) Item_string("", 0, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
2658
sp->str_value.copy(" ", 1, &my_charset_utf8_general_ci, cs, &dummy_errors);
2866
sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors);
2927
3135
{ { C_STRING_WITH_LEN("CONV") }, BUILDER(Create_func_conv)},
2928
3136
{ { C_STRING_WITH_LEN("COS") }, BUILDER(Create_func_cos)},
2929
3137
{ { C_STRING_WITH_LEN("COT") }, BUILDER(Create_func_cot)},
3138
{ { C_STRING_WITH_LEN("CRC32") }, BUILDER(Create_func_crc32)},
2930
3139
{ { C_STRING_WITH_LEN("DATEDIFF") }, BUILDER(Create_func_datediff)},
2931
3140
{ { C_STRING_WITH_LEN("DATE_FORMAT") }, BUILDER(Create_func_date_format)},
2932
3141
{ { C_STRING_WITH_LEN("DAYNAME") }, BUILDER(Create_func_dayname)},
2933
3142
{ { C_STRING_WITH_LEN("DAYOFMONTH") }, BUILDER(Create_func_dayofmonth)},
2934
3143
{ { C_STRING_WITH_LEN("DAYOFWEEK") }, BUILDER(Create_func_dayofweek)},
2935
3144
{ { C_STRING_WITH_LEN("DAYOFYEAR") }, BUILDER(Create_func_dayofyear)},
3145
{ { C_STRING_WITH_LEN("DECODE") }, BUILDER(Create_func_decode)},
2936
3146
{ { C_STRING_WITH_LEN("DEGREES") }, BUILDER(Create_func_degrees)},
2937
3147
{ { C_STRING_WITH_LEN("ELT") }, BUILDER(Create_func_elt)},
3148
{ { C_STRING_WITH_LEN("ENCODE") }, BUILDER(Create_func_encode)},
3149
{ { C_STRING_WITH_LEN("ENCRYPT") }, BUILDER(Create_func_encrypt)},
2938
3150
{ { C_STRING_WITH_LEN("EXP") }, BUILDER(Create_func_exp)},
2939
3151
{ { C_STRING_WITH_LEN("EXPORT_SET") }, BUILDER(Create_func_export_set)},
2940
3152
{ { C_STRING_WITH_LEN("FIELD") }, BUILDER(Create_func_field)},
2967
3179
{ { C_STRING_WITH_LEN("MAKETIME") }, BUILDER(Create_func_maketime)},
2968
3180
{ { C_STRING_WITH_LEN("MAKE_SET") }, BUILDER(Create_func_make_set)},
2969
3181
{ { C_STRING_WITH_LEN("MASTER_POS_WAIT") }, BUILDER(Create_func_master_pos_wait)},
3182
{ { C_STRING_WITH_LEN("MD5") }, BUILDER(Create_func_md5)},
2970
3183
{ { C_STRING_WITH_LEN("MONTHNAME") }, BUILDER(Create_func_monthname)},
2971
3184
{ { C_STRING_WITH_LEN("NULLIF") }, BUILDER(Create_func_nullif)},
2972
3185
{ { C_STRING_WITH_LEN("OCT") }, BUILDER(Create_func_oct)},
3014
3227
static HASH native_functions_hash;
3016
extern "C" unsigned char*
3017
get_native_fct_hash_key(const unsigned char *buff, size_t *length,
3230
get_native_fct_hash_key(const uchar *buff, size_t *length,
3231
my_bool /* unused */)
3020
3233
Native_func_registry *func= (Native_func_registry*) buff;
3021
3234
*length= func->name.length;
3022
return (unsigned char*) func->name.str;
3235
return (uchar*) func->name.str;
3088
create_func_char_cast(THD *thd, Item *a, int len, const CHARSET_INFO * const cs)
3301
create_func_char_cast(THD *thd, Item *a, int len, CHARSET_INFO *cs)
3090
const CHARSET_INFO * const real_cs= (cs ? cs : thd->variables.collation_connection);
3303
CHARSET_INFO *real_cs= (cs ? cs : thd->variables.collation_connection);
3091
3304
return new (thd->mem_root) Item_char_typecast(a, len, real_cs);
3096
3309
create_func_cast(THD *thd, Item *a, Cast_target cast_type,
3097
3310
const char *c_len, const char *c_dec,
3098
const CHARSET_INFO * const cs)
3104
3317
switch (cast_type) {
3105
3318
case ITEM_CAST_BINARY: