1
/* Copyright (C) 2000-2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
20
Functions to create an item. Used by sql_yac.yy
23
#include <drizzled/server_includes.h>
26
=============================================================================
28
=============================================================================
32
Adapter for native functions with a variable number of arguments.
33
The main use of this class is to discard the following calls:
34
<code>foo(expr1 AS name1, expr2 AS name2, ...)</code>
35
which are syntactically correct (the syntax can refer to a UDF),
36
but semantically invalid for native functions.
39
class Create_native_func : public Create_func
42
virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
45
Builder method, with no arguments.
46
@param thd The current thread
47
@param name The native function name
48
@param item_list The function parameters, none of which are named
49
@return An item representing the function call
51
virtual Item *create_native(THD *thd, LEX_STRING name,
52
List<Item> *item_list) = 0;
56
Create_native_func() {}
58
virtual ~Create_native_func() {}
63
Adapter for functions that takes exactly zero arguments.
66
class Create_func_arg0 : public Create_func
69
virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
72
Builder method, with no arguments.
73
@param thd The current thread
74
@return An item representing the function call
76
virtual Item *create(THD *thd) = 0;
82
virtual ~Create_func_arg0() {}
87
Adapter for functions that takes exactly one argument.
90
class Create_func_arg1 : public Create_func
93
virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
96
Builder method, with one argument.
97
@param thd The current thread
98
@param arg1 The first argument of the function
99
@return An item representing the function call
101
virtual Item *create(THD *thd, Item *arg1) = 0;
105
Create_func_arg1() {}
107
virtual ~Create_func_arg1() {}
112
Adapter for functions that takes exactly two arguments.
115
class Create_func_arg2 : public Create_func
118
virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
121
Builder method, with two arguments.
122
@param thd The current thread
123
@param arg1 The first argument of the function
124
@param arg2 The second argument of the function
125
@return An item representing the function call
127
virtual Item *create(THD *thd, Item *arg1, Item *arg2) = 0;
131
Create_func_arg2() {}
133
virtual ~Create_func_arg2() {}
138
Adapter for functions that takes exactly three arguments.
141
class Create_func_arg3 : public Create_func
144
virtual Item *create(THD *thd, LEX_STRING name, List<Item> *item_list);
147
Builder method, with three arguments.
148
@param thd The current thread
149
@param arg1 The first argument of the function
150
@param arg2 The second argument of the function
151
@param arg3 The third argument of the function
152
@return An item representing the function call
154
virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3) = 0;
158
Create_func_arg3() {}
160
virtual ~Create_func_arg3() {}
165
Function builder for Stored Functions.
169
Concrete functions builders (native functions).
170
Please keep this list sorted in alphabetical order,
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() {}
252
class Create_func_bin : public Create_func_arg1
255
virtual Item *create(THD *thd, Item *arg1);
257
static Create_func_bin s_singleton;
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() {}
330
class Create_func_concat : public Create_native_func
333
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
335
static Create_func_concat s_singleton;
338
Create_func_concat() {}
339
virtual ~Create_func_concat() {}
343
class Create_func_concat_ws : public Create_native_func
346
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
348
static Create_func_concat_ws s_singleton;
351
Create_func_concat_ws() {}
352
virtual ~Create_func_concat_ws() {}
356
class Create_func_connection_id : public Create_func_arg0
359
virtual Item *create(THD *thd);
361
static Create_func_connection_id s_singleton;
364
Create_func_connection_id() {}
365
virtual ~Create_func_connection_id() {}
369
class Create_func_conv : public Create_func_arg3
372
virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
374
static Create_func_conv s_singleton;
377
Create_func_conv() {}
378
virtual ~Create_func_conv() {}
382
class Create_func_cos : public Create_func_arg1
385
virtual Item *create(THD *thd, Item *arg1);
387
static Create_func_cos s_singleton;
391
virtual ~Create_func_cos() {}
395
class Create_func_cot : public Create_func_arg1
398
virtual Item *create(THD *thd, Item *arg1);
400
static Create_func_cot s_singleton;
404
virtual ~Create_func_cot() {}
407
class Create_func_date_format : public Create_func_arg2
410
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
412
static Create_func_date_format s_singleton;
415
Create_func_date_format() {}
416
virtual ~Create_func_date_format() {}
420
class Create_func_datediff : public Create_func_arg2
423
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
425
static Create_func_datediff s_singleton;
428
Create_func_datediff() {}
429
virtual ~Create_func_datediff() {}
433
class Create_func_dayname : public Create_func_arg1
436
virtual Item *create(THD *thd, Item *arg1);
438
static Create_func_dayname s_singleton;
441
Create_func_dayname() {}
442
virtual ~Create_func_dayname() {}
446
class Create_func_dayofmonth : public Create_func_arg1
449
virtual Item *create(THD *thd, Item *arg1);
451
static Create_func_dayofmonth s_singleton;
454
Create_func_dayofmonth() {}
455
virtual ~Create_func_dayofmonth() {}
459
class Create_func_dayofweek : public Create_func_arg1
462
virtual Item *create(THD *thd, Item *arg1);
464
static Create_func_dayofweek s_singleton;
467
Create_func_dayofweek() {}
468
virtual ~Create_func_dayofweek() {}
472
class Create_func_dayofyear : public Create_func_arg1
475
virtual Item *create(THD *thd, Item *arg1);
477
static Create_func_dayofyear s_singleton;
480
Create_func_dayofyear() {}
481
virtual ~Create_func_dayofyear() {}
485
class Create_func_decode : public Create_func_arg2
488
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
490
static Create_func_decode s_singleton;
493
Create_func_decode() {}
494
virtual ~Create_func_decode() {}
498
class Create_func_degrees : public Create_func_arg1
501
virtual Item *create(THD *thd, Item *arg1);
503
static Create_func_degrees s_singleton;
506
Create_func_degrees() {}
507
virtual ~Create_func_degrees() {}
511
class Create_func_elt : public Create_native_func
514
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
516
static Create_func_elt s_singleton;
520
virtual ~Create_func_elt() {}
524
class Create_func_exp : public Create_func_arg1
527
virtual Item *create(THD *thd, Item *arg1);
529
static Create_func_exp s_singleton;
533
virtual ~Create_func_exp() {}
537
class Create_func_export_set : public Create_native_func
540
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
542
static Create_func_export_set s_singleton;
545
Create_func_export_set() {}
546
virtual ~Create_func_export_set() {}
550
class Create_func_field : public Create_native_func
553
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
555
static Create_func_field s_singleton;
558
Create_func_field() {}
559
virtual ~Create_func_field() {}
563
class Create_func_find_in_set : public Create_func_arg2
566
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
568
static Create_func_find_in_set s_singleton;
571
Create_func_find_in_set() {}
572
virtual ~Create_func_find_in_set() {}
576
class Create_func_floor : public Create_func_arg1
579
virtual Item *create(THD *thd, Item *arg1);
581
static Create_func_floor s_singleton;
584
Create_func_floor() {}
585
virtual ~Create_func_floor() {}
589
class Create_func_format : public Create_func_arg2
592
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
594
static Create_func_format s_singleton;
597
Create_func_format() {}
598
virtual ~Create_func_format() {}
602
class Create_func_found_rows : public Create_func_arg0
605
virtual Item *create(THD *thd);
607
static Create_func_found_rows s_singleton;
610
Create_func_found_rows() {}
611
virtual ~Create_func_found_rows() {}
615
class Create_func_from_days : public Create_func_arg1
618
virtual Item *create(THD *thd, Item *arg1);
620
static Create_func_from_days s_singleton;
623
Create_func_from_days() {}
624
virtual ~Create_func_from_days() {}
628
class Create_func_from_unixtime : public Create_native_func
631
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
633
static Create_func_from_unixtime s_singleton;
636
Create_func_from_unixtime() {}
637
virtual ~Create_func_from_unixtime() {}
641
class Create_func_greatest : public Create_native_func
644
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
646
static Create_func_greatest s_singleton;
649
Create_func_greatest() {}
650
virtual ~Create_func_greatest() {}
654
class Create_func_hex : public Create_func_arg1
657
virtual Item *create(THD *thd, Item *arg1);
659
static Create_func_hex s_singleton;
663
virtual ~Create_func_hex() {}
667
class Create_func_ifnull : public Create_func_arg2
670
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
672
static Create_func_ifnull s_singleton;
675
Create_func_ifnull() {}
676
virtual ~Create_func_ifnull() {}
680
class Create_func_instr : public Create_func_arg2
683
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
685
static Create_func_instr s_singleton;
688
Create_func_instr() {}
689
virtual ~Create_func_instr() {}
693
class Create_func_isnull : public Create_func_arg1
696
virtual Item *create(THD *thd, Item *arg1);
698
static Create_func_isnull s_singleton;
701
Create_func_isnull() {}
702
virtual ~Create_func_isnull() {}
706
class Create_func_last_day : public Create_func_arg1
709
virtual Item *create(THD *thd, Item *arg1);
711
static Create_func_last_day s_singleton;
714
Create_func_last_day() {}
715
virtual ~Create_func_last_day() {}
719
class Create_func_last_insert_id : public Create_native_func
722
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
724
static Create_func_last_insert_id s_singleton;
727
Create_func_last_insert_id() {}
728
virtual ~Create_func_last_insert_id() {}
732
class Create_func_lcase : public Create_func_arg1
735
virtual Item *create(THD *thd, Item *arg1);
737
static Create_func_lcase s_singleton;
740
Create_func_lcase() {}
741
virtual ~Create_func_lcase() {}
745
class Create_func_least : public Create_native_func
748
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
750
static Create_func_least s_singleton;
753
Create_func_least() {}
754
virtual ~Create_func_least() {}
758
class Create_func_length : public Create_func_arg1
761
virtual Item *create(THD *thd, Item *arg1);
763
static Create_func_length s_singleton;
766
Create_func_length() {}
767
virtual ~Create_func_length() {}
771
class Create_func_ln : public Create_func_arg1
774
virtual Item *create(THD *thd, Item *arg1);
776
static Create_func_ln s_singleton;
780
virtual ~Create_func_ln() {}
784
class Create_func_load_file : public Create_func_arg1
787
virtual Item *create(THD *thd, Item *arg1);
789
static Create_func_load_file s_singleton;
792
Create_func_load_file() {}
793
virtual ~Create_func_load_file() {}
797
class Create_func_locate : public Create_native_func
800
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
802
static Create_func_locate s_singleton;
805
Create_func_locate() {}
806
virtual ~Create_func_locate() {}
810
class Create_func_log : public Create_native_func
813
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
815
static Create_func_log s_singleton;
819
virtual ~Create_func_log() {}
823
class Create_func_log10 : public Create_func_arg1
826
virtual Item *create(THD *thd, Item *arg1);
828
static Create_func_log10 s_singleton;
831
Create_func_log10() {}
832
virtual ~Create_func_log10() {}
836
class Create_func_log2 : public Create_func_arg1
839
virtual Item *create(THD *thd, Item *arg1);
841
static Create_func_log2 s_singleton;
844
Create_func_log2() {}
845
virtual ~Create_func_log2() {}
849
class Create_func_lpad : public Create_func_arg3
852
virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
854
static Create_func_lpad s_singleton;
857
Create_func_lpad() {}
858
virtual ~Create_func_lpad() {}
862
class Create_func_ltrim : public Create_func_arg1
865
virtual Item *create(THD *thd, Item *arg1);
867
static Create_func_ltrim s_singleton;
870
Create_func_ltrim() {}
871
virtual ~Create_func_ltrim() {}
875
class Create_func_makedate : public Create_func_arg2
878
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
880
static Create_func_makedate s_singleton;
883
Create_func_makedate() {}
884
virtual ~Create_func_makedate() {}
888
class Create_func_maketime : public Create_func_arg3
891
virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
893
static Create_func_maketime s_singleton;
896
Create_func_maketime() {}
897
virtual ~Create_func_maketime() {}
901
class Create_func_make_set : public Create_native_func
904
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
906
static Create_func_make_set s_singleton;
909
Create_func_make_set() {}
910
virtual ~Create_func_make_set() {}
914
class Create_func_master_pos_wait : public Create_native_func
917
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
919
static Create_func_master_pos_wait s_singleton;
922
Create_func_master_pos_wait() {}
923
virtual ~Create_func_master_pos_wait() {}
926
class Create_func_monthname : public Create_func_arg1
929
virtual Item *create(THD *thd, Item *arg1);
931
static Create_func_monthname s_singleton;
934
Create_func_monthname() {}
935
virtual ~Create_func_monthname() {}
939
class Create_func_name_const : public Create_func_arg2
942
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
944
static Create_func_name_const s_singleton;
947
Create_func_name_const() {}
948
virtual ~Create_func_name_const() {}
952
class Create_func_nullif : public Create_func_arg2
955
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
957
static Create_func_nullif s_singleton;
960
Create_func_nullif() {}
961
virtual ~Create_func_nullif() {}
965
class Create_func_oct : public Create_func_arg1
968
virtual Item *create(THD *thd, Item *arg1);
970
static Create_func_oct s_singleton;
974
virtual ~Create_func_oct() {}
978
class Create_func_ord : public Create_func_arg1
981
virtual Item *create(THD *thd, Item *arg1);
983
static Create_func_ord s_singleton;
987
virtual ~Create_func_ord() {}
991
class Create_func_period_add : public Create_func_arg2
994
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
996
static Create_func_period_add s_singleton;
999
Create_func_period_add() {}
1000
virtual ~Create_func_period_add() {}
1004
class Create_func_period_diff : public Create_func_arg2
1007
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1009
static Create_func_period_diff s_singleton;
1012
Create_func_period_diff() {}
1013
virtual ~Create_func_period_diff() {}
1017
class Create_func_pi : public Create_func_arg0
1020
virtual Item *create(THD *thd);
1022
static Create_func_pi s_singleton;
1026
virtual ~Create_func_pi() {}
1030
class Create_func_pow : public Create_func_arg2
1033
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1035
static Create_func_pow s_singleton;
1038
Create_func_pow() {}
1039
virtual ~Create_func_pow() {}
1043
class Create_func_quote : public Create_func_arg1
1046
virtual Item *create(THD *thd, Item *arg1);
1048
static Create_func_quote s_singleton;
1051
Create_func_quote() {}
1052
virtual ~Create_func_quote() {}
1056
class Create_func_radians : public Create_func_arg1
1059
virtual Item *create(THD *thd, Item *arg1);
1061
static Create_func_radians s_singleton;
1064
Create_func_radians() {}
1065
virtual ~Create_func_radians() {}
1069
class Create_func_rand : public Create_native_func
1072
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1074
static Create_func_rand s_singleton;
1077
Create_func_rand() {}
1078
virtual ~Create_func_rand() {}
1082
class Create_func_round : public Create_native_func
1085
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1087
static Create_func_round s_singleton;
1090
Create_func_round() {}
1091
virtual ~Create_func_round() {}
1095
class Create_func_row_count : public Create_func_arg0
1098
virtual Item *create(THD *thd);
1100
static Create_func_row_count s_singleton;
1103
Create_func_row_count() {}
1104
virtual ~Create_func_row_count() {}
1108
class Create_func_rpad : public Create_func_arg3
1111
virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
1113
static Create_func_rpad s_singleton;
1116
Create_func_rpad() {}
1117
virtual ~Create_func_rpad() {}
1121
class Create_func_rtrim : public Create_func_arg1
1124
virtual Item *create(THD *thd, Item *arg1);
1126
static Create_func_rtrim s_singleton;
1129
Create_func_rtrim() {}
1130
virtual ~Create_func_rtrim() {}
1134
class Create_func_sec_to_time : public Create_func_arg1
1137
virtual Item *create(THD *thd, Item *arg1);
1139
static Create_func_sec_to_time s_singleton;
1142
Create_func_sec_to_time() {}
1143
virtual ~Create_func_sec_to_time() {}
1147
class Create_func_sign : public Create_func_arg1
1150
virtual Item *create(THD *thd, Item *arg1);
1152
static Create_func_sign s_singleton;
1155
Create_func_sign() {}
1156
virtual ~Create_func_sign() {}
1160
class Create_func_sin : public Create_func_arg1
1163
virtual Item *create(THD *thd, Item *arg1);
1165
static Create_func_sin s_singleton;
1168
Create_func_sin() {}
1169
virtual ~Create_func_sin() {}
1173
class Create_func_space : public Create_func_arg1
1176
virtual Item *create(THD *thd, Item *arg1);
1178
static Create_func_space s_singleton;
1181
Create_func_space() {}
1182
virtual ~Create_func_space() {}
1186
class Create_func_sqrt : public Create_func_arg1
1189
virtual Item *create(THD *thd, Item *arg1);
1191
static Create_func_sqrt s_singleton;
1194
Create_func_sqrt() {}
1195
virtual ~Create_func_sqrt() {}
1199
class Create_func_str_to_date : public Create_func_arg2
1202
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1204
static Create_func_str_to_date s_singleton;
1207
Create_func_str_to_date() {}
1208
virtual ~Create_func_str_to_date() {}
1212
class Create_func_strcmp : public Create_func_arg2
1215
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1217
static Create_func_strcmp s_singleton;
1220
Create_func_strcmp() {}
1221
virtual ~Create_func_strcmp() {}
1225
class Create_func_substr_index : public Create_func_arg3
1228
virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
1230
static Create_func_substr_index s_singleton;
1233
Create_func_substr_index() {}
1234
virtual ~Create_func_substr_index() {}
1238
class Create_func_subtime : public Create_func_arg2
1241
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1243
static Create_func_subtime s_singleton;
1246
Create_func_subtime() {}
1247
virtual ~Create_func_subtime() {}
1251
class Create_func_tan : public Create_func_arg1
1254
virtual Item *create(THD *thd, Item *arg1);
1256
static Create_func_tan s_singleton;
1259
Create_func_tan() {}
1260
virtual ~Create_func_tan() {}
1264
class Create_func_time_format : public Create_func_arg2
1267
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1269
static Create_func_time_format s_singleton;
1272
Create_func_time_format() {}
1273
virtual ~Create_func_time_format() {}
1277
class Create_func_time_to_sec : public Create_func_arg1
1280
virtual Item *create(THD *thd, Item *arg1);
1282
static Create_func_time_to_sec s_singleton;
1285
Create_func_time_to_sec() {}
1286
virtual ~Create_func_time_to_sec() {}
1290
class Create_func_timediff : public Create_func_arg2
1293
virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1295
static Create_func_timediff s_singleton;
1298
Create_func_timediff() {}
1299
virtual ~Create_func_timediff() {}
1303
class Create_func_to_days : public Create_func_arg1
1306
virtual Item *create(THD *thd, Item *arg1);
1308
static Create_func_to_days s_singleton;
1311
Create_func_to_days() {}
1312
virtual ~Create_func_to_days() {}
1316
class Create_func_ucase : public Create_func_arg1
1319
virtual Item *create(THD *thd, Item *arg1);
1321
static Create_func_ucase s_singleton;
1324
Create_func_ucase() {}
1325
virtual ~Create_func_ucase() {}
1329
class Create_func_unhex : public Create_func_arg1
1332
virtual Item *create(THD *thd, Item *arg1);
1334
static Create_func_unhex s_singleton;
1337
Create_func_unhex() {}
1338
virtual ~Create_func_unhex() {}
1342
class Create_func_unix_timestamp : public Create_native_func
1345
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1347
static Create_func_unix_timestamp s_singleton;
1350
Create_func_unix_timestamp() {}
1351
virtual ~Create_func_unix_timestamp() {}
1355
class Create_func_uuid : public Create_func_arg0
1358
virtual Item *create(THD *thd);
1360
static Create_func_uuid s_singleton;
1363
Create_func_uuid() {}
1364
virtual ~Create_func_uuid() {}
1368
class Create_func_version : public Create_func_arg0
1371
virtual Item *create(THD *thd);
1373
static Create_func_version s_singleton;
1376
Create_func_version() {}
1377
virtual ~Create_func_version() {}
1381
class Create_func_weekday : public Create_func_arg1
1384
virtual Item *create(THD *thd, Item *arg1);
1386
static Create_func_weekday s_singleton;
1389
Create_func_weekday() {}
1390
virtual ~Create_func_weekday() {}
1394
class Create_func_weekofyear : public Create_func_arg1
1397
virtual Item *create(THD *thd, Item *arg1);
1399
static Create_func_weekofyear s_singleton;
1402
Create_func_weekofyear() {}
1403
virtual ~Create_func_weekofyear() {}
1407
class Create_func_year_week : public Create_native_func
1410
virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1412
static Create_func_year_week s_singleton;
1415
Create_func_year_week() {}
1416
virtual ~Create_func_year_week() {}
1421
=============================================================================
1423
=============================================================================
1427
Checks if there are named parameters in a parameter list.
1428
The syntax to name parameters in a function call is as follow:
1429
<code>foo(expr AS named, expr named, expr AS "named", expr "named")</code>
1430
@param params The parameter list, can be null
1431
@return true if one or more parameter is named
1433
static bool has_named_parameters(List<Item> *params)
1438
List_iterator<Item> it(*params);
1439
while ((param= it++))
1441
if (! param->is_autogenerated_name)
1450
Create_udf_func Create_udf_func::s_singleton;
1453
Create_udf_func::create(THD *thd, LEX_STRING name, List<Item> *item_list)
1455
udf_func *udf= find_udf(name.str, name.length);
1457
return create(thd, udf, item_list);
1462
Create_udf_func::create(THD *thd, udf_func *udf, List<Item> *item_list)
1464
Item_func *func= NULL;
1467
if (item_list != NULL)
1468
arg_count= item_list->elements;
1470
thd->lex->set_stmt_unsafe();
1472
func= udf->create_func(thd->mem_root);
1474
func->set_arguments(*item_list);
1481
Create_native_func::create(THD *thd, LEX_STRING name, List<Item> *item_list)
1483
if (has_named_parameters(item_list))
1485
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
1489
return create_native(thd, name, item_list);
1494
Create_func_arg0::create(THD *thd, LEX_STRING name, List<Item> *item_list)
1498
if (item_list != NULL)
1499
arg_count= item_list->elements;
1503
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1512
Create_func_arg1::create(THD *thd, LEX_STRING name, List<Item> *item_list)
1517
arg_count= item_list->elements;
1521
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1525
Item *param_1= item_list->pop();
1527
if (! param_1->is_autogenerated_name)
1529
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
1533
return create(thd, param_1);
1538
Create_func_arg2::create(THD *thd, LEX_STRING name, List<Item> *item_list)
1543
arg_count= item_list->elements;
1547
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1551
Item *param_1= item_list->pop();
1552
Item *param_2= item_list->pop();
1554
if ( (! param_1->is_autogenerated_name)
1555
|| (! param_2->is_autogenerated_name))
1557
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
1561
return create(thd, param_1, param_2);
1566
Create_func_arg3::create(THD *thd, LEX_STRING name, List<Item> *item_list)
1571
arg_count= item_list->elements;
1575
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1579
Item *param_1= item_list->pop();
1580
Item *param_2= item_list->pop();
1581
Item *param_3= item_list->pop();
1583
if ( (! param_1->is_autogenerated_name)
1584
|| (! param_2->is_autogenerated_name)
1585
|| (! param_3->is_autogenerated_name))
1587
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
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);
1677
Create_func_bin Create_func_bin::s_singleton;
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);
1733
Create_func_concat Create_func_concat::s_singleton;
1736
Create_func_concat::create_native(THD *thd, LEX_STRING name,
1737
List<Item> *item_list)
1741
if (item_list != NULL)
1742
arg_count= item_list->elements;
1746
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1750
return new (thd->mem_root) Item_func_concat(*item_list);
1754
Create_func_concat_ws Create_func_concat_ws::s_singleton;
1757
Create_func_concat_ws::create_native(THD *thd, LEX_STRING name,
1758
List<Item> *item_list)
1762
if (item_list != NULL)
1763
arg_count= item_list->elements;
1765
/* "WS" stands for "With Separator": this function takes 2+ arguments */
1768
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
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();
1785
Create_func_conv Create_func_conv::s_singleton;
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);
1803
Create_func_cot Create_func_cot::s_singleton;
1806
Create_func_cot::create(THD *thd, Item *arg1)
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);
1813
Create_func_date_format Create_func_date_format::s_singleton;
1816
Create_func_date_format::create(THD *thd, Item *arg1, Item *arg2)
1818
return new (thd->mem_root) Item_func_date_format(arg1, arg2, 0);
1822
Create_func_datediff Create_func_datediff::s_singleton;
1825
Create_func_datediff::create(THD *thd, Item *arg1, Item *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);
1830
return new (thd->mem_root) Item_func_minus(i1, i2);
1834
Create_func_dayname Create_func_dayname::s_singleton;
1837
Create_func_dayname::create(THD *thd, Item *arg1)
1839
return new (thd->mem_root) Item_func_dayname(arg1);
1843
Create_func_dayofmonth Create_func_dayofmonth::s_singleton;
1846
Create_func_dayofmonth::create(THD *thd, Item *arg1)
1848
return new (thd->mem_root) Item_func_dayofmonth(arg1);
1852
Create_func_dayofweek Create_func_dayofweek::s_singleton;
1855
Create_func_dayofweek::create(THD *thd, Item *arg1)
1857
return new (thd->mem_root) Item_func_weekday(arg1, 1);
1861
Create_func_dayofyear Create_func_dayofyear::s_singleton;
1864
Create_func_dayofyear::create(THD *thd, Item *arg1)
1866
return new (thd->mem_root) Item_func_dayofyear(arg1);
1870
Create_func_degrees Create_func_degrees::s_singleton;
1873
Create_func_degrees::create(THD *thd, Item *arg1)
1875
return new (thd->mem_root) Item_func_units((char*) "degrees", arg1,
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);
1910
Create_func_export_set Create_func_export_set::s_singleton;
1913
Create_func_export_set::create_native(THD *thd, LEX_STRING name,
1914
List<Item> *item_list)
1919
if (item_list != NULL)
1920
arg_count= item_list->elements;
1922
switch (arg_count) {
1925
Item *param_1= item_list->pop();
1926
Item *param_2= item_list->pop();
1927
Item *param_3= item_list->pop();
1928
func= new (thd->mem_root) Item_func_export_set(param_1, param_2, param_3);
1933
Item *param_1= item_list->pop();
1934
Item *param_2= item_list->pop();
1935
Item *param_3= item_list->pop();
1936
Item *param_4= item_list->pop();
1937
func= new (thd->mem_root) Item_func_export_set(param_1, param_2, param_3,
1943
Item *param_1= item_list->pop();
1944
Item *param_2= item_list->pop();
1945
Item *param_3= item_list->pop();
1946
Item *param_4= item_list->pop();
1947
Item *param_5= item_list->pop();
1948
func= new (thd->mem_root) Item_func_export_set(param_1, param_2, param_3,
1954
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1963
Create_func_field Create_func_field::s_singleton;
1966
Create_func_field::create_native(THD *thd, LEX_STRING name,
1967
List<Item> *item_list)
1971
if (item_list != NULL)
1972
arg_count= item_list->elements;
1976
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
1980
return new (thd->mem_root) Item_func_field(*item_list);
1984
Create_func_find_in_set Create_func_find_in_set::s_singleton;
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);
2011
Create_func_found_rows Create_func_found_rows::s_singleton;
2014
Create_func_found_rows::create(THD *thd)
2016
thd->lex->set_stmt_unsafe();
2017
return new (thd->mem_root) Item_func_found_rows();
2021
Create_func_from_days Create_func_from_days::s_singleton;
2024
Create_func_from_days::create(THD *thd, Item *arg1)
2026
return new (thd->mem_root) Item_func_from_days(arg1);
2030
Create_func_from_unixtime Create_func_from_unixtime::s_singleton;
2033
Create_func_from_unixtime::create_native(THD *thd, LEX_STRING name,
2034
List<Item> *item_list)
2039
if (item_list != NULL)
2040
arg_count= item_list->elements;
2042
switch (arg_count) {
2045
Item *param_1= item_list->pop();
2046
func= new (thd->mem_root) Item_func_from_unixtime(param_1);
2051
Item *param_1= item_list->pop();
2052
Item *param_2= item_list->pop();
2053
Item *ut= new (thd->mem_root) Item_func_from_unixtime(param_1);
2054
func= new (thd->mem_root) Item_func_date_format(ut, param_2, 0);
2059
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2068
Create_func_greatest Create_func_greatest::s_singleton;
2071
Create_func_greatest::create_native(THD *thd, LEX_STRING name,
2072
List<Item> *item_list)
2076
if (item_list != NULL)
2077
arg_count= item_list->elements;
2081
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
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);
2098
Create_func_ifnull Create_func_ifnull::s_singleton;
2101
Create_func_ifnull::create(THD *thd, Item *arg1, Item *arg2)
2103
return new (thd->mem_root) Item_func_ifnull(arg1, arg2);
2107
Create_func_instr Create_func_instr::s_singleton;
2110
Create_func_instr::create(THD *thd, Item *arg1, Item *arg2)
2112
return new (thd->mem_root) Item_func_locate(arg1, arg2);
2116
Create_func_isnull Create_func_isnull::s_singleton;
2119
Create_func_isnull::create(THD *thd, Item *arg1)
2121
return new (thd->mem_root) Item_func_isnull(arg1);
2125
Create_func_last_day Create_func_last_day::s_singleton;
2128
Create_func_last_day::create(THD *thd, Item *arg1)
2130
return new (thd->mem_root) Item_func_last_day(arg1);
2134
Create_func_last_insert_id Create_func_last_insert_id::s_singleton;
2137
Create_func_last_insert_id::create_native(THD *thd, LEX_STRING name,
2138
List<Item> *item_list)
2143
if (item_list != NULL)
2144
arg_count= item_list->elements;
2146
switch (arg_count) {
2149
func= new (thd->mem_root) Item_func_last_insert_id();
2154
Item *param_1= item_list->pop();
2155
func= new (thd->mem_root) Item_func_last_insert_id(param_1);
2160
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2169
Create_func_lcase Create_func_lcase::s_singleton;
2172
Create_func_lcase::create(THD *thd, Item *arg1)
2174
return new (thd->mem_root) Item_func_lcase(arg1);
2178
Create_func_least Create_func_least::s_singleton;
2181
Create_func_least::create_native(THD *thd, LEX_STRING name,
2182
List<Item> *item_list)
2186
if (item_list != NULL)
2187
arg_count= item_list->elements;
2191
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
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);
2217
Create_func_load_file Create_func_load_file::s_singleton;
2220
Create_func_load_file::create(THD *thd, Item *arg1)
2222
return new (thd->mem_root) Item_load_file(arg1);
2226
Create_func_locate Create_func_locate::s_singleton;
2229
Create_func_locate::create_native(THD *thd, LEX_STRING name,
2230
List<Item> *item_list)
2235
if (item_list != NULL)
2236
arg_count= item_list->elements;
2238
switch (arg_count) {
2241
Item *param_1= item_list->pop();
2242
Item *param_2= item_list->pop();
2243
/* Yes, parameters in that order : 2, 1 */
2244
func= new (thd->mem_root) Item_func_locate(param_2, param_1);
2249
Item *param_1= item_list->pop();
2250
Item *param_2= item_list->pop();
2251
Item *param_3= item_list->pop();
2252
/* Yes, parameters in that order : 2, 1, 3 */
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);
2322
Create_func_lpad Create_func_lpad::s_singleton;
2325
Create_func_lpad::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
2327
return new (thd->mem_root) Item_func_lpad(arg1, arg2, arg3);
2331
Create_func_ltrim Create_func_ltrim::s_singleton;
2334
Create_func_ltrim::create(THD *thd, Item *arg1)
2336
return new (thd->mem_root) Item_func_ltrim(arg1);
2340
Create_func_makedate Create_func_makedate::s_singleton;
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);
2358
Create_func_make_set Create_func_make_set::s_singleton;
2361
Create_func_make_set::create_native(THD *thd, LEX_STRING name,
2362
List<Item> *item_list)
2366
if (item_list != NULL)
2367
arg_count= item_list->elements;
2371
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2375
Item *param_1= item_list->pop();
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);
2420
Create_func_monthname Create_func_monthname::s_singleton;
2423
Create_func_monthname::create(THD *thd, Item *arg1)
2425
return new (thd->mem_root) Item_func_monthname(arg1);
2429
Create_func_nullif Create_func_nullif::s_singleton;
2432
Create_func_nullif::create(THD *thd, Item *arg1, Item *arg2)
2434
return new (thd->mem_root) Item_func_nullif(arg1, arg2);
2438
Create_func_oct Create_func_oct::s_singleton;
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);
2458
Create_func_period_add Create_func_period_add::s_singleton;
2461
Create_func_period_add::create(THD *thd, Item *arg1, Item *arg2)
2463
return new (thd->mem_root) Item_func_period_add(arg1, arg2);
2467
Create_func_period_diff Create_func_period_diff::s_singleton;
2470
Create_func_period_diff::create(THD *thd, Item *arg1, Item *arg2)
2472
return new (thd->mem_root) Item_func_period_diff(arg1, arg2);
2476
Create_func_pi Create_func_pi::s_singleton;
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);
2503
Create_func_radians Create_func_radians::s_singleton;
2506
Create_func_radians::create(THD *thd, Item *arg1)
2508
return new (thd->mem_root) Item_func_units((char*) "radians", arg1,
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);
2548
Create_func_round Create_func_round::s_singleton;
2551
Create_func_round::create_native(THD *thd, LEX_STRING name,
2552
List<Item> *item_list)
2557
if (item_list != NULL)
2558
arg_count= item_list->elements;
2560
switch (arg_count) {
2563
Item *param_1= item_list->pop();
2564
Item *i0 = new (thd->mem_root) Item_int((char*)"0", 0, 1);
2565
func= new (thd->mem_root) Item_func_round(param_1, i0, 0);
2570
Item *param_1= item_list->pop();
2571
Item *param_2= item_list->pop();
2572
func= new (thd->mem_root) Item_func_round(param_1, param_2, 0);
2577
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2586
Create_func_row_count Create_func_row_count::s_singleton;
2589
Create_func_row_count::create(THD *thd)
2591
thd->lex->set_stmt_unsafe();
2592
return new (thd->mem_root) Item_func_row_count();
2596
Create_func_rpad Create_func_rpad::s_singleton;
2599
Create_func_rpad::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
2601
return new (thd->mem_root) Item_func_rpad(arg1, arg2, arg3);
2605
Create_func_rtrim Create_func_rtrim::s_singleton;
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);
2623
Create_func_sign Create_func_sign::s_singleton;
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);
2641
Create_func_space Create_func_space::s_singleton;
2644
Create_func_space::create(THD *thd, Item *arg1)
2648
The parsed item tree should not depend on
2649
<code>thd->variables.collation_connection</code>.
2651
const CHARSET_INFO * const cs= thd->variables.collation_connection;
2654
if (cs->mbminlen > 1)
2656
uint32_t dummy_errors;
2657
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);
2662
sp= new (thd->mem_root) Item_string(" ", 1, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
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);
2687
Create_func_strcmp Create_func_strcmp::s_singleton;
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);
2714
Create_func_tan Create_func_tan::s_singleton;
2717
Create_func_tan::create(THD *thd, Item *arg1)
2719
return new (thd->mem_root) Item_func_tan(arg1);
2723
Create_func_time_format Create_func_time_format::s_singleton;
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);
2750
Create_func_to_days Create_func_to_days::s_singleton;
2753
Create_func_to_days::create(THD *thd, Item *arg1)
2755
return new (thd->mem_root) Item_func_to_days(arg1);
2759
Create_func_ucase Create_func_ucase::s_singleton;
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);
2777
Create_func_unix_timestamp Create_func_unix_timestamp::s_singleton;
2780
Create_func_unix_timestamp::create_native(THD *thd, LEX_STRING name,
2781
List<Item> *item_list)
2786
if (item_list != NULL)
2787
arg_count= item_list->elements;
2789
switch (arg_count) {
2792
func= new (thd->mem_root) Item_func_unix_timestamp();
2797
Item *param_1= item_list->pop();
2798
func= new (thd->mem_root) Item_func_unix_timestamp(param_1);
2803
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
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);
2835
Create_func_weekday Create_func_weekday::s_singleton;
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);
2892
struct Native_func_registry
2895
Create_func *builder;
2898
#define BUILDER(F) & F::s_singleton
2901
MySQL native functions.
2903
- Keep sorted for human lookup. At runtime, a hash table is used.
2904
- keep 1 line per entry, it makes grep | sort easier
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)},
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)},
2924
{ { C_STRING_WITH_LEN("CONCAT") }, BUILDER(Create_func_concat)},
2925
{ { C_STRING_WITH_LEN("CONCAT_WS") }, BUILDER(Create_func_concat_ws)},
2926
{ { C_STRING_WITH_LEN("CONNECTION_ID") }, BUILDER(Create_func_connection_id)},
2927
{ { C_STRING_WITH_LEN("CONV") }, BUILDER(Create_func_conv)},
2928
{ { C_STRING_WITH_LEN("COS") }, BUILDER(Create_func_cos)},
2929
{ { C_STRING_WITH_LEN("COT") }, BUILDER(Create_func_cot)},
2930
{ { C_STRING_WITH_LEN("DATEDIFF") }, BUILDER(Create_func_datediff)},
2931
{ { C_STRING_WITH_LEN("DATE_FORMAT") }, BUILDER(Create_func_date_format)},
2932
{ { C_STRING_WITH_LEN("DAYNAME") }, BUILDER(Create_func_dayname)},
2933
{ { C_STRING_WITH_LEN("DAYOFMONTH") }, BUILDER(Create_func_dayofmonth)},
2934
{ { C_STRING_WITH_LEN("DAYOFWEEK") }, BUILDER(Create_func_dayofweek)},
2935
{ { C_STRING_WITH_LEN("DAYOFYEAR") }, BUILDER(Create_func_dayofyear)},
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)},
2939
{ { C_STRING_WITH_LEN("EXPORT_SET") }, BUILDER(Create_func_export_set)},
2940
{ { C_STRING_WITH_LEN("FIELD") }, BUILDER(Create_func_field)},
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)},
2944
{ { C_STRING_WITH_LEN("FOUND_ROWS") }, BUILDER(Create_func_found_rows)},
2945
{ { C_STRING_WITH_LEN("FROM_DAYS") }, BUILDER(Create_func_from_days)},
2946
{ { C_STRING_WITH_LEN("FROM_UNIXTIME") }, BUILDER(Create_func_from_unixtime)},
2947
{ { C_STRING_WITH_LEN("GREATEST") }, BUILDER(Create_func_greatest)},
2948
{ { C_STRING_WITH_LEN("HEX") }, BUILDER(Create_func_hex)},
2949
{ { C_STRING_WITH_LEN("IFNULL") }, BUILDER(Create_func_ifnull)},
2950
{ { C_STRING_WITH_LEN("INSTR") }, BUILDER(Create_func_instr)},
2951
{ { C_STRING_WITH_LEN("ISNULL") }, BUILDER(Create_func_isnull)},
2952
{ { C_STRING_WITH_LEN("LAST_DAY") }, BUILDER(Create_func_last_day)},
2953
{ { C_STRING_WITH_LEN("LAST_INSERT_ID") }, BUILDER(Create_func_last_insert_id)},
2954
{ { C_STRING_WITH_LEN("LCASE") }, BUILDER(Create_func_lcase)},
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)},
2958
{ { C_STRING_WITH_LEN("LOAD_FILE") }, BUILDER(Create_func_load_file)},
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)},
2963
{ { C_STRING_WITH_LEN("LOWER") }, BUILDER(Create_func_lcase)},
2964
{ { C_STRING_WITH_LEN("LPAD") }, BUILDER(Create_func_lpad)},
2965
{ { C_STRING_WITH_LEN("LTRIM") }, BUILDER(Create_func_ltrim)},
2966
{ { C_STRING_WITH_LEN("MAKEDATE") }, BUILDER(Create_func_makedate)},
2967
{ { C_STRING_WITH_LEN("MAKETIME") }, BUILDER(Create_func_maketime)},
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)},
2970
{ { C_STRING_WITH_LEN("MONTHNAME") }, BUILDER(Create_func_monthname)},
2971
{ { C_STRING_WITH_LEN("NULLIF") }, BUILDER(Create_func_nullif)},
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)},
2975
{ { C_STRING_WITH_LEN("PERIOD_ADD") }, BUILDER(Create_func_period_add)},
2976
{ { C_STRING_WITH_LEN("PERIOD_DIFF") }, BUILDER(Create_func_period_diff)},
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)},
2981
{ { C_STRING_WITH_LEN("RADIANS") }, BUILDER(Create_func_radians)},
2982
{ { C_STRING_WITH_LEN("RAND") }, BUILDER(Create_func_rand)},
2983
{ { C_STRING_WITH_LEN("ROUND") }, BUILDER(Create_func_round)},
2984
{ { C_STRING_WITH_LEN("ROW_COUNT") }, BUILDER(Create_func_row_count)},
2985
{ { C_STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad)},
2986
{ { C_STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim)},
2987
{ { C_STRING_WITH_LEN("SEC_TO_TIME") }, BUILDER(Create_func_sec_to_time)},
2988
{ { C_STRING_WITH_LEN("SIGN") }, BUILDER(Create_func_sign)},
2989
{ { C_STRING_WITH_LEN("SIN") }, BUILDER(Create_func_sin)},
2990
{ { C_STRING_WITH_LEN("SPACE") }, BUILDER(Create_func_space)},
2991
{ { C_STRING_WITH_LEN("SQRT") }, BUILDER(Create_func_sqrt)},
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)},
2996
{ { C_STRING_WITH_LEN("TAN") }, BUILDER(Create_func_tan)},
2997
{ { C_STRING_WITH_LEN("TIMEDIFF") }, BUILDER(Create_func_timediff)},
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)},
3000
{ { C_STRING_WITH_LEN("TO_DAYS") }, BUILDER(Create_func_to_days)},
3001
{ { C_STRING_WITH_LEN("UCASE") }, BUILDER(Create_func_ucase)},
3002
{ { C_STRING_WITH_LEN("UNHEX") }, BUILDER(Create_func_unhex)},
3003
{ { C_STRING_WITH_LEN("UNIX_TIMESTAMP") }, BUILDER(Create_func_unix_timestamp)},
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)},
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)},
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;
3026
Load the hash table for native functions.
3027
Note: this code is not thread safe, and is intended to be used at server
3028
startup only (before going multi-threaded)
3031
int item_create_init()
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 */
3045
for (func= func_array; func->builder != NULL; func++)
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);
3067
find_native_function_builder(THD *thd __attribute__((unused)),
3070
Native_func_registry *func;
3071
Create_func *builder= NULL;
3074
func= (Native_func_registry*) hash_search(& native_functions_hash,
3075
(unsigned char*) name.str,
3080
builder= func->builder;
3088
create_func_char_cast(THD *thd, Item *a, int len, const CHARSET_INFO * const 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);
3096
create_func_cast(THD *thd, Item *a, Cast_target cast_type,
3097
const char *c_len, const char *c_dec,
3098
const CHARSET_INFO * const cs)
3104
switch (cast_type) {
3105
case ITEM_CAST_BINARY:
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);
3117
case ITEM_CAST_TIME:
3118
res= new (thd->mem_root) Item_time_typecast(a);
3120
case ITEM_CAST_DATETIME:
3121
res= new (thd->mem_root) Item_datetime_typecast(a);
3123
case ITEM_CAST_DECIMAL:
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);
3148
case ITEM_CAST_CHAR:
3150
len= c_len ? atoi(c_len) : -1;
3151
res= create_func_char_cast(thd, a, len, cs);