1 /*
2    Copyright (c) 2000, 2011, Oracle and/or its affiliates.
3    Copyright (c) 2008, 2021, MariaDB Corporation.
4 
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; version 2 of the License.
8 
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335  USA */
17 
18 /**
19   @file
20 
21   @brief
22   Functions to create an item. Used by sql_yac.yy
23 */
24 
25 #include "mariadb.h"
26 #include "sql_priv.h"
27 /*
28   It is necessary to include set_var.h instead of item.h because there
29   are dependencies on include order for set_var.h and item.h. This
30   will be resolved later.
31 */
32 #include "sql_class.h"                          // set_var.h: THD
33 #include "set_var.h"
34 #include "sp_head.h"
35 #include "sp.h"
36 #include "item_inetfunc.h"
37 #include "sql_time.h"
38 
39 /*
40 =============================================================================
41   LOCAL DECLARATIONS
42 =============================================================================
43 */
44 
45 /**
46   Adapter for functions that takes exactly zero arguments.
47 */
48 
49 class Create_func_arg0 : public Create_func
50 {
51 public:
52   virtual Item *create_func(THD *thd, LEX_CSTRING *name,
53                             List<Item> *item_list);
54 
55   /**
56     Builder method, with no arguments.
57     @param thd The current thread
58     @return An item representing the function call
59   */
60   virtual Item *create_builder(THD *thd) = 0;
61 
62 protected:
63   /** Constructor. */
Create_func_arg0()64   Create_func_arg0() {}
65   /** Destructor. */
~Create_func_arg0()66   virtual ~Create_func_arg0() {}
67 };
68 
69 
70 /**
71   Adapter for functions that takes exactly one argument.
72 */
73 
74 class Create_func_arg1 : public Create_func
75 {
76 public:
77   virtual Item *create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
78 
79   /**
80     Builder method, with one argument.
81     @param thd The current thread
82     @param arg1 The first argument of the function
83     @return An item representing the function call
84   */
85   virtual Item *create_1_arg(THD *thd, Item *arg1) = 0;
86 
87 protected:
88   /** Constructor. */
Create_func_arg1()89   Create_func_arg1() {}
90   /** Destructor. */
~Create_func_arg1()91   virtual ~Create_func_arg1() {}
92 };
93 
94 
95 /**
96   Adapter for functions that takes exactly two arguments.
97 */
98 
99 class Create_func_arg2 : public Create_func
100 {
101 public:
102   virtual Item *create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
103 
104   /**
105     Builder method, with two arguments.
106     @param thd The current thread
107     @param arg1 The first argument of the function
108     @param arg2 The second argument of the function
109     @return An item representing the function call
110   */
111   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2) = 0;
112 protected:
113   /** Constructor. */
Create_func_arg2()114   Create_func_arg2() {}
115   /** Destructor. */
~Create_func_arg2()116   virtual ~Create_func_arg2() {}
117 };
118 
119 
120 /**
121   Adapter for functions that takes exactly three arguments.
122 */
123 
124 class Create_func_arg3 : public Create_func
125 {
126 public:
127   virtual Item *create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
128 
129   /**
130     Builder method, with three arguments.
131     @param thd The current thread
132     @param arg1 The first argument of the function
133     @param arg2 The second argument of the function
134     @param arg3 The third argument of the function
135     @return An item representing the function call
136   */
137   virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) = 0;
138 protected:
139   /** Constructor. */
Create_func_arg3()140   Create_func_arg3() {}
141   /** Destructor. */
~Create_func_arg3()142   virtual ~Create_func_arg3() {}
143 };
144 
145 
146 /**
147   Function builder for Stored Functions.
148 */
149 
150 class Create_sp_func : public Create_qfunc
151 {
152 public:
153   virtual Item *create_with_db(THD *thd, LEX_CSTRING *db, LEX_CSTRING *name,
154                                bool use_explicit_name, List<Item> *item_list);
155 
156   static Create_sp_func s_singleton;
157 
158 protected:
159   /** Constructor. */
Create_sp_func()160   Create_sp_func() {}
161   /** Destructor. */
~Create_sp_func()162   virtual ~Create_sp_func() {}
163 };
164 
165 
166 #ifndef HAVE_SPATIAL
167 /**
168   Common (non) builder for geometry functions.
169   This builder is used in <code>--without-geometry</code> builds only,
170   to report an error.
171 */
172 
173 class Create_func_no_geom : public Create_func
174 {
175 public:
176   virtual Item *create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
177 
178   /** Singleton. */
179   static Create_func_no_geom s_singleton;
180 
181 protected:
182   /** Constructor. */
Create_func_no_geom()183   Create_func_no_geom() {}
184   /** Destructor. */
~Create_func_no_geom()185   virtual ~Create_func_no_geom() {}
186 };
187 #endif
188 
189 
190 /*
191   Concrete functions builders (native functions).
192   Please keep this list sorted in alphabetical order,
193   it helps to compare code between versions, and helps with merges conflicts.
194 */
195 
196 class Create_func_abs : public Create_func_arg1
197 {
198 public:
199   virtual Item *create_1_arg(THD *thd, Item *arg1);
200 
201   static Create_func_abs s_singleton;
202 
203 protected:
Create_func_abs()204   Create_func_abs() {}
~Create_func_abs()205   virtual ~Create_func_abs() {}
206 };
207 
208 
209 class Create_func_acos : public Create_func_arg1
210 {
211 public:
212   virtual Item *create_1_arg(THD *thd, Item *arg1);
213 
214   static Create_func_acos s_singleton;
215 
216 protected:
Create_func_acos()217   Create_func_acos() {}
~Create_func_acos()218   virtual ~Create_func_acos() {}
219 };
220 
221 
222 class Create_func_addtime : public Create_func_arg2
223 {
224 public:
225   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
226 
227   static Create_func_addtime s_singleton;
228 
229 protected:
Create_func_addtime()230   Create_func_addtime() {}
~Create_func_addtime()231   virtual ~Create_func_addtime() {}
232 };
233 
234 
235 class Create_func_aes_encrypt : public Create_func_arg2
236 {
237 public:
238   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
239 
240   static Create_func_aes_encrypt s_singleton;
241 
242 protected:
Create_func_aes_encrypt()243   Create_func_aes_encrypt() {}
~Create_func_aes_encrypt()244   virtual ~Create_func_aes_encrypt() {}
245 };
246 
247 
248 class Create_func_aes_decrypt : public Create_func_arg2
249 {
250 public:
251   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
252 
253   static Create_func_aes_decrypt s_singleton;
254 
255 protected:
Create_func_aes_decrypt()256   Create_func_aes_decrypt() {}
~Create_func_aes_decrypt()257   virtual ~Create_func_aes_decrypt() {}
258 };
259 
260 
261 #ifdef HAVE_SPATIAL
262 class Create_func_area : public Create_func_arg1
263 {
264 public:
265   virtual Item *create_1_arg(THD *thd, Item *arg1);
266 
267   static Create_func_area s_singleton;
268 
269 protected:
Create_func_area()270   Create_func_area() {}
~Create_func_area()271   virtual ~Create_func_area() {}
272 };
273 #endif
274 
275 
276 #ifdef HAVE_SPATIAL
277 class Create_func_as_wkb : public Create_func_arg1
278 {
279 public:
280   virtual Item *create_1_arg(THD *thd, Item *arg1);
281 
282   static Create_func_as_wkb s_singleton;
283 
284 protected:
Create_func_as_wkb()285   Create_func_as_wkb() {}
~Create_func_as_wkb()286   virtual ~Create_func_as_wkb() {}
287 };
288 #endif
289 
290 
291 #ifdef HAVE_SPATIAL
292 class Create_func_as_wkt : public Create_func_arg1
293 {
294 public:
295   virtual Item *create_1_arg(THD *thd, Item *arg1);
296 
297   static Create_func_as_wkt s_singleton;
298 
299 protected:
Create_func_as_wkt()300   Create_func_as_wkt() {}
~Create_func_as_wkt()301   virtual ~Create_func_as_wkt() {}
302 };
303 #endif
304 
305 
306 class Create_func_asin : public Create_func_arg1
307 {
308 public:
309   virtual Item *create_1_arg(THD *thd, Item *arg1);
310 
311   static Create_func_asin s_singleton;
312 
313 protected:
Create_func_asin()314   Create_func_asin() {}
~Create_func_asin()315   virtual ~Create_func_asin() {}
316 };
317 
318 
319 class Create_func_atan : public Create_native_func
320 {
321 public:
322   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
323 
324   static Create_func_atan s_singleton;
325 
326 protected:
Create_func_atan()327   Create_func_atan() {}
~Create_func_atan()328   virtual ~Create_func_atan() {}
329 };
330 
331 
332 class Create_func_benchmark : public Create_func_arg2
333 {
334 public:
335   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
336 
337   static Create_func_benchmark s_singleton;
338 
339 protected:
Create_func_benchmark()340   Create_func_benchmark() {}
~Create_func_benchmark()341   virtual ~Create_func_benchmark() {}
342 };
343 
344 
345 class Create_func_bin : public Create_func_arg1
346 {
347 public:
348   virtual Item *create_1_arg(THD *thd, Item *arg1);
349 
350   static Create_func_bin s_singleton;
351 
352 protected:
Create_func_bin()353   Create_func_bin() {}
~Create_func_bin()354   virtual ~Create_func_bin() {}
355 };
356 
357 
358 class Create_func_binlog_gtid_pos : public Create_func_arg2
359 {
360 public:
361   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
362 
363   static Create_func_binlog_gtid_pos s_singleton;
364 
365 protected:
Create_func_binlog_gtid_pos()366   Create_func_binlog_gtid_pos() {}
~Create_func_binlog_gtid_pos()367   virtual ~Create_func_binlog_gtid_pos() {}
368 };
369 
370 
371 class Create_func_bit_count : public Create_func_arg1
372 {
373 public:
374   virtual Item *create_1_arg(THD *thd, Item *arg1);
375 
376   static Create_func_bit_count s_singleton;
377 
378 protected:
Create_func_bit_count()379   Create_func_bit_count() {}
~Create_func_bit_count()380   virtual ~Create_func_bit_count() {}
381 };
382 
383 
384 class Create_func_bit_length : public Create_func_arg1
385 {
386 public:
387   virtual Item *create_1_arg(THD *thd, Item *arg1);
388 
389   static Create_func_bit_length s_singleton;
390 
391 protected:
Create_func_bit_length()392   Create_func_bit_length() {}
~Create_func_bit_length()393   virtual ~Create_func_bit_length() {}
394 };
395 
396 
397 class Create_func_ceiling : public Create_func_arg1
398 {
399 public:
400   virtual Item *create_1_arg(THD *thd, Item *arg1);
401 
402   static Create_func_ceiling s_singleton;
403 
404 protected:
Create_func_ceiling()405   Create_func_ceiling() {}
~Create_func_ceiling()406   virtual ~Create_func_ceiling() {}
407 };
408 
409 
410 #ifdef HAVE_SPATIAL
411 class Create_func_centroid : public Create_func_arg1
412 {
413 public:
414   virtual Item *create_1_arg(THD *thd, Item *arg1);
415 
416   static Create_func_centroid s_singleton;
417 
418 protected:
Create_func_centroid()419   Create_func_centroid() {}
~Create_func_centroid()420   virtual ~Create_func_centroid() {}
421 };
422 
423 
424 class Create_func_chr : public Create_func_arg1
425 {
426 public:
427   virtual Item *create_1_arg(THD *thd, Item *arg1);
428 
429   static Create_func_chr s_singleton;
430 
431 protected:
Create_func_chr()432   Create_func_chr() {}
~Create_func_chr()433   virtual ~Create_func_chr() {}
434 };
435 
436 
437 class Create_func_convexhull : public Create_func_arg1
438 {
439 public:
440   virtual Item *create_1_arg(THD *thd, Item *arg1);
441 
442   static Create_func_convexhull s_singleton;
443 
444 protected:
Create_func_convexhull()445   Create_func_convexhull() {}
~Create_func_convexhull()446   virtual ~Create_func_convexhull() {}
447 };
448 
449 
450 class Create_func_pointonsurface : public Create_func_arg1
451 {
452 public:
453   virtual Item *create_1_arg(THD *thd, Item *arg1);
454 
455   static Create_func_pointonsurface s_singleton;
456 
457 protected:
Create_func_pointonsurface()458   Create_func_pointonsurface() {}
~Create_func_pointonsurface()459   virtual ~Create_func_pointonsurface() {}
460 };
461 
462 
463 #endif /*HAVE_SPATIAL*/
464 
465 
466 class Create_func_char_length : public Create_func_arg1
467 {
468 public:
469   virtual Item *create_1_arg(THD *thd, Item *arg1);
470 
471   static Create_func_char_length s_singleton;
472 
473 protected:
Create_func_char_length()474   Create_func_char_length() {}
~Create_func_char_length()475   virtual ~Create_func_char_length() {}
476 };
477 
478 
479 class Create_func_coercibility : public Create_func_arg1
480 {
481 public:
482   virtual Item *create_1_arg(THD *thd, Item *arg1);
483 
484   static Create_func_coercibility s_singleton;
485 
486 protected:
Create_func_coercibility()487   Create_func_coercibility() {}
~Create_func_coercibility()488   virtual ~Create_func_coercibility() {}
489 };
490 
491 class Create_func_dyncol_check : public Create_func_arg1
492 {
493 public:
494   virtual Item *create_1_arg(THD *thd, Item *arg1);
495 
496   static Create_func_dyncol_check s_singleton;
497 
498 protected:
Create_func_dyncol_check()499   Create_func_dyncol_check() {}
~Create_func_dyncol_check()500   virtual ~Create_func_dyncol_check() {}
501 };
502 
503 class Create_func_dyncol_exists : public Create_func_arg2
504 {
505 public:
506   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
507 
508   static Create_func_dyncol_exists s_singleton;
509 
510 protected:
Create_func_dyncol_exists()511   Create_func_dyncol_exists() {}
~Create_func_dyncol_exists()512   virtual ~Create_func_dyncol_exists() {}
513 };
514 
515 class Create_func_dyncol_list : public Create_func_arg1
516 {
517 public:
518   virtual Item *create_1_arg(THD *thd, Item *arg1);
519 
520   static Create_func_dyncol_list s_singleton;
521 
522 protected:
Create_func_dyncol_list()523   Create_func_dyncol_list() {}
~Create_func_dyncol_list()524   virtual ~Create_func_dyncol_list() {}
525 };
526 
527 class Create_func_dyncol_json : public Create_func_arg1
528 {
529 public:
530   virtual Item *create_1_arg(THD *thd, Item *arg1);
531 
532   static Create_func_dyncol_json s_singleton;
533 
534 protected:
Create_func_dyncol_json()535   Create_func_dyncol_json() {}
~Create_func_dyncol_json()536   virtual ~Create_func_dyncol_json() {}
537 };
538 
539 
540 class Create_func_compress : public Create_func_arg1
541 {
542 public:
543   virtual Item *create_1_arg(THD *thd, Item *arg1);
544 
545   static Create_func_compress s_singleton;
546 
547 protected:
Create_func_compress()548   Create_func_compress() {}
~Create_func_compress()549   virtual ~Create_func_compress() {}
550 };
551 
552 
553 class Create_func_concat : public Create_native_func
554 {
555 public:
556   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
557 
558   static Create_func_concat s_singleton;
559 
560 protected:
Create_func_concat()561   Create_func_concat() {}
~Create_func_concat()562   virtual ~Create_func_concat() {}
563 };
564 
565 
566 class Create_func_concat_operator_oracle : public Create_native_func
567 {
568 public:
569   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
570 
571   static Create_func_concat_operator_oracle s_singleton;
572 
573 protected:
Create_func_concat_operator_oracle()574   Create_func_concat_operator_oracle() {}
~Create_func_concat_operator_oracle()575   virtual ~Create_func_concat_operator_oracle() {}
576 };
577 
578 
579 class Create_func_decode_histogram : public Create_func_arg2
580 {
581 public:
582   Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
583 
584   static Create_func_decode_histogram s_singleton;
585 
586 protected:
Create_func_decode_histogram()587   Create_func_decode_histogram() {}
~Create_func_decode_histogram()588   virtual ~Create_func_decode_histogram() {}
589 };
590 
591 
592 class Create_func_decode_oracle : public Create_native_func
593 {
594 public:
595   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
596 
597   static Create_func_decode_oracle s_singleton;
598 
599 protected:
Create_func_decode_oracle()600   Create_func_decode_oracle() {}
~Create_func_decode_oracle()601   virtual ~Create_func_decode_oracle() {}
602 };
603 
604 
605 class Create_func_concat_ws : public Create_native_func
606 {
607 public:
608   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
609 
610   static Create_func_concat_ws s_singleton;
611 
612 protected:
Create_func_concat_ws()613   Create_func_concat_ws() {}
~Create_func_concat_ws()614   virtual ~Create_func_concat_ws() {}
615 };
616 
617 
618 class Create_func_connection_id : public Create_func_arg0
619 {
620 public:
621   virtual Item *create_builder(THD *thd);
622 
623   static Create_func_connection_id s_singleton;
624 
625 protected:
Create_func_connection_id()626   Create_func_connection_id() {}
~Create_func_connection_id()627   virtual ~Create_func_connection_id() {}
628 };
629 
630 
631 #ifdef HAVE_SPATIAL
632 class Create_func_mbr_contains : public Create_func_arg2
633 {
634   public:
635     virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
636 
637     static Create_func_mbr_contains s_singleton;
638 
639   protected:
Create_func_mbr_contains()640     Create_func_mbr_contains() {}
~Create_func_mbr_contains()641     virtual ~Create_func_mbr_contains() {}
642 };
643 
644 
645 class Create_func_contains : public Create_func_arg2
646 {
647 public:
648   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
649 
650   static Create_func_contains s_singleton;
651 
652 protected:
Create_func_contains()653   Create_func_contains() {}
~Create_func_contains()654   virtual ~Create_func_contains() {}
655 };
656 #endif
657 
658 
659 class Create_func_nvl2 : public Create_func_arg3
660 {
661 public:
662   virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3);
663 
664   static Create_func_nvl2 s_singleton;
665 
666 protected:
Create_func_nvl2()667   Create_func_nvl2() {}
~Create_func_nvl2()668   virtual ~Create_func_nvl2() {}
669 };
670 
671 
672 class Create_func_conv : public Create_func_arg3
673 {
674 public:
675   virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3);
676 
677   static Create_func_conv s_singleton;
678 
679 protected:
Create_func_conv()680   Create_func_conv() {}
~Create_func_conv()681   virtual ~Create_func_conv() {}
682 };
683 
684 
685 class Create_func_convert_tz : public Create_func_arg3
686 {
687 public:
688   virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3);
689 
690   static Create_func_convert_tz s_singleton;
691 
692 protected:
Create_func_convert_tz()693   Create_func_convert_tz() {}
~Create_func_convert_tz()694   virtual ~Create_func_convert_tz() {}
695 };
696 
697 
698 class Create_func_cos : public Create_func_arg1
699 {
700 public:
701   virtual Item *create_1_arg(THD *thd, Item *arg1);
702 
703   static Create_func_cos s_singleton;
704 
705 protected:
Create_func_cos()706   Create_func_cos() {}
~Create_func_cos()707   virtual ~Create_func_cos() {}
708 };
709 
710 
711 class Create_func_cot : public Create_func_arg1
712 {
713 public:
714   virtual Item *create_1_arg(THD *thd, Item *arg1);
715 
716   static Create_func_cot s_singleton;
717 
718 protected:
Create_func_cot()719   Create_func_cot() {}
~Create_func_cot()720   virtual ~Create_func_cot() {}
721 };
722 
723 
724 class Create_func_crc32 : public Create_func_arg1
725 {
726 public:
727   virtual Item *create_1_arg(THD *thd, Item *arg1);
728 
729   static Create_func_crc32 s_singleton;
730 
731 protected:
Create_func_crc32()732   Create_func_crc32() {}
~Create_func_crc32()733   virtual ~Create_func_crc32() {}
734 };
735 
736 
737 #ifdef HAVE_SPATIAL
738 class Create_func_crosses : public Create_func_arg2
739 {
740 public:
741   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
742 
743   static Create_func_crosses s_singleton;
744 
745 protected:
Create_func_crosses()746   Create_func_crosses() {}
~Create_func_crosses()747   virtual ~Create_func_crosses() {}
748 };
749 #endif
750 
751 
752 class Create_func_datediff : public Create_func_arg2
753 {
754 public:
755   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
756 
757   static Create_func_datediff s_singleton;
758 
759 protected:
Create_func_datediff()760   Create_func_datediff() {}
~Create_func_datediff()761   virtual ~Create_func_datediff() {}
762 };
763 
764 
765 class Create_func_dayname : public Create_func_arg1
766 {
767 public:
768   virtual Item *create_1_arg(THD *thd, Item *arg1);
769 
770   static Create_func_dayname s_singleton;
771 
772 protected:
Create_func_dayname()773   Create_func_dayname() {}
~Create_func_dayname()774   virtual ~Create_func_dayname() {}
775 };
776 
777 
778 class Create_func_dayofmonth : public Create_func_arg1
779 {
780 public:
781   virtual Item *create_1_arg(THD *thd, Item *arg1);
782 
783   static Create_func_dayofmonth s_singleton;
784 
785 protected:
Create_func_dayofmonth()786   Create_func_dayofmonth() {}
~Create_func_dayofmonth()787   virtual ~Create_func_dayofmonth() {}
788 };
789 
790 
791 class Create_func_dayofweek : public Create_func_arg1
792 {
793 public:
794   virtual Item *create_1_arg(THD *thd, Item *arg1);
795 
796   static Create_func_dayofweek s_singleton;
797 
798 protected:
Create_func_dayofweek()799   Create_func_dayofweek() {}
~Create_func_dayofweek()800   virtual ~Create_func_dayofweek() {}
801 };
802 
803 
804 class Create_func_dayofyear : public Create_func_arg1
805 {
806 public:
807   virtual Item *create_1_arg(THD *thd, Item *arg1);
808 
809   static Create_func_dayofyear s_singleton;
810 
811 protected:
Create_func_dayofyear()812   Create_func_dayofyear() {}
~Create_func_dayofyear()813   virtual ~Create_func_dayofyear() {}
814 };
815 
816 
817 class Create_func_degrees : public Create_func_arg1
818 {
819 public:
820   virtual Item *create_1_arg(THD *thd, Item *arg1);
821 
822   static Create_func_degrees s_singleton;
823 
824 protected:
Create_func_degrees()825   Create_func_degrees() {}
~Create_func_degrees()826   virtual ~Create_func_degrees() {}
827 };
828 
829 
830 class Create_func_des_decrypt : public Create_native_func
831 {
832 public:
833   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
834 
835   static Create_func_des_decrypt s_singleton;
836 
837 protected:
Create_func_des_decrypt()838   Create_func_des_decrypt() {}
~Create_func_des_decrypt()839   virtual ~Create_func_des_decrypt() {}
840 };
841 
842 
843 class Create_func_des_encrypt : public Create_native_func
844 {
845 public:
846   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
847 
848   static Create_func_des_encrypt s_singleton;
849 
850 protected:
Create_func_des_encrypt()851   Create_func_des_encrypt() {}
~Create_func_des_encrypt()852   virtual ~Create_func_des_encrypt() {}
853 };
854 
855 
856 #ifdef HAVE_SPATIAL
857 class Create_func_dimension : public Create_func_arg1
858 {
859 public:
860   virtual Item *create_1_arg(THD *thd, Item *arg1);
861 
862   static Create_func_dimension s_singleton;
863 
864 protected:
Create_func_dimension()865   Create_func_dimension() {}
~Create_func_dimension()866   virtual ~Create_func_dimension() {}
867 };
868 #endif
869 
870 
871 #ifdef HAVE_SPATIAL
872 class Create_func_mbr_disjoint : public Create_func_arg2
873 {
874   public:
875     virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
876 
877     static Create_func_mbr_disjoint s_singleton;
878 
879   protected:
Create_func_mbr_disjoint()880     Create_func_mbr_disjoint() {}
~Create_func_mbr_disjoint()881     virtual ~Create_func_mbr_disjoint() {}
882 };
883 
884 
885 class Create_func_disjoint : public Create_func_arg2
886 {
887 public:
888   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
889 
890   static Create_func_disjoint s_singleton;
891 
892 protected:
Create_func_disjoint()893   Create_func_disjoint() {}
~Create_func_disjoint()894   virtual ~Create_func_disjoint() {}
895 };
896 
897 
898 class Create_func_distance : public Create_func_arg2
899 {
900   public:
901     virtual Item* create_2_arg(THD *thd, Item *arg1, Item *arg2);
902 
903     static Create_func_distance s_singleton;
904 
905   protected:
Create_func_distance()906     Create_func_distance() {}
~Create_func_distance()907     virtual ~Create_func_distance() {}
908 };
909 
910 
911 class Create_func_distance_sphere: public Create_native_func
912 {
913   public:
914     Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
915     static Create_func_distance_sphere s_singleton;
916 
917   protected:
Create_func_distance_sphere()918     Create_func_distance_sphere() {}
~Create_func_distance_sphere()919     virtual ~Create_func_distance_sphere() {}
920 };
921 
922 #endif
923 
924 
925 class Create_func_elt : public Create_native_func
926 {
927 public:
928   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
929 
930   static Create_func_elt s_singleton;
931 
932 protected:
Create_func_elt()933   Create_func_elt() {}
~Create_func_elt()934   virtual ~Create_func_elt() {}
935 };
936 
937 
938 class Create_func_encode : public Create_func_arg2
939 {
940 public:
941   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
942 
943   static Create_func_encode s_singleton;
944 
945 protected:
Create_func_encode()946   Create_func_encode() {}
~Create_func_encode()947   virtual ~Create_func_encode() {}
948 };
949 
950 
951 class Create_func_encrypt : public Create_native_func
952 {
953 public:
954   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
955 
956   static Create_func_encrypt s_singleton;
957 
958 protected:
Create_func_encrypt()959   Create_func_encrypt() {}
~Create_func_encrypt()960   virtual ~Create_func_encrypt() {}
961 };
962 
963 
964 #ifdef HAVE_SPATIAL
965 class Create_func_endpoint : public Create_func_arg1
966 {
967 public:
968   virtual Item *create_1_arg(THD *thd, Item *arg1);
969 
970   static Create_func_endpoint s_singleton;
971 
972 protected:
Create_func_endpoint()973   Create_func_endpoint() {}
~Create_func_endpoint()974   virtual ~Create_func_endpoint() {}
975 };
976 #endif
977 
978 
979 #ifdef HAVE_SPATIAL
980 class Create_func_envelope : public Create_func_arg1
981 {
982 public:
983   virtual Item *create_1_arg(THD *thd, Item *arg1);
984 
985   static Create_func_envelope s_singleton;
986 
987 protected:
Create_func_envelope()988   Create_func_envelope() {}
~Create_func_envelope()989   virtual ~Create_func_envelope() {}
990 };
991 
992 class Create_func_boundary : public Create_func_arg1
993 {
994 public:
995   virtual Item *create_1_arg(THD *thd, Item *arg1);
996 
997   static Create_func_boundary s_singleton;
998 
999 protected:
Create_func_boundary()1000   Create_func_boundary() {}
~Create_func_boundary()1001   virtual ~Create_func_boundary() {}
1002 };
1003 #endif /*HAVE_SPATIAL*/
1004 
1005 
1006 #ifdef HAVE_SPATIAL
1007 class Create_func_mbr_equals : public Create_func_arg2
1008 {
1009   public:
1010     virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
1011 
1012     static Create_func_mbr_equals s_singleton;
1013 
1014   protected:
Create_func_mbr_equals()1015     Create_func_mbr_equals() {}
~Create_func_mbr_equals()1016     virtual ~Create_func_mbr_equals() {}
1017 };
1018 
1019 
1020 class Create_func_equals : public Create_func_arg2
1021 {
1022 public:
1023   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
1024 
1025   static Create_func_equals s_singleton;
1026 
1027 protected:
Create_func_equals()1028   Create_func_equals() {}
~Create_func_equals()1029   virtual ~Create_func_equals() {}
1030 };
1031 #endif
1032 
1033 
1034 class Create_func_exp : public Create_func_arg1
1035 {
1036 public:
1037   virtual Item *create_1_arg(THD *thd, Item *arg1);
1038 
1039   static Create_func_exp s_singleton;
1040 
1041 protected:
Create_func_exp()1042   Create_func_exp() {}
~Create_func_exp()1043   virtual ~Create_func_exp() {}
1044 };
1045 
1046 
1047 class Create_func_export_set : public Create_native_func
1048 {
1049 public:
1050   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1051 
1052   static Create_func_export_set s_singleton;
1053 
1054 protected:
Create_func_export_set()1055   Create_func_export_set() {}
~Create_func_export_set()1056   virtual ~Create_func_export_set() {}
1057 };
1058 
1059 
1060 #ifdef HAVE_SPATIAL
1061 class Create_func_exteriorring : public Create_func_arg1
1062 {
1063 public:
1064   virtual Item *create_1_arg(THD *thd, Item *arg1);
1065 
1066   static Create_func_exteriorring s_singleton;
1067 
1068 protected:
Create_func_exteriorring()1069   Create_func_exteriorring() {}
~Create_func_exteriorring()1070   virtual ~Create_func_exteriorring() {}
1071 };
1072 #endif
1073 
1074 
1075 class Create_func_field : public Create_native_func
1076 {
1077 public:
1078   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1079 
1080   static Create_func_field s_singleton;
1081 
1082 protected:
Create_func_field()1083   Create_func_field() {}
~Create_func_field()1084   virtual ~Create_func_field() {}
1085 };
1086 
1087 
1088 class Create_func_find_in_set : public Create_func_arg2
1089 {
1090 public:
1091   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
1092 
1093   static Create_func_find_in_set s_singleton;
1094 
1095 protected:
Create_func_find_in_set()1096   Create_func_find_in_set() {}
~Create_func_find_in_set()1097   virtual ~Create_func_find_in_set() {}
1098 };
1099 
1100 
1101 class Create_func_floor : public Create_func_arg1
1102 {
1103 public:
1104   virtual Item *create_1_arg(THD *thd, Item *arg1);
1105 
1106   static Create_func_floor s_singleton;
1107 
1108 protected:
Create_func_floor()1109   Create_func_floor() {}
~Create_func_floor()1110   virtual ~Create_func_floor() {}
1111 };
1112 
1113 
1114 class Create_func_format : public Create_native_func
1115 {
1116 public:
1117   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1118 
1119   static Create_func_format s_singleton;
1120 
1121 protected:
Create_func_format()1122   Create_func_format() {}
~Create_func_format()1123   virtual ~Create_func_format() {}
1124 };
1125 
1126 
1127 class Create_func_found_rows : public Create_func_arg0
1128 {
1129 public:
1130   virtual Item *create_builder(THD *thd);
1131 
1132   static Create_func_found_rows s_singleton;
1133 
1134 protected:
Create_func_found_rows()1135   Create_func_found_rows() {}
~Create_func_found_rows()1136   virtual ~Create_func_found_rows() {}
1137 };
1138 
1139 
1140 class Create_func_from_base64 : public Create_func_arg1
1141 {
1142 public:
1143   virtual Item *create_1_arg(THD *thd, Item *arg1);
1144 
1145   static Create_func_from_base64 s_singleton;
1146 
1147 protected:
Create_func_from_base64()1148   Create_func_from_base64() {}
~Create_func_from_base64()1149   virtual ~Create_func_from_base64() {}
1150 };
1151 
1152 
1153 class Create_func_from_days : public Create_func_arg1
1154 {
1155 public:
1156   virtual Item *create_1_arg(THD *thd, Item *arg1);
1157 
1158   static Create_func_from_days s_singleton;
1159 
1160 protected:
Create_func_from_days()1161   Create_func_from_days() {}
~Create_func_from_days()1162   virtual ~Create_func_from_days() {}
1163 };
1164 
1165 
1166 class Create_func_from_unixtime : public Create_native_func
1167 {
1168 public:
1169   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1170 
1171   static Create_func_from_unixtime s_singleton;
1172 
1173 protected:
Create_func_from_unixtime()1174   Create_func_from_unixtime() {}
~Create_func_from_unixtime()1175   virtual ~Create_func_from_unixtime() {}
1176 };
1177 
1178 
1179 #ifdef HAVE_SPATIAL
1180 class Create_func_geometry_from_text : public Create_native_func
1181 {
1182 public:
1183   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1184 
1185   static Create_func_geometry_from_text s_singleton;
1186 
1187 protected:
Create_func_geometry_from_text()1188   Create_func_geometry_from_text() {}
~Create_func_geometry_from_text()1189   virtual ~Create_func_geometry_from_text() {}
1190 };
1191 #endif
1192 
1193 
1194 #ifdef HAVE_SPATIAL
1195 class Create_func_geometry_from_wkb : public Create_native_func
1196 {
1197 public:
1198   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1199 
1200   static Create_func_geometry_from_wkb s_singleton;
1201 
1202 protected:
Create_func_geometry_from_wkb()1203   Create_func_geometry_from_wkb() {}
~Create_func_geometry_from_wkb()1204   virtual ~Create_func_geometry_from_wkb() {}
1205 };
1206 #endif
1207 
1208 
1209 #ifdef HAVE_SPATIAL
1210 class Create_func_geometry_from_json : public Create_native_func
1211 {
1212 public:
1213   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1214 
1215   static Create_func_geometry_from_json s_singleton;
1216 
1217 protected:
Create_func_geometry_from_json()1218   Create_func_geometry_from_json() {}
~Create_func_geometry_from_json()1219   virtual ~Create_func_geometry_from_json() {}
1220 };
1221 
1222 
1223 class Create_func_as_geojson : public Create_native_func
1224 {
1225 public:
1226   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1227 
1228   static Create_func_as_geojson s_singleton;
1229 
1230 protected:
Create_func_as_geojson()1231   Create_func_as_geojson() {}
~Create_func_as_geojson()1232   virtual ~Create_func_as_geojson() {}
1233 };
1234 #endif /*HAVE_SPATIAL*/
1235 
1236 
1237 #ifdef HAVE_SPATIAL
1238 class Create_func_geometry_type : public Create_func_arg1
1239 {
1240 public:
1241   virtual Item *create_1_arg(THD *thd, Item *arg1);
1242 
1243   static Create_func_geometry_type s_singleton;
1244 
1245 protected:
Create_func_geometry_type()1246   Create_func_geometry_type() {}
~Create_func_geometry_type()1247   virtual ~Create_func_geometry_type() {}
1248 };
1249 #endif
1250 
1251 
1252 #ifdef HAVE_SPATIAL
1253 class Create_func_geometryn : public Create_func_arg2
1254 {
1255 public:
1256   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
1257 
1258   static Create_func_geometryn s_singleton;
1259 
1260 protected:
Create_func_geometryn()1261   Create_func_geometryn() {}
~Create_func_geometryn()1262   virtual ~Create_func_geometryn() {}
1263 };
1264 #endif
1265 
1266 
1267 class Create_func_get_lock : public Create_func_arg2
1268 {
1269 public:
1270   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
1271 
1272   static Create_func_get_lock s_singleton;
1273 
1274 protected:
Create_func_get_lock()1275   Create_func_get_lock() {}
~Create_func_get_lock()1276   virtual ~Create_func_get_lock() {}
1277 };
1278 
1279 
1280 #if defined(HAVE_SPATIAL) && !defined(DBUG_OFF)
1281 class Create_func_gis_debug : public Create_func_arg1
1282 {
1283   public:
1284     virtual Item *create_1_arg(THD *thd, Item *arg1);
1285 
1286     static Create_func_gis_debug s_singleton;
1287 
1288   protected:
Create_func_gis_debug()1289     Create_func_gis_debug() {}
~Create_func_gis_debug()1290     virtual ~Create_func_gis_debug() {}
1291 };
1292 #endif
1293 
1294 
1295 #ifdef HAVE_SPATIAL
1296 class Create_func_glength : public Create_func_arg1
1297 {
1298 public:
1299   virtual Item *create_1_arg(THD *thd, Item *arg1);
1300 
1301   static Create_func_glength s_singleton;
1302 
1303 protected:
Create_func_glength()1304   Create_func_glength() {}
~Create_func_glength()1305   virtual ~Create_func_glength() {}
1306 };
1307 #endif
1308 
1309 
1310 class Create_func_greatest : public Create_native_func
1311 {
1312 public:
1313   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1314 
1315   static Create_func_greatest s_singleton;
1316 
1317 protected:
Create_func_greatest()1318   Create_func_greatest() {}
~Create_func_greatest()1319   virtual ~Create_func_greatest() {}
1320 };
1321 
1322 
1323 class Create_func_hex : public Create_func_arg1
1324 {
1325 public:
1326   virtual Item *create_1_arg(THD *thd, Item *arg1);
1327 
1328   static Create_func_hex s_singleton;
1329 
1330 protected:
Create_func_hex()1331   Create_func_hex() {}
~Create_func_hex()1332   virtual ~Create_func_hex() {}
1333 };
1334 
1335 
1336 class Create_func_ifnull : public Create_func_arg2
1337 {
1338 public:
1339   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
1340 
1341   static Create_func_ifnull s_singleton;
1342 
1343 protected:
Create_func_ifnull()1344   Create_func_ifnull() {}
~Create_func_ifnull()1345   virtual ~Create_func_ifnull() {}
1346 };
1347 
1348 
1349 class Create_func_inet_ntoa : public Create_func_arg1
1350 {
1351 public:
1352   virtual Item *create_1_arg(THD *thd, Item *arg1);
1353 
1354   static Create_func_inet_ntoa s_singleton;
1355 
1356 protected:
Create_func_inet_ntoa()1357   Create_func_inet_ntoa() {}
~Create_func_inet_ntoa()1358   virtual ~Create_func_inet_ntoa() {}
1359 };
1360 
1361 
1362 class Create_func_inet_aton : public Create_func_arg1
1363 {
1364 public:
1365   virtual Item *create_1_arg(THD *thd, Item *arg1);
1366 
1367   static Create_func_inet_aton s_singleton;
1368 
1369 protected:
Create_func_inet_aton()1370   Create_func_inet_aton() {}
~Create_func_inet_aton()1371   virtual ~Create_func_inet_aton() {}
1372 };
1373 
1374 
1375 class Create_func_inet6_aton : public Create_func_arg1
1376 {
1377 public:
1378   virtual Item *create_1_arg(THD *thd, Item *arg1);
1379 
1380   static Create_func_inet6_aton s_singleton;
1381 
1382 protected:
Create_func_inet6_aton()1383   Create_func_inet6_aton() {}
~Create_func_inet6_aton()1384   virtual ~Create_func_inet6_aton() {}
1385 };
1386 
1387 
1388 class Create_func_inet6_ntoa : public Create_func_arg1
1389 {
1390 public:
1391   virtual Item *create_1_arg(THD *thd, Item *arg1);
1392 
1393   static Create_func_inet6_ntoa s_singleton;
1394 
1395 protected:
Create_func_inet6_ntoa()1396   Create_func_inet6_ntoa() {}
~Create_func_inet6_ntoa()1397   virtual ~Create_func_inet6_ntoa() {}
1398 };
1399 
1400 
1401 class Create_func_is_ipv4 : public Create_func_arg1
1402 {
1403 public:
1404   virtual Item *create_1_arg(THD *thd, Item *arg1);
1405 
1406   static Create_func_is_ipv4 s_singleton;
1407 
1408 protected:
Create_func_is_ipv4()1409   Create_func_is_ipv4() {}
~Create_func_is_ipv4()1410   virtual ~Create_func_is_ipv4() {}
1411 };
1412 
1413 
1414 class Create_func_is_ipv6 : public Create_func_arg1
1415 {
1416 public:
1417   virtual Item *create_1_arg(THD *thd, Item *arg1);
1418 
1419   static Create_func_is_ipv6 s_singleton;
1420 
1421 protected:
Create_func_is_ipv6()1422   Create_func_is_ipv6() {}
~Create_func_is_ipv6()1423   virtual ~Create_func_is_ipv6() {}
1424 };
1425 
1426 
1427 class Create_func_is_ipv4_compat : public Create_func_arg1
1428 {
1429 public:
1430   virtual Item *create_1_arg(THD *thd, Item *arg1);
1431 
1432   static Create_func_is_ipv4_compat s_singleton;
1433 
1434 protected:
Create_func_is_ipv4_compat()1435   Create_func_is_ipv4_compat() {}
~Create_func_is_ipv4_compat()1436   virtual ~Create_func_is_ipv4_compat() {}
1437 };
1438 
1439 
1440 class Create_func_is_ipv4_mapped : public Create_func_arg1
1441 {
1442 public:
1443   virtual Item *create_1_arg(THD *thd, Item *arg1);
1444 
1445   static Create_func_is_ipv4_mapped s_singleton;
1446 
1447 protected:
Create_func_is_ipv4_mapped()1448   Create_func_is_ipv4_mapped() {}
~Create_func_is_ipv4_mapped()1449   virtual ~Create_func_is_ipv4_mapped() {}
1450 };
1451 
1452 
1453 class Create_func_instr : public Create_func_arg2
1454 {
1455 public:
1456   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
1457 
1458   static Create_func_instr s_singleton;
1459 
1460 protected:
Create_func_instr()1461   Create_func_instr() {}
~Create_func_instr()1462   virtual ~Create_func_instr() {}
1463 };
1464 
1465 
1466 #ifdef HAVE_SPATIAL
1467 class Create_func_interiorringn : public Create_func_arg2
1468 {
1469 public:
1470   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
1471 
1472   static Create_func_interiorringn s_singleton;
1473 
1474 protected:
Create_func_interiorringn()1475   Create_func_interiorringn() {}
~Create_func_interiorringn()1476   virtual ~Create_func_interiorringn() {}
1477 };
1478 #endif
1479 
1480 
1481 #ifdef HAVE_SPATIAL
1482 class Create_func_relate : public Create_func_arg3
1483 {
1484 public:
1485   virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3);
1486 
1487   static Create_func_relate s_singleton;
1488 
1489 protected:
Create_func_relate()1490   Create_func_relate() {}
~Create_func_relate()1491   virtual ~Create_func_relate() {}
1492 };
1493 
1494 
1495 class Create_func_mbr_intersects : public Create_func_arg2
1496 {
1497   public:
1498     virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
1499 
1500     static Create_func_mbr_intersects s_singleton;
1501 
1502   protected:
Create_func_mbr_intersects()1503     Create_func_mbr_intersects() {}
~Create_func_mbr_intersects()1504     virtual ~Create_func_mbr_intersects() {}
1505 };
1506 
1507 
1508 class Create_func_intersects : public Create_func_arg2
1509 {
1510 public:
1511   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
1512 
1513   static Create_func_intersects s_singleton;
1514 
1515 protected:
Create_func_intersects()1516   Create_func_intersects() {}
~Create_func_intersects()1517   virtual ~Create_func_intersects() {}
1518 };
1519 
1520 
1521 class Create_func_intersection : public Create_func_arg2
1522 {
1523 public:
1524   virtual Item* create_2_arg(THD *thd, Item *arg1, Item *arg2);
1525 
1526   static Create_func_intersection s_singleton;
1527 
1528 protected:
Create_func_intersection()1529   Create_func_intersection() {}
~Create_func_intersection()1530   virtual ~Create_func_intersection() {}
1531 };
1532 
1533 
1534 class Create_func_difference : public Create_func_arg2
1535 {
1536 public:
1537   virtual Item* create_2_arg(THD *thd, Item *arg1, Item *arg2);
1538 
1539   static Create_func_difference s_singleton;
1540 
1541 protected:
Create_func_difference()1542   Create_func_difference() {}
~Create_func_difference()1543   virtual ~Create_func_difference() {}
1544 };
1545 
1546 
1547 class Create_func_union : public Create_func_arg2
1548 {
1549 public:
1550   virtual Item* create_2_arg(THD *thd, Item *arg1, Item *arg2);
1551 
1552   static Create_func_union s_singleton;
1553 
1554 protected:
Create_func_union()1555   Create_func_union() {}
~Create_func_union()1556   virtual ~Create_func_union() {}
1557 };
1558 
1559 
1560 class Create_func_symdifference : public Create_func_arg2
1561 {
1562 public:
1563   virtual Item* create_2_arg(THD *thd, Item *arg1, Item *arg2);
1564 
1565   static Create_func_symdifference s_singleton;
1566 
1567 protected:
Create_func_symdifference()1568   Create_func_symdifference() {}
~Create_func_symdifference()1569   virtual ~Create_func_symdifference() {}
1570 };
1571 
1572 
1573 class Create_func_buffer : public Create_func_arg2
1574 {
1575 public:
1576   virtual Item* create_2_arg(THD *thd, Item *arg1, Item *arg2);
1577 
1578   static Create_func_buffer s_singleton;
1579 
1580 protected:
Create_func_buffer()1581   Create_func_buffer() {}
~Create_func_buffer()1582   virtual ~Create_func_buffer() {}
1583 };
1584 #endif /*HAVE_SPATIAL*/
1585 
1586 
1587 class Create_func_is_free_lock : public Create_func_arg1
1588 {
1589 public:
1590   virtual Item *create_1_arg(THD *thd, Item *arg1);
1591 
1592   static Create_func_is_free_lock s_singleton;
1593 
1594 protected:
Create_func_is_free_lock()1595   Create_func_is_free_lock() {}
~Create_func_is_free_lock()1596   virtual ~Create_func_is_free_lock() {}
1597 };
1598 
1599 
1600 class Create_func_is_used_lock : public Create_func_arg1
1601 {
1602 public:
1603   virtual Item *create_1_arg(THD *thd, Item *arg1);
1604 
1605   static Create_func_is_used_lock s_singleton;
1606 
1607 protected:
Create_func_is_used_lock()1608   Create_func_is_used_lock() {}
~Create_func_is_used_lock()1609   virtual ~Create_func_is_used_lock() {}
1610 };
1611 
1612 
1613 #ifdef HAVE_SPATIAL
1614 class Create_func_isclosed : public Create_func_arg1
1615 {
1616 public:
1617   virtual Item *create_1_arg(THD *thd, Item *arg1);
1618 
1619   static Create_func_isclosed s_singleton;
1620 
1621 protected:
Create_func_isclosed()1622   Create_func_isclosed() {}
~Create_func_isclosed()1623   virtual ~Create_func_isclosed() {}
1624 };
1625 
1626 
1627 class Create_func_isring : public Create_func_arg1
1628 {
1629 public:
1630   virtual Item *create_1_arg(THD *thd, Item *arg1);
1631 
1632   static Create_func_isring s_singleton;
1633 
1634 protected:
Create_func_isring()1635   Create_func_isring() {}
~Create_func_isring()1636   virtual ~Create_func_isring() {}
1637 };
1638 #endif
1639 
1640 
1641 #ifdef HAVE_SPATIAL
1642 class Create_func_isempty : public Create_func_arg1
1643 {
1644 public:
1645   virtual Item *create_1_arg(THD *thd, Item *arg1);
1646 
1647   static Create_func_isempty s_singleton;
1648 
1649 protected:
Create_func_isempty()1650   Create_func_isempty() {}
~Create_func_isempty()1651   virtual ~Create_func_isempty() {}
1652 };
1653 #endif
1654 
1655 
1656 class Create_func_isnull : public Create_func_arg1
1657 {
1658 public:
1659   virtual Item *create_1_arg(THD *thd, Item *arg1);
1660 
1661   static Create_func_isnull s_singleton;
1662 
1663 protected:
Create_func_isnull()1664   Create_func_isnull() {}
~Create_func_isnull()1665   virtual ~Create_func_isnull() {}
1666 };
1667 
1668 
1669 #ifdef HAVE_SPATIAL
1670 class Create_func_issimple : public Create_func_arg1
1671 {
1672 public:
1673   virtual Item *create_1_arg(THD *thd, Item *arg1);
1674 
1675   static Create_func_issimple s_singleton;
1676 
1677 protected:
Create_func_issimple()1678   Create_func_issimple() {}
~Create_func_issimple()1679   virtual ~Create_func_issimple() {}
1680 };
1681 #endif
1682 
1683 
1684 class Create_func_json_exists : public Create_func_arg2
1685 {
1686 public:
1687   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
1688 
1689   static Create_func_json_exists s_singleton;
1690 
1691 protected:
Create_func_json_exists()1692   Create_func_json_exists() {}
~Create_func_json_exists()1693   virtual ~Create_func_json_exists() {}
1694 };
1695 
1696 
1697 class Create_func_json_valid : public Create_func_arg1
1698 {
1699 public:
1700   virtual Item *create_1_arg(THD *thd, Item *arg1);
1701 
1702   static Create_func_json_valid s_singleton;
1703 
1704 protected:
Create_func_json_valid()1705   Create_func_json_valid() {}
~Create_func_json_valid()1706   virtual ~Create_func_json_valid() {}
1707 };
1708 
1709 
1710 class Create_func_json_compact : public Create_func_arg1
1711 {
1712 public:
1713   virtual Item *create_1_arg(THD *thd, Item *arg1);
1714 
1715   static Create_func_json_compact s_singleton;
1716 
1717 protected:
Create_func_json_compact()1718   Create_func_json_compact() {}
~Create_func_json_compact()1719   virtual ~Create_func_json_compact() {}
1720 };
1721 
1722 
1723 class Create_func_json_loose : public Create_func_arg1
1724 {
1725 public:
1726   virtual Item *create_1_arg(THD *thd, Item *arg1);
1727 
1728   static Create_func_json_loose s_singleton;
1729 
1730 protected:
Create_func_json_loose()1731   Create_func_json_loose() {}
~Create_func_json_loose()1732   virtual ~Create_func_json_loose() {}
1733 };
1734 
1735 
1736 class Create_func_json_detailed: public Create_native_func
1737 {
1738 public:
1739   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1740 
1741   static Create_func_json_detailed s_singleton;
1742 
1743 protected:
Create_func_json_detailed()1744   Create_func_json_detailed() {}
~Create_func_json_detailed()1745   virtual ~Create_func_json_detailed() {}
1746 };
1747 
1748 
1749 class Create_func_json_type : public Create_func_arg1
1750 {
1751 public:
1752   virtual Item *create_1_arg(THD *thd, Item *arg1);
1753 
1754   static Create_func_json_type s_singleton;
1755 
1756 protected:
Create_func_json_type()1757   Create_func_json_type() {}
~Create_func_json_type()1758   virtual ~Create_func_json_type() {}
1759 };
1760 
1761 
1762 class Create_func_json_depth : public Create_func_arg1
1763 {
1764 public:
1765   virtual Item *create_1_arg(THD *thd, Item *arg1);
1766 
1767   static Create_func_json_depth s_singleton;
1768 
1769 protected:
Create_func_json_depth()1770   Create_func_json_depth() {}
~Create_func_json_depth()1771   virtual ~Create_func_json_depth() {}
1772 };
1773 
1774 
1775 class Create_func_json_value : public Create_func_arg2
1776 {
1777 public:
1778   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
1779 
1780   static Create_func_json_value s_singleton;
1781 
1782 protected:
Create_func_json_value()1783   Create_func_json_value() {}
~Create_func_json_value()1784   virtual ~Create_func_json_value() {}
1785 };
1786 
1787 
1788 class Create_func_json_query : public Create_func_arg2
1789 {
1790 public:
1791   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
1792 
1793   static Create_func_json_query s_singleton;
1794 
1795 protected:
Create_func_json_query()1796   Create_func_json_query() {}
~Create_func_json_query()1797   virtual ~Create_func_json_query() {}
1798 };
1799 
1800 
1801 class Create_func_json_keys: public Create_native_func
1802 {
1803 public:
1804   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1805 
1806   static Create_func_json_keys s_singleton;
1807 
1808 protected:
Create_func_json_keys()1809   Create_func_json_keys() {}
~Create_func_json_keys()1810   virtual ~Create_func_json_keys() {}
1811 };
1812 
1813 
1814 class Create_func_json_contains: public Create_native_func
1815 {
1816 public:
1817   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1818 
1819   static Create_func_json_contains s_singleton;
1820 
1821 protected:
Create_func_json_contains()1822   Create_func_json_contains() {}
~Create_func_json_contains()1823   virtual ~Create_func_json_contains() {}
1824 };
1825 
1826 
1827 class Create_func_json_contains_path : public Create_native_func
1828 {
1829 public:
1830   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1831 
1832   static Create_func_json_contains_path s_singleton;
1833 
1834 protected:
Create_func_json_contains_path()1835   Create_func_json_contains_path() {}
~Create_func_json_contains_path()1836   virtual ~Create_func_json_contains_path() {}
1837 };
1838 
1839 
1840 class Create_func_json_extract : public Create_native_func
1841 {
1842 public:
1843   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1844 
1845   static Create_func_json_extract s_singleton;
1846 
1847 protected:
Create_func_json_extract()1848   Create_func_json_extract() {}
~Create_func_json_extract()1849   virtual ~Create_func_json_extract() {}
1850 };
1851 
1852 
1853 class Create_func_json_search : public Create_native_func
1854 {
1855 public:
1856   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1857 
1858   static Create_func_json_search s_singleton;
1859 
1860 protected:
Create_func_json_search()1861   Create_func_json_search() {}
~Create_func_json_search()1862   virtual ~Create_func_json_search() {}
1863 };
1864 
1865 
1866 class Create_func_json_array : public Create_native_func
1867 {
1868 public:
1869   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1870 
1871   static Create_func_json_array s_singleton;
1872 
1873 protected:
Create_func_json_array()1874   Create_func_json_array() {}
~Create_func_json_array()1875   virtual ~Create_func_json_array() {}
1876 };
1877 
1878 
1879 class Create_func_json_array_append : public Create_native_func
1880 {
1881 public:
1882   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1883 
1884   static Create_func_json_array_append s_singleton;
1885 
1886 protected:
Create_func_json_array_append()1887   Create_func_json_array_append() {}
~Create_func_json_array_append()1888   virtual ~Create_func_json_array_append() {}
1889 };
1890 
1891 
1892 class Create_func_json_array_insert : public Create_native_func
1893 {
1894 public:
1895   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1896 
1897   static Create_func_json_array_insert s_singleton;
1898 
1899 protected:
Create_func_json_array_insert()1900   Create_func_json_array_insert() {}
~Create_func_json_array_insert()1901   virtual ~Create_func_json_array_insert() {}
1902 };
1903 
1904 
1905 class Create_func_json_insert : public Create_native_func
1906 {
1907 public:
1908   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1909 
1910   static Create_func_json_insert s_singleton;
1911 
1912 protected:
Create_func_json_insert()1913   Create_func_json_insert() {}
~Create_func_json_insert()1914   virtual ~Create_func_json_insert() {}
1915 };
1916 
1917 
1918 class Create_func_json_set : public Create_native_func
1919 {
1920 public:
1921   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1922 
1923   static Create_func_json_set s_singleton;
1924 
1925 protected:
Create_func_json_set()1926   Create_func_json_set() {}
~Create_func_json_set()1927   virtual ~Create_func_json_set() {}
1928 };
1929 
1930 
1931 class Create_func_json_replace : public Create_native_func
1932 {
1933 public:
1934   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1935 
1936   static Create_func_json_replace s_singleton;
1937 
1938 protected:
Create_func_json_replace()1939   Create_func_json_replace() {}
~Create_func_json_replace()1940   virtual ~Create_func_json_replace() {}
1941 };
1942 
1943 
1944 class Create_func_json_remove : public Create_native_func
1945 {
1946 public:
1947   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1948 
1949   static Create_func_json_remove s_singleton;
1950 
1951 protected:
Create_func_json_remove()1952   Create_func_json_remove() {}
~Create_func_json_remove()1953   virtual ~Create_func_json_remove() {}
1954 };
1955 
1956 
1957 class Create_func_json_object : public Create_native_func
1958 {
1959 public:
1960   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1961 
1962   static Create_func_json_object s_singleton;
1963 
1964 protected:
Create_func_json_object()1965   Create_func_json_object() {}
~Create_func_json_object()1966   virtual ~Create_func_json_object() {}
1967 };
1968 
1969 
1970 class Create_func_json_length : public Create_native_func
1971 {
1972 public:
1973   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1974 
1975   static Create_func_json_length s_singleton;
1976 
1977 protected:
Create_func_json_length()1978   Create_func_json_length() {}
~Create_func_json_length()1979   virtual ~Create_func_json_length() {}
1980 };
1981 
1982 
1983 class Create_func_json_merge : public Create_native_func
1984 {
1985 public:
1986   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
1987 
1988   static Create_func_json_merge s_singleton;
1989 
1990 protected:
Create_func_json_merge()1991   Create_func_json_merge() {}
~Create_func_json_merge()1992   virtual ~Create_func_json_merge() {}
1993 };
1994 
1995 
1996 class Create_func_json_merge_patch : public Create_native_func
1997 {
1998 public:
1999   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
2000 
2001   static Create_func_json_merge_patch s_singleton;
2002 
2003 protected:
Create_func_json_merge_patch()2004   Create_func_json_merge_patch() {}
~Create_func_json_merge_patch()2005   virtual ~Create_func_json_merge_patch() {}
2006 };
2007 
2008 
2009 class Create_func_json_quote : public Create_func_arg1
2010 {
2011 public:
2012   virtual Item *create_1_arg(THD *thd, Item *arg1);
2013 
2014   static Create_func_json_quote s_singleton;
2015 
2016 protected:
Create_func_json_quote()2017   Create_func_json_quote() {}
~Create_func_json_quote()2018   virtual ~Create_func_json_quote() {}
2019 };
2020 
2021 
2022 class Create_func_json_unquote : public Create_func_arg1
2023 {
2024 public:
2025   virtual Item *create_1_arg(THD *thd, Item *arg1);
2026 
2027   static Create_func_json_unquote s_singleton;
2028 
2029 protected:
Create_func_json_unquote()2030   Create_func_json_unquote() {}
~Create_func_json_unquote()2031   virtual ~Create_func_json_unquote() {}
2032 };
2033 
2034 
2035 class Create_func_last_day : public Create_func_arg1
2036 {
2037 public:
2038   virtual Item *create_1_arg(THD *thd, Item *arg1);
2039 
2040   static Create_func_last_day s_singleton;
2041 
2042 protected:
Create_func_last_day()2043   Create_func_last_day() {}
~Create_func_last_day()2044   virtual ~Create_func_last_day() {}
2045 };
2046 
2047 
2048 class Create_func_last_insert_id : public Create_native_func
2049 {
2050 public:
2051   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
2052 
2053   static Create_func_last_insert_id s_singleton;
2054 
2055 protected:
Create_func_last_insert_id()2056   Create_func_last_insert_id() {}
~Create_func_last_insert_id()2057   virtual ~Create_func_last_insert_id() {}
2058 };
2059 
2060 
2061 class Create_func_lcase : public Create_func_arg1
2062 {
2063 public:
2064   virtual Item *create_1_arg(THD *thd, Item *arg1);
2065 
2066   static Create_func_lcase s_singleton;
2067 
2068 protected:
Create_func_lcase()2069   Create_func_lcase() {}
~Create_func_lcase()2070   virtual ~Create_func_lcase() {}
2071 };
2072 
2073 
2074 class Create_func_least : public Create_native_func
2075 {
2076 public:
2077   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
2078 
2079   static Create_func_least s_singleton;
2080 
2081 protected:
Create_func_least()2082   Create_func_least() {}
~Create_func_least()2083   virtual ~Create_func_least() {}
2084 };
2085 
2086 
2087 class Create_func_length : public Create_func_arg1
2088 {
2089 public:
2090   virtual Item *create_1_arg(THD *thd, Item *arg1);
2091 
2092   static Create_func_length s_singleton;
2093 
2094 protected:
Create_func_length()2095   Create_func_length() {}
~Create_func_length()2096   virtual ~Create_func_length() {}
2097 };
2098 
2099 class Create_func_octet_length : public Create_func_arg1
2100 {
2101 public:
2102   virtual Item *create_1_arg(THD *thd, Item *arg1);
2103 
2104   static Create_func_octet_length s_singleton;
2105 
2106 protected:
Create_func_octet_length()2107   Create_func_octet_length() {}
~Create_func_octet_length()2108   virtual ~Create_func_octet_length() {}
2109 };
2110 
2111 
2112 #ifndef DBUG_OFF
2113 class Create_func_like_range_min : public Create_func_arg2
2114 {
2115 public:
2116   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2117 
2118   static Create_func_like_range_min s_singleton;
2119 
2120 protected:
Create_func_like_range_min()2121   Create_func_like_range_min() {}
~Create_func_like_range_min()2122   virtual ~Create_func_like_range_min() {}
2123 };
2124 
2125 
2126 class Create_func_like_range_max : public Create_func_arg2
2127 {
2128 public:
2129   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2130 
2131   static Create_func_like_range_max s_singleton;
2132 
2133 protected:
Create_func_like_range_max()2134   Create_func_like_range_max() {}
~Create_func_like_range_max()2135   virtual ~Create_func_like_range_max() {}
2136 };
2137 #endif
2138 
2139 
2140 class Create_func_ln : public Create_func_arg1
2141 {
2142 public:
2143   virtual Item *create_1_arg(THD *thd, Item *arg1);
2144 
2145   static Create_func_ln s_singleton;
2146 
2147 protected:
Create_func_ln()2148   Create_func_ln() {}
~Create_func_ln()2149   virtual ~Create_func_ln() {}
2150 };
2151 
2152 
2153 class Create_func_load_file : public Create_func_arg1
2154 {
2155 public:
2156   virtual Item *create_1_arg(THD *thd, Item *arg1);
2157 
2158   static Create_func_load_file s_singleton;
2159 
2160 protected:
Create_func_load_file()2161   Create_func_load_file() {}
~Create_func_load_file()2162   virtual ~Create_func_load_file() {}
2163 };
2164 
2165 
2166 class Create_func_locate : public Create_native_func
2167 {
2168 public:
2169   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
2170 
2171   static Create_func_locate s_singleton;
2172 
2173 protected:
Create_func_locate()2174   Create_func_locate() {}
~Create_func_locate()2175   virtual ~Create_func_locate() {}
2176 };
2177 
2178 
2179 class Create_func_log : public Create_native_func
2180 {
2181 public:
2182   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
2183 
2184   static Create_func_log s_singleton;
2185 
2186 protected:
Create_func_log()2187   Create_func_log() {}
~Create_func_log()2188   virtual ~Create_func_log() {}
2189 };
2190 
2191 
2192 class Create_func_log10 : public Create_func_arg1
2193 {
2194 public:
2195   virtual Item *create_1_arg(THD *thd, Item *arg1);
2196 
2197   static Create_func_log10 s_singleton;
2198 
2199 protected:
Create_func_log10()2200   Create_func_log10() {}
~Create_func_log10()2201   virtual ~Create_func_log10() {}
2202 };
2203 
2204 
2205 class Create_func_log2 : public Create_func_arg1
2206 {
2207 public:
2208   virtual Item *create_1_arg(THD *thd, Item *arg1);
2209 
2210   static Create_func_log2 s_singleton;
2211 
2212 protected:
Create_func_log2()2213   Create_func_log2() {}
~Create_func_log2()2214   virtual ~Create_func_log2() {}
2215 };
2216 
2217 
2218 class Create_func_lpad : public Create_native_func
2219 {
2220 public:
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)2221   virtual Item *create_native(THD *thd, LEX_CSTRING *name,
2222                               List<Item> *item_list)
2223   {
2224     return thd->variables.sql_mode & MODE_ORACLE ?
2225            create_native_oracle(thd, name, item_list) :
2226            create_native_std(thd, name, item_list);
2227   }
2228   static Create_func_lpad s_singleton;
2229 
2230 protected:
Create_func_lpad()2231   Create_func_lpad() {}
~Create_func_lpad()2232   virtual ~Create_func_lpad() {}
2233   Item *create_native_std(THD *thd, LEX_CSTRING *name, List<Item> *items);
2234   Item *create_native_oracle(THD *thd, LEX_CSTRING *name, List<Item> *items);
2235 };
2236 
2237 
2238 class Create_func_lpad_oracle : public Create_func_lpad
2239 {
2240 public:
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)2241   Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
2242   {
2243     return create_native_oracle(thd, name, item_list);
2244   }
2245   static Create_func_lpad_oracle s_singleton;
2246 };
2247 
2248 
2249 class Create_func_ltrim : public Create_func_arg1
2250 {
2251 public:
2252   virtual Item *create_1_arg(THD *thd, Item *arg1);
2253 
2254   static Create_func_ltrim s_singleton;
2255 
2256 protected:
Create_func_ltrim()2257   Create_func_ltrim() {}
~Create_func_ltrim()2258   virtual ~Create_func_ltrim() {}
2259 };
2260 
2261 
2262 class Create_func_ltrim_oracle : public Create_func_arg1
2263 {
2264 public:
2265   virtual Item *create_1_arg(THD *thd, Item *arg1);
2266 
2267   static Create_func_ltrim_oracle s_singleton;
2268 
2269 protected:
Create_func_ltrim_oracle()2270   Create_func_ltrim_oracle() {}
~Create_func_ltrim_oracle()2271   virtual ~Create_func_ltrim_oracle() {}
2272 };
2273 
2274 
2275 class Create_func_makedate : public Create_func_arg2
2276 {
2277 public:
2278   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2279 
2280   static Create_func_makedate s_singleton;
2281 
2282 protected:
Create_func_makedate()2283   Create_func_makedate() {}
~Create_func_makedate()2284   virtual ~Create_func_makedate() {}
2285 };
2286 
2287 
2288 class Create_func_maketime : public Create_func_arg3
2289 {
2290 public:
2291   virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3);
2292 
2293   static Create_func_maketime s_singleton;
2294 
2295 protected:
Create_func_maketime()2296   Create_func_maketime() {}
~Create_func_maketime()2297   virtual ~Create_func_maketime() {}
2298 };
2299 
2300 
2301 class Create_func_make_set : public Create_native_func
2302 {
2303 public:
2304   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
2305 
2306   static Create_func_make_set s_singleton;
2307 
2308 protected:
Create_func_make_set()2309   Create_func_make_set() {}
~Create_func_make_set()2310   virtual ~Create_func_make_set() {}
2311 };
2312 
2313 
2314 class Create_func_master_pos_wait : public Create_native_func
2315 {
2316 public:
2317   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
2318 
2319   static Create_func_master_pos_wait s_singleton;
2320 
2321 protected:
Create_func_master_pos_wait()2322   Create_func_master_pos_wait() {}
~Create_func_master_pos_wait()2323   virtual ~Create_func_master_pos_wait() {}
2324 };
2325 
2326 
2327 class Create_func_master_gtid_wait : public Create_native_func
2328 {
2329 public:
2330   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
2331 
2332   static Create_func_master_gtid_wait s_singleton;
2333 
2334 protected:
Create_func_master_gtid_wait()2335   Create_func_master_gtid_wait() {}
~Create_func_master_gtid_wait()2336   virtual ~Create_func_master_gtid_wait() {}
2337 };
2338 
2339 
2340 class Create_func_md5 : public Create_func_arg1
2341 {
2342 public:
2343   virtual Item *create_1_arg(THD *thd, Item *arg1);
2344 
2345   static Create_func_md5 s_singleton;
2346 
2347 protected:
Create_func_md5()2348   Create_func_md5() {}
~Create_func_md5()2349   virtual ~Create_func_md5() {}
2350 };
2351 
2352 
2353 class Create_func_monthname : public Create_func_arg1
2354 {
2355 public:
2356   virtual Item *create_1_arg(THD *thd, Item *arg1);
2357 
2358   static Create_func_monthname s_singleton;
2359 
2360 protected:
Create_func_monthname()2361   Create_func_monthname() {}
~Create_func_monthname()2362   virtual ~Create_func_monthname() {}
2363 };
2364 
2365 
2366 class Create_func_name_const : public Create_func_arg2
2367 {
2368 public:
2369   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2370 
2371   static Create_func_name_const s_singleton;
2372 
2373 protected:
Create_func_name_const()2374   Create_func_name_const() {}
~Create_func_name_const()2375   virtual ~Create_func_name_const() {}
2376 };
2377 
2378 
2379 class Create_func_nullif : public Create_func_arg2
2380 {
2381 public:
2382   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2383 
2384   static Create_func_nullif s_singleton;
2385 
2386 protected:
Create_func_nullif()2387   Create_func_nullif() {}
~Create_func_nullif()2388   virtual ~Create_func_nullif() {}
2389 };
2390 
2391 
2392 #ifdef HAVE_SPATIAL
2393 class Create_func_numgeometries : public Create_func_arg1
2394 {
2395 public:
2396   virtual Item *create_1_arg(THD *thd, Item *arg1);
2397 
2398   static Create_func_numgeometries s_singleton;
2399 
2400 protected:
Create_func_numgeometries()2401   Create_func_numgeometries() {}
~Create_func_numgeometries()2402   virtual ~Create_func_numgeometries() {}
2403 };
2404 #endif
2405 
2406 
2407 #ifdef HAVE_SPATIAL
2408 class Create_func_numinteriorring : public Create_func_arg1
2409 {
2410 public:
2411   virtual Item *create_1_arg(THD *thd, Item *arg1);
2412 
2413   static Create_func_numinteriorring s_singleton;
2414 
2415 protected:
Create_func_numinteriorring()2416   Create_func_numinteriorring() {}
~Create_func_numinteriorring()2417   virtual ~Create_func_numinteriorring() {}
2418 };
2419 #endif
2420 
2421 
2422 #ifdef HAVE_SPATIAL
2423 class Create_func_numpoints : public Create_func_arg1
2424 {
2425 public:
2426   virtual Item *create_1_arg(THD *thd, Item *arg1);
2427 
2428   static Create_func_numpoints s_singleton;
2429 
2430 protected:
Create_func_numpoints()2431   Create_func_numpoints() {}
~Create_func_numpoints()2432   virtual ~Create_func_numpoints() {}
2433 };
2434 #endif
2435 
2436 
2437 class Create_func_oct : public Create_func_arg1
2438 {
2439 public:
2440   virtual Item *create_1_arg(THD *thd, Item *arg1);
2441 
2442   static Create_func_oct s_singleton;
2443 
2444 protected:
Create_func_oct()2445   Create_func_oct() {}
~Create_func_oct()2446   virtual ~Create_func_oct() {}
2447 };
2448 
2449 
2450 class Create_func_ord : public Create_func_arg1
2451 {
2452 public:
2453   virtual Item *create_1_arg(THD *thd, Item *arg1);
2454 
2455   static Create_func_ord s_singleton;
2456 
2457 protected:
Create_func_ord()2458   Create_func_ord() {}
~Create_func_ord()2459   virtual ~Create_func_ord() {}
2460 };
2461 
2462 
2463 #ifdef HAVE_SPATIAL
2464 class Create_func_mbr_overlaps : public Create_func_arg2
2465 {
2466   public:
2467     virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2468 
2469     static Create_func_mbr_overlaps s_singleton;
2470 
2471   protected:
Create_func_mbr_overlaps()2472     Create_func_mbr_overlaps() {}
~Create_func_mbr_overlaps()2473     virtual ~Create_func_mbr_overlaps() {}
2474 };
2475 
2476 
2477 class Create_func_overlaps : public Create_func_arg2
2478 {
2479 public:
2480   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2481 
2482   static Create_func_overlaps s_singleton;
2483 
2484 protected:
Create_func_overlaps()2485   Create_func_overlaps() {}
~Create_func_overlaps()2486   virtual ~Create_func_overlaps() {}
2487 };
2488 #endif
2489 
2490 
2491 class Create_func_period_add : public Create_func_arg2
2492 {
2493 public:
2494   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2495 
2496   static Create_func_period_add s_singleton;
2497 
2498 protected:
Create_func_period_add()2499   Create_func_period_add() {}
~Create_func_period_add()2500   virtual ~Create_func_period_add() {}
2501 };
2502 
2503 
2504 class Create_func_period_diff : public Create_func_arg2
2505 {
2506 public:
2507   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2508 
2509   static Create_func_period_diff s_singleton;
2510 
2511 protected:
Create_func_period_diff()2512   Create_func_period_diff() {}
~Create_func_period_diff()2513   virtual ~Create_func_period_diff() {}
2514 };
2515 
2516 
2517 class Create_func_pi : public Create_func_arg0
2518 {
2519 public:
2520   virtual Item *create_builder(THD *thd);
2521 
2522   static Create_func_pi s_singleton;
2523 
2524 protected:
Create_func_pi()2525   Create_func_pi() {}
~Create_func_pi()2526   virtual ~Create_func_pi() {}
2527 };
2528 
2529 
2530 #ifdef HAVE_SPATIAL
2531 class Create_func_pointn : public Create_func_arg2
2532 {
2533 public:
2534   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2535 
2536   static Create_func_pointn s_singleton;
2537 
2538 protected:
Create_func_pointn()2539   Create_func_pointn() {}
~Create_func_pointn()2540   virtual ~Create_func_pointn() {}
2541 };
2542 #endif
2543 
2544 
2545 class Create_func_pow : public Create_func_arg2
2546 {
2547 public:
2548   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2549 
2550   static Create_func_pow s_singleton;
2551 
2552 protected:
Create_func_pow()2553   Create_func_pow() {}
~Create_func_pow()2554   virtual ~Create_func_pow() {}
2555 };
2556 
2557 
2558 class Create_func_quote : public Create_func_arg1
2559 {
2560 public:
2561   virtual Item *create_1_arg(THD *thd, Item *arg1);
2562 
2563   static Create_func_quote s_singleton;
2564 
2565 protected:
Create_func_quote()2566   Create_func_quote() {}
~Create_func_quote()2567   virtual ~Create_func_quote() {}
2568 };
2569 
2570 
2571 class Create_func_regexp_instr : public Create_func_arg2
2572 {
2573 public:
2574   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2575 
2576   static Create_func_regexp_instr s_singleton;
2577 
2578 protected:
Create_func_regexp_instr()2579   Create_func_regexp_instr() {}
~Create_func_regexp_instr()2580   virtual ~Create_func_regexp_instr() {}
2581 };
2582 
2583 
2584 class Create_func_regexp_replace : public Create_func_arg3
2585 {
2586 public:
2587   virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3);
2588 
2589   static Create_func_regexp_replace s_singleton;
2590 
2591 protected:
Create_func_regexp_replace()2592   Create_func_regexp_replace() {}
~Create_func_regexp_replace()2593   virtual ~Create_func_regexp_replace() {}
2594 };
2595 
2596 
2597 class Create_func_regexp_substr : public Create_func_arg2
2598 {
2599 public:
2600   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2601 
2602   static Create_func_regexp_substr s_singleton;
2603 
2604 protected:
Create_func_regexp_substr()2605   Create_func_regexp_substr() {}
~Create_func_regexp_substr()2606   virtual ~Create_func_regexp_substr() {}
2607 };
2608 
2609 
2610 class Create_func_radians : public Create_func_arg1
2611 {
2612 public:
2613   virtual Item *create_1_arg(THD *thd, Item *arg1);
2614 
2615   static Create_func_radians s_singleton;
2616 
2617 protected:
Create_func_radians()2618   Create_func_radians() {}
~Create_func_radians()2619   virtual ~Create_func_radians() {}
2620 };
2621 
2622 
2623 class Create_func_rand : public Create_native_func
2624 {
2625 public:
2626   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
2627 
2628   static Create_func_rand s_singleton;
2629 
2630 protected:
Create_func_rand()2631   Create_func_rand() {}
~Create_func_rand()2632   virtual ~Create_func_rand() {}
2633 };
2634 
2635 
2636 class Create_func_release_lock : public Create_func_arg1
2637 {
2638 public:
2639   virtual Item *create_1_arg(THD *thd, Item *arg1);
2640 
2641   static Create_func_release_lock s_singleton;
2642 
2643 protected:
Create_func_release_lock()2644   Create_func_release_lock() {}
~Create_func_release_lock()2645   virtual ~Create_func_release_lock() {}
2646 };
2647 
2648 
2649 class Create_func_replace_oracle : public Create_func_arg3
2650 {
2651 public:
2652   virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3);
2653 
2654   static Create_func_replace_oracle s_singleton;
2655 
2656 protected:
Create_func_replace_oracle()2657   Create_func_replace_oracle() {}
~Create_func_replace_oracle()2658   virtual ~Create_func_replace_oracle() {}
2659 };
2660 
2661 
2662 class Create_func_reverse : public Create_func_arg1
2663 {
2664 public:
2665   virtual Item *create_1_arg(THD *thd, Item *arg1);
2666 
2667   static Create_func_reverse s_singleton;
2668 
2669 protected:
Create_func_reverse()2670   Create_func_reverse() {}
~Create_func_reverse()2671   virtual ~Create_func_reverse() {}
2672 };
2673 
2674 
2675 class Create_func_round : public Create_native_func
2676 {
2677 public:
2678   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
2679 
2680   static Create_func_round s_singleton;
2681 
2682 protected:
Create_func_round()2683   Create_func_round() {}
~Create_func_round()2684   virtual ~Create_func_round() {}
2685 };
2686 
2687 
2688 class Create_func_rpad : public Create_native_func
2689 {
2690 public:
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)2691   virtual Item *create_native(THD *thd, LEX_CSTRING *name,
2692                               List<Item> *item_list)
2693   {
2694     return thd->variables.sql_mode & MODE_ORACLE ?
2695            create_native_oracle(thd, name, item_list) :
2696            create_native_std(thd, name, item_list);
2697   }
2698   static Create_func_rpad s_singleton;
2699 
2700 protected:
Create_func_rpad()2701   Create_func_rpad() {}
~Create_func_rpad()2702   virtual ~Create_func_rpad() {}
2703   Item *create_native_std(THD *thd, LEX_CSTRING *name, List<Item> *items);
2704   Item *create_native_oracle(THD *thd, LEX_CSTRING *name, List<Item> *items);
2705 };
2706 
2707 
2708 class Create_func_rpad_oracle : public Create_func_rpad
2709 {
2710 public:
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)2711   Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
2712   {
2713     return create_native_oracle(thd, name, item_list);
2714   }
2715   static Create_func_rpad_oracle s_singleton;
2716 };
2717 
2718 
2719 class Create_func_rtrim : public Create_func_arg1
2720 {
2721 public:
2722   virtual Item *create_1_arg(THD *thd, Item *arg1);
2723 
2724   static Create_func_rtrim s_singleton;
2725 
2726 protected:
Create_func_rtrim()2727   Create_func_rtrim() {}
~Create_func_rtrim()2728   virtual ~Create_func_rtrim() {}
2729 };
2730 
2731 
2732 class Create_func_rtrim_oracle : public Create_func_arg1
2733 {
2734 public:
2735   virtual Item *create_1_arg(THD *thd, Item *arg1);
2736 
2737   static Create_func_rtrim_oracle s_singleton;
2738 
2739 protected:
Create_func_rtrim_oracle()2740   Create_func_rtrim_oracle() {}
~Create_func_rtrim_oracle()2741   virtual ~Create_func_rtrim_oracle() {}
2742 };
2743 
2744 
2745 class Create_func_sec_to_time : public Create_func_arg1
2746 {
2747 public:
2748   virtual Item *create_1_arg(THD *thd, Item *arg1);
2749 
2750   static Create_func_sec_to_time s_singleton;
2751 
2752 protected:
Create_func_sec_to_time()2753   Create_func_sec_to_time() {}
~Create_func_sec_to_time()2754   virtual ~Create_func_sec_to_time() {}
2755 };
2756 
2757 
2758 class Create_func_sha : public Create_func_arg1
2759 {
2760 public:
2761   virtual Item *create_1_arg(THD *thd, Item *arg1);
2762 
2763   static Create_func_sha s_singleton;
2764 
2765 protected:
Create_func_sha()2766   Create_func_sha() {}
~Create_func_sha()2767   virtual ~Create_func_sha() {}
2768 };
2769 
2770 
2771 class Create_func_sha2 : public Create_func_arg2
2772 {
2773 public:
2774   virtual Item* create_2_arg(THD *thd, Item *arg1, Item *arg2);
2775 
2776   static Create_func_sha2 s_singleton;
2777 
2778 protected:
Create_func_sha2()2779   Create_func_sha2() {}
~Create_func_sha2()2780   virtual ~Create_func_sha2() {}
2781 };
2782 
2783 
2784 class Create_func_sign : public Create_func_arg1
2785 {
2786 public:
2787   virtual Item *create_1_arg(THD *thd, Item *arg1);
2788 
2789   static Create_func_sign s_singleton;
2790 
2791 protected:
Create_func_sign()2792   Create_func_sign() {}
~Create_func_sign()2793   virtual ~Create_func_sign() {}
2794 };
2795 
2796 
2797 class Create_func_sin : public Create_func_arg1
2798 {
2799 public:
2800   virtual Item *create_1_arg(THD *thd, Item *arg1);
2801 
2802   static Create_func_sin s_singleton;
2803 
2804 protected:
Create_func_sin()2805   Create_func_sin() {}
~Create_func_sin()2806   virtual ~Create_func_sin() {}
2807 };
2808 
2809 
2810 class Create_func_sleep : public Create_func_arg1
2811 {
2812 public:
2813   virtual Item *create_1_arg(THD *thd, Item *arg1);
2814 
2815   static Create_func_sleep s_singleton;
2816 
2817 protected:
Create_func_sleep()2818   Create_func_sleep() {}
~Create_func_sleep()2819   virtual ~Create_func_sleep() {}
2820 };
2821 
2822 
2823 class Create_func_soundex : public Create_func_arg1
2824 {
2825 public:
2826   virtual Item *create_1_arg(THD *thd, Item *arg1);
2827 
2828   static Create_func_soundex s_singleton;
2829 
2830 protected:
Create_func_soundex()2831   Create_func_soundex() {}
~Create_func_soundex()2832   virtual ~Create_func_soundex() {}
2833 };
2834 
2835 
2836 class Create_func_space : public Create_func_arg1
2837 {
2838 public:
2839   virtual Item *create_1_arg(THD *thd, Item *arg1);
2840 
2841   static Create_func_space s_singleton;
2842 
2843 protected:
Create_func_space()2844   Create_func_space() {}
~Create_func_space()2845   virtual ~Create_func_space() {}
2846 };
2847 
2848 
2849 class Create_func_sqrt : public Create_func_arg1
2850 {
2851 public:
2852   virtual Item *create_1_arg(THD *thd, Item *arg1);
2853 
2854   static Create_func_sqrt s_singleton;
2855 
2856 protected:
Create_func_sqrt()2857   Create_func_sqrt() {}
~Create_func_sqrt()2858   virtual ~Create_func_sqrt() {}
2859 };
2860 
2861 
2862 #ifdef HAVE_SPATIAL
2863 class Create_func_srid : public Create_func_arg1
2864 {
2865 public:
2866   virtual Item *create_1_arg(THD *thd, Item *arg1);
2867 
2868   static Create_func_srid s_singleton;
2869 
2870 protected:
Create_func_srid()2871   Create_func_srid() {}
~Create_func_srid()2872   virtual ~Create_func_srid() {}
2873 };
2874 #endif
2875 
2876 
2877 #ifdef HAVE_SPATIAL
2878 class Create_func_startpoint : public Create_func_arg1
2879 {
2880 public:
2881   virtual Item *create_1_arg(THD *thd, Item *arg1);
2882 
2883   static Create_func_startpoint s_singleton;
2884 
2885 protected:
Create_func_startpoint()2886   Create_func_startpoint() {}
~Create_func_startpoint()2887   virtual ~Create_func_startpoint() {}
2888 };
2889 #endif
2890 
2891 
2892 class Create_func_str_to_date : public Create_func_arg2
2893 {
2894 public:
2895   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2896 
2897   static Create_func_str_to_date s_singleton;
2898 
2899 protected:
Create_func_str_to_date()2900   Create_func_str_to_date() {}
~Create_func_str_to_date()2901   virtual ~Create_func_str_to_date() {}
2902 };
2903 
2904 
2905 class Create_func_strcmp : public Create_func_arg2
2906 {
2907 public:
2908   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2909 
2910   static Create_func_strcmp s_singleton;
2911 
2912 protected:
Create_func_strcmp()2913   Create_func_strcmp() {}
~Create_func_strcmp()2914   virtual ~Create_func_strcmp() {}
2915 };
2916 
2917 
2918 class Create_func_substr_index : public Create_func_arg3
2919 {
2920 public:
2921   virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3);
2922 
2923   static Create_func_substr_index s_singleton;
2924 
2925 protected:
Create_func_substr_index()2926   Create_func_substr_index() {}
~Create_func_substr_index()2927   virtual ~Create_func_substr_index() {}
2928 };
2929 
2930 
2931 class Create_func_substr_oracle : public Create_native_func
2932 {
2933 public:
2934   virtual Item *create_native(THD *thd, LEX_CSTRING *name,
2935                               List<Item> *item_list);
2936 
2937   static Create_func_substr_oracle s_singleton;
2938 
2939 protected:
Create_func_substr_oracle()2940   Create_func_substr_oracle() {}
~Create_func_substr_oracle()2941   virtual ~Create_func_substr_oracle() {}
2942 };
2943 
2944 
2945 class Create_func_subtime : public Create_func_arg2
2946 {
2947 public:
2948   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2949 
2950   static Create_func_subtime s_singleton;
2951 
2952 protected:
Create_func_subtime()2953   Create_func_subtime() {}
~Create_func_subtime()2954   virtual ~Create_func_subtime() {}
2955 };
2956 
2957 
2958 class Create_func_tan : public Create_func_arg1
2959 {
2960 public:
2961   virtual Item *create_1_arg(THD *thd, Item *arg1);
2962 
2963   static Create_func_tan s_singleton;
2964 
2965 protected:
Create_func_tan()2966   Create_func_tan() {}
~Create_func_tan()2967   virtual ~Create_func_tan() {}
2968 };
2969 
2970 
2971 class Create_func_time_format : public Create_func_arg2
2972 {
2973 public:
2974   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
2975 
2976   static Create_func_time_format s_singleton;
2977 
2978 protected:
Create_func_time_format()2979   Create_func_time_format() {}
~Create_func_time_format()2980   virtual ~Create_func_time_format() {}
2981 };
2982 
2983 
2984 class Create_func_time_to_sec : public Create_func_arg1
2985 {
2986 public:
2987   virtual Item *create_1_arg(THD *thd, Item *arg1);
2988 
2989   static Create_func_time_to_sec s_singleton;
2990 
2991 protected:
Create_func_time_to_sec()2992   Create_func_time_to_sec() {}
~Create_func_time_to_sec()2993   virtual ~Create_func_time_to_sec() {}
2994 };
2995 
2996 
2997 class Create_func_timediff : public Create_func_arg2
2998 {
2999 public:
3000   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
3001 
3002   static Create_func_timediff s_singleton;
3003 
3004 protected:
Create_func_timediff()3005   Create_func_timediff() {}
~Create_func_timediff()3006   virtual ~Create_func_timediff() {}
3007 };
3008 
3009 
3010 class Create_func_to_base64 : public Create_func_arg1
3011 {
3012 public:
3013   virtual Item *create_1_arg(THD *thd, Item *arg1);
3014 
3015   static Create_func_to_base64 s_singleton;
3016 
3017 protected:
Create_func_to_base64()3018   Create_func_to_base64() {}
~Create_func_to_base64()3019   virtual ~Create_func_to_base64() {}
3020 };
3021 
3022 
3023 class Create_func_to_days : public Create_func_arg1
3024 {
3025 public:
3026   virtual Item *create_1_arg(THD *thd, Item *arg1);
3027 
3028   static Create_func_to_days s_singleton;
3029 
3030 protected:
Create_func_to_days()3031   Create_func_to_days() {}
~Create_func_to_days()3032   virtual ~Create_func_to_days() {}
3033 };
3034 
3035 class Create_func_to_seconds : public Create_func_arg1
3036 {
3037 public:
3038   virtual Item* create_1_arg(THD *thd, Item *arg1);
3039 
3040   static Create_func_to_seconds s_singleton;
3041 
3042 protected:
Create_func_to_seconds()3043   Create_func_to_seconds() {}
~Create_func_to_seconds()3044   virtual ~Create_func_to_seconds() {}
3045 };
3046 
3047 
3048 #ifdef HAVE_SPATIAL
3049 class Create_func_touches : public Create_func_arg2
3050 {
3051 public:
3052   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
3053 
3054   static Create_func_touches s_singleton;
3055 
3056 protected:
Create_func_touches()3057   Create_func_touches() {}
~Create_func_touches()3058   virtual ~Create_func_touches() {}
3059 };
3060 #endif
3061 
3062 
3063 class Create_func_ucase : public Create_func_arg1
3064 {
3065 public:
3066   virtual Item *create_1_arg(THD *thd, Item *arg1);
3067 
3068   static Create_func_ucase s_singleton;
3069 
3070 protected:
Create_func_ucase()3071   Create_func_ucase() {}
~Create_func_ucase()3072   virtual ~Create_func_ucase() {}
3073 };
3074 
3075 
3076 class Create_func_uncompress : public Create_func_arg1
3077 {
3078 public:
3079   virtual Item *create_1_arg(THD *thd, Item *arg1);
3080 
3081   static Create_func_uncompress s_singleton;
3082 
3083 protected:
Create_func_uncompress()3084   Create_func_uncompress() {}
~Create_func_uncompress()3085   virtual ~Create_func_uncompress() {}
3086 };
3087 
3088 
3089 class Create_func_uncompressed_length : public Create_func_arg1
3090 {
3091 public:
3092   virtual Item *create_1_arg(THD *thd, Item *arg1);
3093 
3094   static Create_func_uncompressed_length s_singleton;
3095 
3096 protected:
Create_func_uncompressed_length()3097   Create_func_uncompressed_length() {}
~Create_func_uncompressed_length()3098   virtual ~Create_func_uncompressed_length() {}
3099 };
3100 
3101 
3102 class Create_func_unhex : public Create_func_arg1
3103 {
3104 public:
3105   virtual Item *create_1_arg(THD *thd, Item *arg1);
3106 
3107   static Create_func_unhex s_singleton;
3108 
3109 protected:
Create_func_unhex()3110   Create_func_unhex() {}
~Create_func_unhex()3111   virtual ~Create_func_unhex() {}
3112 };
3113 
3114 
3115 class Create_func_unix_timestamp : public Create_native_func
3116 {
3117 public:
3118   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
3119 
3120   static Create_func_unix_timestamp s_singleton;
3121 
3122 protected:
Create_func_unix_timestamp()3123   Create_func_unix_timestamp() {}
~Create_func_unix_timestamp()3124   virtual ~Create_func_unix_timestamp() {}
3125 };
3126 
3127 
3128 class Create_func_uuid : public Create_func_arg0
3129 {
3130 public:
3131   virtual Item *create_builder(THD *thd);
3132 
3133   static Create_func_uuid s_singleton;
3134 
3135 protected:
Create_func_uuid()3136   Create_func_uuid() {}
~Create_func_uuid()3137   virtual ~Create_func_uuid() {}
3138 };
3139 
3140 
3141 class Create_func_uuid_short : public Create_func_arg0
3142 {
3143 public:
3144   virtual Item *create_builder(THD *thd);
3145 
3146   static Create_func_uuid_short s_singleton;
3147 
3148 protected:
Create_func_uuid_short()3149   Create_func_uuid_short() {}
~Create_func_uuid_short()3150   virtual ~Create_func_uuid_short() {}
3151 };
3152 
3153 
3154 class Create_func_version : public Create_func_arg0
3155 {
3156 public:
3157   virtual Item *create_builder(THD *thd);
3158 
3159   static Create_func_version s_singleton;
3160 
3161 protected:
Create_func_version()3162   Create_func_version() {}
~Create_func_version()3163   virtual ~Create_func_version() {}
3164 };
3165 
3166 
3167 class Create_func_weekday : public Create_func_arg1
3168 {
3169 public:
3170   virtual Item *create_1_arg(THD *thd, Item *arg1);
3171 
3172   static Create_func_weekday s_singleton;
3173 
3174 protected:
Create_func_weekday()3175   Create_func_weekday() {}
~Create_func_weekday()3176   virtual ~Create_func_weekday() {}
3177 };
3178 
3179 
3180 class Create_func_weekofyear : public Create_func_arg1
3181 {
3182 public:
3183   virtual Item *create_1_arg(THD *thd, Item *arg1);
3184 
3185   static Create_func_weekofyear s_singleton;
3186 
3187 protected:
Create_func_weekofyear()3188   Create_func_weekofyear() {}
~Create_func_weekofyear()3189   virtual ~Create_func_weekofyear() {}
3190 };
3191 
3192 
3193 #ifdef HAVE_SPATIAL
3194 class Create_func_mbr_within : public Create_func_arg2
3195 {
3196   public:
3197     virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
3198 
3199     static Create_func_mbr_within s_singleton;
3200 
3201   protected:
Create_func_mbr_within()3202     Create_func_mbr_within() {}
~Create_func_mbr_within()3203     virtual ~Create_func_mbr_within() {}
3204 };
3205 
3206 
3207 class Create_func_within : public Create_func_arg2
3208 {
3209 public:
3210   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
3211 
3212   static Create_func_within s_singleton;
3213 
3214 protected:
Create_func_within()3215   Create_func_within() {}
~Create_func_within()3216   virtual ~Create_func_within() {}
3217 };
3218 #endif
3219 
3220 #ifdef WITH_WSREP
3221 class Create_func_wsrep_last_written_gtid : public Create_func_arg0
3222 {
3223 public:
3224   virtual Item *create_builder(THD *thd);
3225 
3226   static Create_func_wsrep_last_written_gtid s_singleton;
3227 
3228 protected:
Create_func_wsrep_last_written_gtid()3229   Create_func_wsrep_last_written_gtid() {}
~Create_func_wsrep_last_written_gtid()3230   virtual ~Create_func_wsrep_last_written_gtid() {}
3231 };
3232 
3233 
3234 class Create_func_wsrep_last_seen_gtid : public Create_func_arg0
3235 {
3236 public:
3237   virtual Item *create_builder(THD *thd);
3238 
3239   static Create_func_wsrep_last_seen_gtid s_singleton;
3240 
3241 protected:
Create_func_wsrep_last_seen_gtid()3242   Create_func_wsrep_last_seen_gtid() {}
~Create_func_wsrep_last_seen_gtid()3243   virtual ~Create_func_wsrep_last_seen_gtid() {}
3244 };
3245 
3246 
3247 class Create_func_wsrep_sync_wait_upto : public Create_native_func
3248 {
3249 public:
3250   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
3251 
3252   static Create_func_wsrep_sync_wait_upto s_singleton;
3253 
3254 protected:
Create_func_wsrep_sync_wait_upto()3255   Create_func_wsrep_sync_wait_upto() {}
~Create_func_wsrep_sync_wait_upto()3256   virtual ~Create_func_wsrep_sync_wait_upto() {}
3257 };
3258 #endif /* WITH_WSREP */
3259 
3260 #ifdef HAVE_SPATIAL
3261 class Create_func_x : public Create_func_arg1
3262 {
3263 public:
3264   virtual Item *create_1_arg(THD *thd, Item *arg1);
3265 
3266   static Create_func_x s_singleton;
3267 
3268 protected:
Create_func_x()3269   Create_func_x() {}
~Create_func_x()3270   virtual ~Create_func_x() {}
3271 };
3272 #endif
3273 
3274 
3275 class Create_func_xml_extractvalue : public Create_func_arg2
3276 {
3277 public:
3278   virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
3279 
3280   static Create_func_xml_extractvalue s_singleton;
3281 
3282 protected:
Create_func_xml_extractvalue()3283   Create_func_xml_extractvalue() {}
~Create_func_xml_extractvalue()3284   virtual ~Create_func_xml_extractvalue() {}
3285 };
3286 
3287 
3288 class Create_func_xml_update : public Create_func_arg3
3289 {
3290 public:
3291   virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3);
3292 
3293   static Create_func_xml_update s_singleton;
3294 
3295 protected:
Create_func_xml_update()3296   Create_func_xml_update() {}
~Create_func_xml_update()3297   virtual ~Create_func_xml_update() {}
3298 };
3299 
3300 
3301 #ifdef HAVE_SPATIAL
3302 class Create_func_y : public Create_func_arg1
3303 {
3304 public:
3305   virtual Item *create_1_arg(THD *thd, Item *arg1);
3306 
3307   static Create_func_y s_singleton;
3308 
3309 protected:
Create_func_y()3310   Create_func_y() {}
~Create_func_y()3311   virtual ~Create_func_y() {}
3312 };
3313 #endif
3314 
3315 
3316 class Create_func_year_week : public Create_native_func
3317 {
3318 public:
3319   virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list);
3320 
3321   static Create_func_year_week s_singleton;
3322 
3323 protected:
Create_func_year_week()3324   Create_func_year_week() {}
~Create_func_year_week()3325   virtual ~Create_func_year_week() {}
3326 };
3327 
3328 
3329 /*
3330 =============================================================================
3331   IMPLEMENTATION
3332 =============================================================================
3333 */
3334 
3335 /**
3336   Checks if there are named parameters in a parameter list.
3337   The syntax to name parameters in a function call is as follow:
3338   <code>foo(expr AS named, expr named, expr AS "named", expr "named")</code>
3339   @param params The parameter list, can be null
3340   @return true if one or more parameter is named
3341 */
has_named_parameters(List<Item> * params)3342 static bool has_named_parameters(List<Item> *params)
3343 {
3344   if (params)
3345   {
3346     Item *param;
3347     List_iterator<Item> it(*params);
3348     while ((param= it++))
3349     {
3350       if (! param->is_autogenerated_name)
3351         return true;
3352     }
3353   }
3354 
3355   return false;
3356 }
3357 
3358 #ifndef HAVE_SPATIAL
3359 Create_func_no_geom Create_func_no_geom::s_singleton;
3360 
3361 Item*
create_func(THD *,LEX_CSTRING,List<Item> *)3362 Create_func_no_geom::create_func(THD * /* unused */,
3363                             LEX_CSTRING /* unused */,
3364                             List<Item> * /* unused */)
3365 {
3366   /* FIXME: error message can't be translated. */
3367   my_error(ER_FEATURE_DISABLED, MYF(0),
3368            sym_group_geom.name, sym_group_geom.needed_define);
3369   return NULL;
3370 }
3371 #endif
3372 
3373 
3374 Item*
create_func(THD * thd,LEX_CSTRING * name,List<Item> * item_list)3375 Create_qfunc::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
3376 {
3377   LEX_CSTRING db;
3378 
3379   if (unlikely(! thd->db.str && ! thd->lex->sphead))
3380   {
3381     /*
3382       The proper error message should be in the lines of:
3383         Can't resolve <name>() to a function call,
3384         because this function:
3385         - is not a native function,
3386         - is not a user defined function,
3387         - can not match a qualified (read: stored) function
3388           since no database is selected.
3389       Reusing ER_SP_DOES_NOT_EXIST have a message consistent with
3390       the case when a default database exist, see Create_sp_func::create().
3391     */
3392     my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
3393              "FUNCTION", name->str);
3394     return NULL;
3395   }
3396 
3397   if (thd->lex->copy_db_to(&db))
3398     return NULL;
3399 
3400   return create_with_db(thd, &db, name, false, item_list);
3401 }
3402 
3403 
3404 #ifdef HAVE_DLOPEN
3405 Create_udf_func Create_udf_func::s_singleton;
3406 
3407 Item*
create_func(THD * thd,LEX_CSTRING * name,List<Item> * item_list)3408 Create_udf_func::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
3409 {
3410   udf_func *udf= find_udf(name->str,  name->length);
3411   DBUG_ASSERT(udf);
3412   return create(thd, udf, item_list);
3413 }
3414 
3415 
3416 Item*
create(THD * thd,udf_func * udf,List<Item> * item_list)3417 Create_udf_func::create(THD *thd, udf_func *udf, List<Item> *item_list)
3418 {
3419   Item *func= NULL;
3420   int arg_count= 0;
3421 
3422   DBUG_ENTER("Create_udf_func::create");
3423   if (item_list != NULL)
3424     arg_count= item_list->elements;
3425 
3426   thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_UDF);
3427 
3428   DBUG_ASSERT(   (udf->type == UDFTYPE_FUNCTION)
3429               || (udf->type == UDFTYPE_AGGREGATE));
3430 
3431   switch(udf->returns) {
3432   case STRING_RESULT:
3433   {
3434     if (udf->type == UDFTYPE_FUNCTION)
3435     {
3436       if (arg_count)
3437         func= new (thd->mem_root) Item_func_udf_str(thd, udf, *item_list);
3438       else
3439         func= new (thd->mem_root) Item_func_udf_str(thd, udf);
3440     }
3441     else
3442     {
3443       if (arg_count)
3444         func= new (thd->mem_root) Item_sum_udf_str(thd, udf, *item_list);
3445       else
3446         func= new (thd->mem_root) Item_sum_udf_str(thd, udf);
3447     }
3448     break;
3449   }
3450   case REAL_RESULT:
3451   {
3452     if (udf->type == UDFTYPE_FUNCTION)
3453     {
3454       if (arg_count)
3455         func= new (thd->mem_root) Item_func_udf_float(thd, udf, *item_list);
3456       else
3457         func= new (thd->mem_root) Item_func_udf_float(thd, udf);
3458     }
3459     else
3460     {
3461       if (arg_count)
3462         func= new (thd->mem_root) Item_sum_udf_float(thd, udf, *item_list);
3463       else
3464         func= new (thd->mem_root) Item_sum_udf_float(thd, udf);
3465     }
3466     break;
3467   }
3468   case INT_RESULT:
3469   {
3470     if (udf->type == UDFTYPE_FUNCTION)
3471     {
3472       if (arg_count)
3473         func= new (thd->mem_root) Item_func_udf_int(thd, udf, *item_list);
3474       else
3475         func= new (thd->mem_root) Item_func_udf_int(thd, udf);
3476     }
3477     else
3478     {
3479       if (arg_count)
3480         func= new (thd->mem_root) Item_sum_udf_int(thd, udf, *item_list);
3481       else
3482         func= new (thd->mem_root) Item_sum_udf_int(thd, udf);
3483     }
3484     break;
3485   }
3486   case DECIMAL_RESULT:
3487   {
3488     if (udf->type == UDFTYPE_FUNCTION)
3489     {
3490       if (arg_count)
3491         func= new (thd->mem_root) Item_func_udf_decimal(thd, udf, *item_list);
3492       else
3493         func= new (thd->mem_root) Item_func_udf_decimal(thd, udf);
3494     }
3495     else
3496     {
3497       if (arg_count)
3498         func= new (thd->mem_root) Item_sum_udf_decimal(thd, udf, *item_list);
3499       else
3500         func= new (thd->mem_root) Item_sum_udf_decimal(thd, udf);
3501     }
3502     break;
3503   }
3504   default:
3505   {
3506     my_error(ER_NOT_SUPPORTED_YET, MYF(0), "UDF return type");
3507   }
3508   }
3509   thd->lex->safe_to_cache_query= 0;
3510   DBUG_RETURN(func);
3511 }
3512 #endif
3513 
3514 
3515 Create_sp_func Create_sp_func::s_singleton;
3516 
3517 Item*
create_with_db(THD * thd,LEX_CSTRING * db,LEX_CSTRING * name,bool use_explicit_name,List<Item> * item_list)3518 Create_sp_func::create_with_db(THD *thd, LEX_CSTRING *db, LEX_CSTRING *name,
3519                                bool use_explicit_name, List<Item> *item_list)
3520 {
3521   int arg_count= 0;
3522   Item *func= NULL;
3523   LEX *lex= thd->lex;
3524   sp_name *qname;
3525   const Sp_handler *sph= &sp_handler_function;
3526   Database_qualified_name pkgname(&null_clex_str, &null_clex_str);
3527 
3528   if (unlikely(has_named_parameters(item_list)))
3529   {
3530     /*
3531       The syntax "db.foo(expr AS p1, expr AS p2, ...) is invalid,
3532       and has been rejected during syntactic parsing already,
3533       because a stored function call may not have named parameters.
3534 
3535       The syntax "foo(expr AS p1, expr AS p2, ...)" is correct,
3536       because it can refer to a User Defined Function call.
3537       For a Stored Function however, this has no semantic.
3538     */
3539     my_error(ER_WRONG_PARAMETERS_TO_STORED_FCT, MYF(0), name->str);
3540     return NULL;
3541   }
3542 
3543   if (item_list != NULL)
3544     arg_count= item_list->elements;
3545 
3546   qname= new (thd->mem_root) sp_name(db, name, use_explicit_name);
3547   if (unlikely(sph->sp_resolve_package_routine(thd, thd->lex->sphead,
3548                                                qname, &sph, &pkgname)))
3549     return NULL;
3550   sph->add_used_routine(lex, thd, qname);
3551   if (pkgname.m_name.length)
3552     sp_handler_package_body.add_used_routine(lex, thd, &pkgname);
3553   Name_resolution_context *ctx= lex->current_context();
3554   if (arg_count > 0)
3555     func= new (thd->mem_root) Item_func_sp(thd, ctx, qname, sph, *item_list);
3556   else
3557     func= new (thd->mem_root) Item_func_sp(thd, ctx, qname, sph);
3558 
3559   lex->safe_to_cache_query= 0;
3560   return func;
3561 }
3562 
3563 
3564 Item*
create_func(THD * thd,LEX_CSTRING * name,List<Item> * item_list)3565 Create_native_func::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
3566 {
3567   if (unlikely(has_named_parameters(item_list)))
3568   {
3569     my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
3570     return NULL;
3571   }
3572 
3573   return create_native(thd, name, item_list);
3574 }
3575 
3576 
3577 Item*
create_func(THD * thd,LEX_CSTRING * name,List<Item> * item_list)3578 Create_func_arg0::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
3579 {
3580   int arg_count= 0;
3581 
3582   if (item_list != NULL)
3583     arg_count= item_list->elements;
3584 
3585   if (unlikely(arg_count != 0))
3586   {
3587     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
3588     return NULL;
3589   }
3590 
3591   return create_builder(thd);
3592 }
3593 
3594 
3595 Item*
create_func(THD * thd,LEX_CSTRING * name,List<Item> * item_list)3596 Create_func_arg1::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
3597 {
3598   int arg_count= 0;
3599 
3600   if (item_list)
3601     arg_count= item_list->elements;
3602 
3603   if (unlikely(arg_count != 1))
3604   {
3605     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
3606     return NULL;
3607   }
3608 
3609   Item *param_1= item_list->pop();
3610 
3611   if (unlikely(! param_1->is_autogenerated_name))
3612   {
3613     my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
3614     return NULL;
3615   }
3616 
3617   return create_1_arg(thd, param_1);
3618 }
3619 
3620 
3621 Item*
create_func(THD * thd,LEX_CSTRING * name,List<Item> * item_list)3622 Create_func_arg2::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
3623 {
3624   int arg_count= 0;
3625 
3626   if (item_list)
3627     arg_count= item_list->elements;
3628 
3629   if (unlikely(arg_count != 2))
3630   {
3631     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
3632     return NULL;
3633   }
3634 
3635   Item *param_1= item_list->pop();
3636   Item *param_2= item_list->pop();
3637 
3638   if (unlikely(!param_1->is_autogenerated_name ||
3639                !param_2->is_autogenerated_name))
3640   {
3641     my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
3642     return NULL;
3643   }
3644 
3645   return create_2_arg(thd, param_1, param_2);
3646 }
3647 
3648 
3649 Item*
create_func(THD * thd,LEX_CSTRING * name,List<Item> * item_list)3650 Create_func_arg3::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
3651 {
3652   int arg_count= 0;
3653 
3654   if (item_list)
3655     arg_count= item_list->elements;
3656 
3657   if (unlikely(arg_count != 3))
3658   {
3659     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
3660     return NULL;
3661   }
3662 
3663   Item *param_1= item_list->pop();
3664   Item *param_2= item_list->pop();
3665   Item *param_3= item_list->pop();
3666 
3667   if (unlikely(!param_1->is_autogenerated_name ||
3668                !param_2->is_autogenerated_name ||
3669                !param_3->is_autogenerated_name))
3670   {
3671     my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
3672     return NULL;
3673   }
3674 
3675   return create_3_arg(thd, param_1, param_2, param_3);
3676 }
3677 
3678 
3679 Create_func_abs Create_func_abs::s_singleton;
3680 
3681 Item*
create_1_arg(THD * thd,Item * arg1)3682 Create_func_abs::create_1_arg(THD *thd, Item *arg1)
3683 {
3684   return new (thd->mem_root) Item_func_abs(thd, arg1);
3685 }
3686 
3687 
3688 Create_func_acos Create_func_acos::s_singleton;
3689 
3690 Item*
create_1_arg(THD * thd,Item * arg1)3691 Create_func_acos::create_1_arg(THD *thd, Item *arg1)
3692 {
3693   return new (thd->mem_root) Item_func_acos(thd, arg1);
3694 }
3695 
3696 
3697 Create_func_addtime Create_func_addtime::s_singleton;
3698 
3699 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)3700 Create_func_addtime::create_2_arg(THD *thd, Item *arg1, Item *arg2)
3701 {
3702   return new (thd->mem_root) Item_func_add_time(thd, arg1, arg2, false);
3703 }
3704 
3705 
3706 Create_func_aes_encrypt Create_func_aes_encrypt::s_singleton;
3707 
3708 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)3709 Create_func_aes_encrypt::create_2_arg(THD *thd, Item *arg1, Item *arg2)
3710 {
3711   return new (thd->mem_root) Item_func_aes_encrypt(thd, arg1, arg2);
3712 }
3713 
3714 
3715 Create_func_aes_decrypt Create_func_aes_decrypt::s_singleton;
3716 
3717 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)3718 Create_func_aes_decrypt::create_2_arg(THD *thd, Item *arg1, Item *arg2)
3719 {
3720   return new (thd->mem_root) Item_func_aes_decrypt(thd, arg1, arg2);
3721 }
3722 
3723 
3724 #ifdef HAVE_SPATIAL
3725 Create_func_area Create_func_area::s_singleton;
3726 
3727 Item*
create_1_arg(THD * thd,Item * arg1)3728 Create_func_area::create_1_arg(THD *thd, Item *arg1)
3729 {
3730   return new (thd->mem_root) Item_func_area(thd, arg1);
3731 }
3732 #endif
3733 
3734 
3735 #ifdef HAVE_SPATIAL
3736 Create_func_as_wkb Create_func_as_wkb::s_singleton;
3737 
3738 Item*
create_1_arg(THD * thd,Item * arg1)3739 Create_func_as_wkb::create_1_arg(THD *thd, Item *arg1)
3740 {
3741   return new (thd->mem_root) Item_func_as_wkb(thd, arg1);
3742 }
3743 #endif
3744 
3745 
3746 #ifdef HAVE_SPATIAL
3747 Create_func_as_wkt Create_func_as_wkt::s_singleton;
3748 
3749 Item*
create_1_arg(THD * thd,Item * arg1)3750 Create_func_as_wkt::create_1_arg(THD *thd, Item *arg1)
3751 {
3752   return new (thd->mem_root) Item_func_as_wkt(thd, arg1);
3753 }
3754 #endif
3755 
3756 
3757 Create_func_asin Create_func_asin::s_singleton;
3758 
3759 Item*
create_1_arg(THD * thd,Item * arg1)3760 Create_func_asin::create_1_arg(THD *thd, Item *arg1)
3761 {
3762   return new (thd->mem_root) Item_func_asin(thd, arg1);
3763 }
3764 
3765 
3766 Create_func_atan Create_func_atan::s_singleton;
3767 
3768 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)3769 Create_func_atan::create_native(THD *thd, LEX_CSTRING *name,
3770                                 List<Item> *item_list)
3771 {
3772   Item* func= NULL;
3773   int arg_count= 0;
3774 
3775   if (item_list != NULL)
3776     arg_count= item_list->elements;
3777 
3778   switch (arg_count) {
3779   case 1:
3780   {
3781     Item *param_1= item_list->pop();
3782     func= new (thd->mem_root) Item_func_atan(thd, param_1);
3783     break;
3784   }
3785   case 2:
3786   {
3787     Item *param_1= item_list->pop();
3788     Item *param_2= item_list->pop();
3789     func= new (thd->mem_root) Item_func_atan(thd, param_1, param_2);
3790     break;
3791   }
3792   default:
3793   {
3794     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
3795     break;
3796   }
3797   }
3798 
3799   return func;
3800 }
3801 
3802 
3803 Create_func_benchmark Create_func_benchmark::s_singleton;
3804 
3805 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)3806 Create_func_benchmark::create_2_arg(THD *thd, Item *arg1, Item *arg2)
3807 {
3808   thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
3809   return new (thd->mem_root) Item_func_benchmark(thd, arg1, arg2);
3810 }
3811 
3812 
3813 Create_func_bin Create_func_bin::s_singleton;
3814 
3815 Item*
create_1_arg(THD * thd,Item * arg1)3816 Create_func_bin::create_1_arg(THD *thd, Item *arg1)
3817 {
3818   Item *i10= new (thd->mem_root) Item_int(thd, (int32) 10,2);
3819   Item *i2= new (thd->mem_root) Item_int(thd, (int32) 2,1);
3820   return new (thd->mem_root) Item_func_conv(thd, arg1, i10, i2);
3821 }
3822 
3823 
3824 Create_func_binlog_gtid_pos Create_func_binlog_gtid_pos::s_singleton;
3825 
3826 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)3827 Create_func_binlog_gtid_pos::create_2_arg(THD *thd, Item *arg1, Item *arg2)
3828 {
3829 #ifdef HAVE_REPLICATION
3830   if (unlikely(!mysql_bin_log.is_open()))
3831 #endif
3832   {
3833     my_error(ER_NO_BINARY_LOGGING, MYF(0));
3834     return NULL;
3835   }
3836   thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
3837   return new (thd->mem_root) Item_func_binlog_gtid_pos(thd, arg1, arg2);
3838 }
3839 
3840 
3841 Create_func_bit_count Create_func_bit_count::s_singleton;
3842 
3843 Item*
create_1_arg(THD * thd,Item * arg1)3844 Create_func_bit_count::create_1_arg(THD *thd, Item *arg1)
3845 {
3846   return new (thd->mem_root) Item_func_bit_count(thd, arg1);
3847 }
3848 
3849 
3850 Create_func_bit_length Create_func_bit_length::s_singleton;
3851 
3852 Item*
create_1_arg(THD * thd,Item * arg1)3853 Create_func_bit_length::create_1_arg(THD *thd, Item *arg1)
3854 {
3855   return new (thd->mem_root) Item_func_bit_length(thd, arg1);
3856 }
3857 
3858 
3859 Create_func_ceiling Create_func_ceiling::s_singleton;
3860 
3861 Item*
create_1_arg(THD * thd,Item * arg1)3862 Create_func_ceiling::create_1_arg(THD *thd, Item *arg1)
3863 {
3864   return new (thd->mem_root) Item_func_ceiling(thd, arg1);
3865 }
3866 
3867 
3868 #ifdef HAVE_SPATIAL
3869 Create_func_centroid Create_func_centroid::s_singleton;
3870 
3871 Item*
create_1_arg(THD * thd,Item * arg1)3872 Create_func_centroid::create_1_arg(THD *thd, Item *arg1)
3873 {
3874   return new (thd->mem_root) Item_func_centroid(thd, arg1);
3875 }
3876 
3877 
3878 Create_func_chr Create_func_chr::s_singleton;
3879 
3880 Item*
create_1_arg(THD * thd,Item * arg1)3881 Create_func_chr::create_1_arg(THD *thd, Item *arg1)
3882 {
3883   CHARSET_INFO *cs_db= thd->variables.collation_database;
3884   return new (thd->mem_root) Item_func_chr(thd, arg1, cs_db);
3885 }
3886 
3887 
3888 Create_func_convexhull Create_func_convexhull::s_singleton;
3889 
3890 Item*
create_1_arg(THD * thd,Item * arg1)3891 Create_func_convexhull::create_1_arg(THD *thd, Item *arg1)
3892 {
3893   return new (thd->mem_root) Item_func_convexhull(thd, arg1);
3894 }
3895 
3896 
3897 Create_func_pointonsurface Create_func_pointonsurface::s_singleton;
3898 
3899 Item*
create_1_arg(THD * thd,Item * arg1)3900 Create_func_pointonsurface::create_1_arg(THD *thd, Item *arg1)
3901 {
3902   return new (thd->mem_root) Item_func_pointonsurface(thd, arg1);
3903 }
3904 #endif /*HAVE_SPATIAL*/
3905 
3906 
3907 Create_func_char_length Create_func_char_length::s_singleton;
3908 
3909 Item*
create_1_arg(THD * thd,Item * arg1)3910 Create_func_char_length::create_1_arg(THD *thd, Item *arg1)
3911 {
3912   return new (thd->mem_root) Item_func_char_length(thd, arg1);
3913 }
3914 
3915 
3916 Create_func_coercibility Create_func_coercibility::s_singleton;
3917 
3918 Item*
create_1_arg(THD * thd,Item * arg1)3919 Create_func_coercibility::create_1_arg(THD *thd, Item *arg1)
3920 {
3921   return new (thd->mem_root) Item_func_coercibility(thd, arg1);
3922 }
3923 
3924 
3925 Create_func_dyncol_check Create_func_dyncol_check::s_singleton;
3926 
3927 Item*
create_1_arg(THD * thd,Item * arg1)3928 Create_func_dyncol_check::create_1_arg(THD *thd, Item *arg1)
3929 {
3930   return new (thd->mem_root) Item_func_dyncol_check(thd, arg1);
3931 }
3932 
3933 Create_func_dyncol_exists Create_func_dyncol_exists::s_singleton;
3934 
3935 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)3936 Create_func_dyncol_exists::create_2_arg(THD *thd, Item *arg1, Item *arg2)
3937 {
3938   return new (thd->mem_root) Item_func_dyncol_exists(thd, arg1, arg2);
3939 }
3940 
3941 Create_func_dyncol_list Create_func_dyncol_list::s_singleton;
3942 
3943 Item*
create_1_arg(THD * thd,Item * arg1)3944 Create_func_dyncol_list::create_1_arg(THD *thd, Item *arg1)
3945 {
3946   return new (thd->mem_root) Item_func_dyncol_list(thd, arg1);
3947 }
3948 
3949 Create_func_dyncol_json Create_func_dyncol_json::s_singleton;
3950 
3951 Item*
create_1_arg(THD * thd,Item * arg1)3952 Create_func_dyncol_json::create_1_arg(THD *thd, Item *arg1)
3953 {
3954   return new (thd->mem_root) Item_func_dyncol_json(thd, arg1);
3955 }
3956 
3957 Create_func_concat Create_func_concat::s_singleton;
3958 
3959 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)3960 Create_func_concat::create_native(THD *thd, LEX_CSTRING *name,
3961                                   List<Item> *item_list)
3962 {
3963   int arg_count= 0;
3964 
3965   if (item_list != NULL)
3966     arg_count= item_list->elements;
3967 
3968   if (unlikely(arg_count < 1))
3969   {
3970     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
3971     return NULL;
3972   }
3973 
3974   return thd->variables.sql_mode & MODE_ORACLE ?
3975     new (thd->mem_root) Item_func_concat_operator_oracle(thd, *item_list) :
3976     new (thd->mem_root) Item_func_concat(thd, *item_list);
3977 }
3978 
3979 Create_func_concat_operator_oracle
3980   Create_func_concat_operator_oracle::s_singleton;
3981 
3982 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)3983 Create_func_concat_operator_oracle::create_native(THD *thd, LEX_CSTRING *name,
3984                                                   List<Item> *item_list)
3985 {
3986   int arg_count= 0;
3987 
3988   if (item_list != NULL)
3989     arg_count= item_list->elements;
3990 
3991   if (unlikely(arg_count < 1))
3992   {
3993     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
3994     return NULL;
3995   }
3996 
3997   return new (thd->mem_root) Item_func_concat_operator_oracle(thd, *item_list);
3998 }
3999 
4000 Create_func_decode_histogram Create_func_decode_histogram::s_singleton;
4001 
4002 Item *
create_2_arg(THD * thd,Item * arg1,Item * arg2)4003 Create_func_decode_histogram::create_2_arg(THD *thd, Item *arg1, Item *arg2)
4004 {
4005   return new (thd->mem_root) Item_func_decode_histogram(thd, arg1, arg2);
4006 }
4007 
4008 Create_func_decode_oracle Create_func_decode_oracle::s_singleton;
4009 
4010 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4011 Create_func_decode_oracle::create_native(THD *thd, LEX_CSTRING *name,
4012                                          List<Item> *item_list)
4013 {
4014   uint arg_count= item_list ? item_list->elements : 0;
4015   if (unlikely(arg_count < 3))
4016   {
4017     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4018     return NULL;
4019   }
4020   return new (thd->mem_root) Item_func_decode_oracle(thd, *item_list);
4021 }
4022 
4023 Create_func_concat_ws Create_func_concat_ws::s_singleton;
4024 
4025 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4026 Create_func_concat_ws::create_native(THD *thd, LEX_CSTRING *name,
4027                                      List<Item> *item_list)
4028 {
4029   int arg_count= 0;
4030 
4031   if (item_list != NULL)
4032     arg_count= item_list->elements;
4033 
4034   /* "WS" stands for "With Separator": this function takes 2+ arguments */
4035   if (unlikely(arg_count < 2))
4036   {
4037     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4038     return NULL;
4039   }
4040 
4041   return new (thd->mem_root) Item_func_concat_ws(thd, *item_list);
4042 }
4043 
4044 
4045 Create_func_compress Create_func_compress::s_singleton;
4046 
4047 Item*
create_1_arg(THD * thd,Item * arg1)4048 Create_func_compress::create_1_arg(THD *thd, Item *arg1)
4049 {
4050   return new (thd->mem_root) Item_func_compress(thd, arg1);
4051 }
4052 
4053 
4054 Create_func_connection_id Create_func_connection_id::s_singleton;
4055 
4056 Item*
create_builder(THD * thd)4057 Create_func_connection_id::create_builder(THD *thd)
4058 {
4059   thd->lex->safe_to_cache_query= 0;
4060   return new (thd->mem_root) Item_func_connection_id(thd);
4061 }
4062 
4063 
4064 #ifdef HAVE_SPATIAL
4065 Create_func_mbr_contains Create_func_mbr_contains::s_singleton;
4066 
4067 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)4068 Create_func_mbr_contains::create_2_arg(THD *thd, Item *arg1, Item *arg2)
4069 {
4070   return new (thd->mem_root) Item_func_spatial_mbr_rel(thd, arg1, arg2,
4071       Item_func::SP_CONTAINS_FUNC);
4072 }
4073 
4074 
4075 Create_func_contains Create_func_contains::s_singleton;
4076 
4077 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)4078 Create_func_contains::create_2_arg(THD *thd, Item *arg1, Item *arg2)
4079 {
4080   return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2,
4081                                                   Item_func::SP_CONTAINS_FUNC);
4082 }
4083 #endif
4084 
4085 
4086 Create_func_nvl2 Create_func_nvl2::s_singleton;
4087 
4088 Item*
create_3_arg(THD * thd,Item * arg1,Item * arg2,Item * arg3)4089 Create_func_nvl2::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3)
4090 {
4091   return new (thd->mem_root) Item_func_nvl2(thd, arg1, arg2, arg3);
4092 }
4093 
4094 
4095 Create_func_conv Create_func_conv::s_singleton;
4096 
4097 Item*
create_3_arg(THD * thd,Item * arg1,Item * arg2,Item * arg3)4098 Create_func_conv::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3)
4099 {
4100   return new (thd->mem_root) Item_func_conv(thd, arg1, arg2, arg3);
4101 }
4102 
4103 
4104 Create_func_convert_tz Create_func_convert_tz::s_singleton;
4105 
4106 Item*
create_3_arg(THD * thd,Item * arg1,Item * arg2,Item * arg3)4107 Create_func_convert_tz::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3)
4108 {
4109   return new (thd->mem_root) Item_func_convert_tz(thd, arg1, arg2, arg3);
4110 }
4111 
4112 
4113 Create_func_cos Create_func_cos::s_singleton;
4114 
4115 Item*
create_1_arg(THD * thd,Item * arg1)4116 Create_func_cos::create_1_arg(THD *thd, Item *arg1)
4117 {
4118   return new (thd->mem_root) Item_func_cos(thd, arg1);
4119 }
4120 
4121 
4122 Create_func_cot Create_func_cot::s_singleton;
4123 
4124 Item*
create_1_arg(THD * thd,Item * arg1)4125 Create_func_cot::create_1_arg(THD *thd, Item *arg1)
4126 {
4127   return new (thd->mem_root) Item_func_cot(thd, arg1);
4128 }
4129 
4130 
4131 Create_func_crc32 Create_func_crc32::s_singleton;
4132 
4133 Item*
create_1_arg(THD * thd,Item * arg1)4134 Create_func_crc32::create_1_arg(THD *thd, Item *arg1)
4135 {
4136   return new (thd->mem_root) Item_func_crc32(thd, arg1);
4137 }
4138 
4139 
4140 #ifdef HAVE_SPATIAL
4141 Create_func_crosses Create_func_crosses::s_singleton;
4142 
4143 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)4144 Create_func_crosses::create_2_arg(THD *thd, Item *arg1, Item *arg2)
4145 {
4146   return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2,
4147                                                    Item_func::SP_CROSSES_FUNC);
4148 }
4149 #endif
4150 
4151 
4152 Create_func_datediff Create_func_datediff::s_singleton;
4153 
4154 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)4155 Create_func_datediff::create_2_arg(THD *thd, Item *arg1, Item *arg2)
4156 {
4157   Item *i1= new (thd->mem_root) Item_func_to_days(thd, arg1);
4158   Item *i2= new (thd->mem_root) Item_func_to_days(thd, arg2);
4159 
4160   return new (thd->mem_root) Item_func_minus(thd, i1, i2);
4161 }
4162 
4163 
4164 Create_func_dayname Create_func_dayname::s_singleton;
4165 
4166 Item*
create_1_arg(THD * thd,Item * arg1)4167 Create_func_dayname::create_1_arg(THD *thd, Item *arg1)
4168 {
4169   return new (thd->mem_root) Item_func_dayname(thd, arg1);
4170 }
4171 
4172 
4173 Create_func_dayofmonth Create_func_dayofmonth::s_singleton;
4174 
4175 Item*
create_1_arg(THD * thd,Item * arg1)4176 Create_func_dayofmonth::create_1_arg(THD *thd, Item *arg1)
4177 {
4178   return new (thd->mem_root) Item_func_dayofmonth(thd, arg1);
4179 }
4180 
4181 
4182 Create_func_dayofweek Create_func_dayofweek::s_singleton;
4183 
4184 Item*
create_1_arg(THD * thd,Item * arg1)4185 Create_func_dayofweek::create_1_arg(THD *thd, Item *arg1)
4186 {
4187   return new (thd->mem_root) Item_func_weekday(thd, arg1, 1);
4188 }
4189 
4190 
4191 Create_func_dayofyear Create_func_dayofyear::s_singleton;
4192 
4193 Item*
create_1_arg(THD * thd,Item * arg1)4194 Create_func_dayofyear::create_1_arg(THD *thd, Item *arg1)
4195 {
4196   return new (thd->mem_root) Item_func_dayofyear(thd, arg1);
4197 }
4198 
4199 
4200 Create_func_degrees Create_func_degrees::s_singleton;
4201 
4202 Item*
create_1_arg(THD * thd,Item * arg1)4203 Create_func_degrees::create_1_arg(THD *thd, Item *arg1)
4204 {
4205   return new (thd->mem_root) Item_func_units(thd, (char*) "degrees", arg1,
4206                                              180/M_PI, 0.0);
4207 }
4208 
4209 
4210 Create_func_des_decrypt Create_func_des_decrypt::s_singleton;
4211 
4212 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4213 Create_func_des_decrypt::create_native(THD *thd, LEX_CSTRING *name,
4214                                        List<Item> *item_list)
4215 {
4216   Item *func= NULL;
4217   int arg_count= 0;
4218 
4219   if (item_list != NULL)
4220     arg_count= item_list->elements;
4221 
4222   switch (arg_count) {
4223   case 1:
4224   {
4225     Item *param_1= item_list->pop();
4226     func= new (thd->mem_root) Item_func_des_decrypt(thd, param_1);
4227     break;
4228   }
4229   case 2:
4230   {
4231     Item *param_1= item_list->pop();
4232     Item *param_2= item_list->pop();
4233     func= new (thd->mem_root) Item_func_des_decrypt(thd, param_1, param_2);
4234     break;
4235   }
4236   default:
4237   {
4238     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4239     break;
4240   }
4241   }
4242 
4243   return func;
4244 }
4245 
4246 
4247 Create_func_des_encrypt Create_func_des_encrypt::s_singleton;
4248 
4249 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4250 Create_func_des_encrypt::create_native(THD *thd, LEX_CSTRING *name,
4251                                        List<Item> *item_list)
4252 {
4253   Item *func= NULL;
4254   int arg_count= 0;
4255 
4256   if (item_list != NULL)
4257     arg_count= item_list->elements;
4258 
4259   switch (arg_count) {
4260   case 1:
4261   {
4262     Item *param_1= item_list->pop();
4263     func= new (thd->mem_root) Item_func_des_encrypt(thd, param_1);
4264     break;
4265   }
4266   case 2:
4267   {
4268     Item *param_1= item_list->pop();
4269     Item *param_2= item_list->pop();
4270     func= new (thd->mem_root) Item_func_des_encrypt(thd, param_1, param_2);
4271     break;
4272   }
4273   default:
4274   {
4275     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4276     break;
4277   }
4278   }
4279 
4280   return func;
4281 }
4282 
4283 
4284 #ifdef HAVE_SPATIAL
4285 Create_func_dimension Create_func_dimension::s_singleton;
4286 
4287 Item*
create_1_arg(THD * thd,Item * arg1)4288 Create_func_dimension::create_1_arg(THD *thd, Item *arg1)
4289 {
4290   return new (thd->mem_root) Item_func_dimension(thd, arg1);
4291 }
4292 #endif
4293 
4294 
4295 #ifdef HAVE_SPATIAL
4296 Create_func_mbr_disjoint Create_func_mbr_disjoint::s_singleton;
4297 
4298 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)4299 Create_func_mbr_disjoint::create_2_arg(THD *thd, Item *arg1, Item *arg2)
4300 {
4301   return new (thd->mem_root) Item_func_spatial_mbr_rel(thd, arg1, arg2,
4302       Item_func::SP_DISJOINT_FUNC);
4303 }
4304 
4305 
4306 Create_func_disjoint Create_func_disjoint::s_singleton;
4307 
4308 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)4309 Create_func_disjoint::create_2_arg(THD *thd, Item *arg1, Item *arg2)
4310 {
4311   return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2,
4312                                                   Item_func::SP_DISJOINT_FUNC);
4313 }
4314 
4315 
4316 Create_func_distance Create_func_distance::s_singleton;
4317 
4318 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)4319 Create_func_distance::create_2_arg(THD *thd, Item *arg1, Item *arg2)
4320 {
4321   return new (thd->mem_root) Item_func_distance(thd, arg1, arg2);
4322 }
4323 #endif
4324 
4325 
4326 Create_func_elt Create_func_elt::s_singleton;
4327 
4328 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4329 Create_func_elt::create_native(THD *thd, LEX_CSTRING *name,
4330                                List<Item> *item_list)
4331 {
4332   int arg_count= 0;
4333 
4334   if (item_list != NULL)
4335     arg_count= item_list->elements;
4336 
4337   if (unlikely(arg_count < 2))
4338   {
4339     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4340     return NULL;
4341   }
4342 
4343   return new (thd->mem_root) Item_func_elt(thd, *item_list);
4344 }
4345 
4346 
4347 Create_func_encode Create_func_encode::s_singleton;
4348 
4349 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)4350 Create_func_encode::create_2_arg(THD *thd, Item *arg1, Item *arg2)
4351 {
4352   return new (thd->mem_root) Item_func_encode(thd, arg1, arg2);
4353 }
4354 
4355 
4356 Create_func_encrypt Create_func_encrypt::s_singleton;
4357 
4358 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4359 Create_func_encrypt::create_native(THD *thd, LEX_CSTRING *name,
4360                                    List<Item> *item_list)
4361 {
4362   Item *func= NULL;
4363   int arg_count= 0;
4364 
4365   if (item_list != NULL)
4366     arg_count= item_list->elements;
4367 
4368   switch (arg_count) {
4369   case 1:
4370   {
4371     Item *param_1= item_list->pop();
4372     func= new (thd->mem_root) Item_func_encrypt(thd, param_1);
4373     thd->lex->uncacheable(UNCACHEABLE_RAND);
4374     break;
4375   }
4376   case 2:
4377   {
4378     Item *param_1= item_list->pop();
4379     Item *param_2= item_list->pop();
4380     func= new (thd->mem_root) Item_func_encrypt(thd, param_1, param_2);
4381     break;
4382   }
4383   default:
4384   {
4385     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4386     break;
4387   }
4388   }
4389 
4390   return func;
4391 }
4392 
4393 
4394 #ifdef HAVE_SPATIAL
4395 Create_func_endpoint Create_func_endpoint::s_singleton;
4396 
4397 Item*
create_1_arg(THD * thd,Item * arg1)4398 Create_func_endpoint::create_1_arg(THD *thd, Item *arg1)
4399 {
4400   return new (thd->mem_root) Item_func_spatial_decomp(thd, arg1,
4401                                                       Item_func::SP_ENDPOINT);
4402 }
4403 #endif
4404 
4405 
4406 #ifdef HAVE_SPATIAL
4407 Create_func_envelope Create_func_envelope::s_singleton;
4408 
4409 Item*
create_1_arg(THD * thd,Item * arg1)4410 Create_func_envelope::create_1_arg(THD *thd, Item *arg1)
4411 {
4412   return new (thd->mem_root) Item_func_envelope(thd, arg1);
4413 }
4414 
4415 
4416 Create_func_boundary Create_func_boundary::s_singleton;
4417 
4418 Item*
create_1_arg(THD * thd,Item * arg1)4419 Create_func_boundary::create_1_arg(THD *thd, Item *arg1)
4420 {
4421   return new (thd->mem_root) Item_func_boundary(thd, arg1);
4422 }
4423 #endif
4424 
4425 
4426 #ifdef HAVE_SPATIAL
4427 Create_func_mbr_equals Create_func_mbr_equals::s_singleton;
4428 
4429 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)4430 Create_func_mbr_equals::create_2_arg(THD *thd, Item *arg1, Item *arg2)
4431 {
4432   return new (thd->mem_root) Item_func_spatial_mbr_rel(thd, arg1, arg2,
4433       Item_func::SP_EQUALS_FUNC);
4434 }
4435 
4436 
4437 Create_func_equals Create_func_equals::s_singleton;
4438 
4439 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)4440 Create_func_equals::create_2_arg(THD *thd, Item *arg1, Item *arg2)
4441 {
4442   return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2,
4443                                                     Item_func::SP_EQUALS_FUNC);
4444 }
4445 #endif
4446 
4447 
4448 Create_func_exp Create_func_exp::s_singleton;
4449 
4450 Item*
create_1_arg(THD * thd,Item * arg1)4451 Create_func_exp::create_1_arg(THD *thd, Item *arg1)
4452 {
4453   return new (thd->mem_root) Item_func_exp(thd, arg1);
4454 }
4455 
4456 
4457 Create_func_export_set Create_func_export_set::s_singleton;
4458 
4459 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4460 Create_func_export_set::create_native(THD *thd, LEX_CSTRING *name,
4461                                       List<Item> *item_list)
4462 {
4463   Item *func= NULL;
4464   int arg_count= 0;
4465 
4466   if (item_list != NULL)
4467     arg_count= item_list->elements;
4468 
4469   switch (arg_count) {
4470   case 3:
4471   {
4472     Item *param_1= item_list->pop();
4473     Item *param_2= item_list->pop();
4474     Item *param_3= item_list->pop();
4475     func= new (thd->mem_root) Item_func_export_set(thd, param_1, param_2, param_3);
4476     break;
4477   }
4478   case 4:
4479   {
4480     Item *param_1= item_list->pop();
4481     Item *param_2= item_list->pop();
4482     Item *param_3= item_list->pop();
4483     Item *param_4= item_list->pop();
4484     func= new (thd->mem_root) Item_func_export_set(thd, param_1, param_2, param_3,
4485                                                    param_4);
4486     break;
4487   }
4488   case 5:
4489   {
4490     Item *param_1= item_list->pop();
4491     Item *param_2= item_list->pop();
4492     Item *param_3= item_list->pop();
4493     Item *param_4= item_list->pop();
4494     Item *param_5= item_list->pop();
4495     func= new (thd->mem_root) Item_func_export_set(thd, param_1, param_2, param_3,
4496                                                    param_4, param_5);
4497     break;
4498   }
4499   default:
4500   {
4501     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4502     break;
4503   }
4504   }
4505 
4506   return func;
4507 }
4508 
4509 
4510 #ifdef HAVE_SPATIAL
4511 Create_func_exteriorring Create_func_exteriorring::s_singleton;
4512 
4513 Item*
create_1_arg(THD * thd,Item * arg1)4514 Create_func_exteriorring::create_1_arg(THD *thd, Item *arg1)
4515 {
4516   return new (thd->mem_root) Item_func_spatial_decomp(thd, arg1,
4517                                                       Item_func::SP_EXTERIORRING);
4518 }
4519 #endif
4520 
4521 
4522 Create_func_field Create_func_field::s_singleton;
4523 
4524 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4525 Create_func_field::create_native(THD *thd, LEX_CSTRING *name,
4526                                  List<Item> *item_list)
4527 {
4528   int arg_count= 0;
4529 
4530   if (item_list != NULL)
4531     arg_count= item_list->elements;
4532 
4533   if (unlikely(arg_count < 2))
4534   {
4535     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4536     return NULL;
4537   }
4538 
4539   return new (thd->mem_root) Item_func_field(thd, *item_list);
4540 }
4541 
4542 
4543 Create_func_find_in_set Create_func_find_in_set::s_singleton;
4544 
4545 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)4546 Create_func_find_in_set::create_2_arg(THD *thd, Item *arg1, Item *arg2)
4547 {
4548   return new (thd->mem_root) Item_func_find_in_set(thd, arg1, arg2);
4549 }
4550 
4551 
4552 Create_func_floor Create_func_floor::s_singleton;
4553 
4554 Item*
create_1_arg(THD * thd,Item * arg1)4555 Create_func_floor::create_1_arg(THD *thd, Item *arg1)
4556 {
4557   return new (thd->mem_root) Item_func_floor(thd, arg1);
4558 }
4559 
4560 
4561 Create_func_format Create_func_format::s_singleton;
4562 
4563 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4564 Create_func_format::create_native(THD *thd, LEX_CSTRING *name,
4565                                   List<Item> *item_list)
4566 {
4567   Item *func= NULL;
4568   int arg_count= item_list ? item_list->elements : 0;
4569 
4570   switch (arg_count) {
4571   case 2:
4572   {
4573     Item *param_1= item_list->pop();
4574     Item *param_2= item_list->pop();
4575     func= new (thd->mem_root) Item_func_format(thd, param_1, param_2);
4576     break;
4577   }
4578   case 3:
4579   {
4580     Item *param_1= item_list->pop();
4581     Item *param_2= item_list->pop();
4582     Item *param_3= item_list->pop();
4583     func= new (thd->mem_root) Item_func_format(thd, param_1, param_2, param_3);
4584     break;
4585   }
4586   default:
4587     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4588     break;
4589   }
4590 
4591   return func;
4592 }
4593 
4594 
4595 Create_func_from_base64 Create_func_from_base64::s_singleton;
4596 
4597 
4598 Item *
create_1_arg(THD * thd,Item * arg1)4599 Create_func_from_base64::create_1_arg(THD *thd, Item *arg1)
4600 {
4601   return new (thd->mem_root) Item_func_from_base64(thd, arg1);
4602 }
4603 
4604 
4605 Create_func_found_rows Create_func_found_rows::s_singleton;
4606 
4607 Item*
create_builder(THD * thd)4608 Create_func_found_rows::create_builder(THD *thd)
4609 {
4610   DBUG_ENTER("Create_func_found_rows::create");
4611   thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4612   thd->lex->safe_to_cache_query= 0;
4613   DBUG_RETURN(new (thd->mem_root) Item_func_found_rows(thd));
4614 }
4615 
4616 
4617 Create_func_from_days Create_func_from_days::s_singleton;
4618 
4619 Item*
create_1_arg(THD * thd,Item * arg1)4620 Create_func_from_days::create_1_arg(THD *thd, Item *arg1)
4621 {
4622   return new (thd->mem_root) Item_func_from_days(thd, arg1);
4623 }
4624 
4625 
4626 Create_func_from_unixtime Create_func_from_unixtime::s_singleton;
4627 
4628 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4629 Create_func_from_unixtime::create_native(THD *thd, LEX_CSTRING *name,
4630                                          List<Item> *item_list)
4631 {
4632   Item *func= NULL;
4633   int arg_count= 0;
4634 
4635   if (item_list != NULL)
4636     arg_count= item_list->elements;
4637 
4638   switch (arg_count) {
4639   case 1:
4640   {
4641     Item *param_1= item_list->pop();
4642     func= new (thd->mem_root) Item_func_from_unixtime(thd, param_1);
4643     break;
4644   }
4645   case 2:
4646   {
4647     Item *param_1= item_list->pop();
4648     Item *param_2= item_list->pop();
4649     Item *ut= new (thd->mem_root) Item_func_from_unixtime(thd, param_1);
4650     func= new (thd->mem_root) Item_func_date_format(thd, ut, param_2);
4651     break;
4652   }
4653   default:
4654   {
4655     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4656     break;
4657   }
4658   }
4659 
4660   return func;
4661 }
4662 
4663 
4664 #ifdef HAVE_SPATIAL
4665 Create_func_geometry_from_text Create_func_geometry_from_text::s_singleton;
4666 
4667 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4668 Create_func_geometry_from_text::create_native(THD *thd, LEX_CSTRING *name,
4669                                               List<Item> *item_list)
4670 {
4671   Item *func= NULL;
4672   int arg_count= 0;
4673 
4674   if (item_list != NULL)
4675     arg_count= item_list->elements;
4676 
4677   switch (arg_count) {
4678   case 1:
4679   {
4680     Item *param_1= item_list->pop();
4681     func= new (thd->mem_root) Item_func_geometry_from_text(thd, param_1);
4682     thd->lex->uncacheable(UNCACHEABLE_RAND);
4683     break;
4684   }
4685   case 2:
4686   {
4687     Item *param_1= item_list->pop();
4688     Item *param_2= item_list->pop();
4689     func= new (thd->mem_root) Item_func_geometry_from_text(thd, param_1, param_2);
4690     break;
4691   }
4692   default:
4693   {
4694     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4695     break;
4696   }
4697   }
4698 
4699   return func;
4700 }
4701 #endif
4702 
4703 
4704 #ifdef HAVE_SPATIAL
4705 Create_func_geometry_from_wkb Create_func_geometry_from_wkb::s_singleton;
4706 
4707 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4708 Create_func_geometry_from_wkb::create_native(THD *thd, LEX_CSTRING *name,
4709                                              List<Item> *item_list)
4710 {
4711   Item *func= NULL;
4712   int arg_count= 0;
4713 
4714   if (item_list != NULL)
4715     arg_count= item_list->elements;
4716 
4717   switch (arg_count) {
4718   case 1:
4719   {
4720     Item *param_1= item_list->pop();
4721     func= new (thd->mem_root) Item_func_geometry_from_wkb(thd, param_1);
4722     thd->lex->uncacheable(UNCACHEABLE_RAND);
4723     break;
4724   }
4725   case 2:
4726   {
4727     Item *param_1= item_list->pop();
4728     Item *param_2= item_list->pop();
4729     func= new (thd->mem_root) Item_func_geometry_from_wkb(thd, param_1, param_2);
4730     break;
4731   }
4732   default:
4733   {
4734     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4735     break;
4736   }
4737   }
4738 
4739   return func;
4740 }
4741 #endif
4742 
4743 
4744 #ifdef HAVE_SPATIAL
4745 Create_func_geometry_from_json Create_func_geometry_from_json::s_singleton;
4746 
4747 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4748 Create_func_geometry_from_json::create_native(THD *thd, LEX_CSTRING *name,
4749                                              List<Item> *item_list)
4750 {
4751   Item *func= NULL;
4752   int arg_count= 0;
4753 
4754   if (item_list != NULL)
4755     arg_count= item_list->elements;
4756 
4757   switch (arg_count) {
4758   case 1:
4759   {
4760     Item *json= item_list->pop();
4761     func= new (thd->mem_root) Item_func_geometry_from_json(thd, json);
4762     thd->lex->uncacheable(UNCACHEABLE_RAND);
4763     break;
4764   }
4765   case 2:
4766   {
4767     Item *json= item_list->pop();
4768     Item *options= item_list->pop();
4769     func= new (thd->mem_root) Item_func_geometry_from_json(thd, json, options);
4770     break;
4771   }
4772   case 3:
4773   {
4774     Item *json= item_list->pop();
4775     Item *options= item_list->pop();
4776     Item *srid= item_list->pop();
4777     func= new (thd->mem_root) Item_func_geometry_from_json(thd, json, options,
4778                                                            srid);
4779     break;
4780   }
4781   default:
4782   {
4783     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4784     break;
4785   }
4786   }
4787 
4788   return func;
4789 }
4790 
4791 
4792 Create_func_as_geojson Create_func_as_geojson::s_singleton;
4793 
4794 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4795 Create_func_as_geojson::create_native(THD *thd, LEX_CSTRING *name,
4796                                              List<Item> *item_list)
4797 {
4798   Item *func= NULL;
4799   int arg_count= 0;
4800 
4801   if (item_list != NULL)
4802     arg_count= item_list->elements;
4803 
4804   switch (arg_count) {
4805   case 1:
4806   {
4807     Item *geom= item_list->pop();
4808     func= new (thd->mem_root) Item_func_as_geojson(thd, geom);
4809     thd->lex->uncacheable(UNCACHEABLE_RAND);
4810     break;
4811   }
4812   case 2:
4813   {
4814     Item *geom= item_list->pop();
4815     Item *max_dec= item_list->pop();
4816     func= new (thd->mem_root) Item_func_as_geojson(thd, geom, max_dec);
4817     break;
4818   }
4819   case 3:
4820   {
4821     Item *geom= item_list->pop();
4822     Item *max_dec= item_list->pop();
4823     Item *options= item_list->pop();
4824     func= new (thd->mem_root) Item_func_as_geojson(thd, geom, max_dec, options);
4825     break;
4826   }
4827   default:
4828   {
4829     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4830     break;
4831   }
4832   }
4833 
4834   return func;
4835 }
4836 #endif /*HAVE_SPATIAL*/
4837 
4838 
4839 #ifdef HAVE_SPATIAL
4840 Create_func_geometry_type Create_func_geometry_type::s_singleton;
4841 
4842 Item*
create_1_arg(THD * thd,Item * arg1)4843 Create_func_geometry_type::create_1_arg(THD *thd, Item *arg1)
4844 {
4845   return new (thd->mem_root) Item_func_geometry_type(thd, arg1);
4846 }
4847 #endif
4848 
4849 
4850 #ifdef HAVE_SPATIAL
4851 Create_func_geometryn Create_func_geometryn::s_singleton;
4852 
4853 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)4854 Create_func_geometryn::create_2_arg(THD *thd, Item *arg1, Item *arg2)
4855 {
4856   return new (thd->mem_root) Item_func_spatial_decomp_n(thd, arg1, arg2,
4857                                                         Item_func::SP_GEOMETRYN);
4858 }
4859 #endif
4860 
4861 
4862 Create_func_get_lock Create_func_get_lock::s_singleton;
4863 
4864 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)4865 Create_func_get_lock::create_2_arg(THD *thd, Item *arg1, Item *arg2)
4866 {
4867   thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4868   thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
4869   return new (thd->mem_root) Item_func_get_lock(thd, arg1, arg2);
4870 }
4871 
4872 
4873 #if defined(HAVE_SPATIAL) && !defined(DBUG_OFF)
4874 Create_func_gis_debug Create_func_gis_debug::s_singleton;
4875 
4876 Item*
create_1_arg(THD * thd,Item * arg1)4877 Create_func_gis_debug::create_1_arg(THD *thd, Item *arg1)
4878 {
4879   return new (thd->mem_root) Item_func_gis_debug(thd, arg1);
4880 }
4881 #endif
4882 
4883 
4884 #ifdef HAVE_SPATIAL
4885 Create_func_glength Create_func_glength::s_singleton;
4886 
4887 Item*
create_1_arg(THD * thd,Item * arg1)4888 Create_func_glength::create_1_arg(THD *thd, Item *arg1)
4889 {
4890   return new (thd->mem_root) Item_func_glength(thd, arg1);
4891 }
4892 
4893 
4894 Create_func_distance_sphere Create_func_distance_sphere::s_singleton;
4895 
4896 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4897 Create_func_distance_sphere::create_native(THD *thd, LEX_CSTRING *name,
4898                                            List<Item> *item_list)
4899 {
4900   int arg_count= 0;
4901 
4902   if (item_list != NULL)
4903     arg_count= item_list->elements;
4904 
4905   if (arg_count < 2)
4906   {
4907     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4908     return NULL;
4909   }
4910   return new (thd->mem_root) Item_func_sphere_distance(thd, *item_list);
4911 }
4912 #endif
4913 
4914 
4915 Create_func_greatest Create_func_greatest::s_singleton;
4916 
4917 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)4918 Create_func_greatest::create_native(THD *thd, LEX_CSTRING *name,
4919                                     List<Item> *item_list)
4920 {
4921   int arg_count= 0;
4922 
4923   if (item_list != NULL)
4924     arg_count= item_list->elements;
4925 
4926   if (unlikely(arg_count < 2))
4927   {
4928     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
4929     return NULL;
4930   }
4931 
4932   return new (thd->mem_root) Item_func_max(thd, *item_list);
4933 }
4934 
4935 
4936 Create_func_hex Create_func_hex::s_singleton;
4937 
4938 Item*
create_1_arg(THD * thd,Item * arg1)4939 Create_func_hex::create_1_arg(THD *thd, Item *arg1)
4940 {
4941   return new (thd->mem_root) Item_func_hex(thd, arg1);
4942 }
4943 
4944 
4945 Create_func_ifnull Create_func_ifnull::s_singleton;
4946 
4947 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)4948 Create_func_ifnull::create_2_arg(THD *thd, Item *arg1, Item *arg2)
4949 {
4950   return new (thd->mem_root) Item_func_ifnull(thd, arg1, arg2);
4951 }
4952 
4953 
4954 Create_func_inet_ntoa Create_func_inet_ntoa::s_singleton;
4955 
4956 Item*
create_1_arg(THD * thd,Item * arg1)4957 Create_func_inet_ntoa::create_1_arg(THD *thd, Item *arg1)
4958 {
4959   return new (thd->mem_root) Item_func_inet_ntoa(thd, arg1);
4960 }
4961 
4962 
4963 Create_func_inet6_aton Create_func_inet6_aton::s_singleton;
4964 
4965 Item*
create_1_arg(THD * thd,Item * arg1)4966 Create_func_inet6_aton::create_1_arg(THD *thd, Item *arg1)
4967 {
4968   return new (thd->mem_root) Item_func_inet6_aton(thd, arg1);
4969 }
4970 
4971 
4972 Create_func_inet6_ntoa Create_func_inet6_ntoa::s_singleton;
4973 
4974 Item*
create_1_arg(THD * thd,Item * arg1)4975 Create_func_inet6_ntoa::create_1_arg(THD *thd, Item *arg1)
4976 {
4977   return new (thd->mem_root) Item_func_inet6_ntoa(thd, arg1);
4978 }
4979 
4980 
4981 Create_func_inet_aton Create_func_inet_aton::s_singleton;
4982 
4983 Item*
create_1_arg(THD * thd,Item * arg1)4984 Create_func_inet_aton::create_1_arg(THD *thd, Item *arg1)
4985 {
4986   return new (thd->mem_root) Item_func_inet_aton(thd, arg1);
4987 }
4988 
4989 
4990 Create_func_is_ipv4 Create_func_is_ipv4::s_singleton;
4991 
4992 Item*
create_1_arg(THD * thd,Item * arg1)4993 Create_func_is_ipv4::create_1_arg(THD *thd, Item *arg1)
4994 {
4995   return new (thd->mem_root) Item_func_is_ipv4(thd, arg1);
4996 }
4997 
4998 
4999 Create_func_is_ipv6 Create_func_is_ipv6::s_singleton;
5000 
5001 Item*
create_1_arg(THD * thd,Item * arg1)5002 Create_func_is_ipv6::create_1_arg(THD *thd, Item *arg1)
5003 {
5004   return new (thd->mem_root) Item_func_is_ipv6(thd, arg1);
5005 }
5006 
5007 
5008 Create_func_is_ipv4_compat Create_func_is_ipv4_compat::s_singleton;
5009 
5010 Item*
create_1_arg(THD * thd,Item * arg1)5011 Create_func_is_ipv4_compat::create_1_arg(THD *thd, Item *arg1)
5012 {
5013   return new (thd->mem_root) Item_func_is_ipv4_compat(thd, arg1);
5014 }
5015 
5016 
5017 Create_func_is_ipv4_mapped Create_func_is_ipv4_mapped::s_singleton;
5018 
5019 Item*
create_1_arg(THD * thd,Item * arg1)5020 Create_func_is_ipv4_mapped::create_1_arg(THD *thd, Item *arg1)
5021 {
5022   return new (thd->mem_root) Item_func_is_ipv4_mapped(thd, arg1);
5023 }
5024 
5025 
5026 Create_func_instr Create_func_instr::s_singleton;
5027 
5028 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)5029 Create_func_instr::create_2_arg(THD *thd, Item *arg1, Item *arg2)
5030 {
5031   return new (thd->mem_root) Item_func_locate(thd, arg1, arg2);
5032 }
5033 
5034 
5035 #ifdef HAVE_SPATIAL
5036 Create_func_interiorringn Create_func_interiorringn::s_singleton;
5037 
5038 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)5039 Create_func_interiorringn::create_2_arg(THD *thd, Item *arg1, Item *arg2)
5040 {
5041   return new (thd->mem_root) Item_func_spatial_decomp_n(thd, arg1, arg2,
5042                                                         Item_func::SP_INTERIORRINGN);
5043 }
5044 #endif
5045 
5046 
5047 #ifdef HAVE_SPATIAL
5048 Create_func_relate Create_func_relate::s_singleton;
5049 
5050 Item*
create_3_arg(THD * thd,Item * arg1,Item * arg2,Item * matrix)5051 Create_func_relate::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *matrix)
5052 {
5053   return new (thd->mem_root) Item_func_spatial_relate(thd, arg1, arg2, matrix);
5054 }
5055 
5056 
5057 Create_func_mbr_intersects Create_func_mbr_intersects::s_singleton;
5058 
5059 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)5060 Create_func_mbr_intersects::create_2_arg(THD *thd, Item *arg1, Item *arg2)
5061 {
5062   return new (thd->mem_root) Item_func_spatial_mbr_rel(thd, arg1, arg2,
5063       Item_func::SP_INTERSECTS_FUNC);
5064 }
5065 
5066 
5067 Create_func_intersects Create_func_intersects::s_singleton;
5068 
5069 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)5070 Create_func_intersects::create_2_arg(THD *thd, Item *arg1, Item *arg2)
5071 {
5072   return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2,
5073                                                 Item_func::SP_INTERSECTS_FUNC);
5074 }
5075 
5076 
5077 Create_func_intersection Create_func_intersection::s_singleton;
5078 
5079 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)5080 Create_func_intersection::create_2_arg(THD *thd, Item *arg1, Item *arg2)
5081 {
5082   return new (thd->mem_root) Item_func_spatial_operation(thd, arg1, arg2,
5083                                Gcalc_function::op_intersection);
5084 }
5085 
5086 
5087 Create_func_difference Create_func_difference::s_singleton;
5088 
5089 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)5090 Create_func_difference::create_2_arg(THD *thd, Item *arg1, Item *arg2)
5091 {
5092   return new (thd->mem_root) Item_func_spatial_operation(thd, arg1, arg2,
5093                                Gcalc_function::op_difference);
5094 }
5095 
5096 
5097 Create_func_union Create_func_union::s_singleton;
5098 
5099 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)5100 Create_func_union::create_2_arg(THD *thd, Item *arg1, Item *arg2)
5101 {
5102   return new (thd->mem_root) Item_func_spatial_operation(thd, arg1, arg2,
5103                                Gcalc_function::op_union);
5104 }
5105 
5106 
5107 Create_func_symdifference Create_func_symdifference::s_singleton;
5108 
5109 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)5110 Create_func_symdifference::create_2_arg(THD *thd, Item *arg1, Item *arg2)
5111 {
5112   return new (thd->mem_root) Item_func_spatial_operation(thd, arg1, arg2,
5113                                Gcalc_function::op_symdifference);
5114 }
5115 
5116 
5117 Create_func_buffer Create_func_buffer::s_singleton;
5118 
5119 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)5120 Create_func_buffer::create_2_arg(THD *thd, Item *arg1, Item *arg2)
5121 {
5122   return new (thd->mem_root) Item_func_buffer(thd, arg1, arg2);
5123 }
5124 #endif /*HAVE_SPATAI*/
5125 
5126 
5127 Create_func_is_free_lock Create_func_is_free_lock::s_singleton;
5128 
5129 Item*
create_1_arg(THD * thd,Item * arg1)5130 Create_func_is_free_lock::create_1_arg(THD *thd, Item *arg1)
5131 {
5132   thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
5133   thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
5134   return new (thd->mem_root) Item_func_is_free_lock(thd, arg1);
5135 }
5136 
5137 
5138 Create_func_is_used_lock Create_func_is_used_lock::s_singleton;
5139 
5140 Item*
create_1_arg(THD * thd,Item * arg1)5141 Create_func_is_used_lock::create_1_arg(THD *thd, Item *arg1)
5142 {
5143   thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
5144   thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
5145   return new (thd->mem_root) Item_func_is_used_lock(thd, arg1);
5146 }
5147 
5148 
5149 #ifdef HAVE_SPATIAL
5150 Create_func_isclosed Create_func_isclosed::s_singleton;
5151 
5152 Item*
create_1_arg(THD * thd,Item * arg1)5153 Create_func_isclosed::create_1_arg(THD *thd, Item *arg1)
5154 {
5155   return new (thd->mem_root) Item_func_isclosed(thd, arg1);
5156 }
5157 
5158 
5159 Create_func_isring Create_func_isring::s_singleton;
5160 
5161 Item*
create_1_arg(THD * thd,Item * arg1)5162 Create_func_isring::create_1_arg(THD *thd, Item *arg1)
5163 {
5164   return new (thd->mem_root) Item_func_isring(thd, arg1);
5165 }
5166 
5167 
5168 Create_func_isempty Create_func_isempty::s_singleton;
5169 
5170 Item*
create_1_arg(THD * thd,Item * arg1)5171 Create_func_isempty::create_1_arg(THD *thd, Item *arg1)
5172 {
5173   return new (thd->mem_root) Item_func_isempty(thd, arg1);
5174 }
5175 #endif /*HAVE_SPATIAL*/
5176 
5177 
5178 Create_func_isnull Create_func_isnull::s_singleton;
5179 
5180 Item*
create_1_arg(THD * thd,Item * arg1)5181 Create_func_isnull::create_1_arg(THD *thd, Item *arg1)
5182 {
5183   return new (thd->mem_root) Item_func_isnull(thd, arg1);
5184 }
5185 
5186 
5187 #ifdef HAVE_SPATIAL
5188 Create_func_issimple Create_func_issimple::s_singleton;
5189 
5190 Item*
create_1_arg(THD * thd,Item * arg1)5191 Create_func_issimple::create_1_arg(THD *thd, Item *arg1)
5192 {
5193   return new (thd->mem_root) Item_func_issimple(thd, arg1);
5194 }
5195 #endif
5196 
5197 
5198 Create_func_json_exists Create_func_json_exists::s_singleton;
5199 
5200 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)5201 Create_func_json_exists::create_2_arg(THD *thd, Item *arg1, Item *arg2)
5202 {
5203   status_var_increment(current_thd->status_var.feature_json);
5204   return new (thd->mem_root) Item_func_json_exists(thd, arg1, arg2);
5205 }
5206 
5207 
5208 Create_func_json_detailed Create_func_json_detailed::s_singleton;
5209 
5210 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5211 Create_func_json_detailed::create_native(THD *thd, LEX_CSTRING *name,
5212                                      List<Item> *item_list)
5213 {
5214   Item *func= NULL;
5215   int arg_count= 0;
5216 
5217   if (item_list != NULL)
5218     arg_count= item_list->elements;
5219 
5220   if (unlikely(arg_count < 1 || arg_count > 2 /* json_doc, [path]...*/))
5221   {
5222     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5223   }
5224   else
5225   {
5226     func= new (thd->mem_root) Item_func_json_format(thd, *item_list);
5227   }
5228 
5229   status_var_increment(current_thd->status_var.feature_json);
5230   return func;
5231 }
5232 
5233 
5234 Create_func_json_loose Create_func_json_loose::s_singleton;
5235 
5236 Item*
create_1_arg(THD * thd,Item * arg1)5237 Create_func_json_loose::create_1_arg(THD *thd, Item *arg1)
5238 {
5239   status_var_increment(current_thd->status_var.feature_json);
5240   return new (thd->mem_root) Item_func_json_format(thd, arg1,
5241                Item_func_json_format::LOOSE);
5242 }
5243 
5244 
5245 Create_func_json_compact Create_func_json_compact::s_singleton;
5246 
5247 Item*
create_1_arg(THD * thd,Item * arg1)5248 Create_func_json_compact::create_1_arg(THD *thd, Item *arg1)
5249 {
5250   status_var_increment(current_thd->status_var.feature_json);
5251   return new (thd->mem_root) Item_func_json_format(thd, arg1,
5252                Item_func_json_format::COMPACT);
5253 }
5254 
5255 
5256 Create_func_json_valid Create_func_json_valid::s_singleton;
5257 
5258 Item*
create_1_arg(THD * thd,Item * arg1)5259 Create_func_json_valid::create_1_arg(THD *thd, Item *arg1)
5260 {
5261   status_var_increment(current_thd->status_var.feature_json);
5262   return new (thd->mem_root) Item_func_json_valid(thd, arg1);
5263 }
5264 
5265 
5266 Create_func_json_type Create_func_json_type::s_singleton;
5267 
5268 Item*
create_1_arg(THD * thd,Item * arg1)5269 Create_func_json_type::create_1_arg(THD *thd, Item *arg1)
5270 {
5271   status_var_increment(current_thd->status_var.feature_json);
5272   return new (thd->mem_root) Item_func_json_type(thd, arg1);
5273 }
5274 
5275 
5276 Create_func_json_depth Create_func_json_depth::s_singleton;
5277 
5278 Item*
create_1_arg(THD * thd,Item * arg1)5279 Create_func_json_depth::create_1_arg(THD *thd, Item *arg1)
5280 {
5281   status_var_increment(current_thd->status_var.feature_json);
5282   return new (thd->mem_root) Item_func_json_depth(thd, arg1);
5283 }
5284 
5285 
5286 Create_func_json_value Create_func_json_value::s_singleton;
5287 
5288 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)5289 Create_func_json_value::create_2_arg(THD *thd, Item *arg1, Item *arg2)
5290 {
5291   status_var_increment(current_thd->status_var.feature_json);
5292   return new (thd->mem_root) Item_func_json_value(thd, arg1, arg2);
5293 }
5294 
5295 
5296 Create_func_json_query Create_func_json_query::s_singleton;
5297 
5298 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)5299 Create_func_json_query::create_2_arg(THD *thd, Item *arg1, Item *arg2)
5300 {
5301   status_var_increment(current_thd->status_var.feature_json);
5302   return new (thd->mem_root) Item_func_json_query(thd, arg1, arg2);
5303 }
5304 
5305 
5306 Create_func_json_quote Create_func_json_quote::s_singleton;
5307 
5308 Item*
create_1_arg(THD * thd,Item * arg1)5309 Create_func_json_quote::create_1_arg(THD *thd, Item *arg1)
5310 {
5311   status_var_increment(current_thd->status_var.feature_json);
5312   return new (thd->mem_root) Item_func_json_quote(thd, arg1);
5313 }
5314 
5315 
5316 Create_func_json_unquote Create_func_json_unquote::s_singleton;
5317 
5318 Item*
create_1_arg(THD * thd,Item * arg1)5319 Create_func_json_unquote::create_1_arg(THD *thd, Item *arg1)
5320 {
5321   status_var_increment(current_thd->status_var.feature_json);
5322   return new (thd->mem_root) Item_func_json_unquote(thd, arg1);
5323 }
5324 
5325 
5326 Create_func_last_day Create_func_last_day::s_singleton;
5327 
5328 Item*
create_1_arg(THD * thd,Item * arg1)5329 Create_func_last_day::create_1_arg(THD *thd, Item *arg1)
5330 {
5331   return new (thd->mem_root) Item_func_last_day(thd, arg1);
5332 }
5333 
5334 
5335 Create_func_json_array Create_func_json_array::s_singleton;
5336 
5337 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5338 Create_func_json_array::create_native(THD *thd, LEX_CSTRING *name,
5339                                       List<Item> *item_list)
5340 {
5341   Item *func;
5342 
5343   if (item_list != NULL)
5344   {
5345     func= new (thd->mem_root) Item_func_json_array(thd, *item_list);
5346   }
5347   else
5348   {
5349     func= new (thd->mem_root) Item_func_json_array(thd);
5350   }
5351 
5352   status_var_increment(current_thd->status_var.feature_json);
5353   return func;
5354 }
5355 
5356 
5357 Create_func_json_array_append Create_func_json_array_append::s_singleton;
5358 
5359 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5360 Create_func_json_array_append::create_native(THD *thd, LEX_CSTRING *name,
5361                                                  List<Item> *item_list)
5362 {
5363   Item *func= NULL;
5364   int arg_count= 0;
5365 
5366   if (item_list != NULL)
5367     arg_count= item_list->elements;
5368 
5369   if (unlikely(arg_count < 3 || (arg_count & 1) == 0 /*is even*/))
5370   {
5371     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5372   }
5373   else
5374   {
5375     func= new (thd->mem_root) Item_func_json_array_append(thd, *item_list);
5376   }
5377 
5378   status_var_increment(current_thd->status_var.feature_json);
5379   return func;
5380 }
5381 
5382 
5383 Create_func_json_array_insert Create_func_json_array_insert::s_singleton;
5384 
5385 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5386 Create_func_json_array_insert::create_native(THD *thd, LEX_CSTRING *name,
5387                                                  List<Item> *item_list)
5388 {
5389   Item *func= NULL;
5390   int arg_count= 0;
5391 
5392   if (item_list != NULL)
5393     arg_count= item_list->elements;
5394 
5395   if (unlikely(arg_count < 3 || (arg_count & 1) == 0 /*is even*/))
5396   {
5397     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5398   }
5399   else
5400   {
5401     func= new (thd->mem_root) Item_func_json_array_insert(thd, *item_list);
5402   }
5403 
5404   status_var_increment(current_thd->status_var.feature_json);
5405   return func;
5406 }
5407 
5408 
5409 Create_func_json_insert Create_func_json_insert::s_singleton;
5410 
5411 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5412 Create_func_json_insert::create_native(THD *thd, LEX_CSTRING *name,
5413                                                  List<Item> *item_list)
5414 {
5415   Item *func= NULL;
5416   int arg_count= 0;
5417 
5418   if (item_list != NULL)
5419     arg_count= item_list->elements;
5420 
5421   if (unlikely(arg_count < 3 || (arg_count & 1) == 0 /*is even*/))
5422   {
5423     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5424   }
5425   else
5426   {
5427     func= new (thd->mem_root) Item_func_json_insert(true, false,
5428                                                     thd, *item_list);
5429   }
5430 
5431   status_var_increment(current_thd->status_var.feature_json);
5432   return func;
5433 }
5434 
5435 
5436 Create_func_json_set Create_func_json_set::s_singleton;
5437 
5438 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5439 Create_func_json_set::create_native(THD *thd, LEX_CSTRING *name,
5440                                     List<Item> *item_list)
5441 {
5442   Item *func= NULL;
5443   int arg_count= 0;
5444 
5445   if (item_list != NULL)
5446     arg_count= item_list->elements;
5447 
5448   if (unlikely(arg_count < 3 || (arg_count & 1) == 0 /*is even*/))
5449   {
5450     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5451   }
5452   else
5453   {
5454     func= new (thd->mem_root) Item_func_json_insert(true, true,
5455                                                     thd, *item_list);
5456   }
5457 
5458   status_var_increment(current_thd->status_var.feature_json);
5459   return func;
5460 }
5461 
5462 
5463 Create_func_json_replace Create_func_json_replace::s_singleton;
5464 
5465 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5466 Create_func_json_replace::create_native(THD *thd, LEX_CSTRING *name,
5467                                         List<Item> *item_list)
5468 {
5469   Item *func= NULL;
5470   int arg_count= 0;
5471 
5472   if (item_list != NULL)
5473     arg_count= item_list->elements;
5474 
5475   if (unlikely(arg_count < 3 || (arg_count & 1) == 0 /*is even*/))
5476   {
5477     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5478   }
5479   else
5480   {
5481     func= new (thd->mem_root) Item_func_json_insert(false, true,
5482                                                     thd, *item_list);
5483   }
5484 
5485   status_var_increment(current_thd->status_var.feature_json);
5486   return func;
5487 }
5488 
5489 
5490 Create_func_json_remove Create_func_json_remove::s_singleton;
5491 
5492 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5493 Create_func_json_remove::create_native(THD *thd, LEX_CSTRING *name,
5494                                        List<Item> *item_list)
5495 {
5496   Item *func= NULL;
5497   int arg_count= 0;
5498 
5499   if (item_list != NULL)
5500     arg_count= item_list->elements;
5501 
5502   if (unlikely(arg_count < 2 /*json_doc, path [,path]*/))
5503   {
5504     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5505   }
5506   else
5507   {
5508     func= new (thd->mem_root) Item_func_json_remove(thd, *item_list);
5509   }
5510 
5511   status_var_increment(current_thd->status_var.feature_json);
5512   return func;
5513 }
5514 
5515 
5516 Create_func_json_object Create_func_json_object::s_singleton;
5517 
5518 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5519 Create_func_json_object::create_native(THD *thd, LEX_CSTRING *name,
5520                                        List<Item> *item_list)
5521 {
5522   Item *func;
5523   int arg_count;
5524 
5525   if (item_list != NULL)
5526   {
5527     arg_count= item_list->elements;
5528     if (unlikely((arg_count & 1) != 0 /*is odd*/))
5529     {
5530       my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5531       func= NULL;
5532     }
5533     else
5534     {
5535       func= new (thd->mem_root) Item_func_json_object(thd, *item_list);
5536     }
5537   }
5538   else
5539   {
5540     arg_count= 0;
5541     func= new (thd->mem_root) Item_func_json_object(thd);
5542   }
5543 
5544   status_var_increment(current_thd->status_var.feature_json);
5545   return func;
5546 }
5547 
5548 
5549 Create_func_json_length Create_func_json_length::s_singleton;
5550 
5551 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5552 Create_func_json_length::create_native(THD *thd, LEX_CSTRING *name,
5553                                        List<Item> *item_list)
5554 {
5555   Item *func;
5556   int arg_count;
5557 
5558   if (unlikely(item_list == NULL ||
5559                (arg_count= item_list->elements) == 0))
5560   {
5561     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5562     func= NULL;
5563   }
5564   else
5565   {
5566     func= new (thd->mem_root) Item_func_json_length(thd, *item_list);
5567   }
5568 
5569   status_var_increment(current_thd->status_var.feature_json);
5570   return func;
5571 }
5572 
5573 
5574 Create_func_json_merge Create_func_json_merge::s_singleton;
5575 
5576 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5577 Create_func_json_merge::create_native(THD *thd, LEX_CSTRING *name,
5578                                       List<Item> *item_list)
5579 {
5580   Item *func;
5581   int arg_count;
5582 
5583   if (unlikely(item_list == NULL ||
5584                (arg_count= item_list->elements) < 2)) // json, json
5585   {
5586     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5587     func= NULL;
5588   }
5589   else
5590   {
5591     func= new (thd->mem_root) Item_func_json_merge(thd, *item_list);
5592   }
5593 
5594   status_var_increment(current_thd->status_var.feature_json);
5595   return func;
5596 }
5597 
5598 
5599 Create_func_json_merge_patch Create_func_json_merge_patch::s_singleton;
5600 
5601 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5602 Create_func_json_merge_patch::create_native(THD *thd, LEX_CSTRING *name,
5603                                            List<Item> *item_list)
5604 {
5605   Item *func;
5606   int arg_count;
5607 
5608   if (item_list == NULL ||
5609       (arg_count= item_list->elements) < 2) // json, json
5610   {
5611     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5612     func= NULL;
5613   }
5614   else
5615   {
5616     func= new (thd->mem_root) Item_func_json_merge_patch(thd, *item_list);
5617   }
5618 
5619   return func;
5620 }
5621 
5622 
5623 Create_func_json_contains Create_func_json_contains::s_singleton;
5624 
5625 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5626 Create_func_json_contains::create_native(THD *thd, LEX_CSTRING *name,
5627                                          List<Item> *item_list)
5628 {
5629   Item *func= NULL;
5630   int arg_count= 0;
5631 
5632   if (item_list != NULL)
5633     arg_count= item_list->elements;
5634 
5635   if (unlikely(arg_count == 2 || arg_count == 3/* json_doc, val, [path] */))
5636   {
5637     func= new (thd->mem_root) Item_func_json_contains(thd, *item_list);
5638   }
5639   else
5640   {
5641     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5642   }
5643 
5644   status_var_increment(current_thd->status_var.feature_json);
5645   return func;
5646 }
5647 
5648 
5649 Create_func_json_keys Create_func_json_keys::s_singleton;
5650 
5651 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5652 Create_func_json_keys::create_native(THD *thd, LEX_CSTRING *name,
5653                                      List<Item> *item_list)
5654 {
5655   Item *func= NULL;
5656   int arg_count= 0;
5657 
5658   if (item_list != NULL)
5659     arg_count= item_list->elements;
5660 
5661   if (unlikely(arg_count < 1 || arg_count > 2 /* json_doc, [path]...*/))
5662   {
5663     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5664   }
5665   else
5666   {
5667     func= new (thd->mem_root) Item_func_json_keys(thd, *item_list);
5668   }
5669 
5670   status_var_increment(current_thd->status_var.feature_json);
5671   return func;
5672 }
5673 
5674 
5675 Create_func_json_contains_path Create_func_json_contains_path::s_singleton;
5676 
5677 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5678 Create_func_json_contains_path::create_native(THD *thd, LEX_CSTRING *name,
5679                                                  List<Item> *item_list)
5680 {
5681   Item *func= NULL;
5682   int arg_count= 0;
5683 
5684   if (item_list != NULL)
5685     arg_count= item_list->elements;
5686 
5687   if (unlikely(arg_count < 3 /* json_doc, one_or_all, path, [path]...*/))
5688   {
5689     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5690   }
5691   else
5692   {
5693     func= new (thd->mem_root) Item_func_json_contains_path(thd, *item_list);
5694   }
5695 
5696   status_var_increment(current_thd->status_var.feature_json);
5697   return func;
5698 }
5699 
5700 
5701 Create_func_json_extract Create_func_json_extract::s_singleton;
5702 
5703 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5704 Create_func_json_extract::create_native(THD *thd, LEX_CSTRING *name,
5705                                                  List<Item> *item_list)
5706 {
5707   Item *func= NULL;
5708   int arg_count= 0;
5709 
5710   if (item_list != NULL)
5711     arg_count= item_list->elements;
5712 
5713   if (unlikely(arg_count < 2 /* json_doc, path, [path]...*/))
5714   {
5715     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5716   }
5717   else
5718   {
5719     func= new (thd->mem_root) Item_func_json_extract(thd, *item_list);
5720   }
5721 
5722   status_var_increment(current_thd->status_var.feature_json);
5723   return func;
5724 }
5725 
5726 
5727 Create_func_json_search Create_func_json_search::s_singleton;
5728 
5729 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5730 Create_func_json_search::create_native(THD *thd, LEX_CSTRING *name,
5731                                        List<Item> *item_list)
5732 {
5733   Item *func= NULL;
5734   int arg_count= 0;
5735 
5736   if (item_list != NULL)
5737     arg_count= item_list->elements;
5738 
5739   if (unlikely(arg_count < 3 /* json_doc, one_or_all, search_str, [escape_char[, path]...*/))
5740   {
5741     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5742   }
5743   else
5744   {
5745     func= new (thd->mem_root) Item_func_json_search(thd, *item_list);
5746   }
5747 
5748   status_var_increment(current_thd->status_var.feature_json);
5749   return func;
5750 }
5751 
5752 
5753 Create_func_last_insert_id Create_func_last_insert_id::s_singleton;
5754 
5755 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5756 Create_func_last_insert_id::create_native(THD *thd, LEX_CSTRING *name,
5757                                           List<Item> *item_list)
5758 {
5759   Item *func= NULL;
5760   int arg_count= 0;
5761 
5762   if (item_list != NULL)
5763     arg_count= item_list->elements;
5764 
5765   switch (arg_count) {
5766   case 0:
5767   {
5768     func= new (thd->mem_root) Item_func_last_insert_id(thd);
5769     thd->lex->safe_to_cache_query= 0;
5770     break;
5771   }
5772   case 1:
5773   {
5774     Item *param_1= item_list->pop();
5775     func= new (thd->mem_root) Item_func_last_insert_id(thd, param_1);
5776     thd->lex->safe_to_cache_query= 0;
5777     break;
5778   }
5779   default:
5780   {
5781     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5782     break;
5783   }
5784   }
5785 
5786   return func;
5787 }
5788 
5789 
5790 Create_func_lcase Create_func_lcase::s_singleton;
5791 
5792 Item*
create_1_arg(THD * thd,Item * arg1)5793 Create_func_lcase::create_1_arg(THD *thd, Item *arg1)
5794 {
5795   return new (thd->mem_root) Item_func_lcase(thd, arg1);
5796 }
5797 
5798 
5799 Create_func_least Create_func_least::s_singleton;
5800 
5801 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5802 Create_func_least::create_native(THD *thd, LEX_CSTRING *name,
5803                                  List<Item> *item_list)
5804 {
5805   int arg_count= 0;
5806 
5807   if (item_list != NULL)
5808     arg_count= item_list->elements;
5809 
5810   if (unlikely(arg_count < 2))
5811   {
5812     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5813     return NULL;
5814   }
5815 
5816   return new (thd->mem_root) Item_func_min(thd, *item_list);
5817 }
5818 
5819 
5820 Create_func_length Create_func_length::s_singleton;
5821 
5822 Item*
create_1_arg(THD * thd,Item * arg1)5823 Create_func_length::create_1_arg(THD *thd, Item *arg1)
5824 {
5825   if (thd->variables.sql_mode & MODE_ORACLE)
5826     return new (thd->mem_root) Item_func_char_length(thd, arg1);
5827   else
5828     return new (thd->mem_root) Item_func_octet_length(thd, arg1);
5829 }
5830 
5831 Create_func_octet_length Create_func_octet_length::s_singleton;
5832 
5833 Item*
create_1_arg(THD * thd,Item * arg1)5834 Create_func_octet_length::create_1_arg(THD *thd, Item *arg1)
5835 {
5836   return new (thd->mem_root) Item_func_octet_length(thd, arg1);
5837 }
5838 
5839 
5840 #ifndef DBUG_OFF
5841 Create_func_like_range_min Create_func_like_range_min::s_singleton;
5842 
5843 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)5844 Create_func_like_range_min::create_2_arg(THD *thd, Item *arg1, Item *arg2)
5845 {
5846   return new (thd->mem_root) Item_func_like_range_min(thd, arg1, arg2);
5847 }
5848 
5849 
5850 Create_func_like_range_max Create_func_like_range_max::s_singleton;
5851 
5852 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)5853 Create_func_like_range_max::create_2_arg(THD *thd, Item *arg1, Item *arg2)
5854 {
5855   return new (thd->mem_root) Item_func_like_range_max(thd, arg1, arg2);
5856 }
5857 #endif
5858 
5859 
5860 Create_func_ln Create_func_ln::s_singleton;
5861 
5862 Item*
create_1_arg(THD * thd,Item * arg1)5863 Create_func_ln::create_1_arg(THD *thd, Item *arg1)
5864 {
5865   return new (thd->mem_root) Item_func_ln(thd, arg1);
5866 }
5867 
5868 
5869 Create_func_load_file Create_func_load_file::s_singleton;
5870 
5871 Item*
create_1_arg(THD * thd,Item * arg1)5872 Create_func_load_file::create_1_arg(THD *thd, Item *arg1)
5873 {
5874   DBUG_ENTER("Create_func_load_file::create");
5875   thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
5876   thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
5877   DBUG_RETURN(new (thd->mem_root) Item_load_file(thd, arg1));
5878 }
5879 
5880 
5881 Create_func_locate Create_func_locate::s_singleton;
5882 
5883 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5884 Create_func_locate::create_native(THD *thd, LEX_CSTRING *name,
5885                                   List<Item> *item_list)
5886 {
5887   Item *func= NULL;
5888   int arg_count= 0;
5889 
5890   if (item_list != NULL)
5891     arg_count= item_list->elements;
5892 
5893   switch (arg_count) {
5894   case 2:
5895   {
5896     Item *param_1= item_list->pop();
5897     Item *param_2= item_list->pop();
5898     /* Yes, parameters in that order : 2, 1 */
5899     func= new (thd->mem_root) Item_func_locate(thd, param_2, param_1);
5900     break;
5901   }
5902   case 3:
5903   {
5904     Item *param_1= item_list->pop();
5905     Item *param_2= item_list->pop();
5906     Item *param_3= item_list->pop();
5907     /* Yes, parameters in that order : 2, 1, 3 */
5908     func= new (thd->mem_root) Item_func_locate(thd, param_2, param_1, param_3);
5909     break;
5910   }
5911   default:
5912   {
5913     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5914     break;
5915   }
5916   }
5917 
5918   return func;
5919 }
5920 
5921 
5922 Create_func_log Create_func_log::s_singleton;
5923 
5924 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5925 Create_func_log::create_native(THD *thd, LEX_CSTRING *name,
5926                                List<Item> *item_list)
5927 {
5928   Item *func= NULL;
5929   int arg_count= 0;
5930 
5931   if (item_list != NULL)
5932     arg_count= item_list->elements;
5933 
5934   switch (arg_count) {
5935   case 1:
5936   {
5937     Item *param_1= item_list->pop();
5938     func= new (thd->mem_root) Item_func_log(thd, param_1);
5939     break;
5940   }
5941   case 2:
5942   {
5943     Item *param_1= item_list->pop();
5944     Item *param_2= item_list->pop();
5945     func= new (thd->mem_root) Item_func_log(thd, param_1, param_2);
5946     break;
5947   }
5948   default:
5949   {
5950     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
5951     break;
5952   }
5953   }
5954 
5955   return func;
5956 }
5957 
5958 
5959 Create_func_log10 Create_func_log10::s_singleton;
5960 
5961 Item*
create_1_arg(THD * thd,Item * arg1)5962 Create_func_log10::create_1_arg(THD *thd, Item *arg1)
5963 {
5964   return new (thd->mem_root) Item_func_log10(thd, arg1);
5965 }
5966 
5967 
5968 Create_func_log2 Create_func_log2::s_singleton;
5969 
5970 Item*
create_1_arg(THD * thd,Item * arg1)5971 Create_func_log2::create_1_arg(THD *thd, Item *arg1)
5972 {
5973   return new (thd->mem_root) Item_func_log2(thd, arg1);
5974 }
5975 
5976 
5977 Create_func_lpad Create_func_lpad::s_singleton;
5978 
5979 Create_func_lpad_oracle Create_func_lpad_oracle::s_singleton;
5980 
5981 Item*
create_native_std(THD * thd,LEX_CSTRING * name,List<Item> * item_list)5982 Create_func_lpad::create_native_std(THD *thd, LEX_CSTRING *name,
5983                                     List<Item> *item_list)
5984 {
5985   Item *func= NULL;
5986   int arg_count= item_list ? item_list->elements : 0;
5987 
5988   switch (arg_count) {
5989   case 2:
5990   {
5991     Item *param_1= item_list->pop();
5992     Item *param_2= item_list->pop();
5993     func= new (thd->mem_root) Item_func_lpad(thd, param_1, param_2);
5994     break;
5995   }
5996   case 3:
5997   {
5998     Item *param_1= item_list->pop();
5999     Item *param_2= item_list->pop();
6000     Item *param_3= item_list->pop();
6001     func= new (thd->mem_root) Item_func_lpad(thd, param_1, param_2, param_3);
6002     break;
6003   }
6004   default:
6005     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
6006     break;
6007   }
6008 
6009   return func;
6010 }
6011 
6012 
6013 Item*
create_native_oracle(THD * thd,LEX_CSTRING * name,List<Item> * item_list)6014 Create_func_lpad::create_native_oracle(THD *thd, LEX_CSTRING *name,
6015                                        List<Item> *item_list)
6016 {
6017   int arg_count= item_list ? item_list->elements : 0;
6018   switch (arg_count) {
6019   case 2:
6020   {
6021     Item *param_1= item_list->pop();
6022     Item *param_2= item_list->pop();
6023     return new (thd->mem_root) Item_func_lpad_oracle(thd, param_1, param_2);
6024   }
6025   case 3:
6026   {
6027     Item *param_1= item_list->pop();
6028     Item *param_2= item_list->pop();
6029     Item *param_3= item_list->pop();
6030     return new (thd->mem_root) Item_func_lpad_oracle(thd, param_1,
6031                                                      param_2, param_3);
6032   }
6033   default:
6034     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
6035     break;
6036   }
6037   return NULL;
6038 }
6039 
6040 
6041 Create_func_ltrim Create_func_ltrim::s_singleton;
6042 
6043 Item*
create_1_arg(THD * thd,Item * arg1)6044 Create_func_ltrim::create_1_arg(THD *thd, Item *arg1)
6045 {
6046   return Lex_trim(TRIM_LEADING, arg1).make_item_func_trim(thd);
6047 }
6048 
6049 
6050 Create_func_ltrim_oracle Create_func_ltrim_oracle::s_singleton;
6051 
6052 Item*
create_1_arg(THD * thd,Item * arg1)6053 Create_func_ltrim_oracle::create_1_arg(THD *thd, Item *arg1)
6054 {
6055   return new (thd->mem_root) Item_func_ltrim_oracle(thd, arg1);
6056 }
6057 
6058 
6059 Create_func_makedate Create_func_makedate::s_singleton;
6060 
6061 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6062 Create_func_makedate::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6063 {
6064   return new (thd->mem_root) Item_func_makedate(thd, arg1, arg2);
6065 }
6066 
6067 
6068 Create_func_maketime Create_func_maketime::s_singleton;
6069 
6070 Item*
create_3_arg(THD * thd,Item * arg1,Item * arg2,Item * arg3)6071 Create_func_maketime::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3)
6072 {
6073   return new (thd->mem_root) Item_func_maketime(thd, arg1, arg2, arg3);
6074 }
6075 
6076 
6077 Create_func_make_set Create_func_make_set::s_singleton;
6078 
6079 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)6080 Create_func_make_set::create_native(THD *thd, LEX_CSTRING *name,
6081                                     List<Item> *item_list)
6082 {
6083   int arg_count= 0;
6084 
6085   if (item_list != NULL)
6086     arg_count= item_list->elements;
6087 
6088   if (unlikely(arg_count < 2))
6089   {
6090     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
6091     return NULL;
6092   }
6093 
6094   return new (thd->mem_root) Item_func_make_set(thd, *item_list);
6095 }
6096 
6097 
6098 Create_func_master_pos_wait Create_func_master_pos_wait::s_singleton;
6099 
6100 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)6101 Create_func_master_pos_wait::create_native(THD *thd, LEX_CSTRING *name,
6102                                            List<Item> *item_list)
6103 
6104 {
6105   Item *func= NULL;
6106   int arg_count= 0;
6107 
6108   thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
6109 
6110   if (item_list != NULL)
6111     arg_count= item_list->elements;
6112 
6113   if (unlikely(arg_count < 2 || arg_count > 4))
6114   {
6115     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
6116     return func;
6117   }
6118 
6119   thd->lex->safe_to_cache_query= 0;
6120 
6121   Item *param_1= item_list->pop();
6122   Item *param_2= item_list->pop();
6123   switch (arg_count) {
6124   case 2:
6125   {
6126     func= new (thd->mem_root) Item_master_pos_wait(thd, param_1, param_2);
6127     break;
6128   }
6129   case 3:
6130   {
6131     Item *param_3= item_list->pop();
6132     func= new (thd->mem_root) Item_master_pos_wait(thd, param_1, param_2, param_3);
6133     break;
6134   }
6135   case 4:
6136   {
6137     Item *param_3= item_list->pop();
6138     Item *param_4= item_list->pop();
6139     func= new (thd->mem_root) Item_master_pos_wait(thd, param_1, param_2, param_3,
6140                                                    param_4);
6141     break;
6142   }
6143   }
6144 
6145   return func;
6146 }
6147 
6148 
6149 Create_func_master_gtid_wait Create_func_master_gtid_wait::s_singleton;
6150 
6151 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)6152 Create_func_master_gtid_wait::create_native(THD *thd, LEX_CSTRING *name,
6153                                             List<Item> *item_list)
6154 {
6155   Item *func= NULL;
6156   int arg_count= 0;
6157 
6158   thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
6159 
6160   if (item_list != NULL)
6161     arg_count= item_list->elements;
6162 
6163   if (unlikely(arg_count < 1 || arg_count > 2))
6164   {
6165     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
6166     return func;
6167   }
6168 
6169   thd->lex->safe_to_cache_query= 0;
6170 
6171   Item *param_1= item_list->pop();
6172   switch (arg_count) {
6173   case 1:
6174   {
6175     func= new (thd->mem_root) Item_master_gtid_wait(thd, param_1);
6176     break;
6177   }
6178   case 2:
6179   {
6180     Item *param_2= item_list->pop();
6181     func= new (thd->mem_root) Item_master_gtid_wait(thd, param_1, param_2);
6182     break;
6183   }
6184   }
6185 
6186   return func;
6187 }
6188 
6189 
6190 Create_func_md5 Create_func_md5::s_singleton;
6191 
6192 Item*
create_1_arg(THD * thd,Item * arg1)6193 Create_func_md5::create_1_arg(THD *thd, Item *arg1)
6194 {
6195   return new (thd->mem_root) Item_func_md5(thd, arg1);
6196 }
6197 
6198 
6199 Create_func_monthname Create_func_monthname::s_singleton;
6200 
6201 Item*
create_1_arg(THD * thd,Item * arg1)6202 Create_func_monthname::create_1_arg(THD *thd, Item *arg1)
6203 {
6204   return new (thd->mem_root) Item_func_monthname(thd, arg1);
6205 }
6206 
6207 
6208 Create_func_name_const Create_func_name_const::s_singleton;
6209 
6210 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6211 Create_func_name_const::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6212 {
6213   if (!arg1->basic_const_item())
6214     goto err;
6215 
6216   if (arg2->basic_const_item())
6217     return new (thd->mem_root) Item_name_const(thd, arg1, arg2);
6218 
6219   if (arg2->type() == Item::FUNC_ITEM)
6220   {
6221     Item_func *value_func= (Item_func *) arg2;
6222     if (value_func->functype() != Item_func::COLLATE_FUNC &&
6223         value_func->functype() != Item_func::NEG_FUNC)
6224       goto err;
6225 
6226     if (!value_func->key_item()->basic_const_item())
6227       goto err;
6228     return new (thd->mem_root) Item_name_const(thd, arg1, arg2);
6229   }
6230 err:
6231   my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
6232   return NULL;
6233 }
6234 
6235 
6236 Create_func_nullif Create_func_nullif::s_singleton;
6237 
6238 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6239 Create_func_nullif::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6240 {
6241   return new (thd->mem_root) Item_func_nullif(thd, arg1, arg2);
6242 }
6243 
6244 
6245 #ifdef HAVE_SPATIAL
6246 Create_func_numgeometries Create_func_numgeometries::s_singleton;
6247 
6248 Item*
create_1_arg(THD * thd,Item * arg1)6249 Create_func_numgeometries::create_1_arg(THD *thd, Item *arg1)
6250 {
6251   return new (thd->mem_root) Item_func_numgeometries(thd, arg1);
6252 }
6253 #endif
6254 
6255 
6256 #ifdef HAVE_SPATIAL
6257 Create_func_numinteriorring Create_func_numinteriorring::s_singleton;
6258 
6259 Item*
create_1_arg(THD * thd,Item * arg1)6260 Create_func_numinteriorring::create_1_arg(THD *thd, Item *arg1)
6261 {
6262   return new (thd->mem_root) Item_func_numinteriorring(thd, arg1);
6263 }
6264 #endif
6265 
6266 
6267 #ifdef HAVE_SPATIAL
6268 Create_func_numpoints Create_func_numpoints::s_singleton;
6269 
6270 Item*
create_1_arg(THD * thd,Item * arg1)6271 Create_func_numpoints::create_1_arg(THD *thd, Item *arg1)
6272 {
6273   return new (thd->mem_root) Item_func_numpoints(thd, arg1);
6274 }
6275 #endif
6276 
6277 
6278 Create_func_oct Create_func_oct::s_singleton;
6279 
6280 Item*
create_1_arg(THD * thd,Item * arg1)6281 Create_func_oct::create_1_arg(THD *thd, Item *arg1)
6282 {
6283   Item *i10= new (thd->mem_root) Item_int(thd, (int32) 10,2);
6284   Item *i8= new (thd->mem_root) Item_int(thd, (int32) 8,1);
6285   return new (thd->mem_root) Item_func_conv(thd, arg1, i10, i8);
6286 }
6287 
6288 
6289 Create_func_ord Create_func_ord::s_singleton;
6290 
6291 Item*
create_1_arg(THD * thd,Item * arg1)6292 Create_func_ord::create_1_arg(THD *thd, Item *arg1)
6293 {
6294   return new (thd->mem_root) Item_func_ord(thd, arg1);
6295 }
6296 
6297 
6298 #ifdef HAVE_SPATIAL
6299 Create_func_mbr_overlaps Create_func_mbr_overlaps::s_singleton;
6300 
6301 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6302 Create_func_mbr_overlaps::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6303 {
6304   return new (thd->mem_root) Item_func_spatial_mbr_rel(thd, arg1, arg2,
6305       Item_func::SP_OVERLAPS_FUNC);
6306 }
6307 
6308 
6309 Create_func_overlaps Create_func_overlaps::s_singleton;
6310 
6311 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6312 Create_func_overlaps::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6313 {
6314   return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2,
6315                                                   Item_func::SP_OVERLAPS_FUNC);
6316 }
6317 #endif
6318 
6319 
6320 Create_func_period_add Create_func_period_add::s_singleton;
6321 
6322 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6323 Create_func_period_add::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6324 {
6325   return new (thd->mem_root) Item_func_period_add(thd, arg1, arg2);
6326 }
6327 
6328 
6329 Create_func_period_diff Create_func_period_diff::s_singleton;
6330 
6331 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6332 Create_func_period_diff::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6333 {
6334   return new (thd->mem_root) Item_func_period_diff(thd, arg1, arg2);
6335 }
6336 
6337 
6338 Create_func_pi Create_func_pi::s_singleton;
6339 
6340 Item*
create_builder(THD * thd)6341 Create_func_pi::create_builder(THD *thd)
6342 {
6343   return new (thd->mem_root) Item_static_float_func(thd, "pi()", M_PI, 6, 8);
6344 }
6345 
6346 
6347 #ifdef HAVE_SPATIAL
6348 Create_func_pointn Create_func_pointn::s_singleton;
6349 
6350 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6351 Create_func_pointn::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6352 {
6353   return new (thd->mem_root) Item_func_spatial_decomp_n(thd, arg1, arg2,
6354                                                         Item_func::SP_POINTN);
6355 }
6356 #endif
6357 
6358 
6359 Create_func_pow Create_func_pow::s_singleton;
6360 
6361 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6362 Create_func_pow::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6363 {
6364   return new (thd->mem_root) Item_func_pow(thd, arg1, arg2);
6365 }
6366 
6367 
6368 Create_func_quote Create_func_quote::s_singleton;
6369 
6370 Item*
create_1_arg(THD * thd,Item * arg1)6371 Create_func_quote::create_1_arg(THD *thd, Item *arg1)
6372 {
6373   return new (thd->mem_root) Item_func_quote(thd, arg1);
6374 }
6375 
6376 
6377 Create_func_regexp_instr Create_func_regexp_instr::s_singleton;
6378 
6379 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6380 Create_func_regexp_instr::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6381 {
6382   return new (thd->mem_root) Item_func_regexp_instr(thd, arg1, arg2);
6383 }
6384 
6385 
6386 Create_func_regexp_replace Create_func_regexp_replace::s_singleton;
6387 
6388 Item*
create_3_arg(THD * thd,Item * arg1,Item * arg2,Item * arg3)6389 Create_func_regexp_replace::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3)
6390 {
6391   return new (thd->mem_root) Item_func_regexp_replace(thd, arg1, arg2, arg3);
6392 }
6393 
6394 
6395 Create_func_regexp_substr Create_func_regexp_substr::s_singleton;
6396 
6397 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6398 Create_func_regexp_substr::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6399 {
6400   return new (thd->mem_root) Item_func_regexp_substr(thd, arg1, arg2);
6401 }
6402 
6403 
6404 Create_func_radians Create_func_radians::s_singleton;
6405 
6406 Item*
create_1_arg(THD * thd,Item * arg1)6407 Create_func_radians::create_1_arg(THD *thd, Item *arg1)
6408 {
6409   return new (thd->mem_root) Item_func_units(thd, (char*) "radians", arg1,
6410                                              M_PI/180, 0.0);
6411 }
6412 
6413 
6414 Create_func_rand Create_func_rand::s_singleton;
6415 
6416 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)6417 Create_func_rand::create_native(THD *thd, LEX_CSTRING *name,
6418                                 List<Item> *item_list)
6419 {
6420   Item *func= NULL;
6421   int arg_count= 0;
6422 
6423   if (item_list != NULL)
6424     arg_count= item_list->elements;
6425 
6426   /*
6427     When RAND() is binlogged, the seed is binlogged too.  So the
6428     sequence of random numbers is the same on a replication slave as
6429     on the master.  However, if several RAND() values are inserted
6430     into a table, the order in which the rows are modified may differ
6431     between master and slave, because the order is undefined.  Hence,
6432     the statement is unsafe to log in statement format.
6433 
6434     For normal INSERT's this is howevever safe
6435   */
6436   if (thd->lex->sql_command != SQLCOM_INSERT)
6437     thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
6438 
6439   switch (arg_count) {
6440   case 0:
6441   {
6442     func= new (thd->mem_root) Item_func_rand(thd);
6443     thd->lex->uncacheable(UNCACHEABLE_RAND);
6444     break;
6445   }
6446   case 1:
6447   {
6448     Item *param_1= item_list->pop();
6449     func= new (thd->mem_root) Item_func_rand(thd, param_1);
6450     thd->lex->uncacheable(UNCACHEABLE_RAND);
6451     break;
6452   }
6453   default:
6454   {
6455     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
6456     break;
6457   }
6458   }
6459 
6460   return func;
6461 }
6462 
6463 
6464 Create_func_release_lock Create_func_release_lock::s_singleton;
6465 
6466 Item*
create_1_arg(THD * thd,Item * arg1)6467 Create_func_release_lock::create_1_arg(THD *thd, Item *arg1)
6468 {
6469   thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
6470   thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
6471   return new (thd->mem_root) Item_func_release_lock(thd, arg1);
6472 }
6473 
6474 
6475 Create_func_replace_oracle Create_func_replace_oracle::s_singleton;
6476 
6477 Item*
create_3_arg(THD * thd,Item * arg1,Item * arg2,Item * arg3)6478 Create_func_replace_oracle::create_3_arg(THD *thd, Item *arg1, Item *arg2,
6479                                         Item *arg3)
6480 {
6481   return new (thd->mem_root) Item_func_replace_oracle(thd, arg1, arg2, arg3);
6482 }
6483 
6484 
6485 Create_func_reverse Create_func_reverse::s_singleton;
6486 
6487 Item*
create_1_arg(THD * thd,Item * arg1)6488 Create_func_reverse::create_1_arg(THD *thd, Item *arg1)
6489 {
6490   return new (thd->mem_root) Item_func_reverse(thd, arg1);
6491 }
6492 
6493 
6494 Create_func_round Create_func_round::s_singleton;
6495 
6496 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)6497 Create_func_round::create_native(THD *thd, LEX_CSTRING *name,
6498                                  List<Item> *item_list)
6499 {
6500   Item *func= NULL;
6501   int arg_count= 0;
6502 
6503   if (item_list != NULL)
6504     arg_count= item_list->elements;
6505 
6506   switch (arg_count) {
6507   case 1:
6508   {
6509     Item *param_1= item_list->pop();
6510     Item *i0= new (thd->mem_root) Item_int(thd, (char*)"0", 0, 1);
6511     func= new (thd->mem_root) Item_func_round(thd, param_1, i0, 0);
6512     break;
6513   }
6514   case 2:
6515   {
6516     Item *param_1= item_list->pop();
6517     Item *param_2= item_list->pop();
6518     func= new (thd->mem_root) Item_func_round(thd, param_1, param_2, 0);
6519     break;
6520   }
6521   default:
6522   {
6523     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
6524     break;
6525   }
6526   }
6527 
6528   return func;
6529 }
6530 
6531 
6532 Create_func_rpad Create_func_rpad::s_singleton;
6533 
6534 Create_func_rpad_oracle Create_func_rpad_oracle::s_singleton;
6535 
6536 Item*
create_native_std(THD * thd,LEX_CSTRING * name,List<Item> * item_list)6537 Create_func_rpad::create_native_std(THD *thd, LEX_CSTRING *name,
6538                                     List<Item> *item_list)
6539 {
6540   Item *func= NULL;
6541   int arg_count= item_list ? item_list->elements : 0;
6542 
6543   switch (arg_count) {
6544   case 2:
6545   {
6546     Item *param_1= item_list->pop();
6547     Item *param_2= item_list->pop();
6548     func= new (thd->mem_root) Item_func_rpad(thd, param_1, param_2);
6549     break;
6550   }
6551   case 3:
6552   {
6553     Item *param_1= item_list->pop();
6554     Item *param_2= item_list->pop();
6555     Item *param_3= item_list->pop();
6556     func= new (thd->mem_root) Item_func_rpad(thd, param_1, param_2, param_3);
6557     break;
6558   }
6559   default:
6560     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
6561     break;
6562   }
6563 
6564   return func;
6565 }
6566 
6567 
6568 Item*
create_native_oracle(THD * thd,LEX_CSTRING * name,List<Item> * item_list)6569 Create_func_rpad::create_native_oracle(THD *thd, LEX_CSTRING *name,
6570                                        List<Item> *item_list)
6571 {
6572   int arg_count= item_list ? item_list->elements : 0;
6573   switch (arg_count) {
6574   case 2:
6575   {
6576     Item *param_1= item_list->pop();
6577     Item *param_2= item_list->pop();
6578     return new (thd->mem_root) Item_func_rpad_oracle(thd, param_1, param_2);
6579   }
6580   case 3:
6581   {
6582     Item *param_1= item_list->pop();
6583     Item *param_2= item_list->pop();
6584     Item *param_3= item_list->pop();
6585     return new (thd->mem_root) Item_func_rpad_oracle(thd, param_1,
6586                                                      param_2, param_3);
6587   }
6588   default:
6589     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
6590     break;
6591   }
6592   return NULL;
6593 }
6594 
6595 
6596 Create_func_rtrim Create_func_rtrim::s_singleton;
6597 
6598 Item*
create_1_arg(THD * thd,Item * arg1)6599 Create_func_rtrim::create_1_arg(THD *thd, Item *arg1)
6600 {
6601   return Lex_trim(TRIM_TRAILING, arg1).make_item_func_trim(thd);
6602 }
6603 
6604 
6605 Create_func_rtrim_oracle Create_func_rtrim_oracle::s_singleton;
6606 
6607 Item*
create_1_arg(THD * thd,Item * arg1)6608 Create_func_rtrim_oracle::create_1_arg(THD *thd, Item *arg1)
6609 {
6610   return new (thd->mem_root) Item_func_rtrim_oracle(thd, arg1);
6611 }
6612 
6613 
6614 Create_func_sec_to_time Create_func_sec_to_time::s_singleton;
6615 
6616 Item*
create_1_arg(THD * thd,Item * arg1)6617 Create_func_sec_to_time::create_1_arg(THD *thd, Item *arg1)
6618 {
6619   return new (thd->mem_root) Item_func_sec_to_time(thd, arg1);
6620 }
6621 
6622 
6623 Create_func_sha Create_func_sha::s_singleton;
6624 
6625 Item*
create_1_arg(THD * thd,Item * arg1)6626 Create_func_sha::create_1_arg(THD *thd, Item *arg1)
6627 {
6628   return new (thd->mem_root) Item_func_sha(thd, arg1);
6629 }
6630 
6631 
6632 Create_func_sha2 Create_func_sha2::s_singleton;
6633 
6634 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6635 Create_func_sha2::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6636 {
6637   return new (thd->mem_root) Item_func_sha2(thd, arg1, arg2);
6638 }
6639 
6640 
6641 Create_func_sign Create_func_sign::s_singleton;
6642 
6643 Item*
create_1_arg(THD * thd,Item * arg1)6644 Create_func_sign::create_1_arg(THD *thd, Item *arg1)
6645 {
6646   return new (thd->mem_root) Item_func_sign(thd, arg1);
6647 }
6648 
6649 
6650 Create_func_sin Create_func_sin::s_singleton;
6651 
6652 Item*
create_1_arg(THD * thd,Item * arg1)6653 Create_func_sin::create_1_arg(THD *thd, Item *arg1)
6654 {
6655   return new (thd->mem_root) Item_func_sin(thd, arg1);
6656 }
6657 
6658 
6659 Create_func_sleep Create_func_sleep::s_singleton;
6660 
6661 Item*
create_1_arg(THD * thd,Item * arg1)6662 Create_func_sleep::create_1_arg(THD *thd, Item *arg1)
6663 {
6664   thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
6665   thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
6666   return new (thd->mem_root) Item_func_sleep(thd, arg1);
6667 }
6668 
6669 
6670 Create_func_soundex Create_func_soundex::s_singleton;
6671 
6672 Item*
create_1_arg(THD * thd,Item * arg1)6673 Create_func_soundex::create_1_arg(THD *thd, Item *arg1)
6674 {
6675   return new (thd->mem_root) Item_func_soundex(thd, arg1);
6676 }
6677 
6678 
6679 Create_func_space Create_func_space::s_singleton;
6680 
6681 Item*
create_1_arg(THD * thd,Item * arg1)6682 Create_func_space::create_1_arg(THD *thd, Item *arg1)
6683 {
6684   return new (thd->mem_root) Item_func_space(thd, arg1);
6685 }
6686 
6687 
6688 Create_func_sqrt Create_func_sqrt::s_singleton;
6689 
6690 Item*
create_1_arg(THD * thd,Item * arg1)6691 Create_func_sqrt::create_1_arg(THD *thd, Item *arg1)
6692 {
6693   return new (thd->mem_root) Item_func_sqrt(thd, arg1);
6694 }
6695 
6696 
6697 #ifdef HAVE_SPATIAL
6698 Create_func_srid Create_func_srid::s_singleton;
6699 
6700 Item*
create_1_arg(THD * thd,Item * arg1)6701 Create_func_srid::create_1_arg(THD *thd, Item *arg1)
6702 {
6703   return new (thd->mem_root) Item_func_srid(thd, arg1);
6704 }
6705 #endif
6706 
6707 
6708 #ifdef HAVE_SPATIAL
6709 Create_func_startpoint Create_func_startpoint::s_singleton;
6710 
6711 Item*
create_1_arg(THD * thd,Item * arg1)6712 Create_func_startpoint::create_1_arg(THD *thd, Item *arg1)
6713 {
6714   return new (thd->mem_root) Item_func_spatial_decomp(thd, arg1,
6715                                                       Item_func::SP_STARTPOINT);
6716 }
6717 #endif
6718 
6719 
6720 Create_func_str_to_date Create_func_str_to_date::s_singleton;
6721 
6722 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6723 Create_func_str_to_date::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6724 {
6725   return new (thd->mem_root) Item_func_str_to_date(thd, arg1, arg2);
6726 }
6727 
6728 
6729 Create_func_strcmp Create_func_strcmp::s_singleton;
6730 
6731 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6732 Create_func_strcmp::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6733 {
6734   return new (thd->mem_root) Item_func_strcmp(thd, arg1, arg2);
6735 }
6736 
6737 
6738 Create_func_substr_index Create_func_substr_index::s_singleton;
6739 
6740 Item*
create_3_arg(THD * thd,Item * arg1,Item * arg2,Item * arg3)6741 Create_func_substr_index::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3)
6742 {
6743   return new (thd->mem_root) Item_func_substr_index(thd, arg1, arg2, arg3);
6744 }
6745 
6746 
6747 Create_func_substr_oracle Create_func_substr_oracle::s_singleton;
6748 
6749 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)6750 Create_func_substr_oracle::create_native(THD *thd, LEX_CSTRING *name,
6751                                 List<Item> *item_list)
6752 {
6753   Item *func= NULL;
6754   int arg_count= item_list ? item_list->elements : 0;
6755 
6756   switch (arg_count) {
6757   case 2:
6758   {
6759     Item *param_1= item_list->pop();
6760     Item *param_2= item_list->pop();
6761     func= new (thd->mem_root) Item_func_substr_oracle(thd, param_1, param_2);
6762     break;
6763   }
6764   case 3:
6765   {
6766     Item *param_1= item_list->pop();
6767     Item *param_2= item_list->pop();
6768     Item *param_3= item_list->pop();
6769     func= new (thd->mem_root) Item_func_substr_oracle(thd, param_1, param_2, param_3);
6770     break;
6771   }
6772   default:
6773     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
6774     break;
6775   }
6776 
6777   return func;
6778 }
6779 
6780 
6781 Create_func_subtime Create_func_subtime::s_singleton;
6782 
6783 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6784 Create_func_subtime::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6785 {
6786   return new (thd->mem_root) Item_func_add_time(thd, arg1, arg2, true);
6787 }
6788 
6789 
6790 Create_func_tan Create_func_tan::s_singleton;
6791 
6792 Item*
create_1_arg(THD * thd,Item * arg1)6793 Create_func_tan::create_1_arg(THD *thd, Item *arg1)
6794 {
6795   return new (thd->mem_root) Item_func_tan(thd, arg1);
6796 }
6797 
6798 
6799 Create_func_time_format Create_func_time_format::s_singleton;
6800 
6801 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6802 Create_func_time_format::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6803 {
6804   return new (thd->mem_root) Item_func_time_format(thd, arg1, arg2);
6805 }
6806 
6807 
6808 Create_func_time_to_sec Create_func_time_to_sec::s_singleton;
6809 
6810 Item*
create_1_arg(THD * thd,Item * arg1)6811 Create_func_time_to_sec::create_1_arg(THD *thd, Item *arg1)
6812 {
6813   return new (thd->mem_root) Item_func_time_to_sec(thd, arg1);
6814 }
6815 
6816 
6817 Create_func_timediff Create_func_timediff::s_singleton;
6818 
6819 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6820 Create_func_timediff::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6821 {
6822   return new (thd->mem_root) Item_func_timediff(thd, arg1, arg2);
6823 }
6824 
6825 
6826 Create_func_to_base64 Create_func_to_base64::s_singleton;
6827 
6828 Item*
create_1_arg(THD * thd,Item * arg1)6829 Create_func_to_base64::create_1_arg(THD *thd, Item *arg1)
6830 {
6831   return new (thd->mem_root) Item_func_to_base64(thd, arg1);
6832 }
6833 
6834 
6835 Create_func_to_days Create_func_to_days::s_singleton;
6836 
6837 Item*
create_1_arg(THD * thd,Item * arg1)6838 Create_func_to_days::create_1_arg(THD *thd, Item *arg1)
6839 {
6840   return new (thd->mem_root) Item_func_to_days(thd, arg1);
6841 }
6842 
6843 
6844 Create_func_to_seconds Create_func_to_seconds::s_singleton;
6845 
6846 Item*
create_1_arg(THD * thd,Item * arg1)6847 Create_func_to_seconds::create_1_arg(THD *thd, Item *arg1)
6848 {
6849   return new (thd->mem_root) Item_func_to_seconds(thd, arg1);
6850 }
6851 
6852 
6853 #ifdef HAVE_SPATIAL
6854 Create_func_touches Create_func_touches::s_singleton;
6855 
6856 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6857 Create_func_touches::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6858 {
6859   return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2,
6860                                                    Item_func::SP_TOUCHES_FUNC);
6861 }
6862 #endif
6863 
6864 
6865 Create_func_ucase Create_func_ucase::s_singleton;
6866 
6867 Item*
create_1_arg(THD * thd,Item * arg1)6868 Create_func_ucase::create_1_arg(THD *thd, Item *arg1)
6869 {
6870   return new (thd->mem_root) Item_func_ucase(thd, arg1);
6871 }
6872 
6873 
6874 Create_func_uncompress Create_func_uncompress::s_singleton;
6875 
6876 Item*
create_1_arg(THD * thd,Item * arg1)6877 Create_func_uncompress::create_1_arg(THD *thd, Item *arg1)
6878 {
6879   return new (thd->mem_root) Item_func_uncompress(thd, arg1);
6880 }
6881 
6882 
6883 Create_func_uncompressed_length Create_func_uncompressed_length::s_singleton;
6884 
6885 Item*
create_1_arg(THD * thd,Item * arg1)6886 Create_func_uncompressed_length::create_1_arg(THD *thd, Item *arg1)
6887 {
6888   return new (thd->mem_root) Item_func_uncompressed_length(thd, arg1);
6889 }
6890 
6891 
6892 Create_func_unhex Create_func_unhex::s_singleton;
6893 
6894 Item*
create_1_arg(THD * thd,Item * arg1)6895 Create_func_unhex::create_1_arg(THD *thd, Item *arg1)
6896 {
6897   return new (thd->mem_root) Item_func_unhex(thd, arg1);
6898 }
6899 
6900 
6901 Create_func_unix_timestamp Create_func_unix_timestamp::s_singleton;
6902 
6903 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)6904 Create_func_unix_timestamp::create_native(THD *thd, LEX_CSTRING *name,
6905                                           List<Item> *item_list)
6906 {
6907   Item *func= NULL;
6908   int arg_count= 0;
6909 
6910   if (item_list != NULL)
6911     arg_count= item_list->elements;
6912 
6913   switch (arg_count) {
6914   case 0:
6915   {
6916     func= new (thd->mem_root) Item_func_unix_timestamp(thd);
6917     thd->lex->safe_to_cache_query= 0;
6918     break;
6919   }
6920   case 1:
6921   {
6922     Item *param_1= item_list->pop();
6923     func= new (thd->mem_root) Item_func_unix_timestamp(thd, param_1);
6924     break;
6925   }
6926   default:
6927   {
6928     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
6929     break;
6930   }
6931   }
6932 
6933   return func;
6934 }
6935 
6936 
6937 Create_func_uuid Create_func_uuid::s_singleton;
6938 
6939 Item*
create_builder(THD * thd)6940 Create_func_uuid::create_builder(THD *thd)
6941 {
6942   DBUG_ENTER("Create_func_uuid::create");
6943   thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
6944   thd->lex->safe_to_cache_query= 0;
6945   DBUG_RETURN(new (thd->mem_root) Item_func_uuid(thd));
6946 }
6947 
6948 
6949 Create_func_uuid_short Create_func_uuid_short::s_singleton;
6950 
6951 Item*
create_builder(THD * thd)6952 Create_func_uuid_short::create_builder(THD *thd)
6953 {
6954   DBUG_ENTER("Create_func_uuid_short::create");
6955   thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
6956   thd->lex->safe_to_cache_query= 0;
6957   DBUG_RETURN(new (thd->mem_root) Item_func_uuid_short(thd));
6958 }
6959 
6960 
6961 Create_func_version Create_func_version::s_singleton;
6962 
6963 Item*
create_builder(THD * thd)6964 Create_func_version::create_builder(THD *thd)
6965 {
6966   thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
6967   return new (thd->mem_root) Item_static_string_func(thd, "version()",
6968                                                      server_version,
6969                                                      (uint) strlen(server_version),
6970                                                      system_charset_info,
6971                                                      DERIVATION_SYSCONST);
6972 }
6973 
6974 
6975 Create_func_weekday Create_func_weekday::s_singleton;
6976 
6977 Item*
create_1_arg(THD * thd,Item * arg1)6978 Create_func_weekday::create_1_arg(THD *thd, Item *arg1)
6979 {
6980   return new (thd->mem_root) Item_func_weekday(thd, arg1, 0);
6981 }
6982 
6983 
6984 Create_func_weekofyear Create_func_weekofyear::s_singleton;
6985 
6986 Item*
create_1_arg(THD * thd,Item * arg1)6987 Create_func_weekofyear::create_1_arg(THD *thd, Item *arg1)
6988 {
6989   Item *i1= new (thd->mem_root) Item_int(thd, (char*) "3", 3, 1);
6990   return new (thd->mem_root) Item_func_week(thd, arg1, i1);
6991 }
6992 
6993 
6994 #ifdef HAVE_SPATIAL
6995 Create_func_mbr_within Create_func_mbr_within::s_singleton;
6996 
6997 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)6998 Create_func_mbr_within::create_2_arg(THD *thd, Item *arg1, Item *arg2)
6999 {
7000   return new (thd->mem_root) Item_func_spatial_mbr_rel(thd, arg1, arg2,
7001       Item_func::SP_WITHIN_FUNC);
7002 }
7003 
7004 
7005 Create_func_within Create_func_within::s_singleton;
7006 
7007 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)7008 Create_func_within::create_2_arg(THD *thd, Item *arg1, Item *arg2)
7009 {
7010   return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2,
7011                                                     Item_func::SP_WITHIN_FUNC);
7012 }
7013 #endif
7014 
7015 #ifdef WITH_WSREP
7016 Create_func_wsrep_last_written_gtid
7017 Create_func_wsrep_last_written_gtid::s_singleton;
7018 
7019 Item*
create_builder(THD * thd)7020 Create_func_wsrep_last_written_gtid::create_builder(THD *thd)
7021 {
7022   thd->lex->safe_to_cache_query= 0;
7023   return new (thd->mem_root) Item_func_wsrep_last_written_gtid(thd);
7024 }
7025 
7026 
7027 Create_func_wsrep_last_seen_gtid
7028 Create_func_wsrep_last_seen_gtid::s_singleton;
7029 
7030 Item*
create_builder(THD * thd)7031 Create_func_wsrep_last_seen_gtid::create_builder(THD *thd)
7032 {
7033   thd->lex->safe_to_cache_query= 0;
7034   return new (thd->mem_root) Item_func_wsrep_last_seen_gtid(thd);
7035 }
7036 
7037 
7038 Create_func_wsrep_sync_wait_upto
7039 Create_func_wsrep_sync_wait_upto::s_singleton;
7040 
7041 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)7042 Create_func_wsrep_sync_wait_upto::create_native(THD *thd,
7043                                          LEX_CSTRING *name,
7044                                          List<Item> *item_list)
7045 {
7046   Item *func= NULL;
7047   int arg_count= 0;
7048   Item *param_1, *param_2;
7049 
7050   if (item_list != NULL)
7051     arg_count= item_list->elements;
7052 
7053   switch (arg_count)
7054   {
7055   case 1:
7056     param_1= item_list->pop();
7057     func= new (thd->mem_root) Item_func_wsrep_sync_wait_upto(thd, param_1);
7058     break;
7059   case 2:
7060     param_1= item_list->pop();
7061     param_2= item_list->pop();
7062     func= new (thd->mem_root) Item_func_wsrep_sync_wait_upto(thd, param_1, param_2);
7063     break;
7064   default:
7065     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
7066     break;
7067   }
7068   thd->lex->safe_to_cache_query= 0;
7069   return func;
7070 }
7071 #endif /* WITH_WSREP */
7072 
7073 #ifdef HAVE_SPATIAL
7074 Create_func_x Create_func_x::s_singleton;
7075 
7076 Item*
create_1_arg(THD * thd,Item * arg1)7077 Create_func_x::create_1_arg(THD *thd, Item *arg1)
7078 {
7079   return new (thd->mem_root) Item_func_x(thd, arg1);
7080 }
7081 #endif
7082 
7083 
7084 Create_func_xml_extractvalue Create_func_xml_extractvalue::s_singleton;
7085 
7086 Item*
create_2_arg(THD * thd,Item * arg1,Item * arg2)7087 Create_func_xml_extractvalue::create_2_arg(THD *thd, Item *arg1, Item *arg2)
7088 {
7089   return new (thd->mem_root) Item_func_xml_extractvalue(thd, arg1, arg2);
7090 }
7091 
7092 
7093 Create_func_xml_update Create_func_xml_update::s_singleton;
7094 
7095 Item*
create_3_arg(THD * thd,Item * arg1,Item * arg2,Item * arg3)7096 Create_func_xml_update::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3)
7097 {
7098   return new (thd->mem_root) Item_func_xml_update(thd, arg1, arg2, arg3);
7099 }
7100 
7101 
7102 #ifdef HAVE_SPATIAL
7103 Create_func_y Create_func_y::s_singleton;
7104 
7105 Item*
create_1_arg(THD * thd,Item * arg1)7106 Create_func_y::create_1_arg(THD *thd, Item *arg1)
7107 {
7108   return new (thd->mem_root) Item_func_y(thd, arg1);
7109 }
7110 #endif
7111 
7112 
7113 Create_func_year_week Create_func_year_week::s_singleton;
7114 
7115 Item*
create_native(THD * thd,LEX_CSTRING * name,List<Item> * item_list)7116 Create_func_year_week::create_native(THD *thd, LEX_CSTRING *name,
7117                                      List<Item> *item_list)
7118 {
7119   Item *func= NULL;
7120   int arg_count= 0;
7121 
7122   if (item_list != NULL)
7123     arg_count= item_list->elements;
7124 
7125   switch (arg_count) {
7126   case 1:
7127   {
7128     Item *param_1= item_list->pop();
7129     Item *i0= new (thd->mem_root) Item_int(thd, (char*) "0", 0, 1);
7130     func= new (thd->mem_root) Item_func_yearweek(thd, param_1, i0);
7131     break;
7132   }
7133   case 2:
7134   {
7135     Item *param_1= item_list->pop();
7136     Item *param_2= item_list->pop();
7137     func= new (thd->mem_root) Item_func_yearweek(thd, param_1, param_2);
7138     break;
7139   }
7140   default:
7141   {
7142     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
7143     break;
7144   }
7145   }
7146 
7147   return func;
7148 }
7149 
7150 #define BUILDER(F) & F::s_singleton
7151 
7152 #ifdef HAVE_SPATIAL
7153   #define GEOM_BUILDER(F) & F::s_singleton
7154 #else
7155   #define GEOM_BUILDER(F) & Create_func_no_geom::s_singleton
7156 #endif
7157 
7158 /*
7159   MySQL native functions.
7160   MAINTAINER:
7161   - Keep sorted for human lookup. At runtime, a hash table is used.
7162   - do **NOT** conditionally (#ifdef, #ifndef) define a function *NAME*:
7163     doing so will cause user code that works against a --without-XYZ binary
7164     to fail with name collisions against a --with-XYZ binary.
7165     Use something similar to GEOM_BUILDER instead.
7166   - keep 1 line per entry, it makes grep | sort easier
7167 */
7168 
7169 Native_func_registry func_array[] =
7170 {
7171   { { STRING_WITH_LEN("ABS") }, BUILDER(Create_func_abs)},
7172   { { STRING_WITH_LEN("ACOS") }, BUILDER(Create_func_acos)},
7173   { { STRING_WITH_LEN("ADDTIME") }, BUILDER(Create_func_addtime)},
7174   { { STRING_WITH_LEN("AES_DECRYPT") }, BUILDER(Create_func_aes_decrypt)},
7175   { { STRING_WITH_LEN("AES_ENCRYPT") }, BUILDER(Create_func_aes_encrypt)},
7176   { { STRING_WITH_LEN("AREA") }, GEOM_BUILDER(Create_func_area)},
7177   { { STRING_WITH_LEN("ASBINARY") }, GEOM_BUILDER(Create_func_as_wkb)},
7178   { { STRING_WITH_LEN("ASIN") }, BUILDER(Create_func_asin)},
7179   { { STRING_WITH_LEN("ASTEXT") }, GEOM_BUILDER(Create_func_as_wkt)},
7180   { { STRING_WITH_LEN("ASWKB") }, GEOM_BUILDER(Create_func_as_wkb)},
7181   { { STRING_WITH_LEN("ASWKT") }, GEOM_BUILDER(Create_func_as_wkt)},
7182   { { STRING_WITH_LEN("ATAN") }, BUILDER(Create_func_atan)},
7183   { { STRING_WITH_LEN("ATAN2") }, BUILDER(Create_func_atan)},
7184   { { STRING_WITH_LEN("BENCHMARK") }, BUILDER(Create_func_benchmark)},
7185   { { STRING_WITH_LEN("BIN") }, BUILDER(Create_func_bin)},
7186   { { STRING_WITH_LEN("BINLOG_GTID_POS") }, BUILDER(Create_func_binlog_gtid_pos)},
7187   { { STRING_WITH_LEN("BIT_COUNT") }, BUILDER(Create_func_bit_count)},
7188   { { STRING_WITH_LEN("BIT_LENGTH") }, BUILDER(Create_func_bit_length)},
7189   { { STRING_WITH_LEN("BOUNDARY") }, GEOM_BUILDER(Create_func_boundary)},
7190   { { STRING_WITH_LEN("BUFFER") }, GEOM_BUILDER(Create_func_buffer)},
7191   { { STRING_WITH_LEN("CEIL") }, BUILDER(Create_func_ceiling)},
7192   { { STRING_WITH_LEN("CEILING") }, BUILDER(Create_func_ceiling)},
7193   { { STRING_WITH_LEN("CENTROID") }, GEOM_BUILDER(Create_func_centroid)},
7194   { { STRING_WITH_LEN("CHARACTER_LENGTH") }, BUILDER(Create_func_char_length)},
7195   { { STRING_WITH_LEN("CHAR_LENGTH") }, BUILDER(Create_func_char_length)},
7196   { { STRING_WITH_LEN("CHR") }, BUILDER(Create_func_chr)},
7197   { { STRING_WITH_LEN("COERCIBILITY") }, BUILDER(Create_func_coercibility)},
7198   { { STRING_WITH_LEN("COLUMN_CHECK") }, BUILDER(Create_func_dyncol_check)},
7199   { { STRING_WITH_LEN("COLUMN_EXISTS") }, BUILDER(Create_func_dyncol_exists)},
7200   { { STRING_WITH_LEN("COLUMN_LIST") }, BUILDER(Create_func_dyncol_list)},
7201   { { STRING_WITH_LEN("COLUMN_JSON") }, BUILDER(Create_func_dyncol_json)},
7202   { { STRING_WITH_LEN("COMPRESS") }, BUILDER(Create_func_compress)},
7203   { { STRING_WITH_LEN("CONCAT") }, BUILDER(Create_func_concat)},
7204   { { STRING_WITH_LEN("CONCAT_OPERATOR_ORACLE") }, BUILDER(Create_func_concat_operator_oracle)},
7205   { { STRING_WITH_LEN("CONCAT_WS") }, BUILDER(Create_func_concat_ws)},
7206   { { STRING_WITH_LEN("CONNECTION_ID") }, BUILDER(Create_func_connection_id)},
7207   { { STRING_WITH_LEN("CONV") }, BUILDER(Create_func_conv)},
7208   { { STRING_WITH_LEN("CONVERT_TZ") }, BUILDER(Create_func_convert_tz)},
7209   { { STRING_WITH_LEN("CONVEXHULL") }, GEOM_BUILDER(Create_func_convexhull)},
7210   { { STRING_WITH_LEN("COS") }, BUILDER(Create_func_cos)},
7211   { { STRING_WITH_LEN("COT") }, BUILDER(Create_func_cot)},
7212   { { STRING_WITH_LEN("CRC32") }, BUILDER(Create_func_crc32)},
7213   { { STRING_WITH_LEN("CROSSES") }, GEOM_BUILDER(Create_func_crosses)},
7214   { { STRING_WITH_LEN("DATEDIFF") }, BUILDER(Create_func_datediff)},
7215   { { STRING_WITH_LEN("DAYNAME") }, BUILDER(Create_func_dayname)},
7216   { { STRING_WITH_LEN("DAYOFMONTH") }, BUILDER(Create_func_dayofmonth)},
7217   { { STRING_WITH_LEN("DAYOFWEEK") }, BUILDER(Create_func_dayofweek)},
7218   { { STRING_WITH_LEN("DAYOFYEAR") }, BUILDER(Create_func_dayofyear)},
7219   { { STRING_WITH_LEN("DEGREES") }, BUILDER(Create_func_degrees)},
7220   { { STRING_WITH_LEN("DECODE_HISTOGRAM") }, BUILDER(Create_func_decode_histogram)},
7221   { { STRING_WITH_LEN("DECODE_ORACLE") }, BUILDER(Create_func_decode_oracle)},
7222   { { STRING_WITH_LEN("DES_DECRYPT") }, BUILDER(Create_func_des_decrypt)},
7223   { { STRING_WITH_LEN("DES_ENCRYPT") }, BUILDER(Create_func_des_encrypt)},
7224   { { STRING_WITH_LEN("DIMENSION") }, GEOM_BUILDER(Create_func_dimension)},
7225   { { STRING_WITH_LEN("DISJOINT") }, GEOM_BUILDER(Create_func_mbr_disjoint)},
7226   { { STRING_WITH_LEN("ELT") }, BUILDER(Create_func_elt)},
7227   { { STRING_WITH_LEN("ENCODE") }, BUILDER(Create_func_encode)},
7228   { { STRING_WITH_LEN("ENCRYPT") }, BUILDER(Create_func_encrypt)},
7229   { { STRING_WITH_LEN("ENDPOINT") }, GEOM_BUILDER(Create_func_endpoint)},
7230   { { STRING_WITH_LEN("ENVELOPE") }, GEOM_BUILDER(Create_func_envelope)},
7231   { { STRING_WITH_LEN("EQUALS") }, GEOM_BUILDER(Create_func_equals)},
7232   { { STRING_WITH_LEN("EXP") }, BUILDER(Create_func_exp)},
7233   { { STRING_WITH_LEN("EXPORT_SET") }, BUILDER(Create_func_export_set)},
7234   { { STRING_WITH_LEN("EXTERIORRING") }, GEOM_BUILDER(Create_func_exteriorring)},
7235   { { STRING_WITH_LEN("EXTRACTVALUE") }, BUILDER(Create_func_xml_extractvalue)},
7236   { { STRING_WITH_LEN("FIELD") }, BUILDER(Create_func_field)},
7237   { { STRING_WITH_LEN("FIND_IN_SET") }, BUILDER(Create_func_find_in_set)},
7238   { { STRING_WITH_LEN("FLOOR") }, BUILDER(Create_func_floor)},
7239   { { STRING_WITH_LEN("FORMAT") }, BUILDER(Create_func_format)},
7240   { { STRING_WITH_LEN("FOUND_ROWS") }, BUILDER(Create_func_found_rows)},
7241   { { STRING_WITH_LEN("FROM_BASE64") }, BUILDER(Create_func_from_base64)},
7242   { { STRING_WITH_LEN("FROM_DAYS") }, BUILDER(Create_func_from_days)},
7243   { { STRING_WITH_LEN("FROM_UNIXTIME") }, BUILDER(Create_func_from_unixtime)},
7244   { { STRING_WITH_LEN("GEOMCOLLFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7245   { { STRING_WITH_LEN("GEOMCOLLFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7246   { { STRING_WITH_LEN("GEOMETRYCOLLECTIONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7247   { { STRING_WITH_LEN("GEOMETRYCOLLECTIONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7248   { { STRING_WITH_LEN("GEOMETRYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7249   { { STRING_WITH_LEN("GEOMETRYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7250   { { STRING_WITH_LEN("GEOMETRYN") }, GEOM_BUILDER(Create_func_geometryn)},
7251   { { STRING_WITH_LEN("GEOMETRYTYPE") }, GEOM_BUILDER(Create_func_geometry_type)},
7252   { { STRING_WITH_LEN("GEOMFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7253   { { STRING_WITH_LEN("GEOMFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7254   { { STRING_WITH_LEN("GET_LOCK") }, BUILDER(Create_func_get_lock)},
7255   { { STRING_WITH_LEN("GLENGTH") }, GEOM_BUILDER(Create_func_glength)},
7256   { { STRING_WITH_LEN("GREATEST") }, BUILDER(Create_func_greatest)},
7257   { { STRING_WITH_LEN("HEX") }, BUILDER(Create_func_hex)},
7258   { { STRING_WITH_LEN("IFNULL") }, BUILDER(Create_func_ifnull)},
7259   { { STRING_WITH_LEN("INET_ATON") }, BUILDER(Create_func_inet_aton)},
7260   { { STRING_WITH_LEN("INET_NTOA") }, BUILDER(Create_func_inet_ntoa)},
7261   { { STRING_WITH_LEN("INET6_ATON") }, BUILDER(Create_func_inet6_aton)},
7262   { { STRING_WITH_LEN("INET6_NTOA") }, BUILDER(Create_func_inet6_ntoa)},
7263   { { STRING_WITH_LEN("IS_IPV4") }, BUILDER(Create_func_is_ipv4)},
7264   { { STRING_WITH_LEN("IS_IPV6") }, BUILDER(Create_func_is_ipv6)},
7265   { { STRING_WITH_LEN("IS_IPV4_COMPAT") }, BUILDER(Create_func_is_ipv4_compat)},
7266   { { STRING_WITH_LEN("IS_IPV4_MAPPED") }, BUILDER(Create_func_is_ipv4_mapped)},
7267   { { STRING_WITH_LEN("INSTR") }, BUILDER(Create_func_instr)},
7268   { { STRING_WITH_LEN("INTERIORRINGN") }, GEOM_BUILDER(Create_func_interiorringn)},
7269   { { STRING_WITH_LEN("INTERSECTS") }, GEOM_BUILDER(Create_func_mbr_intersects)},
7270   { { STRING_WITH_LEN("ISCLOSED") }, GEOM_BUILDER(Create_func_isclosed)},
7271   { { STRING_WITH_LEN("ISEMPTY") }, GEOM_BUILDER(Create_func_isempty)},
7272   { { STRING_WITH_LEN("ISNULL") }, BUILDER(Create_func_isnull)},
7273   { { STRING_WITH_LEN("ISRING") }, GEOM_BUILDER(Create_func_isring)},
7274   { { STRING_WITH_LEN("ISSIMPLE") }, GEOM_BUILDER(Create_func_issimple)},
7275   { { STRING_WITH_LEN("IS_FREE_LOCK") }, BUILDER(Create_func_is_free_lock)},
7276   { { STRING_WITH_LEN("IS_USED_LOCK") }, BUILDER(Create_func_is_used_lock)},
7277   { { STRING_WITH_LEN("JSON_ARRAY") }, BUILDER(Create_func_json_array)},
7278   { { STRING_WITH_LEN("JSON_ARRAY_APPEND") }, BUILDER(Create_func_json_array_append)},
7279   { { STRING_WITH_LEN("JSON_ARRAY_INSERT") }, BUILDER(Create_func_json_array_insert)},
7280   { { STRING_WITH_LEN("JSON_COMPACT") }, BUILDER(Create_func_json_compact)},
7281   { { STRING_WITH_LEN("JSON_CONTAINS") }, BUILDER(Create_func_json_contains)},
7282   { { STRING_WITH_LEN("JSON_CONTAINS_PATH") }, BUILDER(Create_func_json_contains_path)},
7283   { { STRING_WITH_LEN("JSON_DEPTH") }, BUILDER(Create_func_json_depth)},
7284   { { STRING_WITH_LEN("JSON_DETAILED") }, BUILDER(Create_func_json_detailed)},
7285   { { STRING_WITH_LEN("JSON_EXISTS") }, BUILDER(Create_func_json_exists)},
7286   { { STRING_WITH_LEN("JSON_EXTRACT") }, BUILDER(Create_func_json_extract)},
7287   { { STRING_WITH_LEN("JSON_INSERT") }, BUILDER(Create_func_json_insert)},
7288   { { STRING_WITH_LEN("JSON_KEYS") }, BUILDER(Create_func_json_keys)},
7289   { { STRING_WITH_LEN("JSON_LENGTH") }, BUILDER(Create_func_json_length)},
7290   { { STRING_WITH_LEN("JSON_LOOSE") }, BUILDER(Create_func_json_loose)},
7291   { { STRING_WITH_LEN("JSON_MERGE") }, BUILDER(Create_func_json_merge)},
7292   { { STRING_WITH_LEN("JSON_MERGE_PATCH") }, BUILDER(Create_func_json_merge_patch)},
7293   { { STRING_WITH_LEN("JSON_MERGE_PRESERVE") }, BUILDER(Create_func_json_merge)},
7294   { { STRING_WITH_LEN("JSON_QUERY") }, BUILDER(Create_func_json_query)},
7295   { { STRING_WITH_LEN("JSON_QUOTE") }, BUILDER(Create_func_json_quote)},
7296   { { STRING_WITH_LEN("JSON_OBJECT") }, BUILDER(Create_func_json_object)},
7297   { { STRING_WITH_LEN("JSON_REMOVE") }, BUILDER(Create_func_json_remove)},
7298   { { STRING_WITH_LEN("JSON_REPLACE") }, BUILDER(Create_func_json_replace)},
7299   { { STRING_WITH_LEN("JSON_SET") }, BUILDER(Create_func_json_set)},
7300   { { STRING_WITH_LEN("JSON_SEARCH") }, BUILDER(Create_func_json_search)},
7301   { { STRING_WITH_LEN("JSON_TYPE") }, BUILDER(Create_func_json_type)},
7302   { { STRING_WITH_LEN("JSON_UNQUOTE") }, BUILDER(Create_func_json_unquote)},
7303   { { STRING_WITH_LEN("JSON_VALID") }, BUILDER(Create_func_json_valid)},
7304   { { STRING_WITH_LEN("JSON_VALUE") }, BUILDER(Create_func_json_value)},
7305   { { STRING_WITH_LEN("LAST_DAY") }, BUILDER(Create_func_last_day)},
7306   { { STRING_WITH_LEN("LAST_INSERT_ID") }, BUILDER(Create_func_last_insert_id)},
7307   { { STRING_WITH_LEN("LCASE") }, BUILDER(Create_func_lcase)},
7308   { { STRING_WITH_LEN("LEAST") }, BUILDER(Create_func_least)},
7309   { { STRING_WITH_LEN("LENGTH") }, BUILDER(Create_func_length)},
7310   { { STRING_WITH_LEN("LENGTHB") }, BUILDER(Create_func_octet_length)},
7311 #ifndef DBUG_OFF
7312   { { STRING_WITH_LEN("LIKE_RANGE_MIN") }, BUILDER(Create_func_like_range_min)},
7313   { { STRING_WITH_LEN("LIKE_RANGE_MAX") }, BUILDER(Create_func_like_range_max)},
7314 #endif
7315   { { STRING_WITH_LEN("LINEFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7316   { { STRING_WITH_LEN("LINEFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7317   { { STRING_WITH_LEN("LINESTRINGFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7318   { { STRING_WITH_LEN("LINESTRINGFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7319   { { STRING_WITH_LEN("LN") }, BUILDER(Create_func_ln)},
7320   { { STRING_WITH_LEN("LOAD_FILE") }, BUILDER(Create_func_load_file)},
7321   { { STRING_WITH_LEN("LOCATE") }, BUILDER(Create_func_locate)},
7322   { { STRING_WITH_LEN("LOG") }, BUILDER(Create_func_log)},
7323   { { STRING_WITH_LEN("LOG10") }, BUILDER(Create_func_log10)},
7324   { { STRING_WITH_LEN("LOG2") }, BUILDER(Create_func_log2)},
7325   { { STRING_WITH_LEN("LOWER") }, BUILDER(Create_func_lcase)},
7326   { { STRING_WITH_LEN("LPAD") }, BUILDER(Create_func_lpad)},
7327   { { STRING_WITH_LEN("LPAD_ORACLE") }, BUILDER(Create_func_lpad_oracle)},
7328   { { STRING_WITH_LEN("LTRIM") }, BUILDER(Create_func_ltrim)},
7329   { { STRING_WITH_LEN("LTRIM_ORACLE") }, BUILDER(Create_func_ltrim_oracle)},
7330   { { STRING_WITH_LEN("MAKEDATE") }, BUILDER(Create_func_makedate)},
7331   { { STRING_WITH_LEN("MAKETIME") }, BUILDER(Create_func_maketime)},
7332   { { STRING_WITH_LEN("MAKE_SET") }, BUILDER(Create_func_make_set)},
7333   { { STRING_WITH_LEN("MASTER_GTID_WAIT") }, BUILDER(Create_func_master_gtid_wait)},
7334   { { STRING_WITH_LEN("MASTER_POS_WAIT") }, BUILDER(Create_func_master_pos_wait)},
7335   { { STRING_WITH_LEN("MBRCONTAINS") }, GEOM_BUILDER(Create_func_mbr_contains)},
7336   { { STRING_WITH_LEN("MBRDISJOINT") }, GEOM_BUILDER(Create_func_mbr_disjoint)},
7337   { { STRING_WITH_LEN("MBREQUAL") }, GEOM_BUILDER(Create_func_mbr_equals)},
7338   { { STRING_WITH_LEN("MBREQUALS") }, GEOM_BUILDER(Create_func_mbr_equals)},
7339   { { STRING_WITH_LEN("MBRINTERSECTS") }, GEOM_BUILDER(Create_func_mbr_intersects)},
7340   { { STRING_WITH_LEN("MBROVERLAPS") }, GEOM_BUILDER(Create_func_mbr_overlaps)},
7341   { { STRING_WITH_LEN("MBRTOUCHES") }, GEOM_BUILDER(Create_func_touches)},
7342   { { STRING_WITH_LEN("MBRWITHIN") }, GEOM_BUILDER(Create_func_mbr_within)},
7343   { { STRING_WITH_LEN("MD5") }, BUILDER(Create_func_md5)},
7344   { { STRING_WITH_LEN("MLINEFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7345   { { STRING_WITH_LEN("MLINEFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7346   { { STRING_WITH_LEN("MONTHNAME") }, BUILDER(Create_func_monthname)},
7347   { { STRING_WITH_LEN("MPOINTFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7348   { { STRING_WITH_LEN("MPOINTFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7349   { { STRING_WITH_LEN("MPOLYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7350   { { STRING_WITH_LEN("MPOLYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7351   { { STRING_WITH_LEN("MULTILINESTRINGFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7352   { { STRING_WITH_LEN("MULTILINESTRINGFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7353   { { STRING_WITH_LEN("MULTIPOINTFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7354   { { STRING_WITH_LEN("MULTIPOINTFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7355   { { STRING_WITH_LEN("MULTIPOLYGONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7356   { { STRING_WITH_LEN("MULTIPOLYGONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7357   { { STRING_WITH_LEN("NAME_CONST") }, BUILDER(Create_func_name_const)},
7358   { { STRING_WITH_LEN("NVL") }, BUILDER(Create_func_ifnull)},
7359   { { STRING_WITH_LEN("NVL2") }, BUILDER(Create_func_nvl2)},
7360   { { STRING_WITH_LEN("NULLIF") }, BUILDER(Create_func_nullif)},
7361   { { STRING_WITH_LEN("NUMGEOMETRIES") }, GEOM_BUILDER(Create_func_numgeometries)},
7362   { { STRING_WITH_LEN("NUMINTERIORRINGS") }, GEOM_BUILDER(Create_func_numinteriorring)},
7363   { { STRING_WITH_LEN("NUMPOINTS") }, GEOM_BUILDER(Create_func_numpoints)},
7364   { { STRING_WITH_LEN("OCT") }, BUILDER(Create_func_oct)},
7365   { { STRING_WITH_LEN("OCTET_LENGTH") }, BUILDER(Create_func_octet_length)},
7366   { { STRING_WITH_LEN("ORD") }, BUILDER(Create_func_ord)},
7367   { { STRING_WITH_LEN("OVERLAPS") }, GEOM_BUILDER(Create_func_mbr_overlaps)},
7368   { { STRING_WITH_LEN("PERIOD_ADD") }, BUILDER(Create_func_period_add)},
7369   { { STRING_WITH_LEN("PERIOD_DIFF") }, BUILDER(Create_func_period_diff)},
7370   { { STRING_WITH_LEN("PI") }, BUILDER(Create_func_pi)},
7371   { { STRING_WITH_LEN("POINTFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7372   { { STRING_WITH_LEN("POINTFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7373   { { STRING_WITH_LEN("POINTN") }, GEOM_BUILDER(Create_func_pointn)},
7374   { { STRING_WITH_LEN("POINTONSURFACE") }, GEOM_BUILDER(Create_func_pointonsurface)},
7375   { { STRING_WITH_LEN("POLYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7376   { { STRING_WITH_LEN("POLYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7377   { { STRING_WITH_LEN("POLYGONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7378   { { STRING_WITH_LEN("POLYGONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7379   { { STRING_WITH_LEN("POW") }, BUILDER(Create_func_pow)},
7380   { { STRING_WITH_LEN("POWER") }, BUILDER(Create_func_pow)},
7381   { { STRING_WITH_LEN("QUOTE") }, BUILDER(Create_func_quote)},
7382   { { STRING_WITH_LEN("REGEXP_INSTR") }, BUILDER(Create_func_regexp_instr)},
7383   { { STRING_WITH_LEN("REGEXP_REPLACE") }, BUILDER(Create_func_regexp_replace)},
7384   { { STRING_WITH_LEN("REGEXP_SUBSTR") }, BUILDER(Create_func_regexp_substr)},
7385   { { STRING_WITH_LEN("RADIANS") }, BUILDER(Create_func_radians)},
7386   { { STRING_WITH_LEN("RAND") }, BUILDER(Create_func_rand)},
7387   { { STRING_WITH_LEN("RELEASE_LOCK") }, BUILDER(Create_func_release_lock)},
7388   { { STRING_WITH_LEN("REPLACE_ORACLE") },
7389       BUILDER(Create_func_replace_oracle)},
7390   { { STRING_WITH_LEN("REVERSE") }, BUILDER(Create_func_reverse)},
7391   { { STRING_WITH_LEN("ROUND") }, BUILDER(Create_func_round)},
7392   { { STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad)},
7393   { { STRING_WITH_LEN("RPAD_ORACLE") }, BUILDER(Create_func_rpad_oracle)},
7394   { { STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim)},
7395   { { STRING_WITH_LEN("RTRIM_ORACLE") }, BUILDER(Create_func_rtrim_oracle)},
7396   { { STRING_WITH_LEN("SEC_TO_TIME") }, BUILDER(Create_func_sec_to_time)},
7397   { { STRING_WITH_LEN("SHA") }, BUILDER(Create_func_sha)},
7398   { { STRING_WITH_LEN("SHA1") }, BUILDER(Create_func_sha)},
7399   { { STRING_WITH_LEN("SHA2") }, BUILDER(Create_func_sha2)},
7400   { { STRING_WITH_LEN("SIGN") }, BUILDER(Create_func_sign)},
7401   { { STRING_WITH_LEN("SIN") }, BUILDER(Create_func_sin)},
7402   { { STRING_WITH_LEN("SLEEP") }, BUILDER(Create_func_sleep)},
7403   { { STRING_WITH_LEN("SOUNDEX") }, BUILDER(Create_func_soundex)},
7404   { { STRING_WITH_LEN("SPACE") }, BUILDER(Create_func_space)},
7405   { { STRING_WITH_LEN("SQRT") }, BUILDER(Create_func_sqrt)},
7406   { { STRING_WITH_LEN("SRID") }, GEOM_BUILDER(Create_func_srid)},
7407   { { STRING_WITH_LEN("STARTPOINT") }, GEOM_BUILDER(Create_func_startpoint)},
7408   { { STRING_WITH_LEN("STRCMP") }, BUILDER(Create_func_strcmp)},
7409   { { STRING_WITH_LEN("STR_TO_DATE") }, BUILDER(Create_func_str_to_date)},
7410   { { STRING_WITH_LEN("ST_AREA") }, GEOM_BUILDER(Create_func_area)},
7411   { { STRING_WITH_LEN("ST_ASBINARY") }, GEOM_BUILDER(Create_func_as_wkb)},
7412   { { STRING_WITH_LEN("ST_ASGEOJSON") }, GEOM_BUILDER(Create_func_as_geojson)},
7413   { { STRING_WITH_LEN("ST_ASTEXT") }, GEOM_BUILDER(Create_func_as_wkt)},
7414   { { STRING_WITH_LEN("ST_ASWKB") }, GEOM_BUILDER(Create_func_as_wkb)},
7415   { { STRING_WITH_LEN("ST_ASWKT") }, GEOM_BUILDER(Create_func_as_wkt)},
7416   { { STRING_WITH_LEN("ST_BOUNDARY") }, GEOM_BUILDER(Create_func_boundary)},
7417   { { STRING_WITH_LEN("ST_BUFFER") }, GEOM_BUILDER(Create_func_buffer)},
7418   { { STRING_WITH_LEN("ST_CENTROID") }, GEOM_BUILDER(Create_func_centroid)},
7419   { { STRING_WITH_LEN("ST_CONTAINS") }, GEOM_BUILDER(Create_func_contains)},
7420   { { STRING_WITH_LEN("ST_CONVEXHULL") }, GEOM_BUILDER(Create_func_convexhull)},
7421   { { STRING_WITH_LEN("ST_CROSSES") }, GEOM_BUILDER(Create_func_crosses)},
7422   { { STRING_WITH_LEN("ST_DIFFERENCE") }, GEOM_BUILDER(Create_func_difference)},
7423   { { STRING_WITH_LEN("ST_DIMENSION") }, GEOM_BUILDER(Create_func_dimension)},
7424   { { STRING_WITH_LEN("ST_DISJOINT") }, GEOM_BUILDER(Create_func_disjoint)},
7425   { { STRING_WITH_LEN("ST_DISTANCE") }, GEOM_BUILDER(Create_func_distance)},
7426   { { STRING_WITH_LEN("ST_ENDPOINT") }, GEOM_BUILDER(Create_func_endpoint)},
7427   { { STRING_WITH_LEN("ST_ENVELOPE") }, GEOM_BUILDER(Create_func_envelope)},
7428   { { STRING_WITH_LEN("ST_EQUALS") }, GEOM_BUILDER(Create_func_equals)},
7429   { { STRING_WITH_LEN("ST_EXTERIORRING") }, GEOM_BUILDER(Create_func_exteriorring)},
7430   { { STRING_WITH_LEN("ST_GEOMCOLLFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7431   { { STRING_WITH_LEN("ST_GEOMCOLLFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7432   { { STRING_WITH_LEN("ST_GEOMETRYCOLLECTIONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7433   { { STRING_WITH_LEN("ST_GEOMETRYCOLLECTIONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7434   { { STRING_WITH_LEN("ST_GEOMETRYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7435   { { STRING_WITH_LEN("ST_GEOMETRYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7436   { { STRING_WITH_LEN("ST_GEOMETRYN") }, GEOM_BUILDER(Create_func_geometryn)},
7437   { { STRING_WITH_LEN("ST_GEOMETRYTYPE") }, GEOM_BUILDER(Create_func_geometry_type)},
7438   { { STRING_WITH_LEN("ST_GEOMFROMGEOJSON") }, GEOM_BUILDER(Create_func_geometry_from_json)},
7439   { { STRING_WITH_LEN("ST_GEOMFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7440   { { STRING_WITH_LEN("ST_GEOMFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7441 #ifndef DBUG_OFF
7442     { { STRING_WITH_LEN("ST_GIS_DEBUG") }, GEOM_BUILDER(Create_func_gis_debug)},
7443 #endif
7444   { { STRING_WITH_LEN("ST_EQUALS") }, GEOM_BUILDER(Create_func_equals)},
7445   { { STRING_WITH_LEN("ST_INTERIORRINGN") }, GEOM_BUILDER(Create_func_interiorringn)},
7446   { { STRING_WITH_LEN("ST_INTERSECTS") }, GEOM_BUILDER(Create_func_intersects)},
7447   { { STRING_WITH_LEN("ST_INTERSECTION") }, GEOM_BUILDER(Create_func_intersection)},
7448   { { STRING_WITH_LEN("ST_ISCLOSED") }, GEOM_BUILDER(Create_func_isclosed)},
7449   { { STRING_WITH_LEN("ST_ISEMPTY") }, GEOM_BUILDER(Create_func_isempty)},
7450   { { STRING_WITH_LEN("ST_ISRING") }, GEOM_BUILDER(Create_func_isring)},
7451   { { STRING_WITH_LEN("ST_ISSIMPLE") }, GEOM_BUILDER(Create_func_issimple)},
7452   { { STRING_WITH_LEN("ST_LENGTH") }, GEOM_BUILDER(Create_func_glength)},
7453   { { STRING_WITH_LEN("ST_LINEFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7454   { { STRING_WITH_LEN("ST_LINEFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7455   { { STRING_WITH_LEN("ST_LINESTRINGFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7456   { { STRING_WITH_LEN("ST_LINESTRINGFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7457   { { STRING_WITH_LEN("ST_MLINEFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7458   { { STRING_WITH_LEN("ST_MLINEFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7459   { { STRING_WITH_LEN("ST_MPOINTFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7460   { { STRING_WITH_LEN("ST_MPOINTFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7461   { { STRING_WITH_LEN("ST_MPOLYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7462   { { STRING_WITH_LEN("ST_MPOLYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7463   { { STRING_WITH_LEN("ST_MULTILINESTRINGFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7464   { { STRING_WITH_LEN("ST_MULTILINESTRINGFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7465   { { STRING_WITH_LEN("ST_MULTIPOINTFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7466   { { STRING_WITH_LEN("ST_MULTIPOINTFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7467   { { STRING_WITH_LEN("ST_MULTIPOLYGONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7468   { { STRING_WITH_LEN("ST_MULTIPOLYGONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7469   { { STRING_WITH_LEN("ST_NUMGEOMETRIES") }, GEOM_BUILDER(Create_func_numgeometries)},
7470   { { STRING_WITH_LEN("ST_NUMINTERIORRINGS") }, GEOM_BUILDER(Create_func_numinteriorring)},
7471   { { STRING_WITH_LEN("ST_NUMPOINTS") }, GEOM_BUILDER(Create_func_numpoints)},
7472   { { STRING_WITH_LEN("ST_OVERLAPS") }, GEOM_BUILDER(Create_func_overlaps)},
7473   { { STRING_WITH_LEN("ST_POINTFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7474   { { STRING_WITH_LEN("ST_POINTFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7475   { { STRING_WITH_LEN("ST_POINTN") }, GEOM_BUILDER(Create_func_pointn)},
7476   { { STRING_WITH_LEN("ST_POINTONSURFACE") }, GEOM_BUILDER(Create_func_pointonsurface)},
7477   { { STRING_WITH_LEN("ST_POLYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7478   { { STRING_WITH_LEN("ST_POLYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7479   { { STRING_WITH_LEN("ST_POLYGONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
7480   { { STRING_WITH_LEN("ST_POLYGONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
7481   { { STRING_WITH_LEN("ST_RELATE") }, GEOM_BUILDER(Create_func_relate)},
7482   { { STRING_WITH_LEN("ST_SRID") }, GEOM_BUILDER(Create_func_srid)},
7483   { { STRING_WITH_LEN("ST_STARTPOINT") }, GEOM_BUILDER(Create_func_startpoint)},
7484   { { STRING_WITH_LEN("ST_SYMDIFFERENCE") }, GEOM_BUILDER(Create_func_symdifference)},
7485   { { STRING_WITH_LEN("ST_TOUCHES") }, GEOM_BUILDER(Create_func_touches)},
7486   { { STRING_WITH_LEN("ST_UNION") }, GEOM_BUILDER(Create_func_union)},
7487   { { STRING_WITH_LEN("ST_WITHIN") }, GEOM_BUILDER(Create_func_within)},
7488   { { STRING_WITH_LEN("ST_X") }, GEOM_BUILDER(Create_func_x)},
7489   { { STRING_WITH_LEN("ST_Y") }, GEOM_BUILDER(Create_func_y)},
7490   { { C_STRING_WITH_LEN("ST_DISTANCE_SPHERE") }, GEOM_BUILDER(Create_func_distance_sphere)},
7491   { { STRING_WITH_LEN("SUBSTR_ORACLE") },
7492       BUILDER(Create_func_substr_oracle)},
7493   { { STRING_WITH_LEN("SUBSTRING_INDEX") }, BUILDER(Create_func_substr_index)},
7494   { { STRING_WITH_LEN("SUBTIME") }, BUILDER(Create_func_subtime)},
7495   { { STRING_WITH_LEN("TAN") }, BUILDER(Create_func_tan)},
7496   { { STRING_WITH_LEN("TIMEDIFF") }, BUILDER(Create_func_timediff)},
7497   { { STRING_WITH_LEN("TIME_FORMAT") }, BUILDER(Create_func_time_format)},
7498   { { STRING_WITH_LEN("TIME_TO_SEC") }, BUILDER(Create_func_time_to_sec)},
7499   { { STRING_WITH_LEN("TOUCHES") }, GEOM_BUILDER(Create_func_touches)},
7500   { { STRING_WITH_LEN("TO_BASE64") }, BUILDER(Create_func_to_base64)},
7501   { { STRING_WITH_LEN("TO_DAYS") }, BUILDER(Create_func_to_days)},
7502   { { STRING_WITH_LEN("TO_SECONDS") }, BUILDER(Create_func_to_seconds)},
7503   { { STRING_WITH_LEN("UCASE") }, BUILDER(Create_func_ucase)},
7504   { { STRING_WITH_LEN("UNCOMPRESS") }, BUILDER(Create_func_uncompress)},
7505   { { STRING_WITH_LEN("UNCOMPRESSED_LENGTH") }, BUILDER(Create_func_uncompressed_length)},
7506   { { STRING_WITH_LEN("UNHEX") }, BUILDER(Create_func_unhex)},
7507   { { STRING_WITH_LEN("UNIX_TIMESTAMP") }, BUILDER(Create_func_unix_timestamp)},
7508   { { STRING_WITH_LEN("UPDATEXML") }, BUILDER(Create_func_xml_update)},
7509   { { STRING_WITH_LEN("UPPER") }, BUILDER(Create_func_ucase)},
7510   { { STRING_WITH_LEN("UUID") }, BUILDER(Create_func_uuid)},
7511   { { STRING_WITH_LEN("UUID_SHORT") }, BUILDER(Create_func_uuid_short)},
7512   { { STRING_WITH_LEN("VERSION") }, BUILDER(Create_func_version)},
7513   { { STRING_WITH_LEN("WEEKDAY") }, BUILDER(Create_func_weekday)},
7514   { { STRING_WITH_LEN("WEEKOFYEAR") }, BUILDER(Create_func_weekofyear)},
7515   { { STRING_WITH_LEN("WITHIN") }, GEOM_BUILDER(Create_func_within)},
7516 #ifdef WITH_WSREP
7517   { { STRING_WITH_LEN("WSREP_LAST_WRITTEN_GTID") }, BUILDER(Create_func_wsrep_last_written_gtid)},
7518   { { STRING_WITH_LEN("WSREP_LAST_SEEN_GTID") }, BUILDER(Create_func_wsrep_last_seen_gtid)},
7519   { { STRING_WITH_LEN("WSREP_SYNC_WAIT_UPTO_GTID") }, BUILDER(Create_func_wsrep_sync_wait_upto)},
7520 #endif /* WITH_WSREP */
7521   { { STRING_WITH_LEN("X") }, GEOM_BUILDER(Create_func_x)},
7522   { { STRING_WITH_LEN("Y") }, GEOM_BUILDER(Create_func_y)},
7523   { { STRING_WITH_LEN("YEARWEEK") }, BUILDER(Create_func_year_week)},
7524 
7525   { {0, 0}, NULL}
7526 };
7527 
7528 size_t func_array_length= sizeof(func_array) / sizeof(Native_func_registry) - 1;
7529 
7530 static HASH native_functions_hash;
7531 
7532 extern "C" uchar*
get_native_fct_hash_key(const uchar * buff,size_t * length,my_bool)7533 get_native_fct_hash_key(const uchar *buff, size_t *length,
7534                         my_bool /* unused */)
7535 {
7536   Native_func_registry *func= (Native_func_registry*) buff;
7537   *length= func->name.length;
7538   return (uchar*) func->name.str;
7539 }
7540 
7541 /*
7542   Load the hash table for native functions.
7543   Note: this code is not thread safe, and is intended to be used at server
7544   startup only (before going multi-threaded)
7545 */
7546 
item_create_init()7547 int item_create_init()
7548 {
7549   DBUG_ENTER("item_create_init");
7550 
7551   if (my_hash_init(& native_functions_hash,
7552                    system_charset_info,
7553                    array_elements(func_array),
7554                    0,
7555                    0,
7556                    (my_hash_get_key) get_native_fct_hash_key,
7557                    NULL,                          /* Nothing to free */
7558                    MYF(0)))
7559     DBUG_RETURN(1);
7560 
7561   DBUG_RETURN(item_create_append(func_array));
7562 }
7563 
item_create_append(Native_func_registry array[])7564 int item_create_append(Native_func_registry array[])
7565 {
7566   Native_func_registry *func;
7567 
7568   DBUG_ENTER("item_create_append");
7569 
7570   for (func= array; func->builder != NULL; func++)
7571   {
7572     if (my_hash_insert(& native_functions_hash, (uchar*) func))
7573       DBUG_RETURN(1);
7574   }
7575 
7576 #ifndef DBUG_OFF
7577   for (uint i=0 ; i < native_functions_hash.records ; i++)
7578   {
7579     func= (Native_func_registry*) my_hash_element(& native_functions_hash, i);
7580     DBUG_PRINT("info", ("native function: %s  length: %u",
7581                         func->name.str, (uint) func->name.length));
7582   }
7583 #endif
7584 
7585   DBUG_RETURN(0);
7586 }
7587 
item_create_remove(Native_func_registry array[])7588 int item_create_remove(Native_func_registry array[])
7589 {
7590   Native_func_registry *func;
7591 
7592   DBUG_ENTER("item_create_remove");
7593 
7594   for (func= array; func->builder != NULL; func++)
7595   {
7596     if (my_hash_delete(& native_functions_hash, (uchar*) func))
7597       DBUG_RETURN(1);
7598   }
7599 
7600   DBUG_RETURN(0);
7601 }
7602 
7603 /*
7604   Empty the hash table for native functions.
7605   Note: this code is not thread safe, and is intended to be used at server
7606   shutdown only (after thread requests have been executed).
7607 */
7608 
item_create_cleanup()7609 void item_create_cleanup()
7610 {
7611   DBUG_ENTER("item_create_cleanup");
7612   my_hash_free(& native_functions_hash);
7613   DBUG_VOID_RETURN;
7614 }
7615 
7616 Create_func *
find_native_function_builder(THD * thd,const LEX_CSTRING * name)7617 find_native_function_builder(THD *thd, const LEX_CSTRING *name)
7618 {
7619   Native_func_registry *func;
7620   Create_func *builder= NULL;
7621 
7622   /* Thread safe */
7623   func= (Native_func_registry*) my_hash_search(&native_functions_hash,
7624                                                (uchar*) name->str,
7625                                                name->length);
7626 
7627   if (func)
7628   {
7629     builder= func->builder;
7630   }
7631 
7632   return builder;
7633 }
7634 
7635 Create_qfunc *
find_qualified_function_builder(THD * thd)7636 find_qualified_function_builder(THD *thd)
7637 {
7638   return & Create_sp_func::s_singleton;
7639 }
7640 
7641 
create_func_dyncol_prepare(THD * thd,DYNCALL_CREATE_DEF ** dfs,List<DYNCALL_CREATE_DEF> & list)7642 static List<Item> *create_func_dyncol_prepare(THD *thd,
7643                                               DYNCALL_CREATE_DEF **dfs,
7644                                               List<DYNCALL_CREATE_DEF> &list)
7645 {
7646   DYNCALL_CREATE_DEF *def;
7647   List_iterator_fast<DYNCALL_CREATE_DEF> li(list);
7648   List<Item> *args= new (thd->mem_root) List<Item>;
7649 
7650   *dfs= (DYNCALL_CREATE_DEF *)alloc_root(thd->mem_root,
7651                                          sizeof(DYNCALL_CREATE_DEF) *
7652                                          list.elements);
7653 
7654   if (!args || !*dfs)
7655     return NULL;
7656 
7657   for (uint i= 0; (def= li++) ;)
7658   {
7659     dfs[0][i++]= *def;
7660     args->push_back(def->key, thd->mem_root);
7661     args->push_back(def->value, thd->mem_root);
7662   }
7663   return args;
7664 }
7665 
create_func_dyncol_create(THD * thd,List<DYNCALL_CREATE_DEF> & list)7666 Item *create_func_dyncol_create(THD *thd, List<DYNCALL_CREATE_DEF> &list)
7667 {
7668   List<Item> *args;
7669   DYNCALL_CREATE_DEF *dfs;
7670   if (!(args= create_func_dyncol_prepare(thd, &dfs, list)))
7671     return NULL;
7672 
7673   return new (thd->mem_root) Item_func_dyncol_create(thd, *args, dfs);
7674 }
7675 
create_func_dyncol_add(THD * thd,Item * str,List<DYNCALL_CREATE_DEF> & list)7676 Item *create_func_dyncol_add(THD *thd, Item *str,
7677                              List<DYNCALL_CREATE_DEF> &list)
7678 {
7679   List<Item> *args;
7680   DYNCALL_CREATE_DEF *dfs;
7681 
7682   if (!(args= create_func_dyncol_prepare(thd, &dfs, list)))
7683     return NULL;
7684 
7685   args->push_back(str, thd->mem_root);
7686 
7687   return new (thd->mem_root) Item_func_dyncol_add(thd, *args, dfs);
7688 }
7689 
7690 
7691 
create_func_dyncol_delete(THD * thd,Item * str,List<Item> & nums)7692 Item *create_func_dyncol_delete(THD *thd, Item *str, List<Item> &nums)
7693 {
7694   DYNCALL_CREATE_DEF *dfs;
7695   Item *key;
7696   List_iterator_fast<Item> it(nums);
7697   List<Item> *args= new (thd->mem_root) List<Item>;
7698 
7699   dfs= (DYNCALL_CREATE_DEF *)alloc_root(thd->mem_root,
7700                                         sizeof(DYNCALL_CREATE_DEF) *
7701                                         nums.elements);
7702   if (!args || !dfs)
7703     return NULL;
7704 
7705   for (uint i= 0; (key= it++); i++)
7706   {
7707     dfs[i].key= key;
7708     dfs[i].value= new (thd->mem_root) Item_null(thd);
7709     dfs[i].type= DYN_COL_INT;
7710     args->push_back(dfs[i].key, thd->mem_root);
7711     args->push_back(dfs[i].value, thd->mem_root);
7712   }
7713 
7714   args->push_back(str, thd->mem_root);
7715 
7716   return new (thd->mem_root) Item_func_dyncol_add(thd, *args, dfs);
7717 }
7718 
7719 
create_func_dyncol_get(THD * thd,Item * str,Item * num,const Type_handler * handler,const char * c_len,const char * c_dec,CHARSET_INFO * cs)7720 Item *create_func_dyncol_get(THD *thd,  Item *str, Item *num,
7721                              const Type_handler *handler,
7722                              const char *c_len, const char *c_dec,
7723                              CHARSET_INFO *cs)
7724 {
7725   Item *res;
7726 
7727   if (likely(!(res= new (thd->mem_root) Item_dyncol_get(thd, str, num))))
7728     return res;                                 // Return NULL
7729   return handler->create_typecast_item(thd, res,
7730                                        Type_cast_attributes(c_len, c_dec, cs));
7731 }
7732