1470
1471
thd->lex->set_stmt_unsafe();
1472
func= udf->create_func(thd->mem_root);
1474
func->set_arguments(*item_list);
1473
assert( (udf->type == UDFTYPE_FUNCTION)
1474
|| (udf->type == UDFTYPE_AGGREGATE));
1476
switch(udf->returns) {
1479
if (udf->type == UDFTYPE_FUNCTION)
1482
func= new (thd->mem_root) Item_func_udf_str(udf, *item_list);
1484
func= new (thd->mem_root) Item_func_udf_str(udf);
1489
func= new (thd->mem_root) Item_sum_udf_str(udf, *item_list);
1491
func= new (thd->mem_root) Item_sum_udf_str(udf);
1497
if (udf->type == UDFTYPE_FUNCTION)
1500
func= new (thd->mem_root) Item_func_udf_float(udf, *item_list);
1502
func= new (thd->mem_root) Item_func_udf_float(udf);
1507
func= new (thd->mem_root) Item_sum_udf_float(udf, *item_list);
1509
func= new (thd->mem_root) Item_sum_udf_float(udf);
1515
if (udf->type == UDFTYPE_FUNCTION)
1518
func= new (thd->mem_root) Item_func_udf_int(udf, *item_list);
1520
func= new (thd->mem_root) Item_func_udf_int(udf);
1525
func= new (thd->mem_root) Item_sum_udf_int(udf, *item_list);
1527
func= new (thd->mem_root) Item_sum_udf_int(udf);
1531
case DECIMAL_RESULT:
1533
if (udf->type == UDFTYPE_FUNCTION)
1536
func= new (thd->mem_root) Item_func_udf_decimal(udf, *item_list);
1538
func= new (thd->mem_root) Item_func_udf_decimal(udf);
1543
func= new (thd->mem_root) Item_sum_udf_decimal(udf, *item_list);
1545
func= new (thd->mem_root) Item_sum_udf_decimal(udf);
1551
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "UDF return type");
2648
2726
The parsed item tree should not depend on
2649
2727
<code>thd->variables.collation_connection</code>.
2651
const CHARSET_INFO * const cs= thd->variables.collation_connection;
2729
CHARSET_INFO *cs= thd->variables.collation_connection;
2654
2732
if (cs->mbminlen > 1)
2656
uint32_t dummy_errors;
2657
2735
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);
2736
sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors);
3014
3092
static HASH native_functions_hash;
3016
extern "C" unsigned char*
3017
get_native_fct_hash_key(const unsigned char *buff, size_t *length,
3095
get_native_fct_hash_key(const uchar *buff, size_t *length,
3096
my_bool /* unused */)
3020
3098
Native_func_registry *func= (Native_func_registry*) buff;
3021
3099
*length= func->name.length;
3022
return (unsigned char*) func->name.str;
3100
return (uchar*) func->name.str;
3088
create_func_char_cast(THD *thd, Item *a, int len, const CHARSET_INFO * const cs)
3166
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);
3168
CHARSET_INFO *real_cs= (cs ? cs : thd->variables.collation_connection);
3091
3169
return new (thd->mem_root) Item_char_typecast(a, len, real_cs);
3096
3174
create_func_cast(THD *thd, Item *a, Cast_target cast_type,
3097
3175
const char *c_len, const char *c_dec,
3098
const CHARSET_INFO * const cs)
3104
3182
switch (cast_type) {
3105
3183
case ITEM_CAST_BINARY: