383
class Create_func_convert_tz : public Create_func_arg3
386
virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
388
static Create_func_convert_tz s_singleton;
391
Create_func_convert_tz() {}
392
virtual ~Create_func_convert_tz() {}
382
396
class Create_func_cos : public Create_func_arg1
404
418
virtual ~Create_func_cot() {}
422
class Create_func_crc32 : public Create_func_arg1
425
virtual Item *create(THD *thd, Item *arg1);
427
static Create_func_crc32 s_singleton;
430
Create_func_crc32() {}
431
virtual ~Create_func_crc32() {}
407
435
class Create_func_date_format : public Create_func_arg2
552
class Create_func_encode : public Create_func_arg2
555
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
557
static Create_func_encode s_singleton;
560
Create_func_encode() {}
561
virtual ~Create_func_encode() {}
565
class Create_func_encrypt : public Create_native_func
568
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
570
static Create_func_encrypt s_singleton;
573
Create_func_encrypt() {}
574
virtual ~Create_func_encrypt() {}
524
578
class Create_func_exp : public Create_func_arg1
923
977
virtual ~Create_func_master_pos_wait() {}
981
class Create_func_md5 : public Create_func_arg1
984
virtual Item *create(THD *thd, Item *arg1);
986
static Create_func_md5 s_singleton;
990
virtual ~Create_func_md5() {}
926
994
class Create_func_monthname : public Create_func_arg1
1436
class Create_func_uuid_short : public Create_func_arg0
1439
virtual Item *create(THD *thd);
1441
static Create_func_uuid_short s_singleton;
1444
Create_func_uuid_short() {}
1445
virtual ~Create_func_uuid_short() {}
1368
1449
class Create_func_version : public Create_func_arg0
1450
1532
Create_udf_func Create_udf_func::s_singleton;
1453
1535
Create_udf_func::create(THD *thd, LEX_STRING name, List<Item> *item_list)
1455
1537
udf_func *udf= find_udf(name.str, name.length);
1457
1539
return create(thd, udf, item_list);
1470
1552
thd->lex->set_stmt_unsafe();
1472
func= udf->create_func(thd->mem_root);
1474
func->set_arguments(*item_list);
1554
DBUG_ASSERT( (udf->type == UDFTYPE_FUNCTION)
1555
|| (udf->type == UDFTYPE_AGGREGATE));
1557
switch(udf->returns) {
1560
if (udf->type == UDFTYPE_FUNCTION)
1563
func= new (thd->mem_root) Item_func_udf_str(udf, *item_list);
1565
func= new (thd->mem_root) Item_func_udf_str(udf);
1570
func= new (thd->mem_root) Item_sum_udf_str(udf, *item_list);
1572
func= new (thd->mem_root) Item_sum_udf_str(udf);
1578
if (udf->type == UDFTYPE_FUNCTION)
1581
func= new (thd->mem_root) Item_func_udf_float(udf, *item_list);
1583
func= new (thd->mem_root) Item_func_udf_float(udf);
1588
func= new (thd->mem_root) Item_sum_udf_float(udf, *item_list);
1590
func= new (thd->mem_root) Item_sum_udf_float(udf);
1596
if (udf->type == UDFTYPE_FUNCTION)
1599
func= new (thd->mem_root) Item_func_udf_int(udf, *item_list);
1601
func= new (thd->mem_root) Item_func_udf_int(udf);
1606
func= new (thd->mem_root) Item_sum_udf_int(udf, *item_list);
1608
func= new (thd->mem_root) Item_sum_udf_int(udf);
1612
case DECIMAL_RESULT:
1614
if (udf->type == UDFTYPE_FUNCTION)
1617
func= new (thd->mem_root) Item_func_udf_decimal(udf, *item_list);
1619
func= new (thd->mem_root) Item_func_udf_decimal(udf);
1624
func= new (thd->mem_root) Item_sum_udf_decimal(udf, *item_list);
1626
func= new (thd->mem_root) Item_sum_udf_decimal(udf);
1632
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "UDF return type");
1680
1840
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);
1842
Item *i10= new (thd->mem_root) Item_int((int32) 10,2);
1843
Item *i2= new (thd->mem_root) Item_int((int32) 2,1);
1684
1844
return new (thd->mem_root) Item_func_conv(arg1, i10, i2);
1954
Create_func_convert_tz Create_func_convert_tz::s_singleton;
1957
Create_func_convert_tz::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
1959
return new (thd->mem_root) Item_func_convert_tz(arg1, arg2, arg3);
1794
1963
Create_func_cos Create_func_cos::s_singleton;
1810
1979
return new (thd->mem_root) Item_func_div(i1, i2);
1983
Create_func_crc32 Create_func_crc32::s_singleton;
1986
Create_func_crc32::create(THD *thd, Item *arg1)
1988
return new (thd->mem_root) Item_func_crc32(arg1);
1813
1992
Create_func_date_format Create_func_date_format::s_singleton;
2049
Create_func_decode Create_func_decode::s_singleton;
2052
Create_func_decode::create(THD *thd, Item *arg1, Item *arg2)
2054
return new (thd->mem_root) Item_func_decode(arg1, arg2);
1870
2058
Create_func_degrees Create_func_degrees::s_singleton;
2089
Create_func_encode Create_func_encode::s_singleton;
2092
Create_func_encode::create(THD *thd, Item *arg1, Item *arg2)
2094
return new (thd->mem_root) Item_func_encode(arg1, arg2);
2098
Create_func_encrypt Create_func_encrypt::s_singleton;
2101
Create_func_encrypt::create_native(THD *thd, LEX_STRING name,
2102
List<Item> *item_list)
2107
if (item_list != NULL)
2108
arg_count= item_list->elements;
2110
switch (arg_count) {
2113
Item *param_1= item_list->pop();
2114
func= new (thd->mem_root) Item_func_encrypt(param_1);
2119
Item *param_1= item_list->pop();
2120
Item *param_2= item_list->pop();
2121
func= new (thd->mem_root) Item_func_encrypt(param_1, param_2);
2126
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1901
2135
Create_func_exp Create_func_exp::s_singleton;
2441
2684
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);
2686
Item *i10= new (thd->mem_root) Item_int((int32) 10,2);
2687
Item *i8= new (thd->mem_root) Item_int((int32) 8,1);
2445
2688
return new (thd->mem_root) Item_func_conv(arg1, i10, i8);
2648
2891
The parsed item tree should not depend on
2649
2892
<code>thd->variables.collation_connection</code>.
2651
const CHARSET_INFO * const cs= thd->variables.collation_connection;
2894
CHARSET_INFO *cs= thd->variables.collation_connection;
2654
2897
if (cs->mbminlen > 1)
2656
uint32_t dummy_errors;
2657
2900
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);
2901
sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors);
3065
Create_func_uuid_short Create_func_uuid_short::s_singleton;
3068
Create_func_uuid_short::create(THD *thd)
3070
thd->lex->set_stmt_unsafe();
3071
return new (thd->mem_root) Item_func_uuid_short();
2822
3075
Create_func_version Create_func_version::s_singleton;
2925
3178
{ { C_STRING_WITH_LEN("CONCAT_WS") }, BUILDER(Create_func_concat_ws)},
2926
3179
{ { C_STRING_WITH_LEN("CONNECTION_ID") }, BUILDER(Create_func_connection_id)},
2927
3180
{ { C_STRING_WITH_LEN("CONV") }, BUILDER(Create_func_conv)},
3181
{ { C_STRING_WITH_LEN("CONVERT_TZ") }, BUILDER(Create_func_convert_tz)},
2928
3182
{ { C_STRING_WITH_LEN("COS") }, BUILDER(Create_func_cos)},
2929
3183
{ { C_STRING_WITH_LEN("COT") }, BUILDER(Create_func_cot)},
3184
{ { C_STRING_WITH_LEN("CRC32") }, BUILDER(Create_func_crc32)},
2930
3185
{ { C_STRING_WITH_LEN("DATEDIFF") }, BUILDER(Create_func_datediff)},
2931
3186
{ { C_STRING_WITH_LEN("DATE_FORMAT") }, BUILDER(Create_func_date_format)},
2932
3187
{ { C_STRING_WITH_LEN("DAYNAME") }, BUILDER(Create_func_dayname)},
2933
3188
{ { C_STRING_WITH_LEN("DAYOFMONTH") }, BUILDER(Create_func_dayofmonth)},
2934
3189
{ { C_STRING_WITH_LEN("DAYOFWEEK") }, BUILDER(Create_func_dayofweek)},
2935
3190
{ { C_STRING_WITH_LEN("DAYOFYEAR") }, BUILDER(Create_func_dayofyear)},
3191
{ { C_STRING_WITH_LEN("DECODE") }, BUILDER(Create_func_decode)},
2936
3192
{ { C_STRING_WITH_LEN("DEGREES") }, BUILDER(Create_func_degrees)},
2937
3193
{ { C_STRING_WITH_LEN("ELT") }, BUILDER(Create_func_elt)},
3194
{ { C_STRING_WITH_LEN("ENCODE") }, BUILDER(Create_func_encode)},
3195
{ { C_STRING_WITH_LEN("ENCRYPT") }, BUILDER(Create_func_encrypt)},
2938
3196
{ { C_STRING_WITH_LEN("EXP") }, BUILDER(Create_func_exp)},
2939
3197
{ { C_STRING_WITH_LEN("EXPORT_SET") }, BUILDER(Create_func_export_set)},
2940
3198
{ { C_STRING_WITH_LEN("FIELD") }, BUILDER(Create_func_field)},
2967
3225
{ { C_STRING_WITH_LEN("MAKETIME") }, BUILDER(Create_func_maketime)},
2968
3226
{ { C_STRING_WITH_LEN("MAKE_SET") }, BUILDER(Create_func_make_set)},
2969
3227
{ { C_STRING_WITH_LEN("MASTER_POS_WAIT") }, BUILDER(Create_func_master_pos_wait)},
3228
{ { C_STRING_WITH_LEN("MD5") }, BUILDER(Create_func_md5)},
2970
3229
{ { C_STRING_WITH_LEN("MONTHNAME") }, BUILDER(Create_func_monthname)},
2971
3230
{ { C_STRING_WITH_LEN("NULLIF") }, BUILDER(Create_func_nullif)},
2972
3231
{ { C_STRING_WITH_LEN("OCT") }, BUILDER(Create_func_oct)},
3003
3262
{ { C_STRING_WITH_LEN("UNIX_TIMESTAMP") }, BUILDER(Create_func_unix_timestamp)},
3004
3263
{ { C_STRING_WITH_LEN("UPPER") }, BUILDER(Create_func_ucase)},
3005
3264
{ { C_STRING_WITH_LEN("UUID") }, BUILDER(Create_func_uuid)},
3265
{ { C_STRING_WITH_LEN("UUID_SHORT") }, BUILDER(Create_func_uuid_short)},
3006
3266
{ { C_STRING_WITH_LEN("VERSION") }, BUILDER(Create_func_version)},
3007
3267
{ { C_STRING_WITH_LEN("WEEKDAY") }, BUILDER(Create_func_weekday)},
3008
3268
{ { C_STRING_WITH_LEN("WEEKOFYEAR") }, BUILDER(Create_func_weekofyear)},
3014
3274
static HASH native_functions_hash;
3016
extern "C" unsigned char*
3017
get_native_fct_hash_key(const unsigned char *buff, size_t *length,
3277
get_native_fct_hash_key(const uchar *buff, size_t *length,
3278
my_bool /* unused */)
3020
3280
Native_func_registry *func= (Native_func_registry*) buff;
3021
3281
*length= func->name.length;
3022
return (unsigned char*) func->name.str;
3282
return (uchar*) func->name.str;
3040
3302
(hash_get_key) get_native_fct_hash_key,
3041
3303
NULL, /* Nothing to free */
3045
3307
for (func= func_array; func->builder != NULL; func++)
3047
if (my_hash_insert(& native_functions_hash, (unsigned char*) func))
3309
if (my_hash_insert(& native_functions_hash, (uchar*) func))
3314
for (uint i=0 ; i < native_functions_hash.records ; i++)
3316
func= (Native_func_registry*) hash_element(& native_functions_hash, i);
3317
DBUG_PRINT("info", ("native function: %s length: %u",
3318
func->name.str, (uint) func->name.length));
3060
3331
void item_create_cleanup()
3333
DBUG_ENTER("item_create_cleanup");
3062
3334
hash_free(& native_functions_hash);
3067
find_native_function_builder(THD *thd __attribute__((unused)),
3339
find_native_function_builder(THD *thd, LEX_STRING name)
3070
3341
Native_func_registry *func;
3071
3342
Create_func *builder= NULL;
3073
3344
/* Thread safe */
3074
3345
func= (Native_func_registry*) hash_search(& native_functions_hash,
3075
(unsigned char*) name.str,
3088
create_func_char_cast(THD *thd, Item *a, int len, const CHARSET_INFO * const cs)
3359
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);
3361
CHARSET_INFO *real_cs= (cs ? cs : thd->variables.collation_connection);
3091
3362
return new (thd->mem_root) Item_char_typecast(a, len, real_cs);
3096
3367
create_func_cast(THD *thd, Item *a, Cast_target cast_type,
3097
3368
const char *c_len, const char *c_dec,
3098
const CHARSET_INFO * const cs)
3104
3375
switch (cast_type) {
3105
3376
case ITEM_CAST_BINARY: