23
23
#include <drizzled/server_includes.h>
24
#include <drizzled/item/create.h>
25
#include <drizzled/item/func.h>
26
#include <drizzled/error.h>
28
#include <drizzled/function/str/binary.h>
29
#include <drizzled/function/str/concat.h>
30
#include <drizzled/function/str/conv.h>
31
#include <drizzled/function/str/elt.h>
32
#include <drizzled/function/str/export_set.h>
33
#include <drizzled/function/str/format.h>
34
#include <drizzled/function/str/hex.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/substr.h>
41
#include <drizzled/function/str/trim.h>
42
#include <drizzled/function/str/uuid.h>
44
#include <drizzled/function/time/date_format.h>
45
#include <drizzled/function/time/dayname.h>
46
#include <drizzled/function/time/dayofmonth.h>
47
#include <drizzled/function/time/dayofyear.h>
48
#include <drizzled/function/time/from_unixtime.h>
49
#include <drizzled/function/time/from_days.h>
50
#include <drizzled/function/time/last_day.h>
51
#include <drizzled/function/time/makedate.h>
52
#include <drizzled/function/time/month.h>
53
#include <drizzled/function/time/period_add.h>
54
#include <drizzled/function/time/period_diff.h>
55
#include <drizzled/function/time/to_days.h>
56
#include <drizzled/function/time/typecast.h>
57
#include <drizzled/function/time/unix_timestamp.h>
58
#include <drizzled/function/time/weekday.h>
60
#include <drizzled/item/cmpfunc.h>
61
#include <drizzled/plugin/function.h>
62
#include <drizzled/session.h>
64
/* Function declarations */
66
#include <drizzled/function/func.h>
67
#include <drizzled/function/math/abs.h>
68
#include <drizzled/function/math/acos.h>
69
#include <drizzled/function/additive_op.h>
70
#include <drizzled/function/math/asin.h>
71
#include <drizzled/function/math/atan.h>
72
#include <drizzled/function/math/ceiling.h>
73
#include <drizzled/function/coercibility.h>
74
#include <drizzled/function/math/cos.h>
75
#include <drizzled/function/math/dec.h>
76
#include <drizzled/function/math/decimal_typecast.h>
77
#include <drizzled/function/math//exp.h>
78
#include <drizzled/function/field.h>
79
#include <drizzled/function/find_in_set.h>
80
#include <drizzled/function/math/floor.h>
81
#include <drizzled/function/found_rows.h>
82
#include <drizzled/function/get_system_var.h>
83
#include <drizzled/function/math/int_val.h>
84
#include <drizzled/function/math/integer.h>
85
#include <drizzled/function/last_insert.h>
86
#include <drizzled/function/math/ln.h>
87
#include <drizzled/function/locate.h>
88
#include <drizzled/function/math/log.h>
89
#include <drizzled/function/min_max.h>
90
#include <drizzled/function/num1.h>
91
#include <drizzled/function/num_op.h>
92
#include <drizzled/function/numhybrid.h>
93
#include <drizzled/function/math/ord.h>
94
#include <drizzled/function/math/pow.h>
95
#include <drizzled/function/math/rand.h>
96
#include <drizzled/function/math/real.h>
97
#include <drizzled/function/row_count.h>
98
#include <drizzled/function/set_user_var.h>
99
#include <drizzled/function/sign.h>
100
#include <drizzled/function/signed.h>
101
#include <drizzled/function/math/sin.h>
102
#include <drizzled/function/math/sqrt.h>
103
#include <drizzled/function/str/quote.h>
104
#include <drizzled/function/math/tan.h>
105
#include <drizzled/function/units.h>
106
#include <drizzled/function/unsigned.h>
111
using namespace drizzled;
26
117
=============================================================================
1450
1457
Create_udf_func Create_udf_func::s_singleton;
1453
Create_udf_func::create(THD *thd, LEX_STRING name, List<Item> *item_list)
1460
Create_udf_func::create(Session *session, LEX_STRING name, List<Item> *item_list)
1455
udf_func *udf= find_udf(name.str, name.length);
1462
const plugin::Function *udf= plugin::Function::get(name.str, name.length);
1457
return create(thd, udf, item_list);
1464
return create(session, udf, item_list);
1462
Create_udf_func::create(THD *thd, udf_func *udf, List<Item> *item_list)
1469
Create_udf_func::create(Session *session, const plugin::Function *udf,
1470
List<Item> *item_list)
1472
Item_func *func= NULL;
1465
1473
int arg_count= 0;
1467
1475
if (item_list != NULL)
1468
1476
arg_count= item_list->elements;
1470
thd->lex->set_stmt_unsafe();
1472
assert( (udf->type == UDFTYPE_FUNCTION)
1473
|| (udf->type == UDFTYPE_AGGREGATE));
1475
switch(udf->returns) {
1478
if (udf->type == UDFTYPE_FUNCTION)
1481
func= new (thd->mem_root) Item_func_udf_str(udf, *item_list);
1483
func= new (thd->mem_root) Item_func_udf_str(udf);
1488
func= new (thd->mem_root) Item_sum_udf_str(udf, *item_list);
1490
func= new (thd->mem_root) Item_sum_udf_str(udf);
1496
if (udf->type == UDFTYPE_FUNCTION)
1499
func= new (thd->mem_root) Item_func_udf_float(udf, *item_list);
1501
func= new (thd->mem_root) Item_func_udf_float(udf);
1506
func= new (thd->mem_root) Item_sum_udf_float(udf, *item_list);
1508
func= new (thd->mem_root) Item_sum_udf_float(udf);
1514
if (udf->type == UDFTYPE_FUNCTION)
1517
func= new (thd->mem_root) Item_func_udf_int(udf, *item_list);
1519
func= new (thd->mem_root) Item_func_udf_int(udf);
1524
func= new (thd->mem_root) Item_sum_udf_int(udf, *item_list);
1526
func= new (thd->mem_root) Item_sum_udf_int(udf);
1530
case DECIMAL_RESULT:
1532
if (udf->type == UDFTYPE_FUNCTION)
1535
func= new (thd->mem_root) Item_func_udf_decimal(udf, *item_list);
1537
func= new (thd->mem_root) Item_func_udf_decimal(udf);
1542
func= new (thd->mem_root) Item_sum_udf_decimal(udf, *item_list);
1544
func= new (thd->mem_root) Item_sum_udf_decimal(udf);
1550
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "UDF return type");
1478
func= (*udf)(session->mem_root);
1480
if(!func->check_argument_count(arg_count))
1482
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), func->func_name());
1487
func->set_arguments(*item_list);
1558
Create_native_func::create(THD *thd, LEX_STRING name, List<Item> *item_list)
1494
Create_native_func::create(Session *session, LEX_STRING name, List<Item> *item_list)
1560
1496
if (has_named_parameters(item_list))
1668
return create(thd, param_1, param_2, param_3);
1604
return create(session, param_1, param_2, param_3);
1672
1608
Create_func_abs Create_func_abs::s_singleton;
1675
Create_func_abs::create(THD *thd, Item *arg1)
1611
Create_func_abs::create(Session *session, Item *arg1)
1677
return new (thd->mem_root) Item_func_abs(arg1);
1613
return new (session->mem_root) Item_func_abs(arg1);
1681
1617
Create_func_acos Create_func_acos::s_singleton;
1684
Create_func_acos::create(THD *thd, Item *arg1)
1686
return new (thd->mem_root) Item_func_acos(arg1);
1690
Create_func_addtime Create_func_addtime::s_singleton;
1693
Create_func_addtime::create(THD *thd, Item *arg1, Item *arg2)
1695
return new (thd->mem_root) Item_func_add_time(arg1, arg2, 0, 0);
1620
Create_func_acos::create(Session *session, Item *arg1)
1622
return new (session->mem_root) Item_func_acos(arg1);
1699
1625
Create_func_asin Create_func_asin::s_singleton;
1702
Create_func_asin::create(THD *thd, Item *arg1)
1628
Create_func_asin::create(Session *session, Item *arg1)
1704
return new (thd->mem_root) Item_func_asin(arg1);
1630
return new (session->mem_root) Item_func_asin(arg1);
1708
1634
Create_func_atan Create_func_atan::s_singleton;
1711
Create_func_atan::create_native(THD *thd, LEX_STRING name,
1637
Create_func_atan::create_native(Session *session, LEX_STRING name,
1712
1638
List<Item> *item_list)
1714
1640
Item* func= NULL;
1745
Create_func_benchmark Create_func_benchmark::s_singleton;
1748
Create_func_benchmark::create(THD *thd, Item *arg1, Item *arg2)
1750
return new (thd->mem_root) Item_func_benchmark(arg1, arg2);
1754
1670
Create_func_bin Create_func_bin::s_singleton;
1757
Create_func_bin::create(THD *thd, Item *arg1)
1759
Item *i10= new (thd->mem_root) Item_int((int32_t) 10,2);
1760
Item *i2= new (thd->mem_root) Item_int((int32_t) 2,1);
1761
return new (thd->mem_root) Item_func_conv(arg1, i10, i2);
1765
Create_func_bit_count Create_func_bit_count::s_singleton;
1768
Create_func_bit_count::create(THD *thd, Item *arg1)
1770
return new (thd->mem_root) Item_func_bit_count(arg1);
1774
Create_func_bit_length Create_func_bit_length::s_singleton;
1777
Create_func_bit_length::create(THD *thd, Item *arg1)
1779
return new (thd->mem_root) Item_func_bit_length(arg1);
1673
Create_func_bin::create(Session *session, Item *arg1)
1675
Item *i10= new (session->mem_root) Item_int((int32_t) 10,2);
1676
Item *i2= new (session->mem_root) Item_int((int32_t) 2,1);
1677
return new (session->mem_root) Item_func_conv(arg1, i10, i2);
1783
1681
Create_func_ceiling Create_func_ceiling::s_singleton;
1786
Create_func_ceiling::create(THD *thd, Item *arg1)
1788
return new (thd->mem_root) Item_func_ceiling(arg1);
1792
Create_func_char_length Create_func_char_length::s_singleton;
1795
Create_func_char_length::create(THD *thd, Item *arg1)
1797
return new (thd->mem_root) Item_func_char_length(arg1);
1684
Create_func_ceiling::create(Session *session, Item *arg1)
1686
return new (session->mem_root) Item_func_ceiling(arg1);
1801
1690
Create_func_coercibility Create_func_coercibility::s_singleton;
1804
Create_func_coercibility::create(THD *thd, Item *arg1)
1693
Create_func_coercibility::create(Session *session, Item *arg1)
1806
return new (thd->mem_root) Item_func_coercibility(arg1);
1695
return new (session->mem_root) Item_func_coercibility(arg1);
1810
1699
Create_func_concat Create_func_concat::s_singleton;
1813
Create_func_concat::create_native(THD *thd, LEX_STRING name,
1702
Create_func_concat::create_native(Session *session, LEX_STRING name,
1814
1703
List<Item> *item_list)
1816
1705
int arg_count= 0;
1842
1731
/* "WS" stands for "With Separator": this function takes 2+ arguments */
1843
1732
if (arg_count < 2)
1845
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1734
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1849
return new (thd->mem_root) Item_func_concat_ws(*item_list);
1853
Create_func_connection_id Create_func_connection_id::s_singleton;
1856
Create_func_connection_id::create(THD *thd)
1858
return new (thd->mem_root) Item_func_connection_id();
1738
return new (session->mem_root) Item_func_concat_ws(*item_list);
1862
1742
Create_func_conv Create_func_conv::s_singleton;
1865
Create_func_conv::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
1745
Create_func_conv::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
1867
return new (thd->mem_root) Item_func_conv(arg1, arg2, arg3);
1747
return new (session->mem_root) Item_func_conv(arg1, arg2, arg3);
1871
1751
Create_func_cos Create_func_cos::s_singleton;
1874
Create_func_cos::create(THD *thd, Item *arg1)
1754
Create_func_cos::create(Session *session, Item *arg1)
1876
return new (thd->mem_root) Item_func_cos(arg1);
1756
return new (session->mem_root) Item_func_cos(arg1);
1880
1760
Create_func_cot Create_func_cot::s_singleton;
1883
Create_func_cot::create(THD *thd, Item *arg1)
1763
Create_func_cot::create(Session *session, Item *arg1)
1885
Item *i1= new (thd->mem_root) Item_int((char*) "1", 1, 1);
1886
Item *i2= new (thd->mem_root) Item_func_tan(arg1);
1887
return new (thd->mem_root) Item_func_div(i1, i2);
1765
Item *i1= new (session->mem_root) Item_int((char*) "1", 1, 1);
1766
Item *i2= new (session->mem_root) Item_func_tan(arg1);
1767
return new (session->mem_root) Item_func_div(i1, i2);
1890
1770
Create_func_date_format Create_func_date_format::s_singleton;
1893
Create_func_date_format::create(THD *thd, Item *arg1, Item *arg2)
1773
Create_func_date_format::create(Session *session, Item *arg1, Item *arg2)
1895
return new (thd->mem_root) Item_func_date_format(arg1, arg2, 0);
1775
return new (session->mem_root) Item_func_date_format(arg1, arg2, 0);
1899
1779
Create_func_datediff Create_func_datediff::s_singleton;
1902
Create_func_datediff::create(THD *thd, Item *arg1, Item *arg2)
1782
Create_func_datediff::create(Session *session, Item *arg1, Item *arg2)
1904
Item *i1= new (thd->mem_root) Item_func_to_days(arg1);
1905
Item *i2= new (thd->mem_root) Item_func_to_days(arg2);
1784
Item *i1= new (session->mem_root) Item_func_to_days(arg1);
1785
Item *i2= new (session->mem_root) Item_func_to_days(arg2);
1907
return new (thd->mem_root) Item_func_minus(i1, i2);
1787
return new (session->mem_root) Item_func_minus(i1, i2);
1911
1791
Create_func_dayname Create_func_dayname::s_singleton;
1914
Create_func_dayname::create(THD *thd, Item *arg1)
1794
Create_func_dayname::create(Session *session, Item *arg1)
1916
return new (thd->mem_root) Item_func_dayname(arg1);
1796
return new (session->mem_root) Item_func_dayname(arg1);
1920
1800
Create_func_dayofmonth Create_func_dayofmonth::s_singleton;
1923
Create_func_dayofmonth::create(THD *thd, Item *arg1)
1803
Create_func_dayofmonth::create(Session *session, Item *arg1)
1925
return new (thd->mem_root) Item_func_dayofmonth(arg1);
1805
return new (session->mem_root) Item_func_dayofmonth(arg1);
1929
1809
Create_func_dayofweek Create_func_dayofweek::s_singleton;
1932
Create_func_dayofweek::create(THD *thd, Item *arg1)
1812
Create_func_dayofweek::create(Session *session, Item *arg1)
1934
return new (thd->mem_root) Item_func_weekday(arg1, 1);
1814
return new (session->mem_root) Item_func_weekday(arg1, 1);
1938
1818
Create_func_dayofyear Create_func_dayofyear::s_singleton;
1941
Create_func_dayofyear::create(THD *thd, Item *arg1)
1821
Create_func_dayofyear::create(Session *session, Item *arg1)
1943
return new (thd->mem_root) Item_func_dayofyear(arg1);
1823
return new (session->mem_root) Item_func_dayofyear(arg1);
1947
1827
Create_func_degrees Create_func_degrees::s_singleton;
1950
Create_func_degrees::create(THD *thd, Item *arg1)
1830
Create_func_degrees::create(Session *session, Item *arg1)
1952
return new (thd->mem_root) Item_func_units((char*) "degrees", arg1,
1832
return new (session->mem_root) Item_func_units((char*) "degrees", arg1,
1953
1833
180/M_PI, 0.0);
2051
1931
if (arg_count < 2)
2053
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1933
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
2057
return new (thd->mem_root) Item_func_field(*item_list);
1937
return new (session->mem_root) Item_func_field(*item_list);
2061
1941
Create_func_find_in_set Create_func_find_in_set::s_singleton;
2064
Create_func_find_in_set::create(THD *thd, Item *arg1, Item *arg2)
1944
Create_func_find_in_set::create(Session *session, Item *arg1, Item *arg2)
2066
return new (thd->mem_root) Item_func_find_in_set(arg1, arg2);
1946
return new (session->mem_root) Item_func_find_in_set(arg1, arg2);
2070
1950
Create_func_floor Create_func_floor::s_singleton;
2073
Create_func_floor::create(THD *thd, Item *arg1)
1953
Create_func_floor::create(Session *session, Item *arg1)
2075
return new (thd->mem_root) Item_func_floor(arg1);
1955
return new (session->mem_root) Item_func_floor(arg1);
2079
1959
Create_func_format Create_func_format::s_singleton;
2082
Create_func_format::create(THD *thd, Item *arg1, Item *arg2)
1962
Create_func_format::create(Session *session, Item *arg1, Item *arg2)
2084
return new (thd->mem_root) Item_func_format(arg1, arg2);
1964
return new (session->mem_root) Item_func_format(arg1, arg2);
2088
1968
Create_func_found_rows Create_func_found_rows::s_singleton;
2091
Create_func_found_rows::create(THD *thd)
1971
Create_func_found_rows::create(Session *session)
2093
thd->lex->set_stmt_unsafe();
2094
return new (thd->mem_root) Item_func_found_rows();
1973
return new (session->mem_root) Item_func_found_rows();
2098
1977
Create_func_from_days Create_func_from_days::s_singleton;
2101
Create_func_from_days::create(THD *thd, Item *arg1)
1980
Create_func_from_days::create(Session *session, Item *arg1)
2103
return new (thd->mem_root) Item_func_from_days(arg1);
1982
return new (session->mem_root) Item_func_from_days(arg1);
2107
1986
Create_func_from_unixtime Create_func_from_unixtime::s_singleton;
2110
Create_func_from_unixtime::create_native(THD *thd, LEX_STRING name,
1989
Create_func_from_unixtime::create_native(Session *session, LEX_STRING name,
2111
1990
List<Item> *item_list)
2113
1992
Item *func= NULL;
2156
2035
if (arg_count < 2)
2158
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2037
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
2162
return new (thd->mem_root) Item_func_max(*item_list);
2041
return new (session->mem_root) Item_func_max(*item_list);
2166
2045
Create_func_hex Create_func_hex::s_singleton;
2169
Create_func_hex::create(THD *thd, Item *arg1)
2048
Create_func_hex::create(Session *session, Item *arg1)
2171
return new (thd->mem_root) Item_func_hex(arg1);
2050
return new (session->mem_root) Item_func_hex(arg1);
2175
2054
Create_func_ifnull Create_func_ifnull::s_singleton;
2178
Create_func_ifnull::create(THD *thd, Item *arg1, Item *arg2)
2057
Create_func_ifnull::create(Session *session, Item *arg1, Item *arg2)
2180
return new (thd->mem_root) Item_func_ifnull(arg1, arg2);
2059
return new (session->mem_root) Item_func_ifnull(arg1, arg2);
2184
2063
Create_func_instr Create_func_instr::s_singleton;
2187
Create_func_instr::create(THD *thd, Item *arg1, Item *arg2)
2066
Create_func_instr::create(Session *session, Item *arg1, Item *arg2)
2189
return new (thd->mem_root) Item_func_locate(arg1, arg2);
2068
return new (session->mem_root) Item_func_locate(arg1, arg2);
2193
2072
Create_func_isnull Create_func_isnull::s_singleton;
2196
Create_func_isnull::create(THD *thd, Item *arg1)
2075
Create_func_isnull::create(Session *session, Item *arg1)
2198
return new (thd->mem_root) Item_func_isnull(arg1);
2077
return new (session->mem_root) Item_func_isnull(arg1);
2202
2081
Create_func_last_day Create_func_last_day::s_singleton;
2205
Create_func_last_day::create(THD *thd, Item *arg1)
2084
Create_func_last_day::create(Session *session, Item *arg1)
2207
return new (thd->mem_root) Item_func_last_day(arg1);
2086
return new (session->mem_root) Item_func_last_day(arg1);
2211
2090
Create_func_last_insert_id Create_func_last_insert_id::s_singleton;
2214
Create_func_last_insert_id::create_native(THD *thd, LEX_STRING name,
2093
Create_func_last_insert_id::create_native(Session *session, LEX_STRING name,
2215
2094
List<Item> *item_list)
2217
2096
Item *func= NULL;
2266
2145
if (arg_count < 2)
2268
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2147
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
2272
return new (thd->mem_root) Item_func_min(*item_list);
2276
Create_func_length Create_func_length::s_singleton;
2279
Create_func_length::create(THD *thd, Item *arg1)
2281
return new (thd->mem_root) Item_func_length(arg1);
2151
return new (session->mem_root) Item_func_min(*item_list);
2285
2155
Create_func_ln Create_func_ln::s_singleton;
2288
Create_func_ln::create(THD *thd, Item *arg1)
2158
Create_func_ln::create(Session *session, Item *arg1)
2290
return new (thd->mem_root) Item_func_ln(arg1);
2160
return new (session->mem_root) Item_func_ln(arg1);
2294
2164
Create_func_load_file Create_func_load_file::s_singleton;
2297
Create_func_load_file::create(THD *thd, Item *arg1)
2167
Create_func_load_file::create(Session *session, Item *arg1)
2299
return new (thd->mem_root) Item_load_file(arg1);
2169
return new (session->mem_root) Item_load_file(arg1);
2303
2173
Create_func_locate Create_func_locate::s_singleton;
2306
Create_func_locate::create_native(THD *thd, LEX_STRING name,
2176
Create_func_locate::create_native(Session *session, LEX_STRING name,
2307
2177
List<Item> *item_list)
2309
2179
Item *func= NULL;
2381
2251
Create_func_log10 Create_func_log10::s_singleton;
2384
Create_func_log10::create(THD *thd, Item *arg1)
2254
Create_func_log10::create(Session *session, Item *arg1)
2386
return new (thd->mem_root) Item_func_log10(arg1);
2256
return new (session->mem_root) Item_func_log10(arg1);
2390
2260
Create_func_log2 Create_func_log2::s_singleton;
2393
Create_func_log2::create(THD *thd, Item *arg1)
2263
Create_func_log2::create(Session *session, Item *arg1)
2395
return new (thd->mem_root) Item_func_log2(arg1);
2265
return new (session->mem_root) Item_func_log2(arg1);
2399
2269
Create_func_lpad Create_func_lpad::s_singleton;
2402
Create_func_lpad::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
2272
Create_func_lpad::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
2404
return new (thd->mem_root) Item_func_lpad(arg1, arg2, arg3);
2274
return new (session->mem_root) Item_func_lpad(arg1, arg2, arg3);
2408
2278
Create_func_ltrim Create_func_ltrim::s_singleton;
2411
Create_func_ltrim::create(THD *thd, Item *arg1)
2281
Create_func_ltrim::create(Session *session, Item *arg1)
2413
return new (thd->mem_root) Item_func_ltrim(arg1);
2283
return new (session->mem_root) Item_func_ltrim(arg1);
2417
2287
Create_func_makedate Create_func_makedate::s_singleton;
2420
Create_func_makedate::create(THD *thd, Item *arg1, Item *arg2)
2422
return new (thd->mem_root) Item_func_makedate(arg1, arg2);
2426
Create_func_maketime Create_func_maketime::s_singleton;
2429
Create_func_maketime::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
2431
return new (thd->mem_root) Item_func_maketime(arg1, arg2, arg3);
2290
Create_func_makedate::create(Session *session, Item *arg1, Item *arg2)
2292
return new (session->mem_root) Item_func_makedate(arg1, arg2);
2435
2296
Create_func_make_set Create_func_make_set::s_singleton;
2438
Create_func_make_set::create_native(THD *thd, LEX_STRING name,
2299
Create_func_make_set::create_native(Session *session, LEX_STRING name,
2439
2300
List<Item> *item_list)
2441
2302
int arg_count= 0;
2446
2307
if (arg_count < 2)
2448
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2309
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
2452
2313
Item *param_1= item_list->pop();
2453
return new (thd->mem_root) Item_func_make_set(param_1, *item_list);
2457
Create_func_master_pos_wait Create_func_master_pos_wait::s_singleton;
2460
Create_func_master_pos_wait::create_native(THD *thd, LEX_STRING name,
2461
List<Item> *item_list)
2467
if (item_list != NULL)
2468
arg_count= item_list->elements;
2470
switch (arg_count) {
2473
Item *param_1= item_list->pop();
2474
Item *param_2= item_list->pop();
2475
func= new (thd->mem_root) Item_master_pos_wait(param_1, param_2);
2480
Item *param_1= item_list->pop();
2481
Item *param_2= item_list->pop();
2482
Item *param_3= item_list->pop();
2483
func= new (thd->mem_root) Item_master_pos_wait(param_1, param_2, param_3);
2488
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2314
return new (session->mem_root) Item_func_make_set(param_1, *item_list);
2497
2318
Create_func_monthname Create_func_monthname::s_singleton;
2500
Create_func_monthname::create(THD *thd, Item *arg1)
2321
Create_func_monthname::create(Session *session, Item *arg1)
2502
return new (thd->mem_root) Item_func_monthname(arg1);
2323
return new (session->mem_root) Item_func_monthname(arg1);
2506
2327
Create_func_nullif Create_func_nullif::s_singleton;
2509
Create_func_nullif::create(THD *thd, Item *arg1, Item *arg2)
2330
Create_func_nullif::create(Session *session, Item *arg1, Item *arg2)
2511
return new (thd->mem_root) Item_func_nullif(arg1, arg2);
2332
return new (session->mem_root) Item_func_nullif(arg1, arg2);
2515
2336
Create_func_oct Create_func_oct::s_singleton;
2518
Create_func_oct::create(THD *thd, Item *arg1)
2339
Create_func_oct::create(Session *session, Item *arg1)
2520
Item *i10= new (thd->mem_root) Item_int((int32_t) 10,2);
2521
Item *i8= new (thd->mem_root) Item_int((int32_t) 8,1);
2522
return new (thd->mem_root) Item_func_conv(arg1, i10, i8);
2341
Item *i10= new (session->mem_root) Item_int((int32_t) 10,2);
2342
Item *i8= new (session->mem_root) Item_int((int32_t) 8,1);
2343
return new (session->mem_root) Item_func_conv(arg1, i10, i8);
2526
2347
Create_func_ord Create_func_ord::s_singleton;
2529
Create_func_ord::create(THD *thd, Item *arg1)
2350
Create_func_ord::create(Session *session, Item *arg1)
2531
return new (thd->mem_root) Item_func_ord(arg1);
2352
return new (session->mem_root) Item_func_ord(arg1);
2535
2356
Create_func_period_add Create_func_period_add::s_singleton;
2538
Create_func_period_add::create(THD *thd, Item *arg1, Item *arg2)
2359
Create_func_period_add::create(Session *session, Item *arg1, Item *arg2)
2540
return new (thd->mem_root) Item_func_period_add(arg1, arg2);
2361
return new (session->mem_root) Item_func_period_add(arg1, arg2);
2544
2365
Create_func_period_diff Create_func_period_diff::s_singleton;
2547
Create_func_period_diff::create(THD *thd, Item *arg1, Item *arg2)
2368
Create_func_period_diff::create(Session *session, Item *arg1, Item *arg2)
2549
return new (thd->mem_root) Item_func_period_diff(arg1, arg2);
2370
return new (session->mem_root) Item_func_period_diff(arg1, arg2);
2553
2374
Create_func_pi Create_func_pi::s_singleton;
2556
Create_func_pi::create(THD *thd)
2377
Create_func_pi::create(Session *session)
2558
return new (thd->mem_root) Item_static_float_func("pi()", M_PI, 6, 8);
2379
return new (session->mem_root) Item_static_float_func("pi()", M_PI, 6, 8);
2562
2383
Create_func_pow Create_func_pow::s_singleton;
2565
Create_func_pow::create(THD *thd, Item *arg1, Item *arg2)
2386
Create_func_pow::create(Session *session, Item *arg1, Item *arg2)
2567
return new (thd->mem_root) Item_func_pow(arg1, arg2);
2388
return new (session->mem_root) Item_func_pow(arg1, arg2);
2571
2392
Create_func_quote Create_func_quote::s_singleton;
2574
Create_func_quote::create(THD *thd, Item *arg1)
2395
Create_func_quote::create(Session *session, Item *arg1)
2576
return new (thd->mem_root) Item_func_quote(arg1);
2397
return new (session->mem_root) Item_func_quote(arg1);
2580
2401
Create_func_radians Create_func_radians::s_singleton;
2583
Create_func_radians::create(THD *thd, Item *arg1)
2404
Create_func_radians::create(Session *session, Item *arg1)
2585
return new (thd->mem_root) Item_func_units((char*) "radians", arg1,
2406
return new (session->mem_root) Item_func_units((char*) "radians", arg1,
2586
2407
M_PI/180, 0.0);
2663
2484
Create_func_row_count Create_func_row_count::s_singleton;
2666
Create_func_row_count::create(THD *thd)
2487
Create_func_row_count::create(Session *session)
2668
thd->lex->set_stmt_unsafe();
2669
return new (thd->mem_root) Item_func_row_count();
2489
return new (session->mem_root) Item_func_row_count();
2673
2493
Create_func_rpad Create_func_rpad::s_singleton;
2676
Create_func_rpad::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
2496
Create_func_rpad::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
2678
return new (thd->mem_root) Item_func_rpad(arg1, arg2, arg3);
2498
return new (session->mem_root) Item_func_rpad(arg1, arg2, arg3);
2682
2502
Create_func_rtrim Create_func_rtrim::s_singleton;
2685
Create_func_rtrim::create(THD *thd, Item *arg1)
2687
return new (thd->mem_root) Item_func_rtrim(arg1);
2691
Create_func_sec_to_time Create_func_sec_to_time::s_singleton;
2694
Create_func_sec_to_time::create(THD *thd, Item *arg1)
2696
return new (thd->mem_root) Item_func_sec_to_time(arg1);
2505
Create_func_rtrim::create(Session *session, Item *arg1)
2507
return new (session->mem_root) Item_func_rtrim(arg1);
2700
2511
Create_func_sign Create_func_sign::s_singleton;
2703
Create_func_sign::create(THD *thd, Item *arg1)
2514
Create_func_sign::create(Session *session, Item *arg1)
2705
return new (thd->mem_root) Item_func_sign(arg1);
2516
return new (session->mem_root) Item_func_sign(arg1);
2709
2520
Create_func_sin Create_func_sin::s_singleton;
2712
Create_func_sin::create(THD *thd, Item *arg1)
2523
Create_func_sin::create(Session *session, Item *arg1)
2714
return new (thd->mem_root) Item_func_sin(arg1);
2525
return new (session->mem_root) Item_func_sin(arg1);
2718
2529
Create_func_space Create_func_space::s_singleton;
2721
Create_func_space::create(THD *thd, Item *arg1)
2532
Create_func_space::create(Session *session, Item *arg1)
2724
2535
TODO: Fix Bug#23637
2725
2536
The parsed item tree should not depend on
2726
<code>thd->variables.collation_connection</code>.
2537
<code>session->variables.collation_connection</code>.
2728
const CHARSET_INFO * const cs= thd->variables.collation_connection;
2539
const CHARSET_INFO * const cs= session->variables.getCollation();
2731
2542
if (cs->mbminlen > 1)
2734
sp= new (thd->mem_root) Item_string("", 0, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
2735
sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors);
2544
uint32_t dummy_errors;
2545
sp= new (session->mem_root) Item_string("", 0, cs, DERIVATION_COERCIBLE);
2546
sp->str_value.copy(" ", 1, &my_charset_utf8_general_ci, cs, &dummy_errors);
2739
sp= new (thd->mem_root) Item_string(" ", 1, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
2550
sp= new (session->mem_root) Item_string(" ", 1, cs, DERIVATION_COERCIBLE);
2742
return new (thd->mem_root) Item_func_repeat(sp, arg1);
2553
return new (session->mem_root) Item_func_repeat(sp, arg1);
2746
2557
Create_func_sqrt Create_func_sqrt::s_singleton;
2749
Create_func_sqrt::create(THD *thd, Item *arg1)
2751
return new (thd->mem_root) Item_func_sqrt(arg1);
2755
Create_func_str_to_date Create_func_str_to_date::s_singleton;
2758
Create_func_str_to_date::create(THD *thd, Item *arg1, Item *arg2)
2760
return new (thd->mem_root) Item_func_str_to_date(arg1, arg2);
2560
Create_func_sqrt::create(Session *session, Item *arg1)
2562
return new (session->mem_root) Item_func_sqrt(arg1);
2764
2566
Create_func_strcmp Create_func_strcmp::s_singleton;
2767
Create_func_strcmp::create(THD *thd, Item *arg1, Item *arg2)
2569
Create_func_strcmp::create(Session *session, Item *arg1, Item *arg2)
2769
return new (thd->mem_root) Item_func_strcmp(arg1, arg2);
2571
return new (session->mem_root) Item_func_strcmp(arg1, arg2);
2773
2575
Create_func_substr_index Create_func_substr_index::s_singleton;
2776
Create_func_substr_index::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
2778
return new (thd->mem_root) Item_func_substr_index(arg1, arg2, arg3);
2782
Create_func_subtime Create_func_subtime::s_singleton;
2785
Create_func_subtime::create(THD *thd, Item *arg1, Item *arg2)
2787
return new (thd->mem_root) Item_func_add_time(arg1, arg2, 0, 1);
2578
Create_func_substr_index::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
2580
return new (session->mem_root) Item_func_substr_index(arg1, arg2, arg3);
2791
2583
Create_func_tan Create_func_tan::s_singleton;
2794
Create_func_tan::create(THD *thd, Item *arg1)
2586
Create_func_tan::create(Session *session, Item *arg1)
2796
return new (thd->mem_root) Item_func_tan(arg1);
2588
return new (session->mem_root) Item_func_tan(arg1);
2800
2592
Create_func_time_format Create_func_time_format::s_singleton;
2803
Create_func_time_format::create(THD *thd, Item *arg1, Item *arg2)
2805
return new (thd->mem_root) Item_func_date_format(arg1, arg2, 1);
2809
Create_func_time_to_sec Create_func_time_to_sec::s_singleton;
2812
Create_func_time_to_sec::create(THD *thd, Item *arg1)
2814
return new (thd->mem_root) Item_func_time_to_sec(arg1);
2818
Create_func_timediff Create_func_timediff::s_singleton;
2821
Create_func_timediff::create(THD *thd, Item *arg1, Item *arg2)
2823
return new (thd->mem_root) Item_func_timediff(arg1, arg2);
2595
Create_func_time_format::create(Session *session, Item *arg1, Item *arg2)
2597
return new (session->mem_root) Item_func_date_format(arg1, arg2, 1);
2827
2600
Create_func_to_days Create_func_to_days::s_singleton;
2830
Create_func_to_days::create(THD *thd, Item *arg1)
2603
Create_func_to_days::create(Session *session, Item *arg1)
2832
return new (thd->mem_root) Item_func_to_days(arg1);
2605
return new (session->mem_root) Item_func_to_days(arg1);
2836
2609
Create_func_ucase Create_func_ucase::s_singleton;
2839
Create_func_ucase::create(THD *thd, Item *arg1)
2612
Create_func_ucase::create(Session *session, Item *arg1)
2841
return new (thd->mem_root) Item_func_ucase(arg1);
2614
return new (session->mem_root) Item_func_ucase(arg1);
2845
2618
Create_func_unhex Create_func_unhex::s_singleton;
2848
Create_func_unhex::create(THD *thd, Item *arg1)
2621
Create_func_unhex::create(Session *session, Item *arg1)
2850
return new (thd->mem_root) Item_func_unhex(arg1);
2623
return new (session->mem_root) Item_func_unhex(arg1);
2854
2627
Create_func_unix_timestamp Create_func_unix_timestamp::s_singleton;
2857
Create_func_unix_timestamp::create_native(THD *thd, LEX_STRING name,
2630
Create_func_unix_timestamp::create_native(Session *session, LEX_STRING name,
2858
2631
List<Item> *item_list)
2860
2633
Item *func= NULL;
2889
2662
Create_func_uuid Create_func_uuid::s_singleton;
2892
Create_func_uuid::create(THD *thd)
2894
thd->lex->set_stmt_unsafe();
2895
return new (thd->mem_root) Item_func_uuid();
2899
Create_func_version Create_func_version::s_singleton;
2902
Create_func_version::create(THD *thd)
2904
return new (thd->mem_root) Item_static_string_func("version()",
2906
(uint) strlen(server_version),
2907
system_charset_info,
2908
DERIVATION_SYSCONST);
2665
Create_func_uuid::create(Session *session)
2667
return new (session->mem_root) Item_func_uuid();
2912
2671
Create_func_weekday Create_func_weekday::s_singleton;
2915
Create_func_weekday::create(THD *thd, Item *arg1)
2917
return new (thd->mem_root) Item_func_weekday(arg1, 0);
2921
Create_func_weekofyear Create_func_weekofyear::s_singleton;
2924
Create_func_weekofyear::create(THD *thd, Item *arg1)
2926
Item *i1= new (thd->mem_root) Item_int((char*) "0", 3, 1);
2927
return new (thd->mem_root) Item_func_week(arg1, i1);
2931
Create_func_year_week Create_func_year_week::s_singleton;
2934
Create_func_year_week::create_native(THD *thd, LEX_STRING name,
2935
List<Item> *item_list)
2940
if (item_list != NULL)
2941
arg_count= item_list->elements;
2943
switch (arg_count) {
2946
Item *param_1= item_list->pop();
2947
Item *i0= new (thd->mem_root) Item_int((char*) "0", 0, 1);
2948
func= new (thd->mem_root) Item_func_yearweek(param_1, i0);
2953
Item *param_1= item_list->pop();
2954
Item *param_2= item_list->pop();
2955
func= new (thd->mem_root) Item_func_yearweek(param_1, param_2);
2960
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2674
Create_func_weekday::create(Session *session, Item *arg1)
2676
return new (session->mem_root) Item_func_weekday(arg1, 0);
2969
2679
struct Native_func_registry
2986
2696
{ { C_STRING_WITH_LEN("ABS") }, BUILDER(Create_func_abs)},
2987
2697
{ { C_STRING_WITH_LEN("ACOS") }, BUILDER(Create_func_acos)},
2988
{ { C_STRING_WITH_LEN("ADDTIME") }, BUILDER(Create_func_addtime)},
2989
2698
{ { C_STRING_WITH_LEN("ASIN") }, BUILDER(Create_func_asin)},
2990
2699
{ { C_STRING_WITH_LEN("ATAN") }, BUILDER(Create_func_atan)},
2991
2700
{ { C_STRING_WITH_LEN("ATAN2") }, BUILDER(Create_func_atan)},
2992
{ { C_STRING_WITH_LEN("BENCHMARK") }, BUILDER(Create_func_benchmark)},
2993
2701
{ { C_STRING_WITH_LEN("BIN") }, BUILDER(Create_func_bin)},
2994
{ { C_STRING_WITH_LEN("BIT_COUNT") }, BUILDER(Create_func_bit_count)},
2995
{ { C_STRING_WITH_LEN("BIT_LENGTH") }, BUILDER(Create_func_bit_length)},
2996
2702
{ { C_STRING_WITH_LEN("CEIL") }, BUILDER(Create_func_ceiling)},
2997
2703
{ { C_STRING_WITH_LEN("CEILING") }, BUILDER(Create_func_ceiling)},
2998
{ { C_STRING_WITH_LEN("CHARACTER_LENGTH") }, BUILDER(Create_func_char_length)},
2999
{ { C_STRING_WITH_LEN("CHAR_LENGTH") }, BUILDER(Create_func_char_length)},
3000
2704
{ { C_STRING_WITH_LEN("COERCIBILITY") }, BUILDER(Create_func_coercibility)},
3001
2705
{ { C_STRING_WITH_LEN("CONCAT") }, BUILDER(Create_func_concat)},
3002
2706
{ { C_STRING_WITH_LEN("CONCAT_WS") }, BUILDER(Create_func_concat_ws)},
3003
{ { C_STRING_WITH_LEN("CONNECTION_ID") }, BUILDER(Create_func_connection_id)},
3004
2707
{ { C_STRING_WITH_LEN("CONV") }, BUILDER(Create_func_conv)},
3005
2708
{ { C_STRING_WITH_LEN("COS") }, BUILDER(Create_func_cos)},
3006
2709
{ { C_STRING_WITH_LEN("COT") }, BUILDER(Create_func_cot)},
3061
2760
{ { C_STRING_WITH_LEN("ROW_COUNT") }, BUILDER(Create_func_row_count)},
3062
2761
{ { C_STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad)},
3063
2762
{ { C_STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim)},
3064
{ { C_STRING_WITH_LEN("SEC_TO_TIME") }, BUILDER(Create_func_sec_to_time)},
3065
2763
{ { C_STRING_WITH_LEN("SIGN") }, BUILDER(Create_func_sign)},
3066
2764
{ { C_STRING_WITH_LEN("SIN") }, BUILDER(Create_func_sin)},
3067
2765
{ { C_STRING_WITH_LEN("SPACE") }, BUILDER(Create_func_space)},
3068
2766
{ { C_STRING_WITH_LEN("SQRT") }, BUILDER(Create_func_sqrt)},
3069
2767
{ { C_STRING_WITH_LEN("STRCMP") }, BUILDER(Create_func_strcmp)},
3070
{ { C_STRING_WITH_LEN("STR_TO_DATE") }, BUILDER(Create_func_str_to_date)},
3071
2768
{ { C_STRING_WITH_LEN("SUBSTRING_INDEX") }, BUILDER(Create_func_substr_index)},
3072
{ { C_STRING_WITH_LEN("SUBTIME") }, BUILDER(Create_func_subtime)},
3073
2769
{ { C_STRING_WITH_LEN("TAN") }, BUILDER(Create_func_tan)},
3074
{ { C_STRING_WITH_LEN("TIMEDIFF") }, BUILDER(Create_func_timediff)},
3075
2770
{ { C_STRING_WITH_LEN("TIME_FORMAT") }, BUILDER(Create_func_time_format)},
3076
{ { C_STRING_WITH_LEN("TIME_TO_SEC") }, BUILDER(Create_func_time_to_sec)},
3077
2771
{ { C_STRING_WITH_LEN("TO_DAYS") }, BUILDER(Create_func_to_days)},
3078
2772
{ { C_STRING_WITH_LEN("UCASE") }, BUILDER(Create_func_ucase)},
3079
2773
{ { C_STRING_WITH_LEN("UNHEX") }, BUILDER(Create_func_unhex)},
3080
2774
{ { C_STRING_WITH_LEN("UNIX_TIMESTAMP") }, BUILDER(Create_func_unix_timestamp)},
3081
2775
{ { C_STRING_WITH_LEN("UPPER") }, BUILDER(Create_func_ucase)},
3082
2776
{ { C_STRING_WITH_LEN("UUID") }, BUILDER(Create_func_uuid)},
3083
{ { C_STRING_WITH_LEN("VERSION") }, BUILDER(Create_func_version)},
3084
2777
{ { C_STRING_WITH_LEN("WEEKDAY") }, BUILDER(Create_func_weekday)},
3085
{ { C_STRING_WITH_LEN("WEEKOFYEAR") }, BUILDER(Create_func_weekofyear)},
3086
{ { C_STRING_WITH_LEN("YEARWEEK") }, BUILDER(Create_func_year_week)},
3088
2779
{ {0, 0}, NULL}
3091
static HASH native_functions_hash;
3094
get_native_fct_hash_key(const uchar *buff, size_t *length,
3097
Native_func_registry *func= (Native_func_registry*) buff;
3098
*length= func->name.length;
3099
return (uchar*) func->name.str;
2782
static map<string, Native_func_registry *> native_functions_map;
3103
2785
Load the hash table for native functions.
3108
2790
int item_create_init()
3110
2794
Native_func_registry *func;
3112
if (hash_init(& native_functions_hash,
3113
system_charset_info,
3114
array_elements(func_array),
3117
(hash_get_key) get_native_fct_hash_key,
3118
NULL, /* Nothing to free */
3122
2795
for (func= func_array; func->builder != NULL; func++)
3124
if (my_hash_insert(& native_functions_hash, (uchar*) func))
2797
func_name.assign(func->name.str, func->name.length);
2798
transform(func_name.begin(), func_name.end(), func_name.begin(), ::tolower);
2800
native_functions_map[func_name]= func;
3132
Empty the hash table for native functions.
3133
Note: this code is not thread safe, and is intended to be used at server
3134
shutdown only (after thread requests have been executed).
3137
void item_create_cleanup()
3139
hash_free(& native_functions_hash);
3144
find_native_function_builder(THD *thd __attribute__((unused)),
2808
find_native_function_builder(LEX_STRING name)
3147
2810
Native_func_registry *func;
3148
2811
Create_func *builder= NULL;
3151
func= (Native_func_registry*) hash_search(& native_functions_hash,
2813
string func_name(name.str, name.length);
2814
transform(func_name.begin(), func_name.end(), func_name.begin(), ::tolower);
2816
map<string, Native_func_registry *>::iterator func_iter=
2817
native_functions_map.find(func_name);
2819
if (func_iter != native_functions_map.end())
2821
func= (*func_iter).second;
3157
2822
builder= func->builder;
3165
create_func_char_cast(THD *thd, Item *a, int len, const CHARSET_INFO * const cs)
2830
create_func_char_cast(Session *session, Item *a, int len, const CHARSET_INFO * const cs)
3167
const CHARSET_INFO * const real_cs= (cs ? cs : thd->variables.collation_connection);
3168
return new (thd->mem_root) Item_char_typecast(a, len, real_cs);
2832
const CHARSET_INFO * const real_cs= (cs ? cs : session->variables.getCollation());
2833
return new (session->mem_root) Item_char_typecast(a, len, real_cs);
3173
create_func_cast(THD *thd, Item *a, Cast_target cast_type,
2838
create_func_cast(Session *session, Item *a, Cast_target cast_type,
3174
2839
const char *c_len, const char *c_dec,
3175
2840
const CHARSET_INFO * const cs)
3181
2846
switch (cast_type) {
3182
2847
case ITEM_CAST_BINARY:
3183
res= new (thd->mem_root) Item_func_binary(a);
2848
res= new (session->mem_root) Item_func_binary(a);
3185
2850
case ITEM_CAST_SIGNED_INT:
3186
res= new (thd->mem_root) Item_func_signed(a);
2851
res= new (session->mem_root) Item_func_signed(a);
3188
2853
case ITEM_CAST_UNSIGNED_INT:
3189
res= new (thd->mem_root) Item_func_unsigned(a);
2854
res= new (session->mem_root) Item_func_unsigned(a);
3191
2856
case ITEM_CAST_DATE:
3192
res= new (thd->mem_root) Item_date_typecast(a);
3194
case ITEM_CAST_TIME:
3195
res= new (thd->mem_root) Item_time_typecast(a);
2857
res= new (session->mem_root) Item_date_typecast(a);
3197
2859
case ITEM_CAST_DATETIME:
3198
res= new (thd->mem_root) Item_datetime_typecast(a);
2860
res= new (session->mem_root) Item_datetime_typecast(a);
3200
2862
case ITEM_CAST_DECIMAL: