20
20
Functions to create an item. Used by sql_yac.yy
24
#include <drizzled/item/create.h>
25
#include <drizzled/item/func.h>
26
#include <drizzled/error.h>
28
#include <drizzled/function_container.h>
30
#include <drizzled/function/str/binary.h>
31
#include <drizzled/function/str/concat.h>
32
#include <drizzled/function/str/conv.h>
33
#include <drizzled/function/str/export_set.h>
34
#include <drizzled/function/str/load_file.h>
35
#include <drizzled/function/str/make_set.h>
36
#include <drizzled/function/str/pad.h>
37
#include <drizzled/function/str/repeat.h>
38
#include <drizzled/function/str/str_conv.h>
39
#include <drizzled/function/str/trim.h>
41
#include <drizzled/function/time/date_format.h>
42
#include <drizzled/function/time/dayname.h>
43
#include <drizzled/function/time/dayofmonth.h>
44
#include <drizzled/function/time/dayofyear.h>
45
#include <drizzled/function/time/from_unixtime.h>
46
#include <drizzled/function/time/from_days.h>
47
#include <drizzled/function/time/last_day.h>
48
#include <drizzled/function/time/makedate.h>
49
#include <drizzled/function/time/month.h>
50
#include <drizzled/function/time/period_add.h>
51
#include <drizzled/function/time/period_diff.h>
52
#include <drizzled/function/time/to_days.h>
53
#include <drizzled/function/time/typecast.h>
54
#include <drizzled/function/time/unix_timestamp.h>
55
#include <drizzled/function/time/weekday.h>
57
#include <drizzled/item/cmpfunc.h>
58
#include <drizzled/plugin/function.h>
59
#include <drizzled/session.h>
61
/* Function declarations */
63
#include <drizzled/function/func.h>
64
#include <drizzled/function/additive_op.h>
65
#include <drizzled/function/math/dec.h>
66
#include <drizzled/function/math/decimal_typecast.h>
67
#include <drizzled/function/field.h>
68
#include <drizzled/function/find_in_set.h>
69
#include <drizzled/function/found_rows.h>
70
#include <drizzled/function/get_system_var.h>
71
#include <drizzled/function/math/int_val.h>
72
#include <drizzled/function/math/integer.h>
73
#include <drizzled/function/last_insert.h>
74
#include <drizzled/function/locate.h>
75
#include <drizzled/function/min_max.h>
76
#include <drizzled/function/num1.h>
77
#include <drizzled/function/num_op.h>
78
#include <drizzled/function/numhybrid.h>
79
#include <drizzled/function/math/real.h>
80
#include <drizzled/function/row_count.h>
81
#include <drizzled/function/set_user_var.h>
82
#include <drizzled/function/sign.h>
83
#include <drizzled/function/math/tan.h>
84
#include <drizzled/function/units.h>
86
#include <drizzled/function/cast/boolean.h>
87
#include <drizzled/function/cast/signed.h>
88
#include <drizzled/function/cast/time.h>
89
#include <drizzled/function/cast/unsigned.h>
23
#include <drizzled/server_includes.h>
100
26
=============================================================================
245
171
it helps to compare code between versions, and helps with merges conflicts.
174
class Create_func_abs : public Create_func_arg1
177
virtual Item *create(THD *thd, Item *arg1);
179
static Create_func_abs s_singleton;
183
virtual ~Create_func_abs() {}
187
class Create_func_acos : public Create_func_arg1
190
virtual Item *create(THD *thd, Item *arg1);
192
static Create_func_acos s_singleton;
195
Create_func_acos() {}
196
virtual ~Create_func_acos() {}
200
class Create_func_addtime : public Create_func_arg2
203
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
205
static Create_func_addtime s_singleton;
208
Create_func_addtime() {}
209
virtual ~Create_func_addtime() {}
213
class Create_func_asin : public Create_func_arg1
216
virtual Item *create(THD *thd, Item *arg1);
218
static Create_func_asin s_singleton;
221
Create_func_asin() {}
222
virtual ~Create_func_asin() {}
226
class Create_func_atan : public Create_native_func
229
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
231
static Create_func_atan s_singleton;
234
Create_func_atan() {}
235
virtual ~Create_func_atan() {}
239
class Create_func_benchmark : public Create_func_arg2
242
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
244
static Create_func_benchmark s_singleton;
247
Create_func_benchmark() {}
248
virtual ~Create_func_benchmark() {}
249
252
class Create_func_bin : public Create_func_arg1
252
using Create_func_arg1::create;
254
virtual Item *create(Session *session, Item *arg1);
255
virtual Item *create(THD *thd, Item *arg1);
256
257
static Create_func_bin s_singleton;
260
261
virtual ~Create_func_bin() {}
265
class Create_func_bit_count : public Create_func_arg1
268
virtual Item *create(THD *thd, Item *arg1);
270
static Create_func_bit_count s_singleton;
273
Create_func_bit_count() {}
274
virtual ~Create_func_bit_count() {}
278
class Create_func_bit_length : public Create_func_arg1
281
virtual Item *create(THD *thd, Item *arg1);
283
static Create_func_bit_length s_singleton;
286
Create_func_bit_length() {}
287
virtual ~Create_func_bit_length() {}
291
class Create_func_ceiling : public Create_func_arg1
294
virtual Item *create(THD *thd, Item *arg1);
296
static Create_func_ceiling s_singleton;
299
Create_func_ceiling() {}
300
virtual ~Create_func_ceiling() {}
304
class Create_func_char_length : public Create_func_arg1
307
virtual Item *create(THD *thd, Item *arg1);
309
static Create_func_char_length s_singleton;
312
Create_func_char_length() {}
313
virtual ~Create_func_char_length() {}
317
class Create_func_coercibility : public Create_func_arg1
320
virtual Item *create(THD *thd, Item *arg1);
322
static Create_func_coercibility s_singleton;
325
Create_func_coercibility() {}
326
virtual ~Create_func_coercibility() {}
263
330
class Create_func_concat : public Create_native_func
266
virtual Item *create_native(Session *session, LEX_STRING name, List<Item> *item_list);
333
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
268
335
static Create_func_concat s_singleton;
1215
return create(session, param_1, param_2, param_3);
1591
return create(thd, param_1, param_2, param_3);
1595
Create_func_abs Create_func_abs::s_singleton;
1598
Create_func_abs::create(THD *thd, Item *arg1)
1600
return new (thd->mem_root) Item_func_abs(arg1);
1604
Create_func_acos Create_func_acos::s_singleton;
1607
Create_func_acos::create(THD *thd, Item *arg1)
1609
return new (thd->mem_root) Item_func_acos(arg1);
1613
Create_func_addtime Create_func_addtime::s_singleton;
1616
Create_func_addtime::create(THD *thd, Item *arg1, Item *arg2)
1618
return new (thd->mem_root) Item_func_add_time(arg1, arg2, 0, 0);
1622
Create_func_asin Create_func_asin::s_singleton;
1625
Create_func_asin::create(THD *thd, Item *arg1)
1627
return new (thd->mem_root) Item_func_asin(arg1);
1631
Create_func_atan Create_func_atan::s_singleton;
1634
Create_func_atan::create_native(THD *thd, LEX_STRING name,
1635
List<Item> *item_list)
1640
if (item_list != NULL)
1641
arg_count= item_list->elements;
1643
switch (arg_count) {
1646
Item *param_1= item_list->pop();
1647
func= new (thd->mem_root) Item_func_atan(param_1);
1652
Item *param_1= item_list->pop();
1653
Item *param_2= item_list->pop();
1654
func= new (thd->mem_root) Item_func_atan(param_1, param_2);
1659
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1668
Create_func_benchmark Create_func_benchmark::s_singleton;
1671
Create_func_benchmark::create(THD *thd, Item *arg1, Item *arg2)
1673
return new (thd->mem_root) Item_func_benchmark(arg1, arg2);
1218
1677
Create_func_bin Create_func_bin::s_singleton;
1221
Create_func_bin::create(Session *session, Item *arg1)
1223
Item *i10= new (session->mem_root) Item_int((int32_t) 10,2);
1224
Item *i2= new (session->mem_root) Item_int((int32_t) 2,1);
1225
return new (session->mem_root) Item_func_conv(arg1, i10, i2);
1680
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);
1684
return new (thd->mem_root) Item_func_conv(arg1, i10, i2);
1688
Create_func_bit_count Create_func_bit_count::s_singleton;
1691
Create_func_bit_count::create(THD *thd, Item *arg1)
1693
return new (thd->mem_root) Item_func_bit_count(arg1);
1697
Create_func_bit_length Create_func_bit_length::s_singleton;
1700
Create_func_bit_length::create(THD *thd, Item *arg1)
1702
return new (thd->mem_root) Item_func_bit_length(arg1);
1706
Create_func_ceiling Create_func_ceiling::s_singleton;
1709
Create_func_ceiling::create(THD *thd, Item *arg1)
1711
return new (thd->mem_root) Item_func_ceiling(arg1);
1715
Create_func_char_length Create_func_char_length::s_singleton;
1718
Create_func_char_length::create(THD *thd, Item *arg1)
1720
return new (thd->mem_root) Item_func_char_length(arg1);
1724
Create_func_coercibility Create_func_coercibility::s_singleton;
1727
Create_func_coercibility::create(THD *thd, Item *arg1)
1729
return new (thd->mem_root) Item_func_coercibility(arg1);
1228
1733
Create_func_concat Create_func_concat::s_singleton;
1231
Create_func_concat::create_native(Session *session, LEX_STRING name,
1736
Create_func_concat::create_native(THD *thd, LEX_STRING name,
1232
1737
List<Item> *item_list)
1234
1739
int arg_count= 0;
1260
1765
/* "WS" stands for "With Separator": this function takes 2+ arguments */
1261
1766
if (arg_count < 2)
1263
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1768
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1267
return new (session->mem_root) Item_func_concat_ws(*session, *item_list);
1772
return new (thd->mem_root) Item_func_concat_ws(*item_list);
1776
Create_func_connection_id Create_func_connection_id::s_singleton;
1779
Create_func_connection_id::create(THD *thd)
1781
return new (thd->mem_root) Item_func_connection_id();
1271
1785
Create_func_conv Create_func_conv::s_singleton;
1274
Create_func_conv::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
1276
return new (session->mem_root) Item_func_conv(arg1, arg2, arg3);
1788
Create_func_conv::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
1790
return new (thd->mem_root) Item_func_conv(arg1, arg2, arg3);
1794
Create_func_cos Create_func_cos::s_singleton;
1797
Create_func_cos::create(THD *thd, Item *arg1)
1799
return new (thd->mem_root) Item_func_cos(arg1);
1279
1803
Create_func_cot Create_func_cot::s_singleton;
1282
Create_func_cot::create(Session *session, Item *arg1)
1806
Create_func_cot::create(THD *thd, Item *arg1)
1284
Item *i1= new (session->mem_root) Item_int((char*) "1", 1, 1);
1285
Item *i2= new (session->mem_root) Item_func_tan(arg1);
1286
return new (session->mem_root) Item_func_div(session, i1, i2);
1808
Item *i1= new (thd->mem_root) Item_int((char*) "1", 1, 1);
1809
Item *i2= new (thd->mem_root) Item_func_tan(arg1);
1810
return new (thd->mem_root) Item_func_div(i1, i2);
1289
1813
Create_func_date_format Create_func_date_format::s_singleton;
1292
Create_func_date_format::create(Session *session, Item *arg1, Item *arg2)
1816
Create_func_date_format::create(THD *thd, Item *arg1, Item *arg2)
1294
return new (session->mem_root) Item_func_date_format(arg1, arg2, 0);
1818
return new (thd->mem_root) Item_func_date_format(arg1, arg2, 0);
1298
1822
Create_func_datediff Create_func_datediff::s_singleton;
1301
Create_func_datediff::create(Session *session, Item *arg1, Item *arg2)
1825
Create_func_datediff::create(THD *thd, Item *arg1, Item *arg2)
1303
Item *i1= new (session->mem_root) Item_func_to_days(arg1);
1304
Item *i2= new (session->mem_root) Item_func_to_days(arg2);
1827
Item *i1= new (thd->mem_root) Item_func_to_days(arg1);
1828
Item *i2= new (thd->mem_root) Item_func_to_days(arg2);
1306
return new (session->mem_root) Item_func_minus(i1, i2);
1830
return new (thd->mem_root) Item_func_minus(i1, i2);
1310
1834
Create_func_dayname Create_func_dayname::s_singleton;
1313
Create_func_dayname::create(Session *session, Item *arg1)
1837
Create_func_dayname::create(THD *thd, Item *arg1)
1315
return new (session->mem_root) Item_func_dayname(arg1);
1839
return new (thd->mem_root) Item_func_dayname(arg1);
1319
1843
Create_func_dayofmonth Create_func_dayofmonth::s_singleton;
1322
Create_func_dayofmonth::create(Session *session, Item *arg1)
1846
Create_func_dayofmonth::create(THD *thd, Item *arg1)
1324
return new (session->mem_root) Item_func_dayofmonth(arg1);
1848
return new (thd->mem_root) Item_func_dayofmonth(arg1);
1328
1852
Create_func_dayofweek Create_func_dayofweek::s_singleton;
1331
Create_func_dayofweek::create(Session *session, Item *arg1)
1855
Create_func_dayofweek::create(THD *thd, Item *arg1)
1333
return new (session->mem_root) Item_func_weekday(arg1, 1);
1857
return new (thd->mem_root) Item_func_weekday(arg1, 1);
1337
1861
Create_func_dayofyear Create_func_dayofyear::s_singleton;
1340
Create_func_dayofyear::create(Session *session, Item *arg1)
1864
Create_func_dayofyear::create(THD *thd, Item *arg1)
1342
return new (session->mem_root) Item_func_dayofyear(arg1);
1866
return new (thd->mem_root) Item_func_dayofyear(arg1);
1346
1870
Create_func_degrees Create_func_degrees::s_singleton;
1349
Create_func_degrees::create(Session *session, Item *arg1)
1873
Create_func_degrees::create(THD *thd, Item *arg1)
1351
return new (session->mem_root) Item_func_units((char*) "degrees", arg1,
1875
return new (thd->mem_root) Item_func_units((char*) "degrees", arg1,
1352
1876
180/M_PI, 0.0);
1880
Create_func_elt Create_func_elt::s_singleton;
1883
Create_func_elt::create_native(THD *thd, LEX_STRING name,
1884
List<Item> *item_list)
1888
if (item_list != NULL)
1889
arg_count= item_list->elements;
1893
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1897
return new (thd->mem_root) Item_func_elt(*item_list);
1901
Create_func_exp Create_func_exp::s_singleton;
1904
Create_func_exp::create(THD *thd, Item *arg1)
1906
return new (thd->mem_root) Item_func_exp(arg1);
1355
1910
Create_func_export_set Create_func_export_set::s_singleton;
1358
Create_func_export_set::create_native(Session *session, LEX_STRING name,
1913
Create_func_export_set::create_native(THD *thd, LEX_STRING name,
1359
1914
List<Item> *item_list)
1361
1916
Item *func= NULL;
1419
1974
if (arg_count < 2)
1421
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
1976
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1425
return new (session->mem_root) Item_func_field(*item_list);
1980
return new (thd->mem_root) Item_func_field(*item_list);
1429
1984
Create_func_find_in_set Create_func_find_in_set::s_singleton;
1432
Create_func_find_in_set::create(Session *session, Item *arg1, Item *arg2)
1434
return new (session->mem_root) Item_func_find_in_set(arg1, arg2);
1987
Create_func_find_in_set::create(THD *thd, Item *arg1, Item *arg2)
1989
return new (thd->mem_root) Item_func_find_in_set(arg1, arg2);
1993
Create_func_floor Create_func_floor::s_singleton;
1996
Create_func_floor::create(THD *thd, Item *arg1)
1998
return new (thd->mem_root) Item_func_floor(arg1);
2002
Create_func_format Create_func_format::s_singleton;
2005
Create_func_format::create(THD *thd, Item *arg1, Item *arg2)
2007
return new (thd->mem_root) Item_func_format(arg1, arg2);
1437
2011
Create_func_found_rows Create_func_found_rows::s_singleton;
1440
Create_func_found_rows::create(Session *session)
2014
Create_func_found_rows::create(THD *thd)
1442
return new (session->mem_root) Item_func_found_rows();
2016
thd->lex->set_stmt_unsafe();
2017
return new (thd->mem_root) Item_func_found_rows();
1446
2021
Create_func_from_days Create_func_from_days::s_singleton;
1449
Create_func_from_days::create(Session *session, Item *arg1)
2024
Create_func_from_days::create(THD *thd, Item *arg1)
1451
return new (session->mem_root) Item_func_from_days(arg1);
2026
return new (thd->mem_root) Item_func_from_days(arg1);
1455
2030
Create_func_from_unixtime Create_func_from_unixtime::s_singleton;
1458
Create_func_from_unixtime::create_native(Session *session, LEX_STRING name,
2033
Create_func_from_unixtime::create_native(THD *thd, LEX_STRING name,
1459
2034
List<Item> *item_list)
1461
2036
Item *func= NULL;
1504
2079
if (arg_count < 2)
1506
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
2081
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1510
return new (session->mem_root) Item_func_max(*item_list);
2085
return new (thd->mem_root) Item_func_max(*item_list);
2089
Create_func_hex Create_func_hex::s_singleton;
2092
Create_func_hex::create(THD *thd, Item *arg1)
2094
return new (thd->mem_root) Item_func_hex(arg1);
1513
2098
Create_func_ifnull Create_func_ifnull::s_singleton;
1516
Create_func_ifnull::create(Session *session, Item *arg1, Item *arg2)
2101
Create_func_ifnull::create(THD *thd, Item *arg1, Item *arg2)
1518
return new (session->mem_root) Item_func_ifnull(arg1, arg2);
2103
return new (thd->mem_root) Item_func_ifnull(arg1, arg2);
1522
2107
Create_func_instr Create_func_instr::s_singleton;
1525
Create_func_instr::create(Session *session, Item *arg1, Item *arg2)
2110
Create_func_instr::create(THD *thd, Item *arg1, Item *arg2)
1527
return new (session->mem_root) Item_func_locate(arg1, arg2);
2112
return new (thd->mem_root) Item_func_locate(arg1, arg2);
1531
2116
Create_func_isnull Create_func_isnull::s_singleton;
1534
Create_func_isnull::create(Session *session, Item *arg1)
2119
Create_func_isnull::create(THD *thd, Item *arg1)
1536
return new (session->mem_root) Item_func_isnull(arg1);
2121
return new (thd->mem_root) Item_func_isnull(arg1);
1540
2125
Create_func_last_day Create_func_last_day::s_singleton;
1543
Create_func_last_day::create(Session *session, Item *arg1)
2128
Create_func_last_day::create(THD *thd, Item *arg1)
1545
return new (session->mem_root) Item_func_last_day(arg1);
2130
return new (thd->mem_root) Item_func_last_day(arg1);
1549
2134
Create_func_last_insert_id Create_func_last_insert_id::s_singleton;
1552
Create_func_last_insert_id::create_native(Session *session, LEX_STRING name,
2137
Create_func_last_insert_id::create_native(THD *thd, LEX_STRING name,
1553
2138
List<Item> *item_list)
1555
2140
Item *func= NULL;
1604
2189
if (arg_count < 2)
1606
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
2191
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1610
return new (session->mem_root) Item_func_min(*item_list);
2195
return new (thd->mem_root) Item_func_min(*item_list);
2199
Create_func_length Create_func_length::s_singleton;
2202
Create_func_length::create(THD *thd, Item *arg1)
2204
return new (thd->mem_root) Item_func_length(arg1);
2208
Create_func_ln Create_func_ln::s_singleton;
2211
Create_func_ln::create(THD *thd, Item *arg1)
2213
return new (thd->mem_root) Item_func_ln(arg1);
1613
2217
Create_func_load_file Create_func_load_file::s_singleton;
1616
Create_func_load_file::create(Session *session, Item *arg1)
2220
Create_func_load_file::create(THD *thd, Item *arg1)
1618
return new (session->mem_root) Item_load_file(*session, arg1);
2222
return new (thd->mem_root) Item_load_file(arg1);
1622
2226
Create_func_locate Create_func_locate::s_singleton;
1625
Create_func_locate::create_native(Session *session, LEX_STRING name,
2229
Create_func_locate::create_native(THD *thd, LEX_STRING name,
1626
2230
List<Item> *item_list)
1628
2232
Item *func= NULL;
1646
2250
Item *param_2= item_list->pop();
1647
2251
Item *param_3= item_list->pop();
1648
2252
/* Yes, parameters in that order : 2, 1, 3 */
1649
func= new (session->mem_root) Item_func_locate(param_2, param_1, param_3);
1654
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
2253
func= new (thd->mem_root) Item_func_locate(param_2, param_1, param_3);
2258
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2267
Create_func_log Create_func_log::s_singleton;
2270
Create_func_log::create_native(THD *thd, LEX_STRING name,
2271
List<Item> *item_list)
2276
if (item_list != NULL)
2277
arg_count= item_list->elements;
2279
switch (arg_count) {
2282
Item *param_1= item_list->pop();
2283
func= new (thd->mem_root) Item_func_log(param_1);
2288
Item *param_1= item_list->pop();
2289
Item *param_2= item_list->pop();
2290
func= new (thd->mem_root) Item_func_log(param_1, param_2);
2295
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2304
Create_func_log10 Create_func_log10::s_singleton;
2307
Create_func_log10::create(THD *thd, Item *arg1)
2309
return new (thd->mem_root) Item_func_log10(arg1);
2313
Create_func_log2 Create_func_log2::s_singleton;
2316
Create_func_log2::create(THD *thd, Item *arg1)
2318
return new (thd->mem_root) Item_func_log2(arg1);
1662
2322
Create_func_lpad Create_func_lpad::s_singleton;
1665
Create_func_lpad::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
2325
Create_func_lpad::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
1667
return new (session->mem_root) Item_func_lpad(*session, arg1, arg2, arg3);
2327
return new (thd->mem_root) Item_func_lpad(arg1, arg2, arg3);
1671
2331
Create_func_ltrim Create_func_ltrim::s_singleton;
1674
Create_func_ltrim::create(Session *session, Item *arg1)
2334
Create_func_ltrim::create(THD *thd, Item *arg1)
1676
return new (session->mem_root) Item_func_ltrim(arg1);
2336
return new (thd->mem_root) Item_func_ltrim(arg1);
1680
2340
Create_func_makedate Create_func_makedate::s_singleton;
1683
Create_func_makedate::create(Session *session, Item *arg1, Item *arg2)
1685
return new (session->mem_root) Item_func_makedate(arg1, arg2);
2343
Create_func_makedate::create(THD *thd, Item *arg1, Item *arg2)
2345
return new (thd->mem_root) Item_func_makedate(arg1, arg2);
2349
Create_func_maketime Create_func_maketime::s_singleton;
2352
Create_func_maketime::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
2354
return new (thd->mem_root) Item_func_maketime(arg1, arg2, arg3);
1689
2358
Create_func_make_set Create_func_make_set::s_singleton;
1692
Create_func_make_set::create_native(Session *session_arg, LEX_STRING name,
2361
Create_func_make_set::create_native(THD *thd, LEX_STRING name,
1693
2362
List<Item> *item_list)
1695
2364
int arg_count= 0;
1700
2369
if (arg_count < 2)
1702
my_error(ER_WRONG_PARAMCOUNT_TO_FUNCTION, MYF(0), name.str);
2371
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1706
2375
Item *param_1= item_list->pop();
1707
return new (session_arg->mem_root) Item_func_make_set(*session_arg, param_1, *item_list);
2376
return new (thd->mem_root) Item_func_make_set(param_1, *item_list);
2380
Create_func_master_pos_wait Create_func_master_pos_wait::s_singleton;
2383
Create_func_master_pos_wait::create_native(THD *thd, LEX_STRING name,
2384
List<Item> *item_list)
2390
if (item_list != NULL)
2391
arg_count= item_list->elements;
2393
switch (arg_count) {
2396
Item *param_1= item_list->pop();
2397
Item *param_2= item_list->pop();
2398
func= new (thd->mem_root) Item_master_pos_wait(param_1, param_2);
2403
Item *param_1= item_list->pop();
2404
Item *param_2= item_list->pop();
2405
Item *param_3= item_list->pop();
2406
func= new (thd->mem_root) Item_master_pos_wait(param_1, param_2, param_3);
2411
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1711
2420
Create_func_monthname Create_func_monthname::s_singleton;
1714
Create_func_monthname::create(Session *session, Item *arg1)
2423
Create_func_monthname::create(THD *thd, Item *arg1)
1716
return new (session->mem_root) Item_func_monthname(arg1);
2425
return new (thd->mem_root) Item_func_monthname(arg1);
1720
2429
Create_func_nullif Create_func_nullif::s_singleton;
1723
Create_func_nullif::create(Session *session, Item *arg1, Item *arg2)
2432
Create_func_nullif::create(THD *thd, Item *arg1, Item *arg2)
1725
return new (session->mem_root) Item_func_nullif(arg1, arg2);
2434
return new (thd->mem_root) Item_func_nullif(arg1, arg2);
1729
2438
Create_func_oct Create_func_oct::s_singleton;
1732
Create_func_oct::create(Session *session, Item *arg1)
1734
Item *i10= new (session->mem_root) Item_int((int32_t) 10,2);
1735
Item *i8= new (session->mem_root) Item_int((int32_t) 8,1);
1736
return new (session->mem_root) Item_func_conv(arg1, i10, i8);
2441
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);
2445
return new (thd->mem_root) Item_func_conv(arg1, i10, i8);
2449
Create_func_ord Create_func_ord::s_singleton;
2452
Create_func_ord::create(THD *thd, Item *arg1)
2454
return new (thd->mem_root) Item_func_ord(arg1);
1739
2458
Create_func_period_add Create_func_period_add::s_singleton;
1742
Create_func_period_add::create(Session *session, Item *arg1, Item *arg2)
2461
Create_func_period_add::create(THD *thd, Item *arg1, Item *arg2)
1744
return new (session->mem_root) Item_func_period_add(arg1, arg2);
2463
return new (thd->mem_root) Item_func_period_add(arg1, arg2);
1748
2467
Create_func_period_diff Create_func_period_diff::s_singleton;
1751
Create_func_period_diff::create(Session *session, Item *arg1, Item *arg2)
2470
Create_func_period_diff::create(THD *thd, Item *arg1, Item *arg2)
1753
return new (session->mem_root) Item_func_period_diff(arg1, arg2);
2472
return new (thd->mem_root) Item_func_period_diff(arg1, arg2);
1757
2476
Create_func_pi Create_func_pi::s_singleton;
1760
Create_func_pi::create(Session *session)
1762
return new (session->mem_root) Item_static_float_func("pi()", M_PI, 6, 8);
2479
Create_func_pi::create(THD *thd)
2481
return new (thd->mem_root) Item_static_float_func("pi()", M_PI, 6, 8);
2485
Create_func_pow Create_func_pow::s_singleton;
2488
Create_func_pow::create(THD *thd, Item *arg1, Item *arg2)
2490
return new (thd->mem_root) Item_func_pow(arg1, arg2);
2494
Create_func_quote Create_func_quote::s_singleton;
2497
Create_func_quote::create(THD *thd, Item *arg1)
2499
return new (thd->mem_root) Item_func_quote(arg1);
1765
2503
Create_func_radians Create_func_radians::s_singleton;
1768
Create_func_radians::create(Session *session, Item *arg1)
2506
Create_func_radians::create(THD *thd, Item *arg1)
1770
return new (session->mem_root) Item_func_units((char*) "radians", arg1,
2508
return new (thd->mem_root) Item_func_units((char*) "radians", arg1,
1771
2509
M_PI/180, 0.0);
2513
Create_func_rand Create_func_rand::s_singleton;
2516
Create_func_rand::create_native(THD *thd, LEX_STRING name,
2517
List<Item> *item_list)
2522
if (item_list != NULL)
2523
arg_count= item_list->elements;
2525
switch (arg_count) {
2528
func= new (thd->mem_root) Item_func_rand();
2533
Item *param_1= item_list->pop();
2534
func= new (thd->mem_root) Item_func_rand(param_1);
2539
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1774
2548
Create_func_round Create_func_round::s_singleton;
1777
Create_func_round::create_native(Session *session, LEX_STRING name,
2551
Create_func_round::create_native(THD *thd, LEX_STRING name,
1778
2552
List<Item> *item_list)
1780
2554
Item *func= NULL;
1812
2586
Create_func_row_count Create_func_row_count::s_singleton;
1815
Create_func_row_count::create(Session *session)
2589
Create_func_row_count::create(THD *thd)
1817
return new (session->mem_root) Item_func_row_count();
2591
thd->lex->set_stmt_unsafe();
2592
return new (thd->mem_root) Item_func_row_count();
1821
2596
Create_func_rpad Create_func_rpad::s_singleton;
1824
Create_func_rpad::create(Session *session, Item *arg1, Item *arg2, Item *arg3)
2599
Create_func_rpad::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
1826
return new (session->mem_root) Item_func_rpad(*session, arg1, arg2, arg3);
2601
return new (thd->mem_root) Item_func_rpad(arg1, arg2, arg3);
1830
2605
Create_func_rtrim Create_func_rtrim::s_singleton;
1833
Create_func_rtrim::create(Session *session, Item *arg1)
1835
return new (session->mem_root) Item_func_rtrim(arg1);
2608
Create_func_rtrim::create(THD *thd, Item *arg1)
2610
return new (thd->mem_root) Item_func_rtrim(arg1);
2614
Create_func_sec_to_time Create_func_sec_to_time::s_singleton;
2617
Create_func_sec_to_time::create(THD *thd, Item *arg1)
2619
return new (thd->mem_root) Item_func_sec_to_time(arg1);
1839
2623
Create_func_sign Create_func_sign::s_singleton;
1842
Create_func_sign::create(Session *session, Item *arg1)
1844
return new (session->mem_root) Item_func_sign(arg1);
2626
Create_func_sign::create(THD *thd, Item *arg1)
2628
return new (thd->mem_root) Item_func_sign(arg1);
2632
Create_func_sin Create_func_sin::s_singleton;
2635
Create_func_sin::create(THD *thd, Item *arg1)
2637
return new (thd->mem_root) Item_func_sin(arg1);
1847
2641
Create_func_space Create_func_space::s_singleton;
1850
Create_func_space::create(Session *session, Item *arg1)
2644
Create_func_space::create(THD *thd, Item *arg1)
1853
2647
TODO: Fix Bug#23637
1854
2648
The parsed item tree should not depend on
1855
<code>session->variables.collation_connection</code>.
2649
<code>thd->variables.collation_connection</code>.
1857
const CHARSET_INFO * const cs= session->variables.getCollation();
2651
const CHARSET_INFO * const cs= thd->variables.collation_connection;
1860
2654
if (cs->mbminlen > 1)
1862
size_t dummy_errors;
1863
sp= new (session->mem_root) Item_string("", 0, cs, DERIVATION_COERCIBLE);
2656
uint32_t dummy_errors;
2657
sp= new (thd->mem_root) Item_string("", 0, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
1864
2658
sp->str_value.copy(" ", 1, &my_charset_utf8_general_ci, cs, &dummy_errors);
1868
sp= new (session->mem_root) Item_string(" ", 1, cs, DERIVATION_COERCIBLE);
2662
sp= new (thd->mem_root) Item_string(" ", 1, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
1871
return new (session->mem_root) Item_func_repeat(*session, sp, arg1);
2665
return new (thd->mem_root) Item_func_repeat(sp, arg1);
2669
Create_func_sqrt Create_func_sqrt::s_singleton;
2672
Create_func_sqrt::create(THD *thd, Item *arg1)
2674
return new (thd->mem_root) Item_func_sqrt(arg1);
2678
Create_func_str_to_date Create_func_str_to_date::s_singleton;
2681
Create_func_str_to_date::create(THD *thd, Item *arg1, Item *arg2)
2683
return new (thd->mem_root) Item_func_str_to_date(arg1, arg2);
1874
2687
Create_func_strcmp Create_func_strcmp::s_singleton;
1877
Create_func_strcmp::create(Session *session, Item *arg1, Item *arg2)
1879
return new (session->mem_root) Item_func_strcmp(arg1, arg2);
2690
Create_func_strcmp::create(THD *thd, Item *arg1, Item *arg2)
2692
return new (thd->mem_root) Item_func_strcmp(arg1, arg2);
2696
Create_func_substr_index Create_func_substr_index::s_singleton;
2699
Create_func_substr_index::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
2701
return new (thd->mem_root) Item_func_substr_index(arg1, arg2, arg3);
2705
Create_func_subtime Create_func_subtime::s_singleton;
2708
Create_func_subtime::create(THD *thd, Item *arg1, Item *arg2)
2710
return new (thd->mem_root) Item_func_add_time(arg1, arg2, 0, 1);
1883
2714
Create_func_tan Create_func_tan::s_singleton;
1886
Create_func_tan::create(Session *session, Item *arg1)
2717
Create_func_tan::create(THD *thd, Item *arg1)
1888
return new (session->mem_root) Item_func_tan(arg1);
2719
return new (thd->mem_root) Item_func_tan(arg1);
1892
2723
Create_func_time_format Create_func_time_format::s_singleton;
1895
Create_func_time_format::create(Session *session, Item *arg1, Item *arg2)
1897
return new (session->mem_root) Item_func_date_format(arg1, arg2, 1);
2726
Create_func_time_format::create(THD *thd, Item *arg1, Item *arg2)
2728
return new (thd->mem_root) Item_func_date_format(arg1, arg2, 1);
2732
Create_func_time_to_sec Create_func_time_to_sec::s_singleton;
2735
Create_func_time_to_sec::create(THD *thd, Item *arg1)
2737
return new (thd->mem_root) Item_func_time_to_sec(arg1);
2741
Create_func_timediff Create_func_timediff::s_singleton;
2744
Create_func_timediff::create(THD *thd, Item *arg1, Item *arg2)
2746
return new (thd->mem_root) Item_func_timediff(arg1, arg2);
1900
2750
Create_func_to_days Create_func_to_days::s_singleton;
1903
Create_func_to_days::create(Session *session, Item *arg1)
2753
Create_func_to_days::create(THD *thd, Item *arg1)
1905
return new (session->mem_root) Item_func_to_days(arg1);
2755
return new (thd->mem_root) Item_func_to_days(arg1);
1909
2759
Create_func_ucase Create_func_ucase::s_singleton;
1912
Create_func_ucase::create(Session *session, Item *arg1)
1914
return new (session->mem_root) Item_func_ucase(arg1);
2762
Create_func_ucase::create(THD *thd, Item *arg1)
2764
return new (thd->mem_root) Item_func_ucase(arg1);
2768
Create_func_unhex Create_func_unhex::s_singleton;
2771
Create_func_unhex::create(THD *thd, Item *arg1)
2773
return new (thd->mem_root) Item_func_unhex(arg1);
1917
2777
Create_func_unix_timestamp Create_func_unix_timestamp::s_singleton;
1920
Create_func_unix_timestamp::create_native(Session *session, LEX_STRING name,
2780
Create_func_unix_timestamp::create_native(THD *thd, LEX_STRING name,
1921
2781
List<Item> *item_list)
1923
2783
Item *func= NULL;
2812
Create_func_uuid Create_func_uuid::s_singleton;
2815
Create_func_uuid::create(THD *thd)
2817
thd->lex->set_stmt_unsafe();
2818
return new (thd->mem_root) Item_func_uuid();
2822
Create_func_version Create_func_version::s_singleton;
2825
Create_func_version::create(THD *thd)
2827
return new (thd->mem_root) Item_static_string_func("version()",
2829
(uint) strlen(server_version),
2830
system_charset_info,
2831
DERIVATION_SYSCONST);
1952
2835
Create_func_weekday Create_func_weekday::s_singleton;
1955
Create_func_weekday::create(Session *session, Item *arg1)
1957
return new (session->mem_root) Item_func_weekday(arg1, 0);
2838
Create_func_weekday::create(THD *thd, Item *arg1)
2840
return new (thd->mem_root) Item_func_weekday(arg1, 0);
2844
Create_func_weekofyear Create_func_weekofyear::s_singleton;
2847
Create_func_weekofyear::create(THD *thd, Item *arg1)
2849
Item *i1= new (thd->mem_root) Item_int((char*) "0", 3, 1);
2850
return new (thd->mem_root) Item_func_week(arg1, i1);
2854
Create_func_year_week Create_func_year_week::s_singleton;
2857
Create_func_year_week::create_native(THD *thd, LEX_STRING name,
2858
List<Item> *item_list)
2863
if (item_list != NULL)
2864
arg_count= item_list->elements;
2866
switch (arg_count) {
2869
Item *param_1= item_list->pop();
2870
Item *i0= new (thd->mem_root) Item_int((char*) "0", 0, 1);
2871
func= new (thd->mem_root) Item_func_yearweek(param_1, i0);
2876
Item *param_1= item_list->pop();
2877
Item *param_2= item_list->pop();
2878
func= new (thd->mem_root) Item_func_yearweek(param_1, param_2);
2883
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1960
2892
struct Native_func_registry
1975
2907
static Native_func_registry func_array[] =
2909
{ { C_STRING_WITH_LEN("ABS") }, BUILDER(Create_func_abs)},
2910
{ { C_STRING_WITH_LEN("ACOS") }, BUILDER(Create_func_acos)},
2911
{ { C_STRING_WITH_LEN("ADDTIME") }, BUILDER(Create_func_addtime)},
2912
{ { C_STRING_WITH_LEN("ASIN") }, BUILDER(Create_func_asin)},
2913
{ { C_STRING_WITH_LEN("ATAN") }, BUILDER(Create_func_atan)},
2914
{ { C_STRING_WITH_LEN("ATAN2") }, BUILDER(Create_func_atan)},
2915
{ { C_STRING_WITH_LEN("BENCHMARK") }, BUILDER(Create_func_benchmark)},
1977
2916
{ { C_STRING_WITH_LEN("BIN") }, BUILDER(Create_func_bin)},
2917
{ { C_STRING_WITH_LEN("BIT_COUNT") }, BUILDER(Create_func_bit_count)},
2918
{ { C_STRING_WITH_LEN("BIT_LENGTH") }, BUILDER(Create_func_bit_length)},
2919
{ { C_STRING_WITH_LEN("CEIL") }, BUILDER(Create_func_ceiling)},
2920
{ { C_STRING_WITH_LEN("CEILING") }, BUILDER(Create_func_ceiling)},
2921
{ { C_STRING_WITH_LEN("CHARACTER_LENGTH") }, BUILDER(Create_func_char_length)},
2922
{ { C_STRING_WITH_LEN("CHAR_LENGTH") }, BUILDER(Create_func_char_length)},
2923
{ { C_STRING_WITH_LEN("COERCIBILITY") }, BUILDER(Create_func_coercibility)},
1978
2924
{ { C_STRING_WITH_LEN("CONCAT") }, BUILDER(Create_func_concat)},
1979
2925
{ { C_STRING_WITH_LEN("CONCAT_WS") }, BUILDER(Create_func_concat_ws)},
2926
{ { C_STRING_WITH_LEN("CONNECTION_ID") }, BUILDER(Create_func_connection_id)},
1980
2927
{ { C_STRING_WITH_LEN("CONV") }, BUILDER(Create_func_conv)},
2928
{ { C_STRING_WITH_LEN("COS") }, BUILDER(Create_func_cos)},
1981
2929
{ { C_STRING_WITH_LEN("COT") }, BUILDER(Create_func_cot)},
1982
2930
{ { C_STRING_WITH_LEN("DATEDIFF") }, BUILDER(Create_func_datediff)},
1983
2931
{ { C_STRING_WITH_LEN("DATE_FORMAT") }, BUILDER(Create_func_date_format)},
1986
2934
{ { C_STRING_WITH_LEN("DAYOFWEEK") }, BUILDER(Create_func_dayofweek)},
1987
2935
{ { C_STRING_WITH_LEN("DAYOFYEAR") }, BUILDER(Create_func_dayofyear)},
1988
2936
{ { C_STRING_WITH_LEN("DEGREES") }, BUILDER(Create_func_degrees)},
2937
{ { C_STRING_WITH_LEN("ELT") }, BUILDER(Create_func_elt)},
2938
{ { C_STRING_WITH_LEN("EXP") }, BUILDER(Create_func_exp)},
1989
2939
{ { C_STRING_WITH_LEN("EXPORT_SET") }, BUILDER(Create_func_export_set)},
1990
2940
{ { C_STRING_WITH_LEN("FIELD") }, BUILDER(Create_func_field)},
1991
2941
{ { C_STRING_WITH_LEN("FIND_IN_SET") }, BUILDER(Create_func_find_in_set)},
2942
{ { C_STRING_WITH_LEN("FLOOR") }, BUILDER(Create_func_floor)},
2943
{ { C_STRING_WITH_LEN("FORMAT") }, BUILDER(Create_func_format)},
1992
2944
{ { C_STRING_WITH_LEN("FOUND_ROWS") }, BUILDER(Create_func_found_rows)},
1993
2945
{ { C_STRING_WITH_LEN("FROM_DAYS") }, BUILDER(Create_func_from_days)},
1994
2946
{ { C_STRING_WITH_LEN("FROM_UNIXTIME") }, BUILDER(Create_func_from_unixtime)},
1995
2947
{ { C_STRING_WITH_LEN("GREATEST") }, BUILDER(Create_func_greatest)},
2948
{ { C_STRING_WITH_LEN("HEX") }, BUILDER(Create_func_hex)},
1996
2949
{ { C_STRING_WITH_LEN("IFNULL") }, BUILDER(Create_func_ifnull)},
1997
2950
{ { C_STRING_WITH_LEN("INSTR") }, BUILDER(Create_func_instr)},
1998
2951
{ { C_STRING_WITH_LEN("ISNULL") }, BUILDER(Create_func_isnull)},
2000
2953
{ { C_STRING_WITH_LEN("LAST_INSERT_ID") }, BUILDER(Create_func_last_insert_id)},
2001
2954
{ { C_STRING_WITH_LEN("LCASE") }, BUILDER(Create_func_lcase)},
2002
2955
{ { C_STRING_WITH_LEN("LEAST") }, BUILDER(Create_func_least)},
2956
{ { C_STRING_WITH_LEN("LENGTH") }, BUILDER(Create_func_length)},
2957
{ { C_STRING_WITH_LEN("LN") }, BUILDER(Create_func_ln)},
2003
2958
{ { C_STRING_WITH_LEN("LOAD_FILE") }, BUILDER(Create_func_load_file)},
2004
2959
{ { C_STRING_WITH_LEN("LOCATE") }, BUILDER(Create_func_locate)},
2960
{ { C_STRING_WITH_LEN("LOG") }, BUILDER(Create_func_log)},
2961
{ { C_STRING_WITH_LEN("LOG10") }, BUILDER(Create_func_log10)},
2962
{ { C_STRING_WITH_LEN("LOG2") }, BUILDER(Create_func_log2)},
2005
2963
{ { C_STRING_WITH_LEN("LOWER") }, BUILDER(Create_func_lcase)},
2006
2964
{ { C_STRING_WITH_LEN("LPAD") }, BUILDER(Create_func_lpad)},
2007
2965
{ { C_STRING_WITH_LEN("LTRIM") }, BUILDER(Create_func_ltrim)},
2008
2966
{ { C_STRING_WITH_LEN("MAKEDATE") }, BUILDER(Create_func_makedate)},
2967
{ { C_STRING_WITH_LEN("MAKETIME") }, BUILDER(Create_func_maketime)},
2009
2968
{ { C_STRING_WITH_LEN("MAKE_SET") }, BUILDER(Create_func_make_set)},
2969
{ { C_STRING_WITH_LEN("MASTER_POS_WAIT") }, BUILDER(Create_func_master_pos_wait)},
2010
2970
{ { C_STRING_WITH_LEN("MONTHNAME") }, BUILDER(Create_func_monthname)},
2011
2971
{ { C_STRING_WITH_LEN("NULLIF") }, BUILDER(Create_func_nullif)},
2012
2972
{ { C_STRING_WITH_LEN("OCT") }, BUILDER(Create_func_oct)},
2973
{ { C_STRING_WITH_LEN("OCTET_LENGTH") }, BUILDER(Create_func_length)},
2974
{ { C_STRING_WITH_LEN("ORD") }, BUILDER(Create_func_ord)},
2013
2975
{ { C_STRING_WITH_LEN("PERIOD_ADD") }, BUILDER(Create_func_period_add)},
2014
2976
{ { C_STRING_WITH_LEN("PERIOD_DIFF") }, BUILDER(Create_func_period_diff)},
2015
2977
{ { C_STRING_WITH_LEN("PI") }, BUILDER(Create_func_pi)},
2978
{ { C_STRING_WITH_LEN("POW") }, BUILDER(Create_func_pow)},
2979
{ { C_STRING_WITH_LEN("POWER") }, BUILDER(Create_func_pow)},
2980
{ { C_STRING_WITH_LEN("QUOTE") }, BUILDER(Create_func_quote)},
2016
2981
{ { C_STRING_WITH_LEN("RADIANS") }, BUILDER(Create_func_radians)},
2982
{ { C_STRING_WITH_LEN("RAND") }, BUILDER(Create_func_rand)},
2017
2983
{ { C_STRING_WITH_LEN("ROUND") }, BUILDER(Create_func_round)},
2018
2984
{ { C_STRING_WITH_LEN("ROW_COUNT") }, BUILDER(Create_func_row_count)},
2019
2985
{ { C_STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad)},
2020
2986
{ { C_STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim)},
2987
{ { C_STRING_WITH_LEN("SEC_TO_TIME") }, BUILDER(Create_func_sec_to_time)},
2021
2988
{ { C_STRING_WITH_LEN("SIGN") }, BUILDER(Create_func_sign)},
2989
{ { C_STRING_WITH_LEN("SIN") }, BUILDER(Create_func_sin)},
2022
2990
{ { C_STRING_WITH_LEN("SPACE") }, BUILDER(Create_func_space)},
2991
{ { C_STRING_WITH_LEN("SQRT") }, BUILDER(Create_func_sqrt)},
2023
2992
{ { C_STRING_WITH_LEN("STRCMP") }, BUILDER(Create_func_strcmp)},
2993
{ { C_STRING_WITH_LEN("STR_TO_DATE") }, BUILDER(Create_func_str_to_date)},
2994
{ { C_STRING_WITH_LEN("SUBSTRING_INDEX") }, BUILDER(Create_func_substr_index)},
2995
{ { C_STRING_WITH_LEN("SUBTIME") }, BUILDER(Create_func_subtime)},
2024
2996
{ { C_STRING_WITH_LEN("TAN") }, BUILDER(Create_func_tan)},
2997
{ { C_STRING_WITH_LEN("TIMEDIFF") }, BUILDER(Create_func_timediff)},
2025
2998
{ { C_STRING_WITH_LEN("TIME_FORMAT") }, BUILDER(Create_func_time_format)},
2999
{ { C_STRING_WITH_LEN("TIME_TO_SEC") }, BUILDER(Create_func_time_to_sec)},
2026
3000
{ { C_STRING_WITH_LEN("TO_DAYS") }, BUILDER(Create_func_to_days)},
2027
3001
{ { C_STRING_WITH_LEN("UCASE") }, BUILDER(Create_func_ucase)},
3002
{ { C_STRING_WITH_LEN("UNHEX") }, BUILDER(Create_func_unhex)},
2028
3003
{ { C_STRING_WITH_LEN("UNIX_TIMESTAMP") }, BUILDER(Create_func_unix_timestamp)},
2029
3004
{ { C_STRING_WITH_LEN("UPPER") }, BUILDER(Create_func_ucase)},
3005
{ { C_STRING_WITH_LEN("UUID") }, BUILDER(Create_func_uuid)},
3006
{ { C_STRING_WITH_LEN("VERSION") }, BUILDER(Create_func_version)},
2030
3007
{ { C_STRING_WITH_LEN("WEEKDAY") }, BUILDER(Create_func_weekday)},
3008
{ { C_STRING_WITH_LEN("WEEKOFYEAR") }, BUILDER(Create_func_weekofyear)},
3009
{ { C_STRING_WITH_LEN("YEARWEEK") }, BUILDER(Create_func_year_week)},
2032
3011
{ {0, 0}, NULL}
3014
static HASH native_functions_hash;
3016
extern "C" unsigned char*
3017
get_native_fct_hash_key(const unsigned char *buff, size_t *length,
3020
Native_func_registry *func= (Native_func_registry*) buff;
3021
*length= func->name.length;
3022
return (unsigned char*) func->name.str;
2036
3026
Load the hash table for native functions.
2037
3027
Note: this code is not thread safe, and is intended to be used at server
2041
3031
int item_create_init()
2045
3033
Native_func_registry *func;
3035
if (hash_init(& native_functions_hash,
3036
system_charset_info,
3037
array_elements(func_array),
3040
(hash_get_key) get_native_fct_hash_key,
3041
NULL, /* Nothing to free */
2046
3045
for (func= func_array; func->builder != NULL; func++)
2048
func_name.assign(func->name.str, func->name.length);
2050
FunctionContainer::getMap()[func_name]= func->builder;
3047
if (my_hash_insert(& native_functions_hash, (unsigned char*) func))
3055
Empty the hash table for native functions.
3056
Note: this code is not thread safe, and is intended to be used at server
3057
shutdown only (after thread requests have been executed).
3060
void item_create_cleanup()
3062
hash_free(& native_functions_hash);
2058
find_native_function_builder(LEX_STRING name)
3067
find_native_function_builder(THD *thd __attribute__((unused)),
3070
Native_func_registry *func;
2060
3071
Create_func *builder= NULL;
2062
string func_name(name.str, name.length);
2064
FunctionContainer::Map::iterator func_iter=
2065
FunctionContainer::getMap().find(func_name);
2067
if (func_iter != FunctionContainer::getMap().end())
3074
func= (Native_func_registry*) hash_search(& native_functions_hash,
3075
(unsigned char*) name.str,
2069
builder= (*func_iter).second;
3080
builder= func->builder;
2072
3083
return builder;
2077
create_func_char_cast(Session *session, Item *a, int len, const CHARSET_INFO * const cs)
3088
create_func_char_cast(THD *thd, Item *a, int len, const CHARSET_INFO * const cs)
2079
const CHARSET_INFO * const real_cs= (cs ? cs : session->variables.getCollation());
2080
return new (session->mem_root) Item_char_typecast(a, len, real_cs);
3090
const CHARSET_INFO * const real_cs= (cs ? cs : thd->variables.collation_connection);
3091
return new (thd->mem_root) Item_char_typecast(a, len, real_cs);
2085
create_func_cast(Session *session, Item *a, Cast_target cast_type,
3096
create_func_cast(THD *thd, Item *a, Cast_target cast_type,
2086
3097
const char *c_len, const char *c_dec,
2087
3098
const CHARSET_INFO * const cs)
2093
3104
switch (cast_type) {
2094
case ITEM_CAST_SIGNED:
2095
res= new (session->mem_root) function::cast::Signed(a);
2098
case ITEM_CAST_UNSIGNED:
2099
res= new (session->mem_root) function::cast::Unsigned(a);
2102
3105
case ITEM_CAST_BINARY:
2103
res= new (session->mem_root) Item_func_binary(a);
2106
case ITEM_CAST_BOOLEAN:
2107
res= new (session->mem_root) function::cast::Boolean(a);
3106
res= new (thd->mem_root) Item_func_binary(a);
3108
case ITEM_CAST_SIGNED_INT:
3109
res= new (thd->mem_root) Item_func_signed(a);
3111
case ITEM_CAST_UNSIGNED_INT:
3112
res= new (thd->mem_root) Item_func_unsigned(a);
3114
case ITEM_CAST_DATE:
3115
res= new (thd->mem_root) Item_date_typecast(a);
2110
3117
case ITEM_CAST_TIME:
2111
res= new (session->mem_root) function::cast::Time(a);
2114
case ITEM_CAST_DATE:
2115
res= new (session->mem_root) Item_date_typecast(a);
3118
res= new (thd->mem_root) Item_time_typecast(a);
2118
3120
case ITEM_CAST_DATETIME:
2119
res= new (session->mem_root) Item_datetime_typecast(a);
3121
res= new (thd->mem_root) Item_datetime_typecast(a);
2122
3123
case ITEM_CAST_DECIMAL:
2124
len= c_len ? atoi(c_len) : 0;
2125
dec= c_dec ? atoi(c_dec) : 0;
2126
class_decimal_trim(&len, &dec);
2129
my_error(ER_M_BIGGER_THAN_D, MYF(0), "");
2132
if (len > DECIMAL_MAX_PRECISION)
2134
my_error(ER_TOO_BIG_PRECISION, MYF(0), len, a->name,
2135
DECIMAL_MAX_PRECISION);
2138
if (dec > DECIMAL_MAX_SCALE)
2140
my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->name,
2144
res= new (session->mem_root) Item_decimal_typecast(a, len, dec);
3125
len= c_len ? atoi(c_len) : 0;
3126
dec= c_dec ? atoi(c_dec) : 0;
3127
my_decimal_trim(&len, &dec);
3130
my_error(ER_M_BIGGER_THAN_D, MYF(0), "");
3133
if (len > DECIMAL_MAX_PRECISION)
3135
my_error(ER_TOO_BIG_PRECISION, MYF(0), len, a->name,
3136
DECIMAL_MAX_PRECISION);
3139
if (dec > DECIMAL_MAX_SCALE)
3141
my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->name,
3145
res= new (thd->mem_root) Item_decimal_typecast(a, len, dec);
2147
3148
case ITEM_CAST_CHAR:
2149
len= c_len ? atoi(c_len) : -1;
2150
res= create_func_char_cast(session, a, len, cs);
3150
len= c_len ? atoi(c_len) : -1;
3151
res= create_func_char_cast(thd, a, len, cs);
2158
} /* namespace drizzled */