MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
item_create.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16 
24 #include "sql_priv.h"
25 /*
26  It is necessary to include set_var.h instead of item.h because there
27  are dependencies on include order for set_var.h and item.h. This
28  will be resolved later.
29 */
30 #include "sql_class.h" // set_var.h: THD
31 #include "set_var.h"
32 #include "sp_head.h"
33 #include "sp.h"
34 #include "item_inetfunc.h"
35 #include "sql_time.h"
36 
37 /*
38 =============================================================================
39  LOCAL DECLARATIONS
40 =============================================================================
41 */
42 
52 {
53 public:
54  virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
55 
63  virtual Item *create_native(THD *thd, LEX_STRING name,
64  List<Item> *item_list) = 0;
65 
66 protected:
70  virtual ~Create_native_func() {}
71 };
72 
73 
79 {
80 public:
81  virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
82 
88  virtual Item *create(THD *thd) = 0;
89 
90 protected:
94  virtual ~Create_func_arg0() {}
95 };
96 
97 
103 {
104 public:
105  virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
106 
113  virtual Item *create(THD *thd, Item *arg1) = 0;
114 
115 protected:
119  virtual ~Create_func_arg1() {}
120 };
121 
122 
128 {
129 public:
130  virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
131 
139  virtual Item *create(THD *thd, Item *arg1, Item *arg2) = 0;
140 
141 protected:
145  virtual ~Create_func_arg2() {}
146 };
147 
148 
154 {
155 public:
156  virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
157 
166  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3) = 0;
167 
168 protected:
172  virtual ~Create_func_arg3() {}
173 };
174 
175 
181 {
182 public:
183  virtual Item *create(THD *thd, LEX_STRING db, LEX_STRING name,
184  bool use_explicit_name, List<Item> *item_list);
185 
186  static Create_sp_func s_singleton;
187 
188 protected:
192  virtual ~Create_sp_func() {}
193 };
194 
195 
196 #ifndef HAVE_SPATIAL
197 
204 {
205 public:
206  virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list);
207 
210 
211 protected:
215  virtual ~Create_func_no_geom() {}
216 };
217 #endif
218 
219 
220 /*
221  Concrete functions builders (native functions).
222  Please keep this list sorted in alphabetical order,
223  it helps to compare code between versions, and helps with merges conflicts.
224 */
225 
227 {
228 public:
229  virtual Item *create(THD *thd, Item *arg1);
230 
231  static Create_func_abs s_singleton;
232 
233 protected:
234  Create_func_abs() {}
235  virtual ~Create_func_abs() {}
236 };
237 
238 
240 {
241 public:
242  virtual Item *create(THD *thd, Item *arg1);
243 
244  static Create_func_acos s_singleton;
245 
246 protected:
247  Create_func_acos() {}
248  virtual ~Create_func_acos() {}
249 };
250 
251 
253 {
254 public:
255  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
256 
257  static Create_func_addtime s_singleton;
258 
259 protected:
261  virtual ~Create_func_addtime() {}
262 };
263 
264 
266 {
267 public:
268  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
269 
270  static Create_func_aes_encrypt s_singleton;
271 
272 protected:
274  virtual ~Create_func_aes_encrypt() {}
275 };
276 
277 
279 {
280 public:
281  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
282 
283  static Create_func_aes_decrypt s_singleton;
284 
285 protected:
287  virtual ~Create_func_aes_decrypt() {}
288 };
289 
290 
291 #ifdef HAVE_SPATIAL
292 class Create_func_area : public Create_func_arg1
293 {
294 public:
295  virtual Item *create(THD *thd, Item *arg1);
296 
297  static Create_func_area s_singleton;
298 
299 protected:
300  Create_func_area() {}
301  virtual ~Create_func_area() {}
302 };
303 #endif
304 
305 
306 #ifdef HAVE_SPATIAL
307 class Create_func_as_wkb : public Create_func_arg1
308 {
309 public:
310  virtual Item *create(THD *thd, Item *arg1);
311 
312  static Create_func_as_wkb s_singleton;
313 
314 protected:
315  Create_func_as_wkb() {}
316  virtual ~Create_func_as_wkb() {}
317 };
318 #endif
319 
320 
321 #ifdef HAVE_SPATIAL
322 class Create_func_as_wkt : public Create_func_arg1
323 {
324 public:
325  virtual Item *create(THD *thd, Item *arg1);
326 
327  static Create_func_as_wkt s_singleton;
328 
329 protected:
330  Create_func_as_wkt() {}
331  virtual ~Create_func_as_wkt() {}
332 };
333 #endif
334 
335 
337 {
338 public:
339  virtual Item *create(THD *thd, Item *arg1);
340 
341  static Create_func_asin s_singleton;
342 
343 protected:
344  Create_func_asin() {}
345  virtual ~Create_func_asin() {}
346 };
347 
348 
350 {
351 public:
352  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
353 
354  static Create_func_atan s_singleton;
355 
356 protected:
357  Create_func_atan() {}
358  virtual ~Create_func_atan() {}
359 };
360 
361 
363 {
364 public:
365  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
366 
367  static Create_func_benchmark s_singleton;
368 
369 protected:
371  virtual ~Create_func_benchmark() {}
372 };
373 
374 
376 {
377 public:
378  virtual Item *create(THD *thd, Item *arg1);
379 
380  static Create_func_bin s_singleton;
381 
382 protected:
383  Create_func_bin() {}
384  virtual ~Create_func_bin() {}
385 };
386 
387 
389 {
390 public:
391  virtual Item *create(THD *thd, Item *arg1);
392 
393  static Create_func_bit_count s_singleton;
394 
395 protected:
397  virtual ~Create_func_bit_count() {}
398 };
399 
400 
402 {
403 public:
404  virtual Item *create(THD *thd, Item *arg1);
405 
406  static Create_func_bit_length s_singleton;
407 
408 protected:
410  virtual ~Create_func_bit_length() {}
411 };
412 
413 
415 {
416 public:
417  virtual Item *create(THD *thd, Item *arg1);
418 
419  static Create_func_ceiling s_singleton;
420 
421 protected:
423  virtual ~Create_func_ceiling() {}
424 };
425 
426 
427 #ifdef HAVE_SPATIAL
428 class Create_func_centroid : public Create_func_arg1
429 {
430 public:
431  virtual Item *create(THD *thd, Item *arg1);
432 
433  static Create_func_centroid s_singleton;
434 
435 protected:
436  Create_func_centroid() {}
437  virtual ~Create_func_centroid() {}
438 };
439 #endif
440 
441 
443 {
444 public:
445  virtual Item *create(THD *thd, Item *arg1);
446 
447  static Create_func_char_length s_singleton;
448 
449 protected:
451  virtual ~Create_func_char_length() {}
452 };
453 
454 
456 {
457 public:
458  virtual Item *create(THD *thd, Item *arg1);
459 
460  static Create_func_coercibility s_singleton;
461 
462 protected:
464  virtual ~Create_func_coercibility() {}
465 };
466 
467 
469 {
470 public:
471  virtual Item *create(THD *thd, Item *arg1);
472 
473  static Create_func_compress s_singleton;
474 
475 protected:
477  virtual ~Create_func_compress() {}
478 };
479 
480 
482 {
483 public:
484  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
485 
486  static Create_func_concat s_singleton;
487 
488 protected:
489  Create_func_concat() {}
490  virtual ~Create_func_concat() {}
491 };
492 
493 
495 {
496 public:
497  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
498 
499  static Create_func_concat_ws s_singleton;
500 
501 protected:
503  virtual ~Create_func_concat_ws() {}
504 };
505 
506 
508 {
509 public:
510  virtual Item *create(THD *thd);
511 
512  static Create_func_connection_id s_singleton;
513 
514 protected:
516  virtual ~Create_func_connection_id() {}
517 };
518 
519 
520 #ifdef HAVE_SPATIAL
521 class Create_func_mbr_contains : public Create_func_arg2
522 {
523 public:
524  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
525 
526  static Create_func_mbr_contains s_singleton;
527 
528 protected:
529  Create_func_mbr_contains() {}
530  virtual ~Create_func_mbr_contains() {}
531 };
532 
533 
534 class Create_func_contains : public Create_func_arg2
535 {
536 public:
537  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
538 
539  static Create_func_contains s_singleton;
540 
541 protected:
542  Create_func_contains() {}
543  virtual ~Create_func_contains() {}
544 };
545 #endif
546 
547 
549 {
550 public:
551  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
552 
553  static Create_func_conv s_singleton;
554 
555 protected:
556  Create_func_conv() {}
557  virtual ~Create_func_conv() {}
558 };
559 
560 
562 {
563 public:
564  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
565 
566  static Create_func_convert_tz s_singleton;
567 
568 protected:
570  virtual ~Create_func_convert_tz() {}
571 };
572 
573 
575 {
576 public:
577  virtual Item *create(THD *thd, Item *arg1);
578 
579  static Create_func_cos s_singleton;
580 
581 protected:
582  Create_func_cos() {}
583  virtual ~Create_func_cos() {}
584 };
585 
586 
588 {
589 public:
590  virtual Item *create(THD *thd, Item *arg1);
591 
592  static Create_func_cot s_singleton;
593 
594 protected:
595  Create_func_cot() {}
596  virtual ~Create_func_cot() {}
597 };
598 
599 
601 {
602 public:
603  virtual Item *create(THD *thd, Item *arg1);
604 
605  static Create_func_crc32 s_singleton;
606 
607 protected:
608  Create_func_crc32() {}
609  virtual ~Create_func_crc32() {}
610 };
611 
612 
613 #ifdef HAVE_SPATIAL
614 class Create_func_crosses : public Create_func_arg2
615 {
616 public:
617  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
618 
619  static Create_func_crosses s_singleton;
620 
621 protected:
622  Create_func_crosses() {}
623  virtual ~Create_func_crosses() {}
624 };
625 #endif
626 
627 
629 {
630 public:
631  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
632 
633  static Create_func_date_format s_singleton;
634 
635 protected:
637  virtual ~Create_func_date_format() {}
638 };
639 
640 
642 {
643 public:
644  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
645 
646  static Create_func_datediff s_singleton;
647 
648 protected:
650  virtual ~Create_func_datediff() {}
651 };
652 
653 
655 {
656 public:
657  virtual Item *create(THD *thd, Item *arg1);
658 
659  static Create_func_dayname s_singleton;
660 
661 protected:
663  virtual ~Create_func_dayname() {}
664 };
665 
666 
668 {
669 public:
670  virtual Item *create(THD *thd, Item *arg1);
671 
672  static Create_func_dayofmonth s_singleton;
673 
674 protected:
676  virtual ~Create_func_dayofmonth() {}
677 };
678 
679 
681 {
682 public:
683  virtual Item *create(THD *thd, Item *arg1);
684 
685  static Create_func_dayofweek s_singleton;
686 
687 protected:
689  virtual ~Create_func_dayofweek() {}
690 };
691 
692 
694 {
695 public:
696  virtual Item *create(THD *thd, Item *arg1);
697 
698  static Create_func_dayofyear s_singleton;
699 
700 protected:
702  virtual ~Create_func_dayofyear() {}
703 };
704 
705 
707 {
708 public:
709  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
710 
711  static Create_func_decode s_singleton;
712 
713 protected:
714  Create_func_decode() {}
715  virtual ~Create_func_decode() {}
716 };
717 
718 
720 {
721 public:
722  virtual Item *create(THD *thd, Item *arg1);
723 
724  static Create_func_degrees s_singleton;
725 
726 protected:
728  virtual ~Create_func_degrees() {}
729 };
730 
731 
733 {
734 public:
735  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
736 
737  static Create_func_des_decrypt s_singleton;
738 
739 protected:
741  virtual ~Create_func_des_decrypt() {}
742 };
743 
744 
746 {
747 public:
748  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
749 
750  static Create_func_des_encrypt s_singleton;
751 
752 protected:
754  virtual ~Create_func_des_encrypt() {}
755 };
756 
757 
758 #ifdef HAVE_SPATIAL
759 class Create_func_dimension : public Create_func_arg1
760 {
761 public:
762  virtual Item *create(THD *thd, Item *arg1);
763 
764  static Create_func_dimension s_singleton;
765 
766 protected:
767  Create_func_dimension() {}
768  virtual ~Create_func_dimension() {}
769 };
770 #endif
771 
772 
773 #ifdef HAVE_SPATIAL
774 class Create_func_mbr_disjoint : public Create_func_arg2
775 {
776 public:
777  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
778 
779  static Create_func_mbr_disjoint s_singleton;
780 
781 protected:
782  Create_func_mbr_disjoint() {}
783  virtual ~Create_func_mbr_disjoint() {}
784 };
785 
786 
787 class Create_func_disjoint : public Create_func_arg2
788 {
789 public:
790  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
791 
792  static Create_func_disjoint s_singleton;
793 
794 protected:
795  Create_func_disjoint() {}
796  virtual ~Create_func_disjoint() {}
797 };
798 
799 
800 class Create_func_distance : public Create_func_arg2
801 {
802 public:
803  virtual Item* create(THD *thd, Item *arg1, Item *arg2);
804 
805  static Create_func_distance s_singleton;
806 
807 protected:
808  Create_func_distance() {}
809  virtual ~Create_func_distance() {}
810 };
811 #endif
812 
813 
815 {
816 public:
817  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
818 
819  static Create_func_elt s_singleton;
820 
821 protected:
822  Create_func_elt() {}
823  virtual ~Create_func_elt() {}
824 };
825 
826 
828 {
829 public:
830  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
831 
832  static Create_func_encode s_singleton;
833 
834 protected:
835  Create_func_encode() {}
836  virtual ~Create_func_encode() {}
837 };
838 
839 
841 {
842 public:
843  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
844 
845  static Create_func_encrypt s_singleton;
846 
847 protected:
849  virtual ~Create_func_encrypt() {}
850 };
851 
852 
853 #ifdef HAVE_SPATIAL
854 class Create_func_endpoint : public Create_func_arg1
855 {
856 public:
857  virtual Item *create(THD *thd, Item *arg1);
858 
859  static Create_func_endpoint s_singleton;
860 
861 protected:
862  Create_func_endpoint() {}
863  virtual ~Create_func_endpoint() {}
864 };
865 #endif
866 
867 
868 #ifdef HAVE_SPATIAL
869 class Create_func_envelope : public Create_func_arg1
870 {
871 public:
872  virtual Item *create(THD *thd, Item *arg1);
873 
874  static Create_func_envelope s_singleton;
875 
876 protected:
877  Create_func_envelope() {}
878  virtual ~Create_func_envelope() {}
879 };
880 #endif
881 
882 
883 #ifdef HAVE_SPATIAL
884 class Create_func_mbr_equals : public Create_func_arg2
885 {
886 public:
887  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
888 
889  static Create_func_mbr_equals s_singleton;
890 
891 protected:
892  Create_func_mbr_equals() {}
893  virtual ~Create_func_mbr_equals() {}
894 };
895 
896 
897 class Create_func_equals : public Create_func_arg2
898 {
899 public:
900  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
901 
902  static Create_func_equals s_singleton;
903 
904 protected:
905  Create_func_equals() {}
906  virtual ~Create_func_equals() {}
907 };
908 #endif
909 
910 
912 {
913 public:
914  virtual Item *create(THD *thd, Item *arg1);
915 
916  static Create_func_exp s_singleton;
917 
918 protected:
919  Create_func_exp() {}
920  virtual ~Create_func_exp() {}
921 };
922 
923 
925 {
926 public:
927  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
928 
929  static Create_func_export_set s_singleton;
930 
931 protected:
933  virtual ~Create_func_export_set() {}
934 };
935 
936 
937 #ifdef HAVE_SPATIAL
938 class Create_func_exteriorring : public Create_func_arg1
939 {
940 public:
941  virtual Item *create(THD *thd, Item *arg1);
942 
943  static Create_func_exteriorring s_singleton;
944 
945 protected:
946  Create_func_exteriorring() {}
947  virtual ~Create_func_exteriorring() {}
948 };
949 #endif
950 
951 
953 {
954 public:
955  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
956 
957  static Create_func_field s_singleton;
958 
959 protected:
960  Create_func_field() {}
961  virtual ~Create_func_field() {}
962 };
963 
964 
966 {
967 public:
968  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
969 
970  static Create_func_find_in_set s_singleton;
971 
972 protected:
974  virtual ~Create_func_find_in_set() {}
975 };
976 
977 
979 {
980 public:
981  virtual Item *create(THD *thd, Item *arg1);
982 
983  static Create_func_floor s_singleton;
984 
985 protected:
986  Create_func_floor() {}
987  virtual ~Create_func_floor() {}
988 };
989 
990 
992 {
993 public:
994  virtual Item *create(THD *thd);
995 
996  static Create_func_found_rows s_singleton;
997 
998 protected:
1000  virtual ~Create_func_found_rows() {}
1001 };
1002 
1003 
1005 {
1006 public:
1007  virtual Item *create(THD *thd, Item *arg1);
1008 
1009  static Create_func_from_base64 s_singleton;
1010 
1011 protected:
1013  virtual ~Create_func_from_base64() {}
1014 };
1015 
1016 
1018 {
1019 public:
1020  virtual Item *create(THD *thd, Item *arg1);
1021 
1022  static Create_func_from_days s_singleton;
1023 
1024 protected:
1026  virtual ~Create_func_from_days() {}
1027 };
1028 
1029 
1031 {
1032 public:
1033  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1034 
1035  static Create_func_from_unixtime s_singleton;
1036 
1037 protected:
1039  virtual ~Create_func_from_unixtime() {}
1040 };
1041 
1042 
1043 #ifdef HAVE_SPATIAL
1044 class Create_func_geometry_from_text : public Create_native_func
1045 {
1046 public:
1047  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1048 
1049  static Create_func_geometry_from_text s_singleton;
1050 
1051 protected:
1052  Create_func_geometry_from_text() {}
1053  virtual ~Create_func_geometry_from_text() {}
1054 };
1055 #endif
1056 
1057 
1058 #ifdef HAVE_SPATIAL
1059 class Create_func_geometry_from_wkb : public Create_native_func
1060 {
1061 public:
1062  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1063 
1064  static Create_func_geometry_from_wkb s_singleton;
1065 
1066 protected:
1067  Create_func_geometry_from_wkb() {}
1068  virtual ~Create_func_geometry_from_wkb() {}
1069 };
1070 #endif
1071 
1072 
1073 #ifdef HAVE_SPATIAL
1074 class Create_func_geometry_type : public Create_func_arg1
1075 {
1076 public:
1077  virtual Item *create(THD *thd, Item *arg1);
1078 
1079  static Create_func_geometry_type s_singleton;
1080 
1081 protected:
1082  Create_func_geometry_type() {}
1083  virtual ~Create_func_geometry_type() {}
1084 };
1085 #endif
1086 
1087 
1088 #ifdef HAVE_SPATIAL
1089 class Create_func_geometryn : public Create_func_arg2
1090 {
1091 public:
1092  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1093 
1094  static Create_func_geometryn s_singleton;
1095 
1096 protected:
1097  Create_func_geometryn() {}
1098  virtual ~Create_func_geometryn() {}
1099 };
1100 #endif
1101 
1102 
1104 {
1105 public:
1106  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1107 
1108  static Create_func_get_lock s_singleton;
1109 
1110 protected:
1112  virtual ~Create_func_get_lock() {}
1113 };
1114 
1115 
1116 #if defined(HAVE_SPATIAL) && !defined(DBUG_OFF)
1117 class Create_func_gis_debug : public Create_func_arg1
1118 {
1119 public:
1120  virtual Item *create(THD *thd, Item *arg1);
1121 
1122  static Create_func_gis_debug s_singleton;
1123 
1124 protected:
1125  Create_func_gis_debug() {}
1126  virtual ~Create_func_gis_debug() {}
1127 };
1128 #endif
1129 
1130 
1131 #ifdef HAVE_SPATIAL
1132 class Create_func_glength : public Create_func_arg1
1133 {
1134 public:
1135  virtual Item *create(THD *thd, Item *arg1);
1136 
1137  static Create_func_glength s_singleton;
1138 
1139 protected:
1140  Create_func_glength() {}
1141  virtual ~Create_func_glength() {}
1142 };
1143 #endif
1144 
1145 
1147 {
1148 public:
1149  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1150 
1151  static Create_func_greatest s_singleton;
1152 
1153 protected:
1155  virtual ~Create_func_greatest() {}
1156 };
1157 
1158 
1160 {
1161 public:
1162  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1163 
1164  static Create_func_gtid_subtract s_singleton;
1165 
1166 protected:
1168  virtual ~Create_func_gtid_subtract() {}
1169 };
1170 
1171 
1173 {
1174 public:
1175  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1176 
1177  static Create_func_gtid_subset s_singleton;
1178 
1179 protected:
1181  virtual ~Create_func_gtid_subset() {}
1182 };
1183 
1184 
1186 {
1187 public:
1188  virtual Item *create(THD *thd, Item *arg1);
1189 
1190  static Create_func_hex s_singleton;
1191 
1192 protected:
1193  Create_func_hex() {}
1194  virtual ~Create_func_hex() {}
1195 };
1196 
1197 
1199 {
1200 public:
1201  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1202 
1203  static Create_func_ifnull s_singleton;
1204 
1205 protected:
1206  Create_func_ifnull() {}
1207  virtual ~Create_func_ifnull() {}
1208 };
1209 
1210 
1212 {
1213 public:
1214  virtual Item *create(THD *thd, Item *arg1);
1215 
1216  static Create_func_inet_ntoa s_singleton;
1217 
1218 protected:
1220  virtual ~Create_func_inet_ntoa() {}
1221 };
1222 
1223 
1225 {
1226 public:
1227  virtual Item *create(THD *thd, Item *arg1);
1228 
1229  static Create_func_inet_aton s_singleton;
1230 
1231 protected:
1233  virtual ~Create_func_inet_aton() {}
1234 };
1235 
1236 
1238 {
1239 public:
1240  virtual Item *create(THD *thd, Item *arg1);
1241 
1242  static Create_func_inet6_aton s_singleton;
1243 
1244 protected:
1246  virtual ~Create_func_inet6_aton() {}
1247 };
1248 
1249 
1251 {
1252 public:
1253  virtual Item *create(THD *thd, Item *arg1);
1254 
1255  static Create_func_inet6_ntoa s_singleton;
1256 
1257 protected:
1259  virtual ~Create_func_inet6_ntoa() {}
1260 };
1261 
1262 
1264 {
1265 public:
1266  virtual Item *create(THD *thd, Item *arg1);
1267 
1268  static Create_func_is_ipv4 s_singleton;
1269 
1270 protected:
1271  Create_func_is_ipv4() {}
1272  virtual ~Create_func_is_ipv4() {}
1273 };
1274 
1275 
1277 {
1278 public:
1279  virtual Item *create(THD *thd, Item *arg1);
1280 
1281  static Create_func_is_ipv6 s_singleton;
1282 
1283 protected:
1284  Create_func_is_ipv6() {}
1285  virtual ~Create_func_is_ipv6() {}
1286 };
1287 
1288 
1290 {
1291 public:
1292  virtual Item *create(THD *thd, Item *arg1);
1293 
1294  static Create_func_is_ipv4_compat s_singleton;
1295 
1296 protected:
1298  virtual ~Create_func_is_ipv4_compat() {}
1299 };
1300 
1301 
1303 {
1304 public:
1305  virtual Item *create(THD *thd, Item *arg1);
1306 
1307  static Create_func_is_ipv4_mapped s_singleton;
1308 
1309 protected:
1311  virtual ~Create_func_is_ipv4_mapped() {}
1312 };
1313 
1314 
1316 {
1317 public:
1318  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1319 
1320  static Create_func_instr s_singleton;
1321 
1322 protected:
1323  Create_func_instr() {}
1324  virtual ~Create_func_instr() {}
1325 };
1326 
1327 
1328 #ifdef HAVE_SPATIAL
1329 class Create_func_interiorringn : public Create_func_arg2
1330 {
1331 public:
1332  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1333 
1334  static Create_func_interiorringn s_singleton;
1335 
1336 protected:
1337  Create_func_interiorringn() {}
1338  virtual ~Create_func_interiorringn() {}
1339 };
1340 #endif
1341 
1342 
1343 #ifdef HAVE_SPATIAL
1344 class Create_func_mbr_intersects : public Create_func_arg2
1345 {
1346 public:
1347  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1348 
1349  static Create_func_mbr_intersects s_singleton;
1350 
1351 protected:
1352  Create_func_mbr_intersects() {}
1353  virtual ~Create_func_mbr_intersects() {}
1354 };
1355 
1356 
1357 class Create_func_intersects : public Create_func_arg2
1358 {
1359 public:
1360  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1361 
1362  static Create_func_intersects s_singleton;
1363 
1364 protected:
1365  Create_func_intersects() {}
1366  virtual ~Create_func_intersects() {}
1367 };
1368 
1369 
1370 class Create_func_intersection : public Create_func_arg2
1371 {
1372 public:
1373  virtual Item* create(THD *thd, Item *arg1, Item *arg2);
1374 
1375  static Create_func_intersection s_singleton;
1376 
1377 protected:
1378  Create_func_intersection() {}
1379  virtual ~Create_func_intersection() {}
1380 };
1381 
1382 
1383 class Create_func_difference : public Create_func_arg2
1384 {
1385 public:
1386  virtual Item* create(THD *thd, Item *arg1, Item *arg2);
1387 
1388  static Create_func_difference s_singleton;
1389 
1390 protected:
1391  Create_func_difference() {}
1392  virtual ~Create_func_difference() {}
1393 };
1394 
1395 
1396 class Create_func_union : public Create_func_arg2
1397 {
1398 public:
1399  virtual Item* create(THD *thd, Item *arg1, Item *arg2);
1400 
1401  static Create_func_union s_singleton;
1402 
1403 protected:
1404  Create_func_union() {}
1405  virtual ~Create_func_union() {}
1406 };
1407 
1408 
1409 class Create_func_symdifference : public Create_func_arg2
1410 {
1411 public:
1412  virtual Item* create(THD *thd, Item *arg1, Item *arg2);
1413 
1414  static Create_func_symdifference s_singleton;
1415 
1416 protected:
1417  Create_func_symdifference() {}
1418  virtual ~Create_func_symdifference() {}
1419 };
1420 
1421 
1422 class Create_func_buffer : public Create_func_arg2
1423 {
1424 public:
1425  virtual Item* create(THD *thd, Item *arg1, Item *arg2);
1426 
1427  static Create_func_buffer s_singleton;
1428 
1429 protected:
1430  Create_func_buffer() {}
1431  virtual ~Create_func_buffer() {}
1432 };
1433 #endif /*HAVE_SPATIAL*/
1434 
1435 
1437 {
1438 public:
1439  virtual Item *create(THD *thd, Item *arg1);
1440 
1441  static Create_func_is_free_lock s_singleton;
1442 
1443 protected:
1445  virtual ~Create_func_is_free_lock() {}
1446 };
1447 
1448 
1450 {
1451 public:
1452  virtual Item *create(THD *thd, Item *arg1);
1453 
1454  static Create_func_is_used_lock s_singleton;
1455 
1456 protected:
1458  virtual ~Create_func_is_used_lock() {}
1459 };
1460 
1461 
1462 #ifdef HAVE_SPATIAL
1463 class Create_func_isclosed : public Create_func_arg1
1464 {
1465 public:
1466  virtual Item *create(THD *thd, Item *arg1);
1467 
1468  static Create_func_isclosed s_singleton;
1469 
1470 protected:
1471  Create_func_isclosed() {}
1472  virtual ~Create_func_isclosed() {}
1473 };
1474 #endif
1475 
1476 
1477 #ifdef HAVE_SPATIAL
1478 class Create_func_isempty : public Create_func_arg1
1479 {
1480 public:
1481  virtual Item *create(THD *thd, Item *arg1);
1482 
1483  static Create_func_isempty s_singleton;
1484 
1485 protected:
1486  Create_func_isempty() {}
1487  virtual ~Create_func_isempty() {}
1488 };
1489 #endif
1490 
1491 
1493 {
1494 public:
1495  virtual Item *create(THD *thd, Item *arg1);
1496 
1497  static Create_func_isnull s_singleton;
1498 
1499 protected:
1500  Create_func_isnull() {}
1501  virtual ~Create_func_isnull() {}
1502 };
1503 
1504 
1505 #ifdef HAVE_SPATIAL
1506 class Create_func_issimple : public Create_func_arg1
1507 {
1508 public:
1509  virtual Item *create(THD *thd, Item *arg1);
1510 
1511  static Create_func_issimple s_singleton;
1512 
1513 protected:
1514  Create_func_issimple() {}
1515  virtual ~Create_func_issimple() {}
1516 };
1517 #endif
1518 
1519 
1521 {
1522 public:
1523  virtual Item *create(THD *thd, Item *arg1);
1524 
1525  static Create_func_last_day s_singleton;
1526 
1527 protected:
1529  virtual ~Create_func_last_day() {}
1530 };
1531 
1532 
1534 {
1535 public:
1536  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1537 
1538  static Create_func_last_insert_id s_singleton;
1539 
1540 protected:
1542  virtual ~Create_func_last_insert_id() {}
1543 };
1544 
1545 
1547 {
1548 public:
1549  virtual Item *create(THD *thd, Item *arg1);
1550 
1551  static Create_func_lcase s_singleton;
1552 
1553 protected:
1554  Create_func_lcase() {}
1555  virtual ~Create_func_lcase() {}
1556 };
1557 
1558 
1560 {
1561 public:
1562  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1563 
1564  static Create_func_least s_singleton;
1565 
1566 protected:
1567  Create_func_least() {}
1568  virtual ~Create_func_least() {}
1569 };
1570 
1571 
1573 {
1574 public:
1575  virtual Item *create(THD *thd, Item *arg1);
1576 
1577  static Create_func_length s_singleton;
1578 
1579 protected:
1580  Create_func_length() {}
1581  virtual ~Create_func_length() {}
1582 };
1583 
1584 
1585 #ifndef DBUG_OFF
1587 {
1588 public:
1589  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1590 
1591  static Create_func_like_range_min s_singleton;
1592 
1593 protected:
1595  virtual ~Create_func_like_range_min() {}
1596 };
1597 
1598 
1600 {
1601 public:
1602  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1603 
1604  static Create_func_like_range_max s_singleton;
1605 
1606 protected:
1608  virtual ~Create_func_like_range_max() {}
1609 };
1610 #endif
1611 
1612 
1614 {
1615 public:
1616  virtual Item *create(THD *thd, Item *arg1);
1617 
1618  static Create_func_ln s_singleton;
1619 
1620 protected:
1621  Create_func_ln() {}
1622  virtual ~Create_func_ln() {}
1623 };
1624 
1625 
1627 {
1628 public:
1629  virtual Item *create(THD *thd, Item *arg1);
1630 
1631  static Create_func_load_file s_singleton;
1632 
1633 protected:
1635  virtual ~Create_func_load_file() {}
1636 };
1637 
1638 
1640 {
1641 public:
1642  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1643 
1644  static Create_func_locate s_singleton;
1645 
1646 protected:
1647  Create_func_locate() {}
1648  virtual ~Create_func_locate() {}
1649 };
1650 
1651 
1653 {
1654 public:
1655  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1656 
1657  static Create_func_log s_singleton;
1658 
1659 protected:
1660  Create_func_log() {}
1661  virtual ~Create_func_log() {}
1662 };
1663 
1664 
1666 {
1667 public:
1668  virtual Item *create(THD *thd, Item *arg1);
1669 
1670  static Create_func_log10 s_singleton;
1671 
1672 protected:
1673  Create_func_log10() {}
1674  virtual ~Create_func_log10() {}
1675 };
1676 
1677 
1679 {
1680 public:
1681  virtual Item *create(THD *thd, Item *arg1);
1682 
1683  static Create_func_log2 s_singleton;
1684 
1685 protected:
1686  Create_func_log2() {}
1687  virtual ~Create_func_log2() {}
1688 };
1689 
1690 
1692 {
1693 public:
1694  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
1695 
1696  static Create_func_lpad s_singleton;
1697 
1698 protected:
1699  Create_func_lpad() {}
1700  virtual ~Create_func_lpad() {}
1701 };
1702 
1703 
1705 {
1706 public:
1707  virtual Item *create(THD *thd, Item *arg1);
1708 
1709  static Create_func_ltrim s_singleton;
1710 
1711 protected:
1712  Create_func_ltrim() {}
1713  virtual ~Create_func_ltrim() {}
1714 };
1715 
1716 
1718 {
1719 public:
1720  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1721 
1722  static Create_func_makedate s_singleton;
1723 
1724 protected:
1726  virtual ~Create_func_makedate() {}
1727 };
1728 
1729 
1731 {
1732 public:
1733  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
1734 
1735  static Create_func_maketime s_singleton;
1736 
1737 protected:
1739  virtual ~Create_func_maketime() {}
1740 };
1741 
1742 
1744 {
1745 public:
1746  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1747 
1748  static Create_func_make_set s_singleton;
1749 
1750 protected:
1752  virtual ~Create_func_make_set() {}
1753 };
1754 
1755 
1757 {
1758 public:
1759  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1760 
1761  static Create_func_master_pos_wait s_singleton;
1762 
1763 protected:
1765  virtual ~Create_func_master_pos_wait() {}
1766 };
1767 
1769 {
1770 public:
1771  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
1772 
1773  static Create_func_master_gtid_set_wait s_singleton;
1774 
1775 protected:
1777  virtual ~Create_func_master_gtid_set_wait() {}
1778 };
1779 
1781 {
1782 public:
1783  virtual Item *create(THD *thd, Item *arg1);
1784 
1785  static Create_func_md5 s_singleton;
1786 
1787 protected:
1788  Create_func_md5() {}
1789  virtual ~Create_func_md5() {}
1790 };
1791 
1792 
1794 {
1795 public:
1796  virtual Item *create(THD *thd, Item *arg1);
1797 
1798  static Create_func_monthname s_singleton;
1799 
1800 protected:
1802  virtual ~Create_func_monthname() {}
1803 };
1804 
1805 
1807 {
1808 public:
1809  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1810 
1811  static Create_func_name_const s_singleton;
1812 
1813 protected:
1815  virtual ~Create_func_name_const() {}
1816 };
1817 
1818 
1820 {
1821 public:
1822  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1823 
1824  static Create_func_nullif s_singleton;
1825 
1826 protected:
1827  Create_func_nullif() {}
1828  virtual ~Create_func_nullif() {}
1829 };
1830 
1831 
1832 #ifdef HAVE_SPATIAL
1833 class Create_func_numgeometries : public Create_func_arg1
1834 {
1835 public:
1836  virtual Item *create(THD *thd, Item *arg1);
1837 
1838  static Create_func_numgeometries s_singleton;
1839 
1840 protected:
1841  Create_func_numgeometries() {}
1842  virtual ~Create_func_numgeometries() {}
1843 };
1844 #endif
1845 
1846 
1847 #ifdef HAVE_SPATIAL
1848 class Create_func_numinteriorring : public Create_func_arg1
1849 {
1850 public:
1851  virtual Item *create(THD *thd, Item *arg1);
1852 
1853  static Create_func_numinteriorring s_singleton;
1854 
1855 protected:
1856  Create_func_numinteriorring() {}
1857  virtual ~Create_func_numinteriorring() {}
1858 };
1859 #endif
1860 
1861 
1862 #ifdef HAVE_SPATIAL
1863 class Create_func_numpoints : public Create_func_arg1
1864 {
1865 public:
1866  virtual Item *create(THD *thd, Item *arg1);
1867 
1868  static Create_func_numpoints s_singleton;
1869 
1870 protected:
1871  Create_func_numpoints() {}
1872  virtual ~Create_func_numpoints() {}
1873 };
1874 #endif
1875 
1876 
1878 {
1879 public:
1880  virtual Item *create(THD *thd, Item *arg1);
1881 
1882  static Create_func_oct s_singleton;
1883 
1884 protected:
1885  Create_func_oct() {}
1886  virtual ~Create_func_oct() {}
1887 };
1888 
1889 
1891 {
1892 public:
1893  virtual Item *create(THD *thd, Item *arg1);
1894 
1895  static Create_func_ord s_singleton;
1896 
1897 protected:
1898  Create_func_ord() {}
1899  virtual ~Create_func_ord() {}
1900 };
1901 
1902 
1903 #ifdef HAVE_SPATIAL
1904 class Create_func_mbr_overlaps : public Create_func_arg2
1905 {
1906 public:
1907  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1908 
1909  static Create_func_mbr_overlaps s_singleton;
1910 
1911 protected:
1912  Create_func_mbr_overlaps() {}
1913  virtual ~Create_func_mbr_overlaps() {}
1914 };
1915 
1916 
1917 class Create_func_overlaps : public Create_func_arg2
1918 {
1919 public:
1920  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1921 
1922  static Create_func_overlaps s_singleton;
1923 
1924 protected:
1925  Create_func_overlaps() {}
1926  virtual ~Create_func_overlaps() {}
1927 };
1928 #endif
1929 
1930 
1932 {
1933 public:
1934  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1935 
1936  static Create_func_period_add s_singleton;
1937 
1938 protected:
1940  virtual ~Create_func_period_add() {}
1941 };
1942 
1943 
1945 {
1946 public:
1947  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1948 
1949  static Create_func_period_diff s_singleton;
1950 
1951 protected:
1953  virtual ~Create_func_period_diff() {}
1954 };
1955 
1956 
1958 {
1959 public:
1960  virtual Item *create(THD *thd);
1961 
1962  static Create_func_pi s_singleton;
1963 
1964 protected:
1965  Create_func_pi() {}
1966  virtual ~Create_func_pi() {}
1967 };
1968 
1969 
1970 #ifdef HAVE_SPATIAL
1971 class Create_func_pointn : public Create_func_arg2
1972 {
1973 public:
1974  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1975 
1976  static Create_func_pointn s_singleton;
1977 
1978 protected:
1979  Create_func_pointn() {}
1980  virtual ~Create_func_pointn() {}
1981 };
1982 #endif
1983 
1984 
1986 {
1987 public:
1988  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
1989 
1990  static Create_func_pow s_singleton;
1991 
1992 protected:
1993  Create_func_pow() {}
1994  virtual ~Create_func_pow() {}
1995 };
1996 
1997 
1999 {
2000 public:
2001  virtual Item *create(THD *thd, Item *arg1);
2002 
2003  static Create_func_quote s_singleton;
2004 
2005 protected:
2006  Create_func_quote() {}
2007  virtual ~Create_func_quote() {}
2008 };
2009 
2010 
2012 {
2013 public:
2014  virtual Item *create(THD *thd, Item *arg1);
2015 
2016  static Create_func_radians s_singleton;
2017 
2018 protected:
2019  Create_func_radians() {}
2020  virtual ~Create_func_radians() {}
2021 };
2022 
2023 
2025 {
2026 public:
2027  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
2028 
2029  static Create_func_rand s_singleton;
2030 
2031 protected:
2032  Create_func_rand() {}
2033  virtual ~Create_func_rand() {}
2034 };
2035 
2036 
2038 {
2039 public:
2040  virtual Item *create(THD *thd, Item *arg1);
2041 
2042  static Create_func_release_lock s_singleton;
2043 
2044 protected:
2046  virtual ~Create_func_release_lock() {}
2047 };
2048 
2049 
2051 {
2052 public:
2053  virtual Item *create(THD *thd, Item *arg1);
2054 
2055  static Create_func_reverse s_singleton;
2056 
2057 protected:
2058  Create_func_reverse() {}
2059  virtual ~Create_func_reverse() {}
2060 };
2061 
2062 
2064 {
2065 public:
2066  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
2067 
2068  static Create_func_round s_singleton;
2069 
2070 protected:
2071  Create_func_round() {}
2072  virtual ~Create_func_round() {}
2073 };
2074 
2075 
2077 {
2078 public:
2079  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
2080 
2081  static Create_func_rpad s_singleton;
2082 
2083 protected:
2084  Create_func_rpad() {}
2085  virtual ~Create_func_rpad() {}
2086 };
2087 
2088 
2090 {
2091 public:
2092  virtual Item *create(THD *thd, Item *arg1);
2093 
2094  static Create_func_rtrim s_singleton;
2095 
2096 protected:
2097  Create_func_rtrim() {}
2098  virtual ~Create_func_rtrim() {}
2099 };
2100 
2101 
2103 {
2104 public:
2105  virtual Item *create(THD *thd, Item *arg1);
2106 
2107  static Create_func_sec_to_time s_singleton;
2108 
2109 protected:
2111  virtual ~Create_func_sec_to_time() {}
2112 };
2113 
2114 
2116 {
2117 public:
2118  virtual Item *create(THD *thd, Item *arg1);
2119 
2120  static Create_func_sha s_singleton;
2121 
2122 protected:
2123  Create_func_sha() {}
2124  virtual ~Create_func_sha() {}
2125 };
2126 
2127 
2129 {
2130 public:
2131  virtual Item* create(THD *thd, Item *arg1, Item *arg2);
2132 
2133  static Create_func_sha2 s_singleton;
2134 
2135 protected:
2136  Create_func_sha2() {}
2137  virtual ~Create_func_sha2() {}
2138 };
2139 
2140 
2142 {
2143 public:
2144  virtual Item *create(THD *thd, Item *arg1);
2145 
2146  static Create_func_sign s_singleton;
2147 
2148 protected:
2149  Create_func_sign() {}
2150  virtual ~Create_func_sign() {}
2151 };
2152 
2153 
2155 {
2156 public:
2157  virtual Item *create(THD *thd, Item *arg1);
2158 
2159  static Create_func_sin s_singleton;
2160 
2161 protected:
2162  Create_func_sin() {}
2163  virtual ~Create_func_sin() {}
2164 };
2165 
2166 
2168 {
2169 public:
2170  virtual Item *create(THD *thd, Item *arg1);
2171 
2172  static Create_func_sleep s_singleton;
2173 
2174 protected:
2175  Create_func_sleep() {}
2176  virtual ~Create_func_sleep() {}
2177 };
2178 
2179 
2181 {
2182 public:
2183  virtual Item *create(THD *thd, Item *arg1);
2184 
2185  static Create_func_soundex s_singleton;
2186 
2187 protected:
2188  Create_func_soundex() {}
2189  virtual ~Create_func_soundex() {}
2190 };
2191 
2192 
2194 {
2195 public:
2196  virtual Item *create(THD *thd, Item *arg1);
2197 
2198  static Create_func_space s_singleton;
2199 
2200 protected:
2201  Create_func_space() {}
2202  virtual ~Create_func_space() {}
2203 };
2204 
2205 
2207 {
2208 public:
2209  virtual Item *create(THD *thd, Item *arg1);
2210 
2211  static Create_func_sqrt s_singleton;
2212 
2213 protected:
2214  Create_func_sqrt() {}
2215  virtual ~Create_func_sqrt() {}
2216 };
2217 
2218 
2219 #ifdef HAVE_SPATIAL
2220 class Create_func_srid : public Create_func_arg1
2221 {
2222 public:
2223  virtual Item *create(THD *thd, Item *arg1);
2224 
2225  static Create_func_srid s_singleton;
2226 
2227 protected:
2228  Create_func_srid() {}
2229  virtual ~Create_func_srid() {}
2230 };
2231 #endif
2232 
2233 
2234 #ifdef HAVE_SPATIAL
2235 class Create_func_startpoint : public Create_func_arg1
2236 {
2237 public:
2238  virtual Item *create(THD *thd, Item *arg1);
2239 
2240  static Create_func_startpoint s_singleton;
2241 
2242 protected:
2243  Create_func_startpoint() {}
2244  virtual ~Create_func_startpoint() {}
2245 };
2246 #endif
2247 
2248 
2250 {
2251 public:
2252  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
2253 
2254  static Create_func_str_to_date s_singleton;
2255 
2256 protected:
2258  virtual ~Create_func_str_to_date() {}
2259 };
2260 
2261 
2263 {
2264 public:
2265  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
2266 
2267  static Create_func_strcmp s_singleton;
2268 
2269 protected:
2270  Create_func_strcmp() {}
2271  virtual ~Create_func_strcmp() {}
2272 };
2273 
2274 
2276 {
2277 public:
2278  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
2279 
2280  static Create_func_substr_index s_singleton;
2281 
2282 protected:
2284  virtual ~Create_func_substr_index() {}
2285 };
2286 
2287 
2289 {
2290 public:
2291  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
2292 
2293  static Create_func_subtime s_singleton;
2294 
2295 protected:
2296  Create_func_subtime() {}
2297  virtual ~Create_func_subtime() {}
2298 };
2299 
2300 
2302 {
2303 public:
2304  virtual Item *create(THD *thd, Item *arg1);
2305 
2306  static Create_func_tan s_singleton;
2307 
2308 protected:
2309  Create_func_tan() {}
2310  virtual ~Create_func_tan() {}
2311 };
2312 
2313 
2315 {
2316 public:
2317  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
2318 
2319  static Create_func_time_format s_singleton;
2320 
2321 protected:
2323  virtual ~Create_func_time_format() {}
2324 };
2325 
2326 
2328 {
2329 public:
2330  virtual Item *create(THD *thd, Item *arg1);
2331 
2332  static Create_func_time_to_sec s_singleton;
2333 
2334 protected:
2336  virtual ~Create_func_time_to_sec() {}
2337 };
2338 
2339 
2341 {
2342 public:
2343  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
2344 
2345  static Create_func_timediff s_singleton;
2346 
2347 protected:
2349  virtual ~Create_func_timediff() {}
2350 };
2351 
2352 
2354 {
2355 public:
2356  virtual Item *create(THD *thd, Item *arg1);
2357 
2358  static Create_func_to_base64 s_singleton;
2359 
2360 protected:
2362  virtual ~Create_func_to_base64() {}
2363 };
2364 
2365 
2367 {
2368 public:
2369  virtual Item *create(THD *thd, Item *arg1);
2370 
2371  static Create_func_to_days s_singleton;
2372 
2373 protected:
2374  Create_func_to_days() {}
2375  virtual ~Create_func_to_days() {}
2376 };
2377 
2379 {
2380 public:
2381  virtual Item* create(THD *thd, Item *arg1);
2382 
2383  static Create_func_to_seconds s_singleton;
2384 
2385 protected:
2387  virtual ~Create_func_to_seconds() {}
2388 };
2389 
2390 
2391 #ifdef HAVE_SPATIAL
2392 class Create_func_touches : public Create_func_arg2
2393 {
2394 public:
2395  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
2396 
2397  static Create_func_touches s_singleton;
2398 
2399 protected:
2400  Create_func_touches() {}
2401  virtual ~Create_func_touches() {}
2402 };
2403 #endif
2404 
2405 
2407 {
2408 public:
2409  virtual Item *create(THD *thd, Item *arg1);
2410 
2411  static Create_func_ucase s_singleton;
2412 
2413 protected:
2414  Create_func_ucase() {}
2415  virtual ~Create_func_ucase() {}
2416 };
2417 
2418 
2420 {
2421 public:
2422  virtual Item *create(THD *thd, Item *arg1);
2423 
2424  static Create_func_uncompress s_singleton;
2425 
2426 protected:
2428  virtual ~Create_func_uncompress() {}
2429 };
2430 
2431 
2433 {
2434 public:
2435  virtual Item *create(THD *thd, Item *arg1);
2436 
2437  static Create_func_uncompressed_length s_singleton;
2438 
2439 protected:
2441  virtual ~Create_func_uncompressed_length() {}
2442 };
2443 
2444 
2446 {
2447 public:
2448  virtual Item *create(THD *thd, Item *arg1);
2449 
2450  static Create_func_unhex s_singleton;
2451 
2452 protected:
2453  Create_func_unhex() {}
2454  virtual ~Create_func_unhex() {}
2455 };
2456 
2457 
2459 {
2460 public:
2461  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
2462 
2463  static Create_func_unix_timestamp s_singleton;
2464 
2465 protected:
2467  virtual ~Create_func_unix_timestamp() {}
2468 };
2469 
2470 
2472 {
2473 public:
2474  virtual Item *create(THD *thd);
2475 
2476  static Create_func_uuid s_singleton;
2477 
2478 protected:
2479  Create_func_uuid() {}
2480  virtual ~Create_func_uuid() {}
2481 };
2482 
2483 
2485 {
2486 public:
2487  virtual Item *create(THD *thd);
2488 
2489  static Create_func_uuid_short s_singleton;
2490 
2491 protected:
2493  virtual ~Create_func_uuid_short() {}
2494 };
2495 
2496 
2498 {
2499 public:
2500  virtual Item *create(THD *thd, Item *arg1);
2501 
2502  static Create_func_validate_password_strength s_singleton;
2503 
2504 protected:
2507 };
2508 
2509 
2511 {
2512 public:
2513  virtual Item *create(THD *thd);
2514 
2515  static Create_func_version s_singleton;
2516 
2517 protected:
2518  Create_func_version() {}
2519  virtual ~Create_func_version() {}
2520 };
2521 
2522 
2524 {
2525 public:
2526  virtual Item *create(THD *thd, Item *arg1);
2527 
2528  static Create_func_weekday s_singleton;
2529 
2530 protected:
2531  Create_func_weekday() {}
2532  virtual ~Create_func_weekday() {}
2533 };
2534 
2535 
2537 {
2538 public:
2539  virtual Item *create(THD *thd, Item *arg1);
2540 
2541  static Create_func_weekofyear s_singleton;
2542 
2543 protected:
2545  virtual ~Create_func_weekofyear() {}
2546 };
2547 
2548 
2549 #ifdef HAVE_SPATIAL
2550 class Create_func_mbr_within : public Create_func_arg2
2551 {
2552 public:
2553  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
2554 
2555  static Create_func_mbr_within s_singleton;
2556 
2557 protected:
2558  Create_func_mbr_within() {}
2559  virtual ~Create_func_mbr_within() {}
2560 };
2561 
2562 
2563 class Create_func_within : public Create_func_arg2
2564 {
2565 public:
2566  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
2567 
2568  static Create_func_within s_singleton;
2569 
2570 protected:
2571  Create_func_within() {}
2572  virtual ~Create_func_within() {}
2573 };
2574 #endif
2575 
2576 
2577 #ifdef HAVE_SPATIAL
2578 class Create_func_x : public Create_func_arg1
2579 {
2580 public:
2581  virtual Item *create(THD *thd, Item *arg1);
2582 
2583  static Create_func_x s_singleton;
2584 
2585 protected:
2586  Create_func_x() {}
2587  virtual ~Create_func_x() {}
2588 };
2589 #endif
2590 
2591 
2593 {
2594 public:
2595  virtual Item *create(THD *thd, Item *arg1, Item *arg2);
2596 
2597  static Create_func_xml_extractvalue s_singleton;
2598 
2599 protected:
2601  virtual ~Create_func_xml_extractvalue() {}
2602 };
2603 
2604 
2606 {
2607 public:
2608  virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3);
2609 
2610  static Create_func_xml_update s_singleton;
2611 
2612 protected:
2614  virtual ~Create_func_xml_update() {}
2615 };
2616 
2617 
2618 #ifdef HAVE_SPATIAL
2619 class Create_func_y : public Create_func_arg1
2620 {
2621 public:
2622  virtual Item *create(THD *thd, Item *arg1);
2623 
2624  static Create_func_y s_singleton;
2625 
2626 protected:
2627  Create_func_y() {}
2628  virtual ~Create_func_y() {}
2629 };
2630 #endif
2631 
2632 
2634 {
2635 public:
2636  virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
2637 
2638  static Create_func_year_week s_singleton;
2639 
2640 protected:
2642  virtual ~Create_func_year_week() {}
2643 };
2644 
2645 
2646 /*
2647 =============================================================================
2648  IMPLEMENTATION
2649 =============================================================================
2650 */
2651 
2659 static bool has_named_parameters(List<Item> *params)
2660 {
2661  if (params)
2662  {
2663  Item *param;
2664  List_iterator<Item> it(*params);
2665  while ((param= it++))
2666  {
2667  if (! param->item_name.is_autogenerated())
2668  return true;
2669  }
2670  }
2671 
2672  return false;
2673 }
2674 
2675 #ifndef HAVE_SPATIAL
2677 
2678 Item*
2680  LEX_STRING /* unused */,
2681  List<Item> * /* unused */)
2682 {
2683  /* FIXME: error message can't be translated. */
2684  my_error(ER_FEATURE_DISABLED, MYF(0),
2685  sym_group_geom.name, sym_group_geom.needed_define);
2686  return NULL;
2687 }
2688 #endif
2689 
2690 
2691 Item*
2693 {
2694  LEX_STRING db;
2695 
2696  if (! thd->db && ! thd->lex->sphead)
2697  {
2698  /*
2699  The proper error message should be in the lines of:
2700  Can't resolve <name>() to a function call,
2701  because this function:
2702  - is not a native function,
2703  - is not a user defined function,
2704  - can not match a qualified (read: stored) function
2705  since no database is selected.
2706  Reusing ER_SP_DOES_NOT_EXIST have a message consistent with
2707  the case when a default database exist, see Create_sp_func::create().
2708  */
2709  my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
2710  "FUNCTION", name.str);
2711  return NULL;
2712  }
2713 
2714  if (thd->lex->copy_db_to(&db.str, &db.length))
2715  return NULL;
2716 
2717  return create(thd, db, name, false, item_list);
2718 }
2719 
2720 
2721 #ifdef HAVE_DLOPEN
2722 Create_udf_func Create_udf_func::s_singleton;
2723 
2724 Item*
2725 Create_udf_func::create_func(THD *thd, LEX_STRING name, List<Item> *item_list)
2726 {
2727  udf_func *udf= find_udf(name.str, name.length);
2728  DBUG_ASSERT(udf);
2729  return create(thd, udf, item_list);
2730 }
2731 
2732 
2733 Item*
2734 Create_udf_func::create(THD *thd, udf_func *udf, List<Item> *item_list)
2735 {
2736  Item *func= NULL;
2737  int arg_count= 0;
2738 
2739  DBUG_ENTER("Create_udf_func::create");
2740  if (item_list != NULL)
2741  arg_count= item_list->elements;
2742 
2743  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_UDF);
2744 
2745  DBUG_ASSERT( (udf->type == UDFTYPE_FUNCTION)
2746  || (udf->type == UDFTYPE_AGGREGATE));
2747 
2748  switch(udf->returns) {
2749  case STRING_RESULT:
2750  {
2751  if (udf->type == UDFTYPE_FUNCTION)
2752  {
2753  if (arg_count)
2754  func= new (thd->mem_root) Item_func_udf_str(udf, *item_list);
2755  else
2756  func= new (thd->mem_root) Item_func_udf_str(udf);
2757  }
2758  else
2759  {
2760  if (arg_count)
2761  func= new (thd->mem_root) Item_sum_udf_str(udf, *item_list);
2762  else
2763  func= new (thd->mem_root) Item_sum_udf_str(udf);
2764  }
2765  break;
2766  }
2767  case REAL_RESULT:
2768  {
2769  if (udf->type == UDFTYPE_FUNCTION)
2770  {
2771  if (arg_count)
2772  func= new (thd->mem_root) Item_func_udf_float(udf, *item_list);
2773  else
2774  func= new (thd->mem_root) Item_func_udf_float(udf);
2775  }
2776  else
2777  {
2778  if (arg_count)
2779  func= new (thd->mem_root) Item_sum_udf_float(udf, *item_list);
2780  else
2781  func= new (thd->mem_root) Item_sum_udf_float(udf);
2782  }
2783  break;
2784  }
2785  case INT_RESULT:
2786  {
2787  if (udf->type == UDFTYPE_FUNCTION)
2788  {
2789  if (arg_count)
2790  func= new (thd->mem_root) Item_func_udf_int(udf, *item_list);
2791  else
2792  func= new (thd->mem_root) Item_func_udf_int(udf);
2793  }
2794  else
2795  {
2796  if (arg_count)
2797  func= new (thd->mem_root) Item_sum_udf_int(udf, *item_list);
2798  else
2799  func= new (thd->mem_root) Item_sum_udf_int(udf);
2800  }
2801  break;
2802  }
2803  case DECIMAL_RESULT:
2804  {
2805  if (udf->type == UDFTYPE_FUNCTION)
2806  {
2807  if (arg_count)
2808  func= new (thd->mem_root) Item_func_udf_decimal(udf, *item_list);
2809  else
2810  func= new (thd->mem_root) Item_func_udf_decimal(udf);
2811  }
2812  else
2813  {
2814  if (arg_count)
2815  func= new (thd->mem_root) Item_sum_udf_decimal(udf, *item_list);
2816  else
2817  func= new (thd->mem_root) Item_sum_udf_decimal(udf);
2818  }
2819  break;
2820  }
2821  default:
2822  {
2823  my_error(ER_NOT_SUPPORTED_YET, MYF(0), "UDF return type");
2824  }
2825  }
2826  thd->lex->safe_to_cache_query= 0;
2827  DBUG_RETURN(func);
2828 }
2829 #endif
2830 
2831 
2832 Create_sp_func Create_sp_func::s_singleton;
2833 
2834 Item*
2836  bool use_explicit_name, List<Item> *item_list)
2837 {
2838  int arg_count= 0;
2839  Item *func= NULL;
2840  LEX *lex= thd->lex;
2841  sp_name *qname;
2842 
2843  if (has_named_parameters(item_list))
2844  {
2845  /*
2846  The syntax "db.foo(expr AS p1, expr AS p2, ...) is invalid,
2847  and has been rejected during syntactic parsing already,
2848  because a stored function call may not have named parameters.
2849 
2850  The syntax "foo(expr AS p1, expr AS p2, ...)" is correct,
2851  because it can refer to a User Defined Function call.
2852  For a Stored Function however, this has no semantic.
2853  */
2854  my_error(ER_WRONG_PARAMETERS_TO_STORED_FCT, MYF(0), name.str);
2855  return NULL;
2856  }
2857 
2858  if (item_list != NULL)
2859  arg_count= item_list->elements;
2860 
2861  qname= new (thd->mem_root) sp_name(db, name, use_explicit_name);
2862  qname->init_qname(thd);
2863  sp_add_used_routine(lex, thd, qname, SP_TYPE_FUNCTION);
2864 
2865  if (arg_count > 0)
2866  func= new (thd->mem_root) Item_func_sp(lex->current_context(), qname,
2867  *item_list);
2868  else
2869  func= new (thd->mem_root) Item_func_sp(lex->current_context(), qname);
2870 
2871  lex->safe_to_cache_query= 0;
2872  return func;
2873 }
2874 
2875 
2876 Item*
2878 {
2879  if (has_named_parameters(item_list))
2880  {
2881  my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
2882  return NULL;
2883  }
2884 
2885  return create_native(thd, name, item_list);
2886 }
2887 
2888 
2889 Item*
2891 {
2892  int arg_count= 0;
2893 
2894  if (item_list != NULL)
2895  arg_count= item_list->elements;
2896 
2897  if (arg_count != 0)
2898  {
2899  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2900  return NULL;
2901  }
2902 
2903  return create(thd);
2904 }
2905 
2906 
2907 Item*
2909 {
2910  int arg_count= 0;
2911 
2912  if (item_list)
2913  arg_count= item_list->elements;
2914 
2915  if (arg_count != 1)
2916  {
2917  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2918  return NULL;
2919  }
2920 
2921  Item *param_1= item_list->pop();
2922 
2923  if (! param_1->item_name.is_autogenerated())
2924  {
2925  my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
2926  return NULL;
2927  }
2928 
2929  return create(thd, param_1);
2930 }
2931 
2932 
2933 Item*
2935 {
2936  int arg_count= 0;
2937 
2938  if (item_list)
2939  arg_count= item_list->elements;
2940 
2941  if (arg_count != 2)
2942  {
2943  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2944  return NULL;
2945  }
2946 
2947  Item *param_1= item_list->pop();
2948  Item *param_2= item_list->pop();
2949 
2950  if ( (! param_1->item_name.is_autogenerated())
2951  || (! param_2->item_name.is_autogenerated()))
2952  {
2953  my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
2954  return NULL;
2955  }
2956 
2957  return create(thd, param_1, param_2);
2958 }
2959 
2960 
2961 Item*
2963 {
2964  int arg_count= 0;
2965 
2966  if (item_list)
2967  arg_count= item_list->elements;
2968 
2969  if (arg_count != 3)
2970  {
2971  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2972  return NULL;
2973  }
2974 
2975  Item *param_1= item_list->pop();
2976  Item *param_2= item_list->pop();
2977  Item *param_3= item_list->pop();
2978 
2979  if ( (! param_1->item_name.is_autogenerated())
2980  || (! param_2->item_name.is_autogenerated())
2981  || (! param_3->item_name.is_autogenerated()))
2982  {
2983  my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
2984  return NULL;
2985  }
2986 
2987  return create(thd, param_1, param_2, param_3);
2988 }
2989 
2990 
2991 Create_func_abs Create_func_abs::s_singleton;
2992 
2993 Item*
2995 {
2996  return new (thd->mem_root) Item_func_abs(arg1);
2997 }
2998 
2999 
3000 Create_func_acos Create_func_acos::s_singleton;
3001 
3002 Item*
3004 {
3005  return new (thd->mem_root) Item_func_acos(arg1);
3006 }
3007 
3008 
3009 Create_func_addtime Create_func_addtime::s_singleton;
3010 
3011 Item*
3012 Create_func_addtime::create(THD *thd, Item *arg1, Item *arg2)
3013 {
3014  return new (thd->mem_root) Item_func_add_time(arg1, arg2, 0, 0);
3015 }
3016 
3017 
3018 Create_func_aes_encrypt Create_func_aes_encrypt::s_singleton;
3019 
3020 Item*
3022 {
3023  return new (thd->mem_root) Item_func_aes_encrypt(arg1, arg2);
3024 }
3025 
3026 
3027 Create_func_aes_decrypt Create_func_aes_decrypt::s_singleton;
3028 
3029 Item*
3031 {
3032  return new (thd->mem_root) Item_func_aes_decrypt(arg1, arg2);
3033 }
3034 
3035 
3036 #ifdef HAVE_SPATIAL
3037 Create_func_area Create_func_area::s_singleton;
3038 
3039 Item*
3040 Create_func_area::create(THD *thd, Item *arg1)
3041 {
3042  return new (thd->mem_root) Item_func_area(arg1);
3043 }
3044 #endif
3045 
3046 
3047 #ifdef HAVE_SPATIAL
3048 Create_func_as_wkb Create_func_as_wkb::s_singleton;
3049 
3050 Item*
3051 Create_func_as_wkb::create(THD *thd, Item *arg1)
3052 {
3053  return new (thd->mem_root) Item_func_as_wkb(arg1);
3054 }
3055 #endif
3056 
3057 
3058 #ifdef HAVE_SPATIAL
3059 Create_func_as_wkt Create_func_as_wkt::s_singleton;
3060 
3061 Item*
3062 Create_func_as_wkt::create(THD *thd, Item *arg1)
3063 {
3064  return new (thd->mem_root) Item_func_as_wkt(arg1);
3065 }
3066 #endif
3067 
3068 
3069 Create_func_asin Create_func_asin::s_singleton;
3070 
3071 Item*
3073 {
3074  return new (thd->mem_root) Item_func_asin(arg1);
3075 }
3076 
3077 
3078 Create_func_atan Create_func_atan::s_singleton;
3079 
3080 Item*
3082  List<Item> *item_list)
3083 {
3084  Item* func= NULL;
3085  int arg_count= 0;
3086 
3087  if (item_list != NULL)
3088  arg_count= item_list->elements;
3089 
3090  switch (arg_count) {
3091  case 1:
3092  {
3093  Item *param_1= item_list->pop();
3094  func= new (thd->mem_root) Item_func_atan(param_1);
3095  break;
3096  }
3097  case 2:
3098  {
3099  Item *param_1= item_list->pop();
3100  Item *param_2= item_list->pop();
3101  func= new (thd->mem_root) Item_func_atan(param_1, param_2);
3102  break;
3103  }
3104  default:
3105  {
3106  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3107  break;
3108  }
3109  }
3110 
3111  return func;
3112 }
3113 
3114 
3115 Create_func_benchmark Create_func_benchmark::s_singleton;
3116 
3117 Item*
3118 Create_func_benchmark::create(THD *thd, Item *arg1, Item *arg2)
3119 {
3120  thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
3121  return new (thd->mem_root) Item_func_benchmark(arg1, arg2);
3122 }
3123 
3124 
3125 Create_func_bin Create_func_bin::s_singleton;
3126 
3127 Item*
3129 {
3130  Item *i10= new (thd->mem_root) Item_int((int32) 10,2);
3131  Item *i2= new (thd->mem_root) Item_int((int32) 2,1);
3132  return new (thd->mem_root) Item_func_conv(arg1, i10, i2);
3133 }
3134 
3135 
3136 Create_func_bit_count Create_func_bit_count::s_singleton;
3137 
3138 Item*
3140 {
3141  return new (thd->mem_root) Item_func_bit_count(arg1);
3142 }
3143 
3144 
3145 Create_func_bit_length Create_func_bit_length::s_singleton;
3146 
3147 Item*
3149 {
3150  return new (thd->mem_root) Item_func_bit_length(arg1);
3151 }
3152 
3153 
3154 Create_func_ceiling Create_func_ceiling::s_singleton;
3155 
3156 Item*
3158 {
3159  return new (thd->mem_root) Item_func_ceiling(arg1);
3160 }
3161 
3162 
3163 #ifdef HAVE_SPATIAL
3164 Create_func_centroid Create_func_centroid::s_singleton;
3165 
3166 Item*
3167 Create_func_centroid::create(THD *thd, Item *arg1)
3168 {
3169  return new (thd->mem_root) Item_func_centroid(arg1);
3170 }
3171 #endif
3172 
3173 
3174 Create_func_char_length Create_func_char_length::s_singleton;
3175 
3176 Item*
3178 {
3179  return new (thd->mem_root) Item_func_char_length(arg1);
3180 }
3181 
3182 
3183 Create_func_coercibility Create_func_coercibility::s_singleton;
3184 
3185 Item*
3187 {
3188  return new (thd->mem_root) Item_func_coercibility(arg1);
3189 }
3190 
3191 
3192 Create_func_concat Create_func_concat::s_singleton;
3193 
3194 Item*
3196  List<Item> *item_list)
3197 {
3198  int arg_count= 0;
3199 
3200  if (item_list != NULL)
3201  arg_count= item_list->elements;
3202 
3203  if (arg_count < 1)
3204  {
3205  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3206  return NULL;
3207  }
3208 
3209  return new (thd->mem_root) Item_func_concat(*item_list);
3210 }
3211 
3212 
3213 Create_func_concat_ws Create_func_concat_ws::s_singleton;
3214 
3215 Item*
3217  List<Item> *item_list)
3218 {
3219  int arg_count= 0;
3220 
3221  if (item_list != NULL)
3222  arg_count= item_list->elements;
3223 
3224  /* "WS" stands for "With Separator": this function takes 2+ arguments */
3225  if (arg_count < 2)
3226  {
3227  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3228  return NULL;
3229  }
3230 
3231  return new (thd->mem_root) Item_func_concat_ws(*item_list);
3232 }
3233 
3234 
3235 Create_func_compress Create_func_compress::s_singleton;
3236 
3237 Item*
3239 {
3240  return new (thd->mem_root) Item_func_compress(arg1);
3241 }
3242 
3243 
3244 Create_func_connection_id Create_func_connection_id::s_singleton;
3245 
3246 Item*
3248 {
3249  thd->lex->safe_to_cache_query= 0;
3250  return new (thd->mem_root) Item_func_connection_id();
3251 }
3252 
3253 
3254 #ifdef HAVE_SPATIAL
3255 Create_func_mbr_contains Create_func_mbr_contains::s_singleton;
3256 
3257 Item*
3258 Create_func_mbr_contains::create(THD *thd, Item *arg1, Item *arg2)
3259 {
3260  return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
3261  Item_func::SP_CONTAINS_FUNC);
3262 }
3263 
3264 
3265 Create_func_contains Create_func_contains::s_singleton;
3266 
3267 Item*
3268 Create_func_contains::create(THD *thd, Item *arg1, Item *arg2)
3269 {
3270  return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
3271  Item_func::SP_CONTAINS_FUNC);
3272 }
3273 #endif
3274 
3275 
3276 Create_func_conv Create_func_conv::s_singleton;
3277 
3278 Item*
3279 Create_func_conv::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
3280 {
3281  return new (thd->mem_root) Item_func_conv(arg1, arg2, arg3);
3282 }
3283 
3284 
3285 Create_func_convert_tz Create_func_convert_tz::s_singleton;
3286 
3287 Item*
3288 Create_func_convert_tz::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
3289 {
3290  return new (thd->mem_root) Item_func_convert_tz(arg1, arg2, arg3);
3291 }
3292 
3293 
3294 Create_func_cos Create_func_cos::s_singleton;
3295 
3296 Item*
3298 {
3299  return new (thd->mem_root) Item_func_cos(arg1);
3300 }
3301 
3302 
3303 Create_func_cot Create_func_cot::s_singleton;
3304 
3305 Item*
3307 {
3308  return new (thd->mem_root) Item_func_cot(arg1);
3309 }
3310 
3311 
3312 Create_func_crc32 Create_func_crc32::s_singleton;
3313 
3314 Item*
3316 {
3317  return new (thd->mem_root) Item_func_crc32(arg1);
3318 }
3319 
3320 
3321 #ifdef HAVE_SPATIAL
3322 Create_func_crosses Create_func_crosses::s_singleton;
3323 
3324 Item*
3325 Create_func_crosses::create(THD *thd, Item *arg1, Item *arg2)
3326 {
3327  return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
3328  Item_func::SP_CROSSES_FUNC);
3329 }
3330 #endif
3331 
3332 
3333 Create_func_date_format Create_func_date_format::s_singleton;
3334 
3335 Item*
3337 {
3338  return new (thd->mem_root) Item_func_date_format(arg1, arg2, 0);
3339 }
3340 
3341 
3342 Create_func_datediff Create_func_datediff::s_singleton;
3343 
3344 Item*
3345 Create_func_datediff::create(THD *thd, Item *arg1, Item *arg2)
3346 {
3347  Item *i1= new (thd->mem_root) Item_func_to_days(arg1);
3348  Item *i2= new (thd->mem_root) Item_func_to_days(arg2);
3349 
3350  return new (thd->mem_root) Item_func_minus(i1, i2);
3351 }
3352 
3353 
3354 Create_func_dayname Create_func_dayname::s_singleton;
3355 
3356 Item*
3358 {
3359  return new (thd->mem_root) Item_func_dayname(arg1);
3360 }
3361 
3362 
3363 Create_func_dayofmonth Create_func_dayofmonth::s_singleton;
3364 
3365 Item*
3367 {
3368  return new (thd->mem_root) Item_func_dayofmonth(arg1);
3369 }
3370 
3371 
3372 Create_func_dayofweek Create_func_dayofweek::s_singleton;
3373 
3374 Item*
3376 {
3377  return new (thd->mem_root) Item_func_weekday(arg1, 1);
3378 }
3379 
3380 
3381 Create_func_dayofyear Create_func_dayofyear::s_singleton;
3382 
3383 Item*
3385 {
3386  return new (thd->mem_root) Item_func_dayofyear(arg1);
3387 }
3388 
3389 
3390 Create_func_decode Create_func_decode::s_singleton;
3391 
3392 Item*
3393 Create_func_decode::create(THD *thd, Item *arg1, Item *arg2)
3394 {
3395  return new (thd->mem_root) Item_func_decode(arg1, arg2);
3396 }
3397 
3398 
3399 Create_func_degrees Create_func_degrees::s_singleton;
3400 
3401 Item*
3403 {
3404  return new (thd->mem_root) Item_func_units((char*) "degrees", arg1,
3405  180/M_PI, 0.0);
3406 }
3407 
3408 
3409 Create_func_des_decrypt Create_func_des_decrypt::s_singleton;
3410 
3411 Item*
3413  List<Item> *item_list)
3414 {
3415  Item *func= NULL;
3416  int arg_count= 0;
3417 
3418  if (item_list != NULL)
3419  arg_count= item_list->elements;
3420 
3421  switch (arg_count) {
3422  case 1:
3423  {
3424  Item *param_1= item_list->pop();
3425  func= new (thd->mem_root) Item_func_des_decrypt(param_1);
3426  break;
3427  }
3428  case 2:
3429  {
3430  Item *param_1= item_list->pop();
3431  Item *param_2= item_list->pop();
3432  func= new (thd->mem_root) Item_func_des_decrypt(param_1, param_2);
3433  break;
3434  }
3435  default:
3436  {
3437  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3438  break;
3439  }
3440  }
3441 
3442  return func;
3443 }
3444 
3445 
3446 Create_func_des_encrypt Create_func_des_encrypt::s_singleton;
3447 
3448 Item*
3450  List<Item> *item_list)
3451 {
3452  Item *func= NULL;
3453  int arg_count= 0;
3454 
3455  if (item_list != NULL)
3456  arg_count= item_list->elements;
3457 
3458  switch (arg_count) {
3459  case 1:
3460  {
3461  Item *param_1= item_list->pop();
3462  func= new (thd->mem_root) Item_func_des_encrypt(param_1);
3463  break;
3464  }
3465  case 2:
3466  {
3467  Item *param_1= item_list->pop();
3468  Item *param_2= item_list->pop();
3469  func= new (thd->mem_root) Item_func_des_encrypt(param_1, param_2);
3470  break;
3471  }
3472  default:
3473  {
3474  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3475  break;
3476  }
3477  }
3478 
3479  return func;
3480 }
3481 
3482 
3483 #ifdef HAVE_SPATIAL
3484 Create_func_dimension Create_func_dimension::s_singleton;
3485 
3486 Item*
3487 Create_func_dimension::create(THD *thd, Item *arg1)
3488 {
3489  return new (thd->mem_root) Item_func_dimension(arg1);
3490 }
3491 #endif
3492 
3493 
3494 #ifdef HAVE_SPATIAL
3495 Create_func_mbr_disjoint Create_func_mbr_disjoint::s_singleton;
3496 
3497 Item*
3498 Create_func_mbr_disjoint::create(THD *thd, Item *arg1, Item *arg2)
3499 {
3500  return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
3501  Item_func::SP_DISJOINT_FUNC);
3502 }
3503 
3504 
3505 Create_func_disjoint Create_func_disjoint::s_singleton;
3506 
3507 Item*
3508 Create_func_disjoint::create(THD *thd, Item *arg1, Item *arg2)
3509 {
3510  return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
3511  Item_func::SP_DISJOINT_FUNC);
3512 }
3513 
3514 
3515 Create_func_distance Create_func_distance::s_singleton;
3516 
3517 Item*
3518 Create_func_distance::create(THD *thd, Item *arg1, Item *arg2)
3519 {
3520  return new (thd->mem_root) Item_func_distance(arg1, arg2);
3521 }
3522 #endif
3523 
3524 
3525 Create_func_elt Create_func_elt::s_singleton;
3526 
3527 Item*
3529  List<Item> *item_list)
3530 {
3531  int arg_count= 0;
3532 
3533  if (item_list != NULL)
3534  arg_count= item_list->elements;
3535 
3536  if (arg_count < 2)
3537  {
3538  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3539  return NULL;
3540  }
3541 
3542  return new (thd->mem_root) Item_func_elt(*item_list);
3543 }
3544 
3545 
3546 Create_func_encode Create_func_encode::s_singleton;
3547 
3548 Item*
3549 Create_func_encode::create(THD *thd, Item *arg1, Item *arg2)
3550 {
3551  return new (thd->mem_root) Item_func_encode(arg1, arg2);
3552 }
3553 
3554 
3555 Create_func_encrypt Create_func_encrypt::s_singleton;
3556 
3557 Item*
3559  List<Item> *item_list)
3560 {
3561  Item *func= NULL;
3562  int arg_count= 0;
3563 
3564  if (item_list != NULL)
3565  arg_count= item_list->elements;
3566 
3567  switch (arg_count) {
3568  case 1:
3569  {
3570  Item *param_1= item_list->pop();
3571  func= new (thd->mem_root) Item_func_encrypt(param_1);
3572  thd->lex->uncacheable(UNCACHEABLE_RAND);
3573  break;
3574  }
3575  case 2:
3576  {
3577  Item *param_1= item_list->pop();
3578  Item *param_2= item_list->pop();
3579  func= new (thd->mem_root) Item_func_encrypt(param_1, param_2);
3580  break;
3581  }
3582  default:
3583  {
3584  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3585  break;
3586  }
3587  }
3588 
3589  return func;
3590 }
3591 
3592 
3593 #ifdef HAVE_SPATIAL
3594 Create_func_endpoint Create_func_endpoint::s_singleton;
3595 
3596 Item*
3597 Create_func_endpoint::create(THD *thd, Item *arg1)
3598 {
3599  return new (thd->mem_root) Item_func_spatial_decomp(arg1,
3600  Item_func::SP_ENDPOINT);
3601 }
3602 #endif
3603 
3604 
3605 #ifdef HAVE_SPATIAL
3606 Create_func_envelope Create_func_envelope::s_singleton;
3607 
3608 Item*
3609 Create_func_envelope::create(THD *thd, Item *arg1)
3610 {
3611  return new (thd->mem_root) Item_func_envelope(arg1);
3612 }
3613 #endif
3614 
3615 
3616 #ifdef HAVE_SPATIAL
3617 Create_func_mbr_equals Create_func_mbr_equals::s_singleton;
3618 
3619 Item*
3620 Create_func_mbr_equals::create(THD *thd, Item *arg1, Item *arg2)
3621 {
3622  return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
3623  Item_func::SP_EQUALS_FUNC);
3624 }
3625 
3626 
3627 Create_func_equals Create_func_equals::s_singleton;
3628 
3629 Item*
3630 Create_func_equals::create(THD *thd, Item *arg1, Item *arg2)
3631 {
3632  return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
3633  Item_func::SP_EQUALS_FUNC);
3634 }
3635 #endif
3636 
3637 
3638 Create_func_exp Create_func_exp::s_singleton;
3639 
3640 Item*
3642 {
3643  return new (thd->mem_root) Item_func_exp(arg1);
3644 }
3645 
3646 
3647 Create_func_export_set Create_func_export_set::s_singleton;
3648 
3649 Item*
3651  List<Item> *item_list)
3652 {
3653  Item *func= NULL;
3654  int arg_count= 0;
3655 
3656  if (item_list != NULL)
3657  arg_count= item_list->elements;
3658 
3659  switch (arg_count) {
3660  case 3:
3661  {
3662  Item *param_1= item_list->pop();
3663  Item *param_2= item_list->pop();
3664  Item *param_3= item_list->pop();
3665  func= new (thd->mem_root) Item_func_export_set(param_1, param_2, param_3);
3666  break;
3667  }
3668  case 4:
3669  {
3670  Item *param_1= item_list->pop();
3671  Item *param_2= item_list->pop();
3672  Item *param_3= item_list->pop();
3673  Item *param_4= item_list->pop();
3674  func= new (thd->mem_root) Item_func_export_set(param_1, param_2, param_3,
3675  param_4);
3676  break;
3677  }
3678  case 5:
3679  {
3680  Item *param_1= item_list->pop();
3681  Item *param_2= item_list->pop();
3682  Item *param_3= item_list->pop();
3683  Item *param_4= item_list->pop();
3684  Item *param_5= item_list->pop();
3685  func= new (thd->mem_root) Item_func_export_set(param_1, param_2, param_3,
3686  param_4, param_5);
3687  break;
3688  }
3689  default:
3690  {
3691  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3692  break;
3693  }
3694  }
3695 
3696  return func;
3697 }
3698 
3699 
3700 #ifdef HAVE_SPATIAL
3701 Create_func_exteriorring Create_func_exteriorring::s_singleton;
3702 
3703 Item*
3704 Create_func_exteriorring::create(THD *thd, Item *arg1)
3705 {
3706  return new (thd->mem_root) Item_func_spatial_decomp(arg1,
3707  Item_func::SP_EXTERIORRING);
3708 }
3709 #endif
3710 
3711 
3712 Create_func_field Create_func_field::s_singleton;
3713 
3714 Item*
3716  List<Item> *item_list)
3717 {
3718  int arg_count= 0;
3719 
3720  if (item_list != NULL)
3721  arg_count= item_list->elements;
3722 
3723  if (arg_count < 2)
3724  {
3725  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3726  return NULL;
3727  }
3728 
3729  return new (thd->mem_root) Item_func_field(*item_list);
3730 }
3731 
3732 
3733 Create_func_find_in_set Create_func_find_in_set::s_singleton;
3734 
3735 Item*
3737 {
3738  return new (thd->mem_root) Item_func_find_in_set(arg1, arg2);
3739 }
3740 
3741 
3742 Create_func_floor Create_func_floor::s_singleton;
3743 
3744 Item*
3746 {
3747  return new (thd->mem_root) Item_func_floor(arg1);
3748 }
3749 
3750 
3751 Create_func_found_rows Create_func_found_rows::s_singleton;
3752 
3753 Item*
3755 {
3756  DBUG_ENTER("Create_func_found_rows::create");
3757  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
3758  thd->lex->safe_to_cache_query= 0;
3759  DBUG_RETURN(new (thd->mem_root) Item_func_found_rows());
3760 }
3761 
3762 
3763 Create_func_from_base64 Create_func_from_base64::s_singleton;
3764 
3765 Item*
3767 {
3768  return new (thd->mem_root) Item_func_from_base64(arg1);
3769 }
3770 
3771 
3772 Create_func_from_days Create_func_from_days::s_singleton;
3773 
3774 Item*
3776 {
3777  return new (thd->mem_root) Item_func_from_days(arg1);
3778 }
3779 
3780 
3781 Create_func_from_unixtime Create_func_from_unixtime::s_singleton;
3782 
3783 Item*
3785  List<Item> *item_list)
3786 {
3787  Item *func= NULL;
3788  int arg_count= 0;
3789 
3790  if (item_list != NULL)
3791  arg_count= item_list->elements;
3792 
3793  switch (arg_count) {
3794  case 1:
3795  {
3796  Item *param_1= item_list->pop();
3797  func= new (thd->mem_root) Item_func_from_unixtime(param_1);
3798  break;
3799  }
3800  case 2:
3801  {
3802  Item *param_1= item_list->pop();
3803  Item *param_2= item_list->pop();
3804  Item *ut= new (thd->mem_root) Item_func_from_unixtime(param_1);
3805  func= new (thd->mem_root) Item_func_date_format(ut, param_2, 0);
3806  break;
3807  }
3808  default:
3809  {
3810  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3811  break;
3812  }
3813  }
3814 
3815  return func;
3816 }
3817 
3818 
3819 #ifdef HAVE_SPATIAL
3820 Create_func_geometry_from_text Create_func_geometry_from_text::s_singleton;
3821 
3822 Item*
3824  List<Item> *item_list)
3825 {
3826  Item *func= NULL;
3827  int arg_count= 0;
3828 
3829  if (item_list != NULL)
3830  arg_count= item_list->elements;
3831 
3832  switch (arg_count) {
3833  case 1:
3834  {
3835  Item *param_1= item_list->pop();
3836  func= new (thd->mem_root) Item_func_geometry_from_text(param_1);
3837  thd->lex->uncacheable(UNCACHEABLE_RAND);
3838  break;
3839  }
3840  case 2:
3841  {
3842  Item *param_1= item_list->pop();
3843  Item *param_2= item_list->pop();
3844  func= new (thd->mem_root) Item_func_geometry_from_text(param_1, param_2);
3845  break;
3846  }
3847  default:
3848  {
3849  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3850  break;
3851  }
3852  }
3853 
3854  return func;
3855 }
3856 #endif
3857 
3858 
3859 #ifdef HAVE_SPATIAL
3860 Create_func_geometry_from_wkb Create_func_geometry_from_wkb::s_singleton;
3861 
3862 Item*
3864  List<Item> *item_list)
3865 {
3866  Item *func= NULL;
3867  int arg_count= 0;
3868 
3869  if (item_list != NULL)
3870  arg_count= item_list->elements;
3871 
3872  switch (arg_count) {
3873  case 1:
3874  {
3875  Item *param_1= item_list->pop();
3876  func= new (thd->mem_root) Item_func_geometry_from_wkb(param_1);
3877  thd->lex->uncacheable(UNCACHEABLE_RAND);
3878  break;
3879  }
3880  case 2:
3881  {
3882  Item *param_1= item_list->pop();
3883  Item *param_2= item_list->pop();
3884  func= new (thd->mem_root) Item_func_geometry_from_wkb(param_1, param_2);
3885  break;
3886  }
3887  default:
3888  {
3889  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3890  break;
3891  }
3892  }
3893 
3894  return func;
3895 }
3896 #endif
3897 
3898 
3899 #ifdef HAVE_SPATIAL
3900 Create_func_geometry_type Create_func_geometry_type::s_singleton;
3901 
3902 Item*
3903 Create_func_geometry_type::create(THD *thd, Item *arg1)
3904 {
3905  return new (thd->mem_root) Item_func_geometry_type(arg1);
3906 }
3907 #endif
3908 
3909 
3910 #ifdef HAVE_SPATIAL
3911 Create_func_geometryn Create_func_geometryn::s_singleton;
3912 
3913 Item*
3914 Create_func_geometryn::create(THD *thd, Item *arg1, Item *arg2)
3915 {
3916  return new (thd->mem_root) Item_func_spatial_decomp_n(arg1, arg2,
3917  Item_func::SP_GEOMETRYN);
3918 }
3919 #endif
3920 
3921 
3922 Create_func_get_lock Create_func_get_lock::s_singleton;
3923 
3924 Item*
3925 Create_func_get_lock::create(THD *thd, Item *arg1, Item *arg2)
3926 {
3927  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
3928  thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
3929  return new (thd->mem_root) Item_func_get_lock(arg1, arg2);
3930 }
3931 
3932 
3933 #if defined(HAVE_SPATIAL) && !defined(DBUG_OFF)
3934 Create_func_gis_debug Create_func_gis_debug::s_singleton;
3935 
3936 Item*
3937 Create_func_gis_debug::create(THD *thd, Item *arg1)
3938 {
3939  return new (thd->mem_root) Item_func_gis_debug(arg1);
3940 }
3941 #endif
3942 
3943 
3944 #ifdef HAVE_SPATIAL
3945 Create_func_glength Create_func_glength::s_singleton;
3946 
3947 Item*
3948 Create_func_glength::create(THD *thd, Item *arg1)
3949 {
3950  return new (thd->mem_root) Item_func_glength(arg1);
3951 }
3952 #endif
3953 
3954 
3955 Create_func_greatest Create_func_greatest::s_singleton;
3956 
3957 Item*
3959  List<Item> *item_list)
3960 {
3961  int arg_count= 0;
3962 
3963  if (item_list != NULL)
3964  arg_count= item_list->elements;
3965 
3966  if (arg_count < 2)
3967  {
3968  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3969  return NULL;
3970  }
3971 
3972  return new (thd->mem_root) Item_func_max(*item_list);
3973 }
3974 
3975 
3976 Create_func_gtid_subtract Create_func_gtid_subtract::s_singleton;
3977 
3978 Item*
3980 {
3981  return new (thd->mem_root) Item_func_gtid_subtract(arg1, arg2);
3982 }
3983 
3984 
3985 Create_func_gtid_subset Create_func_gtid_subset::s_singleton;
3986 
3987 Item*
3989 {
3990  return new (thd->mem_root) Item_func_gtid_subset(arg1, arg2);
3991 }
3992 
3993 
3994 Create_func_hex Create_func_hex::s_singleton;
3995 
3996 Item*
3998 {
3999  return new (thd->mem_root) Item_func_hex(arg1);
4000 }
4001 
4002 
4003 Create_func_ifnull Create_func_ifnull::s_singleton;
4004 
4005 Item*
4006 Create_func_ifnull::create(THD *thd, Item *arg1, Item *arg2)
4007 {
4008  return new (thd->mem_root) Item_func_ifnull(arg1, arg2);
4009 }
4010 
4011 
4012 Create_func_inet_ntoa Create_func_inet_ntoa::s_singleton;
4013 
4014 Item*
4016 {
4017  return new (thd->mem_root) Item_func_inet_ntoa(arg1);
4018 }
4019 
4020 
4021 Create_func_inet6_aton Create_func_inet6_aton::s_singleton;
4022 
4023 Item*
4025 {
4026  return new (thd->mem_root) Item_func_inet6_aton(arg1);
4027 }
4028 
4029 
4030 Create_func_inet6_ntoa Create_func_inet6_ntoa::s_singleton;
4031 
4032 Item*
4034 {
4035  return new (thd->mem_root) Item_func_inet6_ntoa(arg1);
4036 }
4037 
4038 
4039 Create_func_inet_aton Create_func_inet_aton::s_singleton;
4040 
4041 Item*
4043 {
4044  return new (thd->mem_root) Item_func_inet_aton(arg1);
4045 }
4046 
4047 
4048 Create_func_is_ipv4 Create_func_is_ipv4::s_singleton;
4049 
4050 Item*
4052 {
4053  return new (thd->mem_root) Item_func_is_ipv4(arg1);
4054 }
4055 
4056 
4057 Create_func_is_ipv6 Create_func_is_ipv6::s_singleton;
4058 
4059 Item*
4061 {
4062  return new (thd->mem_root) Item_func_is_ipv6(arg1);
4063 }
4064 
4065 
4066 Create_func_is_ipv4_compat Create_func_is_ipv4_compat::s_singleton;
4067 
4068 Item*
4070 {
4071  return new (thd->mem_root) Item_func_is_ipv4_compat(arg1);
4072 }
4073 
4074 
4075 Create_func_is_ipv4_mapped Create_func_is_ipv4_mapped::s_singleton;
4076 
4077 Item*
4079 {
4080  return new (thd->mem_root) Item_func_is_ipv4_mapped(arg1);
4081 }
4082 
4083 
4084 Create_func_instr Create_func_instr::s_singleton;
4085 
4086 Item*
4087 Create_func_instr::create(THD *thd, Item *arg1, Item *arg2)
4088 {
4089  return new (thd->mem_root) Item_func_locate(arg1, arg2);
4090 }
4091 
4092 
4093 #ifdef HAVE_SPATIAL
4094 Create_func_interiorringn Create_func_interiorringn::s_singleton;
4095 
4096 Item*
4097 Create_func_interiorringn::create(THD *thd, Item *arg1, Item *arg2)
4098 {
4099  return new (thd->mem_root) Item_func_spatial_decomp_n(arg1, arg2,
4100  Item_func::SP_INTERIORRINGN);
4101 }
4102 #endif
4103 
4104 
4105 #ifdef HAVE_SPATIAL
4106 Create_func_mbr_intersects Create_func_mbr_intersects::s_singleton;
4107 
4108 Item*
4109 Create_func_mbr_intersects::create(THD *thd, Item *arg1, Item *arg2)
4110 {
4111  return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
4112  Item_func::SP_INTERSECTS_FUNC);
4113 }
4114 
4115 
4116 Create_func_intersects Create_func_intersects::s_singleton;
4117 
4118 Item*
4119 Create_func_intersects::create(THD *thd, Item *arg1, Item *arg2)
4120 {
4121  return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
4122  Item_func::SP_INTERSECTS_FUNC);
4123 }
4124 
4125 
4126 Create_func_intersection Create_func_intersection::s_singleton;
4127 
4128 Item*
4129 Create_func_intersection::create(THD *thd, Item *arg1, Item *arg2)
4130 {
4131  return new (thd->mem_root) Item_func_spatial_operation(arg1, arg2,
4132  Gcalc_function::op_intersection);
4133 }
4134 
4135 
4136 Create_func_difference Create_func_difference::s_singleton;
4137 
4138 Item*
4139 Create_func_difference::create(THD *thd, Item *arg1, Item *arg2)
4140 {
4141  return new (thd->mem_root) Item_func_spatial_operation(arg1, arg2,
4142  Gcalc_function::op_difference);
4143 }
4144 
4145 
4146 Create_func_union Create_func_union::s_singleton;
4147 
4148 Item*
4149 Create_func_union::create(THD *thd, Item *arg1, Item *arg2)
4150 {
4151  return new (thd->mem_root) Item_func_spatial_operation(arg1, arg2,
4152  Gcalc_function::op_union);
4153 }
4154 
4155 
4156 Create_func_symdifference Create_func_symdifference::s_singleton;
4157 
4158 Item*
4159 Create_func_symdifference::create(THD *thd, Item *arg1, Item *arg2)
4160 {
4161  return new (thd->mem_root) Item_func_spatial_operation(arg1, arg2,
4162  Gcalc_function::op_symdifference);
4163 }
4164 
4165 
4166 Create_func_buffer Create_func_buffer::s_singleton;
4167 
4168 Item*
4169 Create_func_buffer::create(THD *thd, Item *arg1, Item *arg2)
4170 {
4171  return new (thd->mem_root) Item_func_buffer(arg1, arg2);
4172 }
4173 #endif /*HAVE_SPATIAL*/
4174 
4175 
4176 Create_func_is_free_lock Create_func_is_free_lock::s_singleton;
4177 
4178 Item*
4180 {
4181  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4182  thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
4183  return new (thd->mem_root) Item_func_is_free_lock(arg1);
4184 }
4185 
4186 
4187 Create_func_is_used_lock Create_func_is_used_lock::s_singleton;
4188 
4189 Item*
4191 {
4192  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4193  thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
4194  return new (thd->mem_root) Item_func_is_used_lock(arg1);
4195 }
4196 
4197 
4198 #ifdef HAVE_SPATIAL
4199 Create_func_isclosed Create_func_isclosed::s_singleton;
4200 
4201 Item*
4202 Create_func_isclosed::create(THD *thd, Item *arg1)
4203 {
4204  return new (thd->mem_root) Item_func_isclosed(arg1);
4205 }
4206 #endif
4207 
4208 
4209 #ifdef HAVE_SPATIAL
4210 Create_func_isempty Create_func_isempty::s_singleton;
4211 
4212 Item*
4213 Create_func_isempty::create(THD *thd, Item *arg1)
4214 {
4215  return new (thd->mem_root) Item_func_isempty(arg1);
4216 }
4217 #endif
4218 
4219 
4220 Create_func_isnull Create_func_isnull::s_singleton;
4221 
4222 Item*
4224 {
4225  return new (thd->mem_root) Item_func_isnull(arg1);
4226 }
4227 
4228 
4229 #ifdef HAVE_SPATIAL
4230 Create_func_issimple Create_func_issimple::s_singleton;
4231 
4232 Item*
4233 Create_func_issimple::create(THD *thd, Item *arg1)
4234 {
4235  return new (thd->mem_root) Item_func_issimple(arg1);
4236 }
4237 #endif
4238 
4239 
4240 Create_func_last_day Create_func_last_day::s_singleton;
4241 
4242 Item*
4244 {
4245  return new (thd->mem_root) Item_func_last_day(arg1);
4246 }
4247 
4248 
4249 Create_func_last_insert_id Create_func_last_insert_id::s_singleton;
4250 
4251 Item*
4253  List<Item> *item_list)
4254 {
4255  Item *func= NULL;
4256  int arg_count= 0;
4257 
4258  if (item_list != NULL)
4259  arg_count= item_list->elements;
4260 
4261  switch (arg_count) {
4262  case 0:
4263  {
4264  func= new (thd->mem_root) Item_func_last_insert_id();
4265  thd->lex->safe_to_cache_query= 0;
4266  break;
4267  }
4268  case 1:
4269  {
4270  Item *param_1= item_list->pop();
4271  func= new (thd->mem_root) Item_func_last_insert_id(param_1);
4272  thd->lex->safe_to_cache_query= 0;
4273  break;
4274  }
4275  default:
4276  {
4277  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4278  break;
4279  }
4280  }
4281 
4282  return func;
4283 }
4284 
4285 
4286 Create_func_lcase Create_func_lcase::s_singleton;
4287 
4288 Item*
4290 {
4291  return new (thd->mem_root) Item_func_lcase(arg1);
4292 }
4293 
4294 
4295 Create_func_least Create_func_least::s_singleton;
4296 
4297 Item*
4299  List<Item> *item_list)
4300 {
4301  int arg_count= 0;
4302 
4303  if (item_list != NULL)
4304  arg_count= item_list->elements;
4305 
4306  if (arg_count < 2)
4307  {
4308  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4309  return NULL;
4310  }
4311 
4312  return new (thd->mem_root) Item_func_min(*item_list);
4313 }
4314 
4315 
4316 Create_func_length Create_func_length::s_singleton;
4317 
4318 Item*
4320 {
4321  return new (thd->mem_root) Item_func_length(arg1);
4322 }
4323 
4324 
4325 #ifndef DBUG_OFF
4326 Create_func_like_range_min Create_func_like_range_min::s_singleton;
4327 
4328 Item*
4330 {
4331  return new (thd->mem_root) Item_func_like_range_min(arg1, arg2);
4332 }
4333 
4334 
4335 Create_func_like_range_max Create_func_like_range_max::s_singleton;
4336 
4337 Item*
4339 {
4340  return new (thd->mem_root) Item_func_like_range_max(arg1, arg2);
4341 }
4342 #endif
4343 
4344 
4345 Create_func_ln Create_func_ln::s_singleton;
4346 
4347 Item*
4349 {
4350  return new (thd->mem_root) Item_func_ln(arg1);
4351 }
4352 
4353 
4354 Create_func_load_file Create_func_load_file::s_singleton;
4355 
4356 Item*
4358 {
4359  DBUG_ENTER("Create_func_load_file::create");
4360  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4361  thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
4362  DBUG_RETURN(new (thd->mem_root) Item_load_file(arg1));
4363 }
4364 
4365 
4366 Create_func_locate Create_func_locate::s_singleton;
4367 
4368 Item*
4370  List<Item> *item_list)
4371 {
4372  Item *func= NULL;
4373  int arg_count= 0;
4374 
4375  if (item_list != NULL)
4376  arg_count= item_list->elements;
4377 
4378  switch (arg_count) {
4379  case 2:
4380  {
4381  Item *param_1= item_list->pop();
4382  Item *param_2= item_list->pop();
4383  /* Yes, parameters in that order : 2, 1 */
4384  func= new (thd->mem_root) Item_func_locate(param_2, param_1);
4385  break;
4386  }
4387  case 3:
4388  {
4389  Item *param_1= item_list->pop();
4390  Item *param_2= item_list->pop();
4391  Item *param_3= item_list->pop();
4392  /* Yes, parameters in that order : 2, 1, 3 */
4393  func= new (thd->mem_root) Item_func_locate(param_2, param_1, param_3);
4394  break;
4395  }
4396  default:
4397  {
4398  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4399  break;
4400  }
4401  }
4402 
4403  return func;
4404 }
4405 
4406 
4407 Create_func_log Create_func_log::s_singleton;
4408 
4409 Item*
4411  List<Item> *item_list)
4412 {
4413  Item *func= NULL;
4414  int arg_count= 0;
4415 
4416  if (item_list != NULL)
4417  arg_count= item_list->elements;
4418 
4419  switch (arg_count) {
4420  case 1:
4421  {
4422  Item *param_1= item_list->pop();
4423  func= new (thd->mem_root) Item_func_log(param_1);
4424  break;
4425  }
4426  case 2:
4427  {
4428  Item *param_1= item_list->pop();
4429  Item *param_2= item_list->pop();
4430  func= new (thd->mem_root) Item_func_log(param_1, param_2);
4431  break;
4432  }
4433  default:
4434  {
4435  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4436  break;
4437  }
4438  }
4439 
4440  return func;
4441 }
4442 
4443 
4444 Create_func_log10 Create_func_log10::s_singleton;
4445 
4446 Item*
4448 {
4449  return new (thd->mem_root) Item_func_log10(arg1);
4450 }
4451 
4452 
4453 Create_func_log2 Create_func_log2::s_singleton;
4454 
4455 Item*
4457 {
4458  return new (thd->mem_root) Item_func_log2(arg1);
4459 }
4460 
4461 
4462 Create_func_lpad Create_func_lpad::s_singleton;
4463 
4464 Item*
4465 Create_func_lpad::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
4466 {
4467  return new (thd->mem_root) Item_func_lpad(arg1, arg2, arg3);
4468 }
4469 
4470 
4471 Create_func_ltrim Create_func_ltrim::s_singleton;
4472 
4473 Item*
4475 {
4476  return new (thd->mem_root) Item_func_ltrim(arg1);
4477 }
4478 
4479 
4480 Create_func_makedate Create_func_makedate::s_singleton;
4481 
4482 Item*
4483 Create_func_makedate::create(THD *thd, Item *arg1, Item *arg2)
4484 {
4485  return new (thd->mem_root) Item_func_makedate(arg1, arg2);
4486 }
4487 
4488 
4489 Create_func_maketime Create_func_maketime::s_singleton;
4490 
4491 Item*
4492 Create_func_maketime::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
4493 {
4494  return new (thd->mem_root) Item_func_maketime(arg1, arg2, arg3);
4495 }
4496 
4497 
4498 Create_func_make_set Create_func_make_set::s_singleton;
4499 
4500 Item*
4502  List<Item> *item_list)
4503 {
4504  int arg_count= 0;
4505 
4506  if (item_list != NULL)
4507  arg_count= item_list->elements;
4508 
4509  if (arg_count < 2)
4510  {
4511  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4512  return NULL;
4513  }
4514 
4515  Item *param_1= item_list->pop();
4516  return new (thd->mem_root) Item_func_make_set(param_1, *item_list);
4517 }
4518 
4519 
4520 Create_func_master_pos_wait Create_func_master_pos_wait::s_singleton;
4521 
4522 Item*
4524  List<Item> *item_list)
4525 
4526 {
4527  Item *func= NULL;
4528  int arg_count= 0;
4529 
4530  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4531 
4532  if (item_list != NULL)
4533  arg_count= item_list->elements;
4534 
4535  switch (arg_count) {
4536  case 2:
4537  {
4538  Item *param_1= item_list->pop();
4539  Item *param_2= item_list->pop();
4540  func= new (thd->mem_root) Item_master_pos_wait(param_1, param_2);
4541  thd->lex->safe_to_cache_query= 0;
4542  break;
4543  }
4544  case 3:
4545  {
4546  Item *param_1= item_list->pop();
4547  Item *param_2= item_list->pop();
4548  Item *param_3= item_list->pop();
4549  func= new (thd->mem_root) Item_master_pos_wait(param_1, param_2, param_3);
4550  thd->lex->safe_to_cache_query= 0;
4551  break;
4552  }
4553  default:
4554  {
4555  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4556  break;
4557  }
4558  }
4559 
4560  return func;
4561 }
4562 
4563 Create_func_master_gtid_set_wait Create_func_master_gtid_set_wait::s_singleton;
4564 
4565 Item*
4567  List<Item> *item_list)
4568 
4569 {
4570  Item *func= NULL;
4571  int arg_count= 0;
4572 
4573  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4574 
4575  if (item_list != NULL)
4576  arg_count= item_list->elements;
4577 
4578  switch (arg_count) {
4579  case 1:
4580  {
4581  Item *param_1= item_list->pop();
4582  func= new (thd->mem_root) Item_master_gtid_set_wait(param_1);
4583  thd->lex->safe_to_cache_query= 0;
4584  break;
4585  }
4586  case 2:
4587  {
4588  Item *param_1= item_list->pop();
4589  Item *param_2= item_list->pop();
4590  func= new (thd->mem_root) Item_master_gtid_set_wait(param_1, param_2);
4591  thd->lex->safe_to_cache_query= 0;
4592  break;
4593  }
4594  default:
4595  {
4596  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4597  break;
4598  }
4599  }
4600 
4601  return func;
4602 }
4603 
4604 Create_func_md5 Create_func_md5::s_singleton;
4605 
4606 Item*
4608 {
4609  return new (thd->mem_root) Item_func_md5(arg1);
4610 }
4611 
4612 
4613 Create_func_monthname Create_func_monthname::s_singleton;
4614 
4615 Item*
4617 {
4618  return new (thd->mem_root) Item_func_monthname(arg1);
4619 }
4620 
4621 
4622 Create_func_name_const Create_func_name_const::s_singleton;
4623 
4624 Item*
4626 {
4627  return new (thd->mem_root) Item_name_const(arg1, arg2);
4628 }
4629 
4630 
4631 Create_func_nullif Create_func_nullif::s_singleton;
4632 
4633 Item*
4634 Create_func_nullif::create(THD *thd, Item *arg1, Item *arg2)
4635 {
4636  return new (thd->mem_root) Item_func_nullif(arg1, arg2);
4637 }
4638 
4639 
4640 #ifdef HAVE_SPATIAL
4641 Create_func_numgeometries Create_func_numgeometries::s_singleton;
4642 
4643 Item*
4644 Create_func_numgeometries::create(THD *thd, Item *arg1)
4645 {
4646  return new (thd->mem_root) Item_func_numgeometries(arg1);
4647 }
4648 #endif
4649 
4650 
4651 #ifdef HAVE_SPATIAL
4652 Create_func_numinteriorring Create_func_numinteriorring::s_singleton;
4653 
4654 Item*
4656 {
4657  return new (thd->mem_root) Item_func_numinteriorring(arg1);
4658 }
4659 #endif
4660 
4661 
4662 #ifdef HAVE_SPATIAL
4663 Create_func_numpoints Create_func_numpoints::s_singleton;
4664 
4665 Item*
4666 Create_func_numpoints::create(THD *thd, Item *arg1)
4667 {
4668  return new (thd->mem_root) Item_func_numpoints(arg1);
4669 }
4670 #endif
4671 
4672 
4673 Create_func_oct Create_func_oct::s_singleton;
4674 
4675 Item*
4677 {
4678  Item *i10= new (thd->mem_root) Item_int((int32) 10,2);
4679  Item *i8= new (thd->mem_root) Item_int((int32) 8,1);
4680  return new (thd->mem_root) Item_func_conv(arg1, i10, i8);
4681 }
4682 
4683 
4684 Create_func_ord Create_func_ord::s_singleton;
4685 
4686 Item*
4688 {
4689  return new (thd->mem_root) Item_func_ord(arg1);
4690 }
4691 
4692 
4693 #ifdef HAVE_SPATIAL
4694 Create_func_mbr_overlaps Create_func_mbr_overlaps::s_singleton;
4695 
4696 Item*
4697 Create_func_mbr_overlaps::create(THD *thd, Item *arg1, Item *arg2)
4698 {
4699  return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
4700  Item_func::SP_OVERLAPS_FUNC);
4701 }
4702 
4703 
4704 Create_func_overlaps Create_func_overlaps::s_singleton;
4705 
4706 Item*
4707 Create_func_overlaps::create(THD *thd, Item *arg1, Item *arg2)
4708 {
4709  return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
4710  Item_func::SP_OVERLAPS_FUNC);
4711 }
4712 #endif
4713 
4714 
4715 Create_func_period_add Create_func_period_add::s_singleton;
4716 
4717 Item*
4719 {
4720  return new (thd->mem_root) Item_func_period_add(arg1, arg2);
4721 }
4722 
4723 
4724 Create_func_period_diff Create_func_period_diff::s_singleton;
4725 
4726 Item*
4728 {
4729  return new (thd->mem_root) Item_func_period_diff(arg1, arg2);
4730 }
4731 
4732 
4733 Create_func_pi Create_func_pi::s_singleton;
4734 
4735 Item*
4737 {
4738  return new (thd->mem_root) Item_static_float_func(NAME_STRING("pi()"),
4739  M_PI, 6, 8);
4740 }
4741 
4742 
4743 #ifdef HAVE_SPATIAL
4744 Create_func_pointn Create_func_pointn::s_singleton;
4745 
4746 Item*
4747 Create_func_pointn::create(THD *thd, Item *arg1, Item *arg2)
4748 {
4749  return new (thd->mem_root) Item_func_spatial_decomp_n(arg1, arg2,
4750  Item_func::SP_POINTN);
4751 }
4752 #endif
4753 
4754 
4755 Create_func_pow Create_func_pow::s_singleton;
4756 
4757 Item*
4758 Create_func_pow::create(THD *thd, Item *arg1, Item *arg2)
4759 {
4760  return new (thd->mem_root) Item_func_pow(arg1, arg2);
4761 }
4762 
4763 
4764 Create_func_quote Create_func_quote::s_singleton;
4765 
4766 Item*
4768 {
4769  return new (thd->mem_root) Item_func_quote(arg1);
4770 }
4771 
4772 
4773 Create_func_radians Create_func_radians::s_singleton;
4774 
4775 Item*
4777 {
4778  return new (thd->mem_root) Item_func_units((char*) "radians", arg1,
4779  M_PI/180, 0.0);
4780 }
4781 
4782 
4783 Create_func_rand Create_func_rand::s_singleton;
4784 
4785 Item*
4787  List<Item> *item_list)
4788 {
4789  Item *func= NULL;
4790  int arg_count= 0;
4791 
4792  if (item_list != NULL)
4793  arg_count= item_list->elements;
4794 
4795  /*
4796  When RAND() is binlogged, the seed is binlogged too. So the
4797  sequence of random numbers is the same on a replication slave as
4798  on the master. However, if several RAND() values are inserted
4799  into a table, the order in which the rows are modified may differ
4800  between master and slave, because the order is undefined. Hence,
4801  the statement is unsafe to log in statement format.
4802  */
4803  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4804 
4805  switch (arg_count) {
4806  case 0:
4807  {
4808  func= new (thd->mem_root) Item_func_rand();
4809  thd->lex->uncacheable(UNCACHEABLE_RAND);
4810  break;
4811  }
4812  case 1:
4813  {
4814  Item *param_1= item_list->pop();
4815  func= new (thd->mem_root) Item_func_rand(param_1);
4816  thd->lex->uncacheable(UNCACHEABLE_RAND);
4817  break;
4818  }
4819  default:
4820  {
4821  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4822  break;
4823  }
4824  }
4825 
4826  return func;
4827 }
4828 
4829 
4830 Create_func_release_lock Create_func_release_lock::s_singleton;
4831 
4832 Item*
4834 {
4835  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4836  thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
4837  return new (thd->mem_root) Item_func_release_lock(arg1);
4838 }
4839 
4840 
4841 Create_func_reverse Create_func_reverse::s_singleton;
4842 
4843 Item*
4845 {
4846  return new (thd->mem_root) Item_func_reverse(arg1);
4847 }
4848 
4849 
4850 Create_func_round Create_func_round::s_singleton;
4851 
4852 Item*
4854  List<Item> *item_list)
4855 {
4856  Item *func= NULL;
4857  int arg_count= 0;
4858 
4859  if (item_list != NULL)
4860  arg_count= item_list->elements;
4861 
4862  switch (arg_count) {
4863  case 1:
4864  {
4865  Item *param_1= item_list->pop();
4866  Item *i0 = new (thd->mem_root) Item_int_0();
4867  func= new (thd->mem_root) Item_func_round(param_1, i0, 0);
4868  break;
4869  }
4870  case 2:
4871  {
4872  Item *param_1= item_list->pop();
4873  Item *param_2= item_list->pop();
4874  func= new (thd->mem_root) Item_func_round(param_1, param_2, 0);
4875  break;
4876  }
4877  default:
4878  {
4879  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4880  break;
4881  }
4882  }
4883 
4884  return func;
4885 }
4886 
4887 
4888 Create_func_rpad Create_func_rpad::s_singleton;
4889 
4890 Item*
4891 Create_func_rpad::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
4892 {
4893  return new (thd->mem_root) Item_func_rpad(arg1, arg2, arg3);
4894 }
4895 
4896 
4897 Create_func_rtrim Create_func_rtrim::s_singleton;
4898 
4899 Item*
4901 {
4902  return new (thd->mem_root) Item_func_rtrim(arg1);
4903 }
4904 
4905 
4906 Create_func_sec_to_time Create_func_sec_to_time::s_singleton;
4907 
4908 Item*
4910 {
4911  return new (thd->mem_root) Item_func_sec_to_time(arg1);
4912 }
4913 
4914 
4915 Create_func_sha Create_func_sha::s_singleton;
4916 
4917 Item*
4919 {
4920  return new (thd->mem_root) Item_func_sha(arg1);
4921 }
4922 
4923 
4924 Create_func_sha2 Create_func_sha2::s_singleton;
4925 
4926 Item*
4927 Create_func_sha2::create(THD *thd, Item *arg1, Item *arg2)
4928 {
4929  return new (thd->mem_root) Item_func_sha2(arg1, arg2);
4930 }
4931 
4932 
4933 Create_func_sign Create_func_sign::s_singleton;
4934 
4935 Item*
4937 {
4938  return new (thd->mem_root) Item_func_sign(arg1);
4939 }
4940 
4941 
4942 Create_func_sin Create_func_sin::s_singleton;
4943 
4944 Item*
4946 {
4947  return new (thd->mem_root) Item_func_sin(arg1);
4948 }
4949 
4950 
4951 Create_func_sleep Create_func_sleep::s_singleton;
4952 
4953 Item*
4955 {
4956  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4957  thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
4958  return new (thd->mem_root) Item_func_sleep(arg1);
4959 }
4960 
4961 
4962 Create_func_soundex Create_func_soundex::s_singleton;
4963 
4964 Item*
4966 {
4967  return new (thd->mem_root) Item_func_soundex(arg1);
4968 }
4969 
4970 
4971 Create_func_space Create_func_space::s_singleton;
4972 
4973 Item*
4975 {
4976  return new (thd->mem_root) Item_func_space(arg1);
4977 }
4978 
4979 
4980 Create_func_sqrt Create_func_sqrt::s_singleton;
4981 
4982 Item*
4984 {
4985  return new (thd->mem_root) Item_func_sqrt(arg1);
4986 }
4987 
4988 
4989 #ifdef HAVE_SPATIAL
4990 Create_func_srid Create_func_srid::s_singleton;
4991 
4992 Item*
4993 Create_func_srid::create(THD *thd, Item *arg1)
4994 {
4995  return new (thd->mem_root) Item_func_srid(arg1);
4996 }
4997 #endif
4998 
4999 
5000 #ifdef HAVE_SPATIAL
5001 Create_func_startpoint Create_func_startpoint::s_singleton;
5002 
5003 Item*
5004 Create_func_startpoint::create(THD *thd, Item *arg1)
5005 {
5006  return new (thd->mem_root) Item_func_spatial_decomp(arg1,
5007  Item_func::SP_STARTPOINT);
5008 }
5009 #endif
5010 
5011 
5012 Create_func_str_to_date Create_func_str_to_date::s_singleton;
5013 
5014 Item*
5016 {
5017  return new (thd->mem_root) Item_func_str_to_date(arg1, arg2);
5018 }
5019 
5020 
5021 Create_func_strcmp Create_func_strcmp::s_singleton;
5022 
5023 Item*
5024 Create_func_strcmp::create(THD *thd, Item *arg1, Item *arg2)
5025 {
5026  return new (thd->mem_root) Item_func_strcmp(arg1, arg2);
5027 }
5028 
5029 
5030 Create_func_substr_index Create_func_substr_index::s_singleton;
5031 
5032 Item*
5033 Create_func_substr_index::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
5034 {
5035  return new (thd->mem_root) Item_func_substr_index(arg1, arg2, arg3);
5036 }
5037 
5038 
5039 Create_func_subtime Create_func_subtime::s_singleton;
5040 
5041 Item*
5042 Create_func_subtime::create(THD *thd, Item *arg1, Item *arg2)
5043 {
5044  return new (thd->mem_root) Item_func_add_time(arg1, arg2, 0, 1);
5045 }
5046 
5047 
5048 Create_func_tan Create_func_tan::s_singleton;
5049 
5050 Item*
5052 {
5053  return new (thd->mem_root) Item_func_tan(arg1);
5054 }
5055 
5056 
5057 Create_func_time_format Create_func_time_format::s_singleton;
5058 
5059 Item*
5061 {
5062  return new (thd->mem_root) Item_func_date_format(arg1, arg2, 1);
5063 }
5064 
5065 
5066 Create_func_time_to_sec Create_func_time_to_sec::s_singleton;
5067 
5068 Item*
5070 {
5071  return new (thd->mem_root) Item_func_time_to_sec(arg1);
5072 }
5073 
5074 
5075 Create_func_timediff Create_func_timediff::s_singleton;
5076 
5077 Item*
5078 Create_func_timediff::create(THD *thd, Item *arg1, Item *arg2)
5079 {
5080  return new (thd->mem_root) Item_func_timediff(arg1, arg2);
5081 }
5082 
5083 
5084 Create_func_to_base64 Create_func_to_base64::s_singleton;
5085 
5086 Item*
5088 {
5089  return new (thd->mem_root) Item_func_to_base64(arg1);
5090 }
5091 
5092 
5093 Create_func_to_days Create_func_to_days::s_singleton;
5094 
5095 Item*
5097 {
5098  return new (thd->mem_root) Item_func_to_days(arg1);
5099 }
5100 
5101 
5102 Create_func_to_seconds Create_func_to_seconds::s_singleton;
5103 
5104 Item*
5106 {
5107  return new (thd->mem_root) Item_func_to_seconds(arg1);
5108 }
5109 
5110 
5111 #ifdef HAVE_SPATIAL
5112 Create_func_touches Create_func_touches::s_singleton;
5113 
5114 Item*
5115 Create_func_touches::create(THD *thd, Item *arg1, Item *arg2)
5116 {
5117  return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
5118  Item_func::SP_TOUCHES_FUNC);
5119 }
5120 #endif
5121 
5122 
5123 Create_func_ucase Create_func_ucase::s_singleton;
5124 
5125 Item*
5127 {
5128  return new (thd->mem_root) Item_func_ucase(arg1);
5129 }
5130 
5131 
5132 Create_func_uncompress Create_func_uncompress::s_singleton;
5133 
5134 Item*
5136 {
5137  return new (thd->mem_root) Item_func_uncompress(arg1);
5138 }
5139 
5140 
5141 Create_func_uncompressed_length Create_func_uncompressed_length::s_singleton;
5142 
5143 Item*
5145 {
5146  return new (thd->mem_root) Item_func_uncompressed_length(arg1);
5147 }
5148 
5149 
5150 Create_func_unhex Create_func_unhex::s_singleton;
5151 
5152 Item*
5154 {
5155  return new (thd->mem_root) Item_func_unhex(arg1);
5156 }
5157 
5158 
5159 Create_func_unix_timestamp Create_func_unix_timestamp::s_singleton;
5160 
5161 Item*
5163  List<Item> *item_list)
5164 {
5165  Item *func= NULL;
5166  int arg_count= 0;
5167 
5168  if (item_list != NULL)
5169  arg_count= item_list->elements;
5170 
5171  switch (arg_count) {
5172  case 0:
5173  {
5174  func= new (thd->mem_root) Item_func_unix_timestamp();
5175  thd->lex->safe_to_cache_query= 0;
5176  break;
5177  }
5178  case 1:
5179  {
5180  Item *param_1= item_list->pop();
5181  func= new (thd->mem_root) Item_func_unix_timestamp(param_1);
5182  break;
5183  }
5184  default:
5185  {
5186  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
5187  break;
5188  }
5189  }
5190 
5191  return func;
5192 }
5193 
5194 
5195 Create_func_uuid Create_func_uuid::s_singleton;
5196 
5197 Item*
5199 {
5200  DBUG_ENTER("Create_func_uuid::create");
5201  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
5202  thd->lex->safe_to_cache_query= 0;
5203  DBUG_RETURN(new (thd->mem_root) Item_func_uuid());
5204 }
5205 
5206 
5207 Create_func_uuid_short Create_func_uuid_short::s_singleton;
5208 
5209 Item*
5211 {
5212  DBUG_ENTER("Create_func_uuid_short::create");
5213  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
5214  thd->lex->safe_to_cache_query= 0;
5215  DBUG_RETURN(new (thd->mem_root) Item_func_uuid_short());
5216 }
5217 
5218 
5220  Create_func_validate_password_strength::s_singleton;
5221 
5222 Item*
5224 {
5225  return new (thd->mem_root) Item_func_validate_password_strength(arg1);
5226 }
5227 
5228 
5229 Create_func_version Create_func_version::s_singleton;
5230 
5231 Item*
5233 {
5234  thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
5235  return new (thd->mem_root) Item_static_string_func(NAME_STRING("version()"),
5236  server_version,
5237  (uint) strlen(server_version),
5238  system_charset_info,
5239  DERIVATION_SYSCONST);
5240 }
5241 
5242 
5243 Create_func_weekday Create_func_weekday::s_singleton;
5244 
5245 Item*
5247 {
5248  return new (thd->mem_root) Item_func_weekday(arg1, 0);
5249 }
5250 
5251 
5252 Create_func_weekofyear Create_func_weekofyear::s_singleton;
5253 
5254 Item*
5256 {
5257  Item *i1= new (thd->mem_root) Item_int(NAME_STRING("0"), 3, 1);
5258  return new (thd->mem_root) Item_func_week(arg1, i1);
5259 }
5260 
5261 
5262 #ifdef HAVE_SPATIAL
5263 Create_func_mbr_within Create_func_mbr_within::s_singleton;
5264 
5265 Item*
5266 Create_func_mbr_within::create(THD *thd, Item *arg1, Item *arg2)
5267 {
5268  return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
5269  Item_func::SP_WITHIN_FUNC);
5270 }
5271 
5272 
5273 Create_func_within Create_func_within::s_singleton;
5274 
5275 Item*
5276 Create_func_within::create(THD *thd, Item *arg1, Item *arg2)
5277 {
5278  return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
5279  Item_func::SP_WITHIN_FUNC);
5280 }
5281 #endif
5282 
5283 
5284 #ifdef HAVE_SPATIAL
5285 Create_func_x Create_func_x::s_singleton;
5286 
5287 Item*
5288 Create_func_x::create(THD *thd, Item *arg1)
5289 {
5290  return new (thd->mem_root) Item_func_x(arg1);
5291 }
5292 #endif
5293 
5294 
5295 Create_func_xml_extractvalue Create_func_xml_extractvalue::s_singleton;
5296 
5297 Item*
5299 {
5300  return new (thd->mem_root) Item_func_xml_extractvalue(arg1, arg2);
5301 }
5302 
5303 
5304 Create_func_xml_update Create_func_xml_update::s_singleton;
5305 
5306 Item*
5307 Create_func_xml_update::create(THD *thd, Item *arg1, Item *arg2, Item *arg3)
5308 {
5309  return new (thd->mem_root) Item_func_xml_update(arg1, arg2, arg3);
5310 }
5311 
5312 
5313 #ifdef HAVE_SPATIAL
5314 Create_func_y Create_func_y::s_singleton;
5315 
5316 Item*
5317 Create_func_y::create(THD *thd, Item *arg1)
5318 {
5319  return new (thd->mem_root) Item_func_y(arg1);
5320 }
5321 #endif
5322 
5323 
5324 Create_func_year_week Create_func_year_week::s_singleton;
5325 
5326 Item*
5328  List<Item> *item_list)
5329 {
5330  Item *func= NULL;
5331  int arg_count= 0;
5332 
5333  if (item_list != NULL)
5334  arg_count= item_list->elements;
5335 
5336  switch (arg_count) {
5337  case 1:
5338  {
5339  Item *param_1= item_list->pop();
5340  Item *i0= new (thd->mem_root) Item_int_0();
5341  func= new (thd->mem_root) Item_func_yearweek(param_1, i0);
5342  break;
5343  }
5344  case 2:
5345  {
5346  Item *param_1= item_list->pop();
5347  Item *param_2= item_list->pop();
5348  func= new (thd->mem_root) Item_func_yearweek(param_1, param_2);
5349  break;
5350  }
5351  default:
5352  {
5353  my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
5354  break;
5355  }
5356  }
5357 
5358  return func;
5359 }
5360 
5361 
5363 {
5364  LEX_STRING name;
5365  Create_func *builder;
5366 };
5367 
5368 #define BUILDER(F) & F::s_singleton
5369 
5370 #ifdef HAVE_SPATIAL
5371  #define GEOM_BUILDER(F) & F::s_singleton
5372 #else
5373  #define GEOM_BUILDER(F) & Create_func_no_geom::s_singleton
5374 #endif
5375 
5376 /*
5377  MySQL native functions.
5378  MAINTAINER:
5379  - Keep sorted for human lookup. At runtime, a hash table is used.
5380  - do **NOT** conditionally (#ifdef, #ifndef) define a function *NAME*:
5381  doing so will cause user code that works against a --without-XYZ binary
5382  to fail with name collisions against a --with-XYZ binary.
5383  Use something similar to GEOM_BUILDER instead.
5384  - keep 1 line per entry, it makes grep | sort easier
5385 */
5386 
5387 static Native_func_registry func_array[] =
5388 {
5389  { { C_STRING_WITH_LEN("ABS") }, BUILDER(Create_func_abs)},
5390  { { C_STRING_WITH_LEN("ACOS") }, BUILDER(Create_func_acos)},
5391  { { C_STRING_WITH_LEN("ADDTIME") }, BUILDER(Create_func_addtime)},
5392  { { C_STRING_WITH_LEN("AES_DECRYPT") }, BUILDER(Create_func_aes_decrypt)},
5393  { { C_STRING_WITH_LEN("AES_ENCRYPT") }, BUILDER(Create_func_aes_encrypt)},
5394  { { C_STRING_WITH_LEN("AREA") }, GEOM_BUILDER(Create_func_area)},
5395  { { C_STRING_WITH_LEN("ASBINARY") }, GEOM_BUILDER(Create_func_as_wkb)},
5396  { { C_STRING_WITH_LEN("ASIN") }, BUILDER(Create_func_asin)},
5397  { { C_STRING_WITH_LEN("ASTEXT") }, GEOM_BUILDER(Create_func_as_wkt)},
5398  { { C_STRING_WITH_LEN("ASWKB") }, GEOM_BUILDER(Create_func_as_wkb)},
5399  { { C_STRING_WITH_LEN("ASWKT") }, GEOM_BUILDER(Create_func_as_wkt)},
5400  { { C_STRING_WITH_LEN("ATAN") }, BUILDER(Create_func_atan)},
5401  { { C_STRING_WITH_LEN("ATAN2") }, BUILDER(Create_func_atan)},
5402  { { C_STRING_WITH_LEN("BENCHMARK") }, BUILDER(Create_func_benchmark)},
5403  { { C_STRING_WITH_LEN("BIN") }, BUILDER(Create_func_bin)},
5404  { { C_STRING_WITH_LEN("BIT_COUNT") }, BUILDER(Create_func_bit_count)},
5405  { { C_STRING_WITH_LEN("BUFFER") }, GEOM_BUILDER(Create_func_buffer)},
5406  { { C_STRING_WITH_LEN("BIT_LENGTH") }, BUILDER(Create_func_bit_length)},
5407  { { C_STRING_WITH_LEN("CEIL") }, BUILDER(Create_func_ceiling)},
5408  { { C_STRING_WITH_LEN("CEILING") }, BUILDER(Create_func_ceiling)},
5409  { { C_STRING_WITH_LEN("CENTROID") }, GEOM_BUILDER(Create_func_centroid)},
5410  { { C_STRING_WITH_LEN("CHARACTER_LENGTH") }, BUILDER(Create_func_char_length)},
5411  { { C_STRING_WITH_LEN("CHAR_LENGTH") }, BUILDER(Create_func_char_length)},
5412  { { C_STRING_WITH_LEN("COERCIBILITY") }, BUILDER(Create_func_coercibility)},
5413  { { C_STRING_WITH_LEN("COMPRESS") }, BUILDER(Create_func_compress)},
5414  { { C_STRING_WITH_LEN("CONCAT") }, BUILDER(Create_func_concat)},
5415  { { C_STRING_WITH_LEN("CONCAT_WS") }, BUILDER(Create_func_concat_ws)},
5416  { { C_STRING_WITH_LEN("CONNECTION_ID") }, BUILDER(Create_func_connection_id)},
5417  { { C_STRING_WITH_LEN("CONV") }, BUILDER(Create_func_conv)},
5418  { { C_STRING_WITH_LEN("CONVERT_TZ") }, BUILDER(Create_func_convert_tz)},
5419  { { C_STRING_WITH_LEN("COS") }, BUILDER(Create_func_cos)},
5420  { { C_STRING_WITH_LEN("COT") }, BUILDER(Create_func_cot)},
5421  { { C_STRING_WITH_LEN("CRC32") }, BUILDER(Create_func_crc32)},
5422  { { C_STRING_WITH_LEN("CROSSES") }, GEOM_BUILDER(Create_func_crosses)},
5423  { { C_STRING_WITH_LEN("DATEDIFF") }, BUILDER(Create_func_datediff)},
5424  { { C_STRING_WITH_LEN("DATE_FORMAT") }, BUILDER(Create_func_date_format)},
5425  { { C_STRING_WITH_LEN("DAYNAME") }, BUILDER(Create_func_dayname)},
5426  { { C_STRING_WITH_LEN("DAYOFMONTH") }, BUILDER(Create_func_dayofmonth)},
5427  { { C_STRING_WITH_LEN("DAYOFWEEK") }, BUILDER(Create_func_dayofweek)},
5428  { { C_STRING_WITH_LEN("DAYOFYEAR") }, BUILDER(Create_func_dayofyear)},
5429  { { C_STRING_WITH_LEN("DECODE") }, BUILDER(Create_func_decode)},
5430  { { C_STRING_WITH_LEN("DEGREES") }, BUILDER(Create_func_degrees)},
5431  { { C_STRING_WITH_LEN("DES_DECRYPT") }, BUILDER(Create_func_des_decrypt)},
5432  { { C_STRING_WITH_LEN("DES_ENCRYPT") }, BUILDER(Create_func_des_encrypt)},
5433  { { C_STRING_WITH_LEN("DIMENSION") }, GEOM_BUILDER(Create_func_dimension)},
5434  { { C_STRING_WITH_LEN("DISJOINT") }, GEOM_BUILDER(Create_func_mbr_disjoint)},
5435  { { C_STRING_WITH_LEN("ELT") }, BUILDER(Create_func_elt)},
5436  { { C_STRING_WITH_LEN("ENCODE") }, BUILDER(Create_func_encode)},
5437  { { C_STRING_WITH_LEN("ENCRYPT") }, BUILDER(Create_func_encrypt)},
5438  { { C_STRING_WITH_LEN("ENDPOINT") }, GEOM_BUILDER(Create_func_endpoint)},
5439  { { C_STRING_WITH_LEN("ENVELOPE") }, GEOM_BUILDER(Create_func_envelope)},
5440  { { C_STRING_WITH_LEN("EQUALS") }, GEOM_BUILDER(Create_func_mbr_equals)},
5441  { { C_STRING_WITH_LEN("EXP") }, BUILDER(Create_func_exp)},
5442  { { C_STRING_WITH_LEN("EXPORT_SET") }, BUILDER(Create_func_export_set)},
5443  { { C_STRING_WITH_LEN("EXTERIORRING") }, GEOM_BUILDER(Create_func_exteriorring)},
5444  { { C_STRING_WITH_LEN("EXTRACTVALUE") }, BUILDER(Create_func_xml_extractvalue)},
5445  { { C_STRING_WITH_LEN("FIELD") }, BUILDER(Create_func_field)},
5446  { { C_STRING_WITH_LEN("FIND_IN_SET") }, BUILDER(Create_func_find_in_set)},
5447  { { C_STRING_WITH_LEN("FLOOR") }, BUILDER(Create_func_floor)},
5448  { { C_STRING_WITH_LEN("FOUND_ROWS") }, BUILDER(Create_func_found_rows)},
5449  { { C_STRING_WITH_LEN("FROM_BASE64") }, BUILDER(Create_func_from_base64)},
5450  { { C_STRING_WITH_LEN("FROM_DAYS") }, BUILDER(Create_func_from_days)},
5451  { { C_STRING_WITH_LEN("FROM_UNIXTIME") }, BUILDER(Create_func_from_unixtime)},
5452  { { C_STRING_WITH_LEN("GEOMCOLLFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5453  { { C_STRING_WITH_LEN("GEOMCOLLFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5454  { { C_STRING_WITH_LEN("GEOMETRYCOLLECTIONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5455  { { C_STRING_WITH_LEN("GEOMETRYCOLLECTIONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5456  { { C_STRING_WITH_LEN("GEOMETRYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5457  { { C_STRING_WITH_LEN("GEOMETRYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5458  { { C_STRING_WITH_LEN("GEOMETRYN") }, GEOM_BUILDER(Create_func_geometryn)},
5459  { { C_STRING_WITH_LEN("GEOMETRYTYPE") }, GEOM_BUILDER(Create_func_geometry_type)},
5460  { { C_STRING_WITH_LEN("GEOMFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5461  { { C_STRING_WITH_LEN("GEOMFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5462  { { C_STRING_WITH_LEN("GET_LOCK") }, BUILDER(Create_func_get_lock)},
5463  { { C_STRING_WITH_LEN("GLENGTH") }, GEOM_BUILDER(Create_func_glength)},
5464  { { C_STRING_WITH_LEN("GREATEST") }, BUILDER(Create_func_greatest)},
5465  { { C_STRING_WITH_LEN("GTID_SUBTRACT") }, BUILDER(Create_func_gtid_subtract) },
5466  { { C_STRING_WITH_LEN("GTID_SUBSET") }, BUILDER(Create_func_gtid_subset) },
5467  { { C_STRING_WITH_LEN("HEX") }, BUILDER(Create_func_hex)},
5468  { { C_STRING_WITH_LEN("IFNULL") }, BUILDER(Create_func_ifnull)},
5469  { { C_STRING_WITH_LEN("INET_ATON") }, BUILDER(Create_func_inet_aton)},
5470  { { C_STRING_WITH_LEN("INET_NTOA") }, BUILDER(Create_func_inet_ntoa)},
5471  { { C_STRING_WITH_LEN("INET6_ATON") }, BUILDER(Create_func_inet6_aton)},
5472  { { C_STRING_WITH_LEN("INET6_NTOA") }, BUILDER(Create_func_inet6_ntoa)},
5473  { { C_STRING_WITH_LEN("IS_IPV4") }, BUILDER(Create_func_is_ipv4)},
5474  { { C_STRING_WITH_LEN("IS_IPV6") }, BUILDER(Create_func_is_ipv6)},
5475  { { C_STRING_WITH_LEN("IS_IPV4_COMPAT") }, BUILDER(Create_func_is_ipv4_compat)},
5476  { { C_STRING_WITH_LEN("IS_IPV4_MAPPED") }, BUILDER(Create_func_is_ipv4_mapped)},
5477  { { C_STRING_WITH_LEN("INSTR") }, BUILDER(Create_func_instr)},
5478  { { C_STRING_WITH_LEN("INTERIORRINGN") }, GEOM_BUILDER(Create_func_interiorringn)},
5479  { { C_STRING_WITH_LEN("INTERSECTS") }, GEOM_BUILDER(Create_func_mbr_intersects)},
5480  { { C_STRING_WITH_LEN("ISCLOSED") }, GEOM_BUILDER(Create_func_isclosed)},
5481  { { C_STRING_WITH_LEN("ISEMPTY") }, GEOM_BUILDER(Create_func_isempty)},
5482  { { C_STRING_WITH_LEN("ISNULL") }, BUILDER(Create_func_isnull)},
5483  { { C_STRING_WITH_LEN("ISSIMPLE") }, GEOM_BUILDER(Create_func_issimple)},
5484  { { C_STRING_WITH_LEN("IS_FREE_LOCK") }, BUILDER(Create_func_is_free_lock)},
5485  { { C_STRING_WITH_LEN("IS_USED_LOCK") }, BUILDER(Create_func_is_used_lock)},
5486  { { C_STRING_WITH_LEN("LAST_DAY") }, BUILDER(Create_func_last_day)},
5487  { { C_STRING_WITH_LEN("LAST_INSERT_ID") }, BUILDER(Create_func_last_insert_id)},
5488  { { C_STRING_WITH_LEN("LCASE") }, BUILDER(Create_func_lcase)},
5489  { { C_STRING_WITH_LEN("LEAST") }, BUILDER(Create_func_least)},
5490  { { C_STRING_WITH_LEN("LENGTH") }, BUILDER(Create_func_length)},
5491 #ifndef DBUG_OFF
5492  { { C_STRING_WITH_LEN("LIKE_RANGE_MIN") }, BUILDER(Create_func_like_range_min)},
5493  { { C_STRING_WITH_LEN("LIKE_RANGE_MAX") }, BUILDER(Create_func_like_range_max)},
5494 #endif
5495  { { C_STRING_WITH_LEN("LINEFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5496  { { C_STRING_WITH_LEN("LINEFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5497  { { C_STRING_WITH_LEN("LINESTRINGFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5498  { { C_STRING_WITH_LEN("LINESTRINGFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5499  { { C_STRING_WITH_LEN("LN") }, BUILDER(Create_func_ln)},
5500  { { C_STRING_WITH_LEN("LOAD_FILE") }, BUILDER(Create_func_load_file)},
5501  { { C_STRING_WITH_LEN("LOCATE") }, BUILDER(Create_func_locate)},
5502  { { C_STRING_WITH_LEN("LOG") }, BUILDER(Create_func_log)},
5503  { { C_STRING_WITH_LEN("LOG10") }, BUILDER(Create_func_log10)},
5504  { { C_STRING_WITH_LEN("LOG2") }, BUILDER(Create_func_log2)},
5505  { { C_STRING_WITH_LEN("LOWER") }, BUILDER(Create_func_lcase)},
5506  { { C_STRING_WITH_LEN("LPAD") }, BUILDER(Create_func_lpad)},
5507  { { C_STRING_WITH_LEN("LTRIM") }, BUILDER(Create_func_ltrim)},
5508  { { C_STRING_WITH_LEN("MAKEDATE") }, BUILDER(Create_func_makedate)},
5509  { { C_STRING_WITH_LEN("MAKETIME") }, BUILDER(Create_func_maketime)},
5510  { { C_STRING_WITH_LEN("MAKE_SET") }, BUILDER(Create_func_make_set)},
5511  { { C_STRING_WITH_LEN("MASTER_POS_WAIT") }, BUILDER(Create_func_master_pos_wait)},
5512  { { C_STRING_WITH_LEN("MBRCONTAINS") }, GEOM_BUILDER(Create_func_mbr_contains)},
5513  { { C_STRING_WITH_LEN("MBRDISJOINT") }, GEOM_BUILDER(Create_func_mbr_disjoint)},
5514  { { C_STRING_WITH_LEN("MBREQUAL") }, GEOM_BUILDER(Create_func_mbr_equals)},
5515  { { C_STRING_WITH_LEN("MBRINTERSECTS") }, GEOM_BUILDER(Create_func_mbr_intersects)},
5516  { { C_STRING_WITH_LEN("MBROVERLAPS") }, GEOM_BUILDER(Create_func_mbr_overlaps)},
5517  { { C_STRING_WITH_LEN("MBRTOUCHES") }, GEOM_BUILDER(Create_func_touches)},
5518  { { C_STRING_WITH_LEN("MBRWITHIN") }, GEOM_BUILDER(Create_func_mbr_within)},
5519  { { C_STRING_WITH_LEN("MD5") }, BUILDER(Create_func_md5)},
5520  { { C_STRING_WITH_LEN("MLINEFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5521  { { C_STRING_WITH_LEN("MLINEFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5522  { { C_STRING_WITH_LEN("MONTHNAME") }, BUILDER(Create_func_monthname)},
5523  { { C_STRING_WITH_LEN("MPOINTFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5524  { { C_STRING_WITH_LEN("MPOINTFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5525  { { C_STRING_WITH_LEN("MPOLYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5526  { { C_STRING_WITH_LEN("MPOLYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5527  { { C_STRING_WITH_LEN("MULTILINESTRINGFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5528  { { C_STRING_WITH_LEN("MULTILINESTRINGFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5529  { { C_STRING_WITH_LEN("MULTIPOINTFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5530  { { C_STRING_WITH_LEN("MULTIPOINTFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5531  { { C_STRING_WITH_LEN("MULTIPOLYGONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5532  { { C_STRING_WITH_LEN("MULTIPOLYGONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5533  { { C_STRING_WITH_LEN("NAME_CONST") }, BUILDER(Create_func_name_const)},
5534  { { C_STRING_WITH_LEN("NULLIF") }, BUILDER(Create_func_nullif)},
5535  { { C_STRING_WITH_LEN("NUMGEOMETRIES") }, GEOM_BUILDER(Create_func_numgeometries)},
5536  { { C_STRING_WITH_LEN("NUMINTERIORRINGS") }, GEOM_BUILDER(Create_func_numinteriorring)},
5537  { { C_STRING_WITH_LEN("NUMPOINTS") }, GEOM_BUILDER(Create_func_numpoints)},
5538  { { C_STRING_WITH_LEN("OCT") }, BUILDER(Create_func_oct)},
5539  { { C_STRING_WITH_LEN("OCTET_LENGTH") }, BUILDER(Create_func_length)},
5540  { { C_STRING_WITH_LEN("ORD") }, BUILDER(Create_func_ord)},
5541  { { C_STRING_WITH_LEN("OVERLAPS") }, GEOM_BUILDER(Create_func_mbr_overlaps)},
5542  { { C_STRING_WITH_LEN("PERIOD_ADD") }, BUILDER(Create_func_period_add)},
5543  { { C_STRING_WITH_LEN("PERIOD_DIFF") }, BUILDER(Create_func_period_diff)},
5544  { { C_STRING_WITH_LEN("PI") }, BUILDER(Create_func_pi)},
5545  { { C_STRING_WITH_LEN("POINTFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5546  { { C_STRING_WITH_LEN("POINTFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5547  { { C_STRING_WITH_LEN("POINTN") }, GEOM_BUILDER(Create_func_pointn)},
5548  { { C_STRING_WITH_LEN("POLYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5549  { { C_STRING_WITH_LEN("POLYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5550  { { C_STRING_WITH_LEN("POLYGONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5551  { { C_STRING_WITH_LEN("POLYGONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5552  { { C_STRING_WITH_LEN("POW") }, BUILDER(Create_func_pow)},
5553  { { C_STRING_WITH_LEN("POWER") }, BUILDER(Create_func_pow)},
5554  { { C_STRING_WITH_LEN("QUOTE") }, BUILDER(Create_func_quote)},
5555  { { C_STRING_WITH_LEN("RADIANS") }, BUILDER(Create_func_radians)},
5556  { { C_STRING_WITH_LEN("RAND") }, BUILDER(Create_func_rand)},
5557  { { C_STRING_WITH_LEN("RELEASE_LOCK") }, BUILDER(Create_func_release_lock)},
5558  { { C_STRING_WITH_LEN("REVERSE") }, BUILDER(Create_func_reverse)},
5559  { { C_STRING_WITH_LEN("ROUND") }, BUILDER(Create_func_round)},
5560  { { C_STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad)},
5561  { { C_STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim)},
5562  { { C_STRING_WITH_LEN("SEC_TO_TIME") }, BUILDER(Create_func_sec_to_time)},
5563  { { C_STRING_WITH_LEN("SHA") }, BUILDER(Create_func_sha)},
5564  { { C_STRING_WITH_LEN("SHA1") }, BUILDER(Create_func_sha)},
5565  { { C_STRING_WITH_LEN("SHA2") }, BUILDER(Create_func_sha2)},
5566  { { C_STRING_WITH_LEN("SIGN") }, BUILDER(Create_func_sign)},
5567  { { C_STRING_WITH_LEN("SIN") }, BUILDER(Create_func_sin)},
5568  { { C_STRING_WITH_LEN("SLEEP") }, BUILDER(Create_func_sleep)},
5569  { { C_STRING_WITH_LEN("SOUNDEX") }, BUILDER(Create_func_soundex)},
5570  { { C_STRING_WITH_LEN("SPACE") }, BUILDER(Create_func_space)},
5571  { { C_STRING_WITH_LEN("WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS") }, BUILDER(Create_func_master_gtid_set_wait)},
5572  { { C_STRING_WITH_LEN("SQRT") }, BUILDER(Create_func_sqrt)},
5573  { { C_STRING_WITH_LEN("SRID") }, GEOM_BUILDER(Create_func_srid)},
5574  { { C_STRING_WITH_LEN("STARTPOINT") }, GEOM_BUILDER(Create_func_startpoint)},
5575  { { C_STRING_WITH_LEN("STRCMP") }, BUILDER(Create_func_strcmp)},
5576  { { C_STRING_WITH_LEN("STR_TO_DATE") }, BUILDER(Create_func_str_to_date)},
5577  { { C_STRING_WITH_LEN("ST_AREA") }, GEOM_BUILDER(Create_func_area)},
5578  { { C_STRING_WITH_LEN("ST_ASBINARY") }, GEOM_BUILDER(Create_func_as_wkb)},
5579  { { C_STRING_WITH_LEN("ST_ASTEXT") }, GEOM_BUILDER(Create_func_as_wkt)},
5580  { { C_STRING_WITH_LEN("ST_ASWKB") }, GEOM_BUILDER(Create_func_as_wkb)},
5581  { { C_STRING_WITH_LEN("ST_ASWKT") }, GEOM_BUILDER(Create_func_as_wkt)},
5582  { { C_STRING_WITH_LEN("ST_BUFFER") }, GEOM_BUILDER(Create_func_buffer)},
5583  { { C_STRING_WITH_LEN("ST_CENTROID") }, GEOM_BUILDER(Create_func_centroid)},
5584  { { C_STRING_WITH_LEN("ST_CONTAINS") }, GEOM_BUILDER(Create_func_contains)},
5585  { { C_STRING_WITH_LEN("ST_CROSSES") }, GEOM_BUILDER(Create_func_crosses)},
5586  { { C_STRING_WITH_LEN("ST_DIFFERENCE") }, GEOM_BUILDER(Create_func_difference)},
5587  { { C_STRING_WITH_LEN("ST_DIMENSION") }, GEOM_BUILDER(Create_func_dimension)},
5588  { { C_STRING_WITH_LEN("ST_DISJOINT") }, GEOM_BUILDER(Create_func_disjoint)},
5589  { { C_STRING_WITH_LEN("ST_DISTANCE") }, GEOM_BUILDER(Create_func_distance)},
5590  { { C_STRING_WITH_LEN("ST_ENDPOINT") }, GEOM_BUILDER(Create_func_endpoint)},
5591  { { C_STRING_WITH_LEN("ST_ENVELOPE") }, GEOM_BUILDER(Create_func_envelope)},
5592  { { C_STRING_WITH_LEN("ST_EQUALS") }, GEOM_BUILDER(Create_func_mbr_equals)},
5593  { { C_STRING_WITH_LEN("ST_EXTERIORRING") }, GEOM_BUILDER(Create_func_exteriorring)},
5594  { { C_STRING_WITH_LEN("ST_GEOMCOLLFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5595  { { C_STRING_WITH_LEN("ST_GEOMCOLLFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5596  { { C_STRING_WITH_LEN("ST_GEOMETRYCOLLECTIONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5597  { { C_STRING_WITH_LEN("ST_GEOMETRYCOLLECTIONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5598  { { C_STRING_WITH_LEN("ST_GEOMETRYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5599  { { C_STRING_WITH_LEN("ST_GEOMETRYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5600  { { C_STRING_WITH_LEN("ST_GEOMETRYN") }, GEOM_BUILDER(Create_func_geometryn)},
5601  { { C_STRING_WITH_LEN("ST_GEOMETRYTYPE") }, GEOM_BUILDER(Create_func_geometry_type)},
5602  { { C_STRING_WITH_LEN("ST_GEOMFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5603  { { C_STRING_WITH_LEN("ST_GEOMFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5604 #ifndef DBUG_OFF
5605  { { C_STRING_WITH_LEN("ST_GIS_DEBUG") }, GEOM_BUILDER(Create_func_gis_debug)},
5606 #endif
5607  { { C_STRING_WITH_LEN("ST_EQUALS") }, GEOM_BUILDER(Create_func_equals)},
5608  { { C_STRING_WITH_LEN("ST_INTERIORRINGN") }, GEOM_BUILDER(Create_func_interiorringn)},
5609  { { C_STRING_WITH_LEN("ST_INTERSECTS") }, GEOM_BUILDER(Create_func_intersects)},
5610  { { C_STRING_WITH_LEN("ST_INTERSECTION") }, GEOM_BUILDER(Create_func_intersection)},
5611  { { C_STRING_WITH_LEN("ST_ISCLOSED") }, GEOM_BUILDER(Create_func_isclosed)},
5612  { { C_STRING_WITH_LEN("ST_ISEMPTY") }, GEOM_BUILDER(Create_func_isempty)},
5613  { { C_STRING_WITH_LEN("ST_ISSIMPLE") }, GEOM_BUILDER(Create_func_issimple)},
5614  { { C_STRING_WITH_LEN("ST_LENGTH") }, GEOM_BUILDER(Create_func_glength)},
5615  { { C_STRING_WITH_LEN("ST_LINEFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5616  { { C_STRING_WITH_LEN("ST_LINEFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5617  { { C_STRING_WITH_LEN("ST_LINESTRINGFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5618  { { C_STRING_WITH_LEN("ST_LINESTRINGFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5619  { { C_STRING_WITH_LEN("ST_NUMGEOMETRIES") }, GEOM_BUILDER(Create_func_numgeometries)},
5620  { { C_STRING_WITH_LEN("ST_NUMINTERIORRINGS") }, GEOM_BUILDER(Create_func_numinteriorring)},
5621  { { C_STRING_WITH_LEN("ST_NUMPOINTS") }, GEOM_BUILDER(Create_func_numpoints)},
5622  { { C_STRING_WITH_LEN("ST_OVERLAPS") }, GEOM_BUILDER(Create_func_overlaps)},
5623  { { C_STRING_WITH_LEN("ST_POINTFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5624  { { C_STRING_WITH_LEN("ST_POINTFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5625  { { C_STRING_WITH_LEN("ST_POINTN") }, GEOM_BUILDER(Create_func_pointn)},
5626  { { C_STRING_WITH_LEN("ST_POLYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5627  { { C_STRING_WITH_LEN("ST_POLYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5628  { { C_STRING_WITH_LEN("ST_POLYGONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5629  { { C_STRING_WITH_LEN("ST_POLYGONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5630  { { C_STRING_WITH_LEN("ST_SRID") }, GEOM_BUILDER(Create_func_srid)},
5631  { { C_STRING_WITH_LEN("ST_STARTPOINT") }, GEOM_BUILDER(Create_func_startpoint)},
5632  { { C_STRING_WITH_LEN("ST_SYMDIFFERENCE") }, GEOM_BUILDER(Create_func_symdifference)},
5633  { { C_STRING_WITH_LEN("ST_TOUCHES") }, GEOM_BUILDER(Create_func_touches)},
5634  { { C_STRING_WITH_LEN("ST_UNION") }, GEOM_BUILDER(Create_func_union)},
5635  { { C_STRING_WITH_LEN("ST_WITHIN") }, GEOM_BUILDER(Create_func_within)},
5636  { { C_STRING_WITH_LEN("ST_X") }, GEOM_BUILDER(Create_func_x)},
5637  { { C_STRING_WITH_LEN("ST_Y") }, GEOM_BUILDER(Create_func_y)},
5638  { { C_STRING_WITH_LEN("SUBSTRING_INDEX") }, BUILDER(Create_func_substr_index)},
5639  { { C_STRING_WITH_LEN("SUBTIME") }, BUILDER(Create_func_subtime)},
5640  { { C_STRING_WITH_LEN("TAN") }, BUILDER(Create_func_tan)},
5641  { { C_STRING_WITH_LEN("TIMEDIFF") }, BUILDER(Create_func_timediff)},
5642  { { C_STRING_WITH_LEN("TIME_FORMAT") }, BUILDER(Create_func_time_format)},
5643  { { C_STRING_WITH_LEN("TIME_TO_SEC") }, BUILDER(Create_func_time_to_sec)},
5644  { { C_STRING_WITH_LEN("TOUCHES") }, GEOM_BUILDER(Create_func_touches)},
5645  { { C_STRING_WITH_LEN("TO_BASE64") }, BUILDER(Create_func_to_base64)},
5646  { { C_STRING_WITH_LEN("TO_DAYS") }, BUILDER(Create_func_to_days)},
5647  { { C_STRING_WITH_LEN("TO_SECONDS") }, BUILDER(Create_func_to_seconds)},
5648  { { C_STRING_WITH_LEN("UCASE") }, BUILDER(Create_func_ucase)},
5649  { { C_STRING_WITH_LEN("UNCOMPRESS") }, BUILDER(Create_func_uncompress)},
5650  { { C_STRING_WITH_LEN("UNCOMPRESSED_LENGTH") }, BUILDER(Create_func_uncompressed_length)},
5651  { { C_STRING_WITH_LEN("UNHEX") }, BUILDER(Create_func_unhex)},
5652  { { C_STRING_WITH_LEN("UNIX_TIMESTAMP") }, BUILDER(Create_func_unix_timestamp)},
5653  { { C_STRING_WITH_LEN("UPDATEXML") }, BUILDER(Create_func_xml_update)},
5654  { { C_STRING_WITH_LEN("UPPER") }, BUILDER(Create_func_ucase)},
5655  { { C_STRING_WITH_LEN("UUID") }, BUILDER(Create_func_uuid)},
5656  { { C_STRING_WITH_LEN("UUID_SHORT") }, BUILDER(Create_func_uuid_short)},
5657  { { C_STRING_WITH_LEN("VALIDATE_PASSWORD_STRENGTH") }, BUILDER(Create_func_validate_password_strength)},
5658  { { C_STRING_WITH_LEN("VERSION") }, BUILDER(Create_func_version)},
5659  { { C_STRING_WITH_LEN("WEEKDAY") }, BUILDER(Create_func_weekday)},
5660  { { C_STRING_WITH_LEN("WEEKOFYEAR") }, BUILDER(Create_func_weekofyear)},
5661  { { C_STRING_WITH_LEN("WITHIN") }, GEOM_BUILDER(Create_func_mbr_within)},
5662  { { C_STRING_WITH_LEN("X") }, GEOM_BUILDER(Create_func_x)},
5663  { { C_STRING_WITH_LEN("Y") }, GEOM_BUILDER(Create_func_y)},
5664  { { C_STRING_WITH_LEN("YEARWEEK") }, BUILDER(Create_func_year_week)},
5665 
5666  { {0, 0}, NULL}
5667 };
5668 
5669 static HASH native_functions_hash;
5670 
5671 extern "C" uchar*
5672 get_native_fct_hash_key(const uchar *buff, size_t *length,
5673  my_bool /* unused */)
5674 {
5676  *length= func->name.length;
5677  return (uchar*) func->name.str;
5678 }
5679 
5680 /*
5681  Load the hash table for native functions.
5682  Note: this code is not thread safe, and is intended to be used at server
5683  startup only (before going multi-threaded)
5684 */
5685 
5686 int item_create_init()
5687 {
5688  Native_func_registry *func;
5689 
5690  DBUG_ENTER("item_create_init");
5691 
5692  if (my_hash_init(& native_functions_hash,
5693  system_charset_info,
5694  array_elements(func_array),
5695  0,
5696  0,
5697  (my_hash_get_key) get_native_fct_hash_key,
5698  NULL, /* Nothing to free */
5699  MYF(0)))
5700  DBUG_RETURN(1);
5701 
5702  for (func= func_array; func->builder != NULL; func++)
5703  {
5704  if (my_hash_insert(& native_functions_hash, (uchar*) func))
5705  DBUG_RETURN(1);
5706  }
5707 
5708 #ifndef DBUG_OFF
5709  for (uint i=0 ; i < native_functions_hash.records ; i++)
5710  {
5711  func= (Native_func_registry*) my_hash_element(& native_functions_hash, i);
5712  DBUG_PRINT("info", ("native function: %s length: %u",
5713  func->name.str, (uint) func->name.length));
5714  }
5715 #endif
5716 
5717  DBUG_RETURN(0);
5718 }
5719 
5720 /*
5721  Empty the hash table for native functions.
5722  Note: this code is not thread safe, and is intended to be used at server
5723  shutdown only (after thread requests have been executed).
5724 */
5725 
5726 void item_create_cleanup()
5727 {
5728  DBUG_ENTER("item_create_cleanup");
5729  my_hash_free(& native_functions_hash);
5730  DBUG_VOID_RETURN;
5731 }
5732 
5733 Create_func *
5735 {
5736  Native_func_registry *func;
5737  Create_func *builder= NULL;
5738 
5739  /* Thread safe */
5740  func= (Native_func_registry*) my_hash_search(& native_functions_hash,
5741  (uchar*) name.str,
5742  name.length);
5743 
5744  if (func)
5745  {
5746  builder= func->builder;
5747  }
5748 
5749  return builder;
5750 }
5751 
5752 Create_qfunc *
5754 {
5755  return & Create_sp_func::s_singleton;
5756 }
5757 
5758 
5759 Item *
5760 create_func_cast(THD *thd, Item *a, Cast_target cast_type,
5761  const char *c_len, const char *c_dec,
5762  const CHARSET_INFO *cs)
5763 {
5764  Item *UNINIT_VAR(res);
5765 
5766  switch (cast_type) {
5767  case ITEM_CAST_BINARY:
5768  res= new (thd->mem_root) Item_func_binary(a);
5769  break;
5770  case ITEM_CAST_SIGNED_INT:
5771  res= new (thd->mem_root) Item_func_signed(a);
5772  break;
5773  case ITEM_CAST_UNSIGNED_INT:
5774  res= new (thd->mem_root) Item_func_unsigned(a);
5775  break;
5776  case ITEM_CAST_DATE:
5777  res= new (thd->mem_root) Item_date_typecast(a);
5778  break;
5779  case ITEM_CAST_TIME:
5780  case ITEM_CAST_DATETIME:
5781  {
5782  uint dec= c_dec ? strtoul(c_dec, NULL, 10) : 0;
5783  if (dec > DATETIME_MAX_DECIMALS)
5784  {
5785  my_error(ER_TOO_BIG_PRECISION, MYF(0),
5786  (int) dec, "CAST", DATETIME_MAX_DECIMALS);
5787  return 0;
5788  }
5789  res= (cast_type == ITEM_CAST_TIME) ?
5790  (Item*) new (thd->mem_root) Item_time_typecast(a, dec) :
5791  (Item*) new (thd->mem_root) Item_datetime_typecast(a, dec);
5792  break;
5793  }
5794  case ITEM_CAST_DECIMAL:
5795  {
5796  ulong len= 0;
5797  uint dec= 0;
5798 
5799  if (c_len)
5800  {
5801  ulong decoded_size;
5802  errno= 0;
5803  decoded_size= strtoul(c_len, NULL, 10);
5804  if (errno != 0)
5805  {
5806  my_error(ER_TOO_BIG_PRECISION, MYF(0), INT_MAX, a->item_name.ptr(),
5807  static_cast<ulong>(DECIMAL_MAX_PRECISION));
5808  return NULL;
5809  }
5810  len= decoded_size;
5811  }
5812 
5813  if (c_dec)
5814  {
5815  ulong decoded_size;
5816  errno= 0;
5817  decoded_size= strtoul(c_dec, NULL, 10);
5818  if ((errno != 0) || (decoded_size > UINT_MAX))
5819  {
5820  my_error(ER_TOO_BIG_SCALE, MYF(0), INT_MAX, a->item_name.ptr(),
5821  static_cast<ulong>(DECIMAL_MAX_SCALE));
5822  return NULL;
5823  }
5824  dec= decoded_size;
5825  }
5826  my_decimal_trim(&len, &dec);
5827  if (len < dec)
5828  {
5829  my_error(ER_M_BIGGER_THAN_D, MYF(0), "");
5830  return 0;
5831  }
5832  if (len > DECIMAL_MAX_PRECISION)
5833  {
5834  my_error(ER_TOO_BIG_PRECISION, MYF(0), static_cast<int>(len), a->item_name.ptr(),
5835  static_cast<ulong>(DECIMAL_MAX_PRECISION));
5836  return 0;
5837  }
5838  if (dec > DECIMAL_MAX_SCALE)
5839  {
5840  my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->item_name.ptr(),
5841  static_cast<ulong>(DECIMAL_MAX_SCALE));
5842  return 0;
5843  }
5844  res= new (thd->mem_root) Item_decimal_typecast(a, len, dec);
5845  break;
5846  }
5847  case ITEM_CAST_CHAR:
5848  {
5849  int len= -1;
5850  const CHARSET_INFO *real_cs=
5851  (cs ? cs : thd->variables.collation_connection);
5852  if (c_len)
5853  {
5854  ulong decoded_size;
5855  errno= 0;
5856  decoded_size= strtoul(c_len, NULL, 10);
5857  if ((errno != 0) || (decoded_size > MAX_FIELD_BLOBLENGTH))
5858  {
5859  my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), "cast as char", MAX_FIELD_BLOBLENGTH);
5860  return NULL;
5861  }
5862  len= (int) decoded_size;
5863  }
5864  res= new (thd->mem_root) Item_char_typecast(a, len, real_cs);
5865  break;
5866  }
5867  default:
5868  {
5869  DBUG_ASSERT(0);
5870  res= 0;
5871  break;
5872  }
5873  }
5874  return res;
5875 }
5876 
5877 
5889  const char *str, uint length,
5890  const CHARSET_INFO *cs,
5891  enum_field_types type, bool send_error)
5892 {
5893  MYSQL_TIME_STATUS status;
5894  MYSQL_TIME ltime;
5895  Item *item= NULL;
5896  ulonglong flags= TIME_FUZZY_DATE | thd->datetime_flags();
5897 
5898  switch(type)
5899  {
5900  case MYSQL_TYPE_DATE:
5901  case MYSQL_TYPE_NEWDATE:
5902  if (!str_to_datetime(cs, str, length, &ltime, flags, &status) &&
5903  ltime.time_type == MYSQL_TIMESTAMP_DATE && !status.warnings)
5904  item= new (thd->mem_root) Item_date_literal(&ltime);
5905  break;
5906  case MYSQL_TYPE_DATETIME:
5907  if (!str_to_datetime(cs, str, length, &ltime, flags, &status) &&
5908  ltime.time_type == MYSQL_TIMESTAMP_DATETIME && !status.warnings)
5909  item= new (thd->mem_root) Item_datetime_literal(&ltime,
5910  status.fractional_digits);
5911  break;
5912  case MYSQL_TYPE_TIME:
5913  if (!str_to_time(cs, str, length, &ltime, 0, &status) &&
5914  ltime.time_type == MYSQL_TIMESTAMP_TIME && !status.warnings)
5915  item= new (thd->mem_root) Item_time_literal(&ltime,
5916  status.fractional_digits);
5917  break;
5918  default:
5919  DBUG_ASSERT(0);
5920  }
5921 
5922  if (item)
5923  return item;
5924 
5925  if (send_error)
5926  {
5927  const char *typestr=
5928  (type == MYSQL_TYPE_DATE) ? "DATE" :
5929  (type == MYSQL_TYPE_TIME) ? "TIME" : "DATETIME";
5930  ErrConvString err(str, length, thd->variables.character_set_client);
5931  my_error(ER_WRONG_VALUE, MYF(0), typestr, err.ptr());
5932  }
5933  return NULL;
5934 }