MySQL 9.6.0
Source Code Documentation
item_func.h
Go to the documentation of this file.
1#ifndef ITEM_FUNC_INCLUDED
2#define ITEM_FUNC_INCLUDED
3
4/* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2.0,
8 as published by the Free Software Foundation.
9
10 This program is designed to work with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have either included with
16 the program or referenced in the documentation.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License, version 2.0, for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
26
27#include <sys/types.h>
28
29#include <climits>
30#include <cmath> // isfinite
31#include <cstddef>
32#include <functional>
33
34#include "decimal.h"
35#include "field_types.h"
36#include "ft_global.h"
37#include "lex_string.h"
38#include "my_alloc.h"
39#include "my_base.h"
40#include "my_compiler.h"
41#include "my_dbug.h"
42#include "my_inttypes.h"
44#include "my_table_map.h"
45#include "my_thread_local.h"
46#include "my_time.h"
50#include "mysql_time.h"
51#include "mysqld_error.h"
52#include "sql-common/my_decimal.h" // str2my_decimal
53#include "sql/enum_query_type.h"
54#include "sql/field.h"
55#include "sql/handler.h"
56#include "sql/item.h" // Item_result_field
57#include "sql/parse_location.h" // POS
58#include "sql/set_var.h" // enum_var_type
59#include "sql/sql_const.h"
60#include "sql/sql_udf.h" // udf_handler
61#include "sql/table.h"
62#include "sql/thr_malloc.h"
63#include "sql_string.h"
64#include "template_utils.h"
65
66class Json_wrapper;
67class PT_item_list;
68class Protocol;
69class Query_block;
70class THD;
71class sp_rcontext;
72class sp_instr;
73struct MY_BITMAP;
74struct Parse_context;
75struct TYPELIB;
76
77template <class T>
78class List;
79
80/* Function items used by mysql */
81
82void unsupported_json_comparison(size_t arg_count, Item **args,
83 const char *msg);
84
85void report_conversion_error(const CHARSET_INFO *to_cs, const char *from,
86 size_t from_length, const CHARSET_INFO *from_cs);
87
88bool simplify_string_args(THD *thd, const DTCollation &c, Item **items,
89 uint nitems);
90
92 String *buffer);
93
94inline String *eval_string_arg(const CHARSET_INFO *to_cs, Item *arg,
95 String *buffer) {
96 if (my_charset_same(to_cs, arg->collation.collation))
97 return arg->val_str(buffer);
98 return eval_string_arg_noinline(to_cs, arg, buffer);
99}
100
102 protected:
103 /**
104 Array of pointers to arguments. If there are max 2 arguments, this array
105 is often just m_embedded_arguments; otherwise it's explicitly allocated in
106 the constructor.
107 */
109
110 private:
112
113 /// Allocates space for the given number of arguments, if needed. Uses
114 /// #m_embedded_arguments if it's big enough.
115 bool alloc_args(MEM_ROOT *mem_root, unsigned num_args) {
116 if (num_args <= array_elements(m_embedded_arguments)) {
118 } else {
119 args = mem_root->ArrayAlloc<Item *>(num_args);
120 if (args == nullptr) {
121 // OOM
122 arg_count = 0;
123 return true;
124 }
125 }
126 arg_count = num_args;
127 return false;
128 }
129
130 public:
131 uint arg_count; ///< How many arguments in 'args'
132 virtual uint argument_count() const { return arg_count; }
133 inline Item **arguments() const {
134 return (argument_count() > 0) ? args : nullptr;
135 }
136 /*
137 This function is used to provide a unique textual name for the specific
138 subclass of Item_func. E.g, it returns "+" for the arithmetic addition
139 operator, "abs" for the absolute value function, "avg" for the average
140 aggregate function, etc. The function value is currently used to distinguish
141 Item_func subclasses from each other in Item_func::eq(),
142 since Item_func::functype() is not implemented for every subclass.
143 In addition, the function value is used when printing a textual
144 representation of a function reference, which is used within the dictionary
145 implementation and when printing SQL text for explain purposes.
146 Note that for calls to stored functions and UDF functions, func_name()
147 returns the name of the function. This may overlap with the name of an
148 internal function, thus the functype() must be used together with
149 func_name() to get a unique function reference.
150 For runtime type identification, it is adviced to use Item_func::functype()
151 and Item_sum::sum_func() instead.
152 The value is returned in ASCII character set, except for user-defined
153 functions, whose names are returned in the system character set.
154 */
155 virtual const char *func_name() const = 0;
156
157 bool reject_vector_args();
158 uint num_vector_args();
160
161 protected:
162 /*
163 These decide of types of arguments which are prepared-statement
164 parameters.
165 */
168 bool param_type_is_default(THD *thd, uint start, uint end, uint step,
169 enum_field_types def);
170 bool param_type_is_default(THD *thd, uint start, uint end,
172 return param_type_is_default(thd, start, end, 1, def);
173 }
174 bool param_type_is_rejected(uint start, uint end);
175
176 /**
177 Affects how to determine that NULL argument implies a NULL function return.
178 Default behaviour in this class is:
179 - if true, any NULL argument means the function returns NULL.
180 - if false, no such assumption is made and not_null_tables_cache is thus
181 set to 0.
182 null_on_null is true for all Item_func derived classes, except Item_func_sp,
183 all CASE derived functions and a few other functions.
184 RETURNS NULL ON NULL INPUT can be implemented for stored functions by
185 modifying this member in class Item_func_sp.
186 */
187 bool null_on_null{true};
188 /*
189 Allowed numbers of columns in result (usually 1, which means scalar value)
190 0 means get this number from first argument
191 */
193 /// Value used in calculation of result of used_tables()
195 /// Value used in calculation of result of not_null_tables()
197
198 uint64_t hash(bool commutative_args);
199
200 uint64_t hash_args(bool commutative) const;
201
202 public:
203 bool is_null_on_null() const { return null_on_null; }
204
205 /*
206 When updating Functype with new spatial functions,
207 is_spatial_operator() should also be updated.
208
209 DD_INTERNAL_FUNC:
210 Some of the internal functions introduced for the INFORMATION_SCHEMA views
211 opens data-dictionary tables. DD_INTERNAL_FUNC is used for the such type
212 of functions.
213 */
214 enum Functype {
365 };
372 };
373 enum Type type() const override { return FUNC_ITEM; }
374 virtual enum Functype functype() const { return UNKNOWN_FUNC; }
376
377 explicit Item_func(const POS &pos)
379
381 args[0] = a;
383 }
384 Item_func(const POS &pos, Item *a)
386 args[0] = a;
387 }
388
390 args[0] = a;
391 args[1] = b;
395 }
396 Item_func(const POS &pos, Item *a, Item *b)
398 args[0] = a;
399 args[1] = b;
400 }
401
402 Item_func(Item *a, Item *b, Item *c) {
403 if (alloc_args(*THR_MALLOC, 3)) return;
404 args[0] = a;
405 args[1] = b;
406 args[2] = c;
411 }
412
413 Item_func(const POS &pos, Item *a, Item *b, Item *c)
414 : Item_result_field(pos) {
415 if (alloc_args(*THR_MALLOC, 3)) return;
416 args[0] = a;
417 args[1] = b;
418 args[2] = c;
419 }
420
421 Item_func(Item *a, Item *b, Item *c, Item *d) {
422 if (alloc_args(*THR_MALLOC, 4)) return;
423 args[0] = a;
424 args[1] = b;
425 args[2] = c;
426 args[3] = d;
432 }
433
434 Item_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
435 : Item_result_field(pos) {
436 if (alloc_args(*THR_MALLOC, 4)) return;
437 args[0] = a;
438 args[1] = b;
439 args[2] = c;
440 args[3] = d;
441 }
442 Item_func(Item *a, Item *b, Item *c, Item *d, Item *e) {
443 if (alloc_args(*THR_MALLOC, 5)) return;
444 args[0] = a;
445 args[1] = b;
446 args[2] = c;
447 args[3] = d;
448 args[4] = e;
455 }
456 Item_func(const POS &pos, Item *a, Item *b, Item *c, Item *d, Item *e)
457 : Item_result_field(pos) {
458 if (alloc_args(*THR_MALLOC, 5)) return;
459 args[0] = a;
460 args[1] = b;
461 args[2] = c;
462 args[3] = d;
463 args[4] = e;
464 }
465 Item_func(Item *a, Item *b, Item *c, Item *d, Item *e, Item *f) {
466 if (alloc_args(*THR_MALLOC, 6)) return;
467 args[0] = a;
468 args[1] = b;
469 args[2] = c;
470 args[3] = d;
471 args[4] = e;
472 args[5] = f;
480 }
481 Item_func(const POS &pos, Item *a, Item *b, Item *c, Item *d, Item *e,
482 Item *f)
483 : Item_result_field(pos) {
484 if (alloc_args(*THR_MALLOC, 6)) return;
485 args[0] = a;
486 args[1] = b;
487 args[2] = c;
488 args[3] = d;
489 args[4] = e;
490 args[5] = f;
491 }
493 set_arguments(list, false);
494 }
495
496 Item_func(const POS &pos, PT_item_list *opt_list);
497
498 // Constructor used for Item_cond_and/or (see Item comment)
499 Item_func(THD *thd, const Item_func *item);
500
501 /// Get the i'th argument of the function that this object represents.
502 virtual Item *get_arg(uint i) { return args[i]; }
503
504 /// Get the i'th argument of the function that this object represents.
505 virtual const Item *get_arg(uint i) const { return args[i]; }
506 virtual Item *set_arg(THD *, uint, Item *) {
507 assert(0);
508 return nullptr;
509 }
510
511 bool do_itemize(Parse_context *pc, Item **res) override;
512
513 bool fix_fields(THD *, Item **ref) override;
514 bool fix_func_arg(THD *, Item **arg);
515 void fix_after_pullout(Query_block *parent_query_block,
516 Query_block *removed_query_block) override;
517 /**
518 Resolve type of function after all arguments have had their data types
519 resolved. Called from resolve_type() when no dynamic parameters
520 are used and from propagate_type() otherwise.
521 */
522 virtual bool resolve_type_inner(THD *) {
523 assert(false);
524 return false;
525 }
526 bool propagate_type(THD *thd, const Type_properties &type) override;
527 /**
528 Returns the pseudo tables depended upon in order to evaluate this
529 function expression. The default implementation returns the empty
530 set.
531 */
532 virtual table_map get_initial_pseudo_tables() const { return 0; }
533 table_map used_tables() const override { return used_tables_cache; }
535 void update_used_tables() override;
537 bool eq(const Item *item) const override;
538 /**
539 Provide a more specific equality check for a function.
540 Combine with Item::eq() to implement a complete equality check.
541 */
542 virtual bool eq_specific(const Item *) const { return true; }
543 virtual optimize_type select_optimize(const THD *) { return OPTIMIZE_NONE; }
544 virtual bool have_rev_func() const { return false; }
545 virtual Item *key_item() const { return args[0]; }
546 /**
547 Copy arguments from list to args array
548
549 @param list function argument list
550 @param context_free true: for use in context-independent
551 constructors (Item_func(POS,...)) i.e. for use
552 in the parser
553 @return true on OOM, false otherwise
554 */
555 bool set_arguments(mem_root_deque<Item *> *list, bool context_free);
556 bool split_sum_func(THD *thd, Ref_item_array ref_item_array,
557 mem_root_deque<Item *> *fields) override;
558 void print(const THD *thd, String *str,
559 enum_query_type query_type) const override;
560
561 uint64_t hash() override;
562 void print_op(const THD *thd, String *str, enum_query_type query_type) const;
563 void print_args(const THD *thd, String *str, uint from,
564 enum_query_type query_type) const;
565 virtual void fix_num_length_and_dec();
566 virtual bool is_deprecated() const { return false; }
568 return (null_value = args[0]->val_date(date, flags));
569 }
571 return (null_value = args[0]->val_datetime(dt, flags));
572 }
574 return (null_value = args[0]->val_time(time));
575 }
576 bool is_null() override { return update_null_value() || null_value; }
579 friend class udf_handler;
580 Field *tmp_table_field(TABLE *t_arg) override;
581 Item *get_tmp_table_item(THD *thd) override;
582
583 void raise_temporal_overflow(const char *type_name);
584
585 my_decimal *val_decimal(my_decimal *) override;
586
587 /*
588 Aggregate arguments for string result, e.g: CONCAT(a,b)
589 - convert to @@character_set_connection if all arguments are numbers
590 - allow DERIVATION_NONE
591 */
593 uint nitems) {
594 return agg_item_charsets_for_string_result(c, func_name(), items, nitems);
595 }
596 /*
597 Aggregate arguments for comparison, e.g: a=b, a LIKE b, a RLIKE b
598 - don't convert to @@character_set_connection if all arguments are numbers
599 - don't allow DERIVATION_NONE
600 */
602 uint nitems) {
603 return agg_item_charsets_for_comparison(c, func_name(), items, nitems);
604 }
605
606 Item *replace_func_call(uchar *) override;
607
608 bool walk(Item_processor processor, enum_walk walk, uchar *arg) override;
609 Item *transform(Item_transformer transformer, uchar *arg) override;
610 Item *compile(Item_analyzer analyzer, uchar **arg_p,
611 Item_transformer transformer, uchar *arg_t) override;
612 void traverse_cond(Cond_traverser traverser, void *arg,
613 traverse_order order) override;
614
615 bool replace_equal_field_checker(uchar **arg) override {
616 Replace_equal *replace = pointer_cast<Replace_equal *>(*arg);
617 replace->stack.push_front(this);
618 return true;
619 }
620
622 pointer_cast<Replace_equal *>(arg)->stack.pop();
623 return this;
624 }
625
626 /**
627 Check whether a function allows replacement of a field with another item:
628 In particular, a replacement that changes the metadata of some Item
629 from non-nullable to nullable is not allowed.
630 Notice that e.g. changing the nullability of an operand of a comparison
631 operator in a WHERE clause that ignores UNKNOWN values is allowed,
632 according to this criterion.
633
634 @param original the field that could be replaced
635 @param subst the item that could be the replacement
636
637 @returns true if replacement is allowed, false otherwise
638 */
639 virtual bool allow_replacement(Item_field *const original,
640 Item *const subst) {
641 return original->is_nullable() || !subst->is_nullable();
642 }
643
644 /**
645 Throw an error if the input double number is not finite, i.e. is either
646 +/-INF or NAN.
647 */
648 inline double check_float_overflow(double value) {
649 return std::isfinite(value) ? value : raise_float_overflow();
650 }
651 /**
652 Throw an error if the input BIGINT value represented by the
653 (longlong value, bool unsigned flag) pair cannot be returned by the
654 function, i.e. is not compatible with this Item's unsigned_flag.
655 */
656 inline longlong check_integer_overflow(longlong value, bool val_unsigned) {
657 if ((unsigned_flag && !val_unsigned && value < 0) ||
658 (!unsigned_flag && val_unsigned &&
659 (ulonglong)value > (ulonglong)LLONG_MAX))
660 return raise_integer_overflow();
661 return value;
662 }
663 /**
664 Throw an error if the error code of a DECIMAL operation is E_DEC_OVERFLOW.
665 */
668 }
669
671 assert(fixed);
672 for (uint i = 0; i < arg_count; i++) {
673 if (args[i]->type() == Item::FIELD_ITEM &&
675 return true;
676 }
677 return false;
678 }
679
681 assert(fixed);
682 for (uint i = 0; i < arg_count; i++) {
683 if (args[i]->type() == Item::FIELD_ITEM &&
684 (args[i]->data_type() == MYSQL_TYPE_DATE ||
686 return true;
687 }
688 return false;
689 }
690
692 assert(fixed);
693 for (uint i = 0; i < arg_count; i++) {
694 if (args[i]->type() == Item::FIELD_ITEM &&
695 (args[i]->data_type() == MYSQL_TYPE_TIME ||
697 return true;
698 }
699 return false;
700 }
701
703 assert(fixed);
704 for (uint i = 0; i < arg_count; i++) {
705 if (args[i]->type() == Item::FIELD_ITEM &&
707 return true;
708 }
709 return false;
710 }
711
712 /*
713 We assume the result of any function that has a TIMESTAMP argument to be
714 timezone-dependent, since a TIMESTAMP value in both numeric and string
715 contexts is interpreted according to the current timezone.
716 The only exception is UNIX_TIMESTAMP() which returns the internal
717 representation of a TIMESTAMP argument verbatim, and thus does not depend on
718 the timezone.
719 */
721 return has_timestamp_args();
722 }
723
724 Item *gc_subst_transformer(uchar *arg) override;
725
726 bool resolve_type(THD *thd) override {
727 // By default, pick PS-param's type from other arguments, or VARCHAR
728 return param_type_uses_non_param(thd);
729 }
730
731 /**
732 Whether an arg of a JSON function can be cached to avoid repetitive
733 string->JSON conversion. This function returns true only for those args,
734 which are the source of JSON data. JSON path args are cached independently
735 and for them this function returns false. Same as for all other type of
736 args.
737
738 @param arg the arg to cache
739
740 @retval true arg can be cached
741 @retval false otherwise
742 */
743 virtual enum_const_item_cache can_cache_json_arg(Item *arg [[maybe_unused]]) {
744 return CACHE_NONE;
745 }
746
747 /// Whether this Item is an equi-join condition. If this Item is a compound
748 /// item (i.e. multiple condition AND'ed together), it will only return true
749 /// if the Item contains only equi-join conditions AND'ed together. This is
750 /// used to determine whether the condition can be used as a join condition
751 /// for hash join (join conditions in hash join must be equi-join conditions),
752 /// or if it should be placed as a filter after the join.
753 virtual bool contains_only_equi_join_condition() const { return false; }
754
755 protected:
756 /**
757 Whether or not an item should contribute to the filtering effect
758 (@see get_filtering_effect()). First it verifies that table
759 requirements are satisfied as follows:
760
761 1) The item must refer to a field in 'filter_for_table' in some
762 way. This reference may be indirect through any number of
763 intermediate items. For example, this item may be an
764 Item_cond_and which refers to an Item_func_eq which refers to
765 the field.
766 2) The item must not refer to other tables than those already
767 read and the table in 'filter_for_table'
768
769 Then it contines to other properties as follows:
770
771 Item_funcs represent "<operand1> OP <operand2> [OP ...]". If the
772 Item_func is to contribute to the filtering effect, then
773
774 1) one of the operands must be a field from 'filter_for_table' that is not
775 in 'fields_to_ignore', and
776 2) depending on the Item_func type filtering effect is calculated
777 for, one or all [1] of the other operand(s) must be an available
778 value, i.e.:
779 - a constant, or
780 - a constant subquery, or
781 - a field value read from a table in 'read_tables', or
782 - a second field in 'filter_for_table', or
783 - a function that only refers to constants or tables in
784 'read_tables', or
785 - special case: an implicit value like NULL in the case of
786 "field IS NULL". Such Item_funcs have arg_count==1.
787
788 [1] "At least one" for multiple equality (X = Y = Z = ...), "all"
789 for the rest (e.g. BETWEEN)
790
791 @param thd The current thread.
792 @param read_tables Tables earlier in the join sequence.
793 Predicates for table 'filter_for_table' that
794 rely on values from these tables can be part of
795 the filter effect.
796 @param filter_for_table The table we are calculating filter effect for
797 @param fields_to_ignore Columns that should be ignored.
798
799
800 @return Item_field that participates in the predicate if none of the
801 requirements are broken, NULL otherwise
802
803 @note: This function only applies to items doing comparison, i.e.
804 boolean predicates. Unfortunately, some of those items do not
805 inherit from Item_bool_func so the member function has to be
806 placed in Item_func.
807 */
809 THD *thd, table_map read_tables, table_map filter_for_table,
810 const MY_BITMAP *fields_to_ignore) const;
811 /**
812 Named parameters are allowed in a parameter list
813
814 The syntax to name parameters in a function call is as follow:
815 <code>foo(expr AS named, expr named, expr AS "named", expr "named")</code>
816 where "AS" is optional.
817 Only UDF function support that syntax.
818
819 @return true if the function item can have named parameters
820 */
821 virtual bool may_have_named_parameters() const { return false; }
822 bool is_non_const_over_literals(uchar *) override { return false; }
823
824 bool check_function_as_value_generator(uchar *checker_args) override {
825 if (is_deprecated()) {
827 pointer_cast<Check_function_as_value_generator_parameters *>(
828 checker_args);
829 func_arg->banned_function_name = func_name();
830 return true;
831 }
832 return false;
833 }
834 bool is_valid_for_pushdown(uchar *arg) override;
835 bool check_column_in_window_functions(uchar *arg) override;
836 bool check_column_in_group_by(uchar *arg) override;
837
839};
840
841class Item_real_func : public Item_func {
842 public:
844 explicit Item_real_func(const POS &pos) : Item_func(pos) {
846 }
847
849 Item_real_func(const POS &pos, Item *a) : Item_func(pos, a) {
851 }
852
854
855 Item_real_func(const POS &pos, Item *a, Item *b) : Item_func(pos, a, b) {
857 }
858
861 }
862
865 }
866
867 String *val_str(String *str) override;
868 my_decimal *val_decimal(my_decimal *decimal_value) override;
869 longlong val_int() override {
870 assert(fixed);
872 }
873 bool val_date(Date_val *date, my_time_flags_t flags) override {
874 return get_date_from_real(date, flags);
875 }
876 bool val_time(Time_val *time) override { return get_time_from_real(time); }
878 return get_datetime_from_real(dt, flags);
879 }
880 enum Item_result result_type() const override { return REAL_RESULT; }
881};
882
884 protected:
886
887 public:
890 }
892 : Item_func(pos, a), hybrid_type(REAL_RESULT) {
894 }
895
899 }
900 Item_func_numhybrid(const POS &pos, Item *a, Item *b)
901 : Item_func(pos, a, b), hybrid_type(REAL_RESULT) {
903 }
904
908 }
912 }
913
914 enum Item_result result_type() const override { return hybrid_type; }
916 return MYSQL_TYPE_DOUBLE;
917 }
918 bool resolve_type(THD *thd) override;
919 bool resolve_type_inner(THD *thd) override;
920 void fix_num_length_and_dec() override;
921 virtual void set_numeric_type() = 0; // To be called from resolve_type()
922
923 double val_real() override;
924 longlong val_int() override;
925 my_decimal *val_decimal(my_decimal *) override;
926 String *val_str(String *str) override;
927 bool val_date(Date_val *date, my_time_flags_t flags) override;
928 bool val_time(Time_val *time) override;
930 /**
931 Evaluates item when resulting data type is integer type
932
933 @returns The result of the operation (0 when error or result is NULL)
934 */
935 virtual longlong int_op() = 0;
936 /**
937 Evaluates item when resulting data type is floating point type
938
939 @returns The result of the operation (0.0 when error or result is NULL)
940 */
941 virtual double real_op() = 0;
942 /**
943 Evaluates item when resulting data type is DECIMAL
944
945 @param[out] decimal_value Buffer into which decimal value is stored
946 @returns nullptr if error or result is NULL, otherwise pointer to result
947 */
948 virtual my_decimal *decimal_op(my_decimal *decimal_value) = 0;
949 /**
950 Evaluates item when resulting data type is a string type
951
952 @param[out] string string evaluation buffer
953 @returns nullptr if error or result is NULL, otherwise pointer to result
954 */
955 virtual String *str_op(String *string) = 0;
956 /**
957 Evaluates item when resulting data type is DATE
958
959 @param[out] date resulting date value when return value is false
960 @param flags flags for handling invalid date values
961 @returns true if error or result is NULL, false if non-NULL result
962 */
963 virtual bool date_op(Date_val *date, my_time_flags_t flags) = 0;
964 /**
965 Evaluates item when resulting data type is TIME
966
967 @param[out] time resulting time value when return value is false
968 @returns true if error or result is NULL, false if non-NULL result
969 */
970 virtual bool time_op(Time_val *time) = 0;
971 /**
972 Evaluates item when resulting data type is DATETIME or TIMESTAMP
973
974 @param[out] dt resulting datetime value when return value is false
975 @param flags flags for handling invalid date values
976 @returns true if error or result is NULL, false if non-NULL result
977 */
979
980 bool is_null() override { return update_null_value() || null_value; }
981};
982
983/* function where type of result detected by first argument */
985 public:
987 Item_func_num1(const POS &pos, Item *a) : Item_func_numhybrid(pos, a) {}
988
990 Item_func_num1(const POS &pos, Item *a, Item *b)
991 : Item_func_numhybrid(pos, a, b) {}
992
993 void fix_num_length_and_dec() override;
994 void set_numeric_type() override;
995 String *str_op(String *) override {
996 assert(false);
997 return nullptr;
998 }
999 bool date_op(Date_val *, my_time_flags_t) override {
1000 assert(false);
1001 return false;
1002 }
1003 bool time_op(Time_val *) override {
1004 assert(false);
1005 return false;
1006 }
1008 assert(false);
1009 return false;
1010 }
1011};
1012
1013/* Base class for operations like '+', '-', '*' */
1015 public:
1017 Item_num_op(const POS &pos, Item *a, Item *b)
1018 : Item_func_numhybrid(pos, a, b) {}
1019
1020 virtual void result_precision() = 0;
1021
1022 void print(const THD *thd, String *str,
1023 enum_query_type query_type) const override {
1024 print_op(thd, str, query_type);
1025 }
1026
1027 void set_numeric_type() override;
1028 String *str_op(String *) override {
1029 assert(false);
1030 return nullptr;
1031 }
1033 assert(false);
1034 return false;
1035 }
1036 bool time_op(Time_val *) override {
1037 assert(false);
1038 return false;
1039 }
1041 assert(false);
1042 return false;
1043 }
1044};
1045
1046class Item_int_func : public Item_func {
1047 public:
1049 explicit Item_int_func(const POS &pos) : Item_func(pos) {
1051 }
1052
1054 Item_int_func(const POS &pos, Item *a) : Item_func(pos, a) {
1056 }
1057
1060 }
1061 Item_int_func(const POS &pos, Item *a, Item *b) : Item_func(pos, a, b) {
1063 }
1064
1065 Item_int_func(Item *a, Item *b, Item *c) : Item_func(a, b, c) {
1067 }
1068 Item_int_func(const POS &pos, Item *a, Item *b, Item *c)
1069 : Item_func(pos, a, b, c) {
1071 }
1072
1073 Item_int_func(Item *a, Item *b, Item *c, Item *d) : Item_func(a, b, c, d) {
1075 }
1076 Item_int_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
1077 : Item_func(pos, a, b, c, d) {
1079 }
1080
1083 }
1084 Item_int_func(const POS &pos, PT_item_list *opt_list)
1085 : Item_func(pos, opt_list) {
1087 }
1088
1089 Item_int_func(THD *thd, Item_int_func *item) : Item_func(thd, item) {
1091 }
1092 double val_real() override;
1093 String *val_str(String *str) override;
1094 bool val_date(Date_val *date, my_time_flags_t flags) override {
1095 return get_date_from_int(date, flags);
1096 }
1097 bool val_time(Time_val *time) override { return get_time_from_int(time); }
1099 return get_datetime_from_int(dt, flags);
1100 }
1101 enum Item_result result_type() const override { return INT_RESULT; }
1102 /*
1103 Concerning PS-param types,
1104 resolve_type(THD *) is not overridden here, as experience shows that for
1105 most child classes of this class, VARCHAR is the best default
1106 */
1107};
1108
1111
1112 public:
1114
1116 return INNER_TABLE_BIT;
1117 }
1118 bool do_itemize(Parse_context *pc, Item **res) override;
1119 const char *func_name() const override { return "connection_id"; }
1120 bool resolve_type(THD *thd) override;
1121 bool fix_fields(THD *thd, Item **ref) override;
1122 longlong val_int() override;
1123 bool check_function_as_value_generator(uchar *checker_args) override {
1125 pointer_cast<Check_function_as_value_generator_parameters *>(
1126 checker_args);
1127 func_arg->banned_function_name = func_name();
1128 return ((func_arg->source == VGS_GENERATED_COLUMN) ||
1129 (func_arg->source == VGS_CHECK_CONSTRAINT));
1130 }
1131};
1132
1134 public:
1135 Item_typecast_signed(const POS &pos, Item *a) : Item_int_func(pos, a) {
1136 unsigned_flag = false;
1137 }
1138 const char *func_name() const override { return "cast_as_signed"; }
1139 longlong val_int() override;
1140 bool resolve_type(THD *thd) override;
1141 void print(const THD *thd, String *str,
1142 enum_query_type query_type) const override;
1143 enum Functype functype() const override { return TYPECAST_FUNC; }
1144};
1145
1147 public:
1148 Item_typecast_unsigned(const POS &pos, Item *a) : Item_int_func(pos, a) {
1149 unsigned_flag = true;
1150 }
1151 const char *func_name() const override { return "cast_as_unsigned"; }
1152 longlong val_int() override;
1153 bool resolve_type(THD *thd) override;
1154 void print(const THD *thd, String *str,
1155 enum_query_type query_type) const override;
1156 enum Functype functype() const override { return TYPECAST_FUNC; }
1157};
1158
1159class Item_typecast_decimal final : public Item_func {
1160 protected:
1161 void add_json_info(Json_object *obj) override;
1162
1163 public:
1164 Item_typecast_decimal(const POS &pos, Item *a, int len, int dec)
1165 : Item_func(pos, a) {
1167 }
1168 String *val_str(String *str) override;
1169 double val_real() override;
1170 longlong val_int() override;
1171 bool val_date(Date_val *date, my_time_flags_t flags) override {
1172 return get_date_from_decimal(date, flags);
1173 }
1174 bool val_time(Time_val *time) override { return get_time_from_decimal(time); }
1176 return get_datetime_from_decimal(dt, flags);
1177 }
1178 my_decimal *val_decimal(my_decimal *) override;
1179 enum Item_result result_type() const override { return DECIMAL_RESULT; }
1180 bool resolve_type(THD *thd) override {
1181 if (reject_vector_args()) return true;
1182 if (args[0]->propagate_type(thd, MYSQL_TYPE_NEWDECIMAL, false, true))
1183 return true;
1184 return false;
1185 }
1186 const char *func_name() const override { return "cast_as_decimal"; }
1187 enum Functype functype() const override { return TYPECAST_FUNC; }
1188 void print(const THD *thd, String *str,
1189 enum_query_type query_type) const override;
1190 uint64_t hash() override;
1191};
1192
1193/**
1194 Class used to implement CAST to floating-point data types.
1195*/
1196class Item_typecast_real final : public Item_func {
1197 protected:
1198 void add_json_info(Json_object *obj) override {
1199 obj->add_alias("is_double", create_dom_ptr<Json_boolean>(
1201 }
1202
1203 public:
1204 Item_typecast_real(const POS &pos, Item *a, bool as_double)
1205 : Item_func(pos, a) {
1206 if (as_double)
1208 else
1210 }
1212 String *val_str(String *str) override;
1213 double val_real() override;
1214 longlong val_int() override { return val_int_from_real(); }
1215 bool val_date(Date_val *date, my_time_flags_t flags) override;
1216 bool val_time(Time_val *time) override;
1217 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1218 my_decimal *val_decimal(my_decimal *decimal_value) override;
1219 enum Item_result result_type() const override { return REAL_RESULT; }
1220 bool resolve_type(THD *thd) override {
1221 if (reject_vector_args()) return true;
1222 return args[0]->propagate_type(thd, MYSQL_TYPE_DOUBLE, false, true);
1223 }
1224 const char *func_name() const override { return "cast_as_real"; }
1225 enum Functype functype() const override { return TYPECAST_FUNC; }
1226 void print(const THD *thd, String *str,
1227 enum_query_type query_type) const override;
1228};
1229
1231 public:
1234 : Item_num_op(pos, a, b) {}
1235
1236 void result_precision() override;
1237 bool check_partition_func_processor(uchar *) override { return false; }
1238 bool check_function_as_value_generator(uchar *) override { return false; }
1239};
1240
1242 public:
1244 Item_func_plus(const POS &pos, Item *a, Item *b)
1245 : Item_func_additive_op(pos, a, b) {}
1246
1247 const char *func_name() const override { return "+"; }
1248
1249 // SUPPRESS_UBSAN: signed integer overflow
1250 longlong int_op() override SUPPRESS_UBSAN;
1251 uint64_t hash() override { return Item_func::hash(true); }
1252 double real_op() override;
1253 my_decimal *decimal_op(my_decimal *) override;
1254 enum Functype functype() const override { return PLUS_FUNC; }
1255};
1256
1258 public:
1260 Item_func_minus(const POS &pos, Item *a, Item *b)
1261 : Item_func_additive_op(pos, a, b) {}
1262
1263 const char *func_name() const override { return "-"; }
1264
1265 // SUPPRESS_UBSAN: signed integer overflow
1266 longlong int_op() override SUPPRESS_UBSAN;
1267
1268 double real_op() override;
1269 my_decimal *decimal_op(my_decimal *) override;
1270 bool resolve_type(THD *thd) override;
1271 enum Functype functype() const override { return MINUS_FUNC; }
1272};
1273
1274class Item_func_mul final : public Item_num_op {
1275 public:
1277 Item_func_mul(const POS &pos, Item *a, Item *b) : Item_num_op(pos, a, b) {}
1278
1279 const char *func_name() const override { return "*"; }
1280 longlong int_op() override;
1281 double real_op() override;
1282 uint64_t hash() override { return Item_func::hash(true); }
1283 my_decimal *decimal_op(my_decimal *) override;
1284 void result_precision() override;
1285 bool check_partition_func_processor(uchar *) override { return false; }
1286 bool check_function_as_value_generator(uchar *) override { return false; }
1287 enum Functype functype() const override { return MUL_FUNC; }
1288};
1289
1291 public:
1292 Item_func_div_base(const POS &pos, Item *a, Item *b)
1293 : Item_num_op(pos, a, b) {}
1295 longlong int_op() override;
1296 double real_op() override;
1297 my_decimal *decimal_op(my_decimal *) override;
1298 enum Functype functype() const override { return DIV_FUNC; }
1299
1300 protected:
1302};
1303
1304class Item_func_div final : public Item_func_div_base {
1305 public:
1306 Item_func_div(const POS &pos, Item *a, Item *b)
1307 : Item_func_div_base(pos, a, b) {}
1308 const char *func_name() const override { return "/"; }
1309 bool resolve_type(THD *thd) override;
1310 void result_precision() override;
1311};
1312
1314 public:
1316 Item_func_div_int(const POS &pos, Item *a, Item *b)
1317 : Item_func_div_base(pos, a, b) {}
1318 const char *func_name() const override { return "DIV"; }
1320 return MYSQL_TYPE_LONGLONG;
1321 }
1322 bool resolve_type(THD *thd) override;
1323 void result_precision() override;
1324 void set_numeric_type() override;
1325 bool check_partition_func_processor(uchar *) override { return false; }
1326 bool check_function_as_value_generator(uchar *) override { return false; }
1327};
1328
1329class Item_func_mod final : public Item_num_op {
1330 public:
1332 Item_func_mod(const POS &pos, Item *a, Item *b) : Item_num_op(pos, a, b) {}
1333
1334 longlong int_op() override;
1335 double real_op() override;
1336 my_decimal *decimal_op(my_decimal *) override;
1337 const char *func_name() const override { return "%"; }
1338 void result_precision() override;
1339 bool resolve_type(THD *thd) override;
1340 bool check_partition_func_processor(uchar *) override { return false; }
1341 bool check_function_as_value_generator(uchar *) override { return false; }
1342 enum Functype functype() const override { return MOD_FUNC; }
1343};
1344
1345class Item_func_neg final : public Item_func_num1 {
1346 public:
1348 Item_func_neg(const POS &pos, Item *a) : Item_func_num1(pos, a) {}
1349
1350 double real_op() override;
1351 longlong int_op() override;
1352 my_decimal *decimal_op(my_decimal *) override;
1353 const char *func_name() const override { return "-"; }
1354 enum Functype functype() const override { return NEG_FUNC; }
1355 bool resolve_type(THD *thd) override;
1356 void fix_num_length_and_dec() override;
1357 bool check_partition_func_processor(uchar *) override { return false; }
1358 bool check_function_as_value_generator(uchar *) override { return false; }
1359};
1360
1361class Item_func_abs final : public Item_func_num1 {
1362 public:
1363 Item_func_abs(const POS &pos, Item *a) : Item_func_num1(pos, a) {}
1364 double real_op() override;
1365 longlong int_op() override;
1366 my_decimal *decimal_op(my_decimal *) override;
1367 const char *func_name() const override { return "abs"; }
1368 bool resolve_type(THD *) override;
1369 bool check_partition_func_processor(uchar *) override { return false; }
1370 bool check_function_as_value_generator(uchar *) override { return false; }
1371 enum Functype functype() const override { return ABS_FUNC; }
1372};
1373
1374// A class to handle logarithmic and trigonometric functions
1375
1377 public:
1379 Item_dec_func(const POS &pos, Item *a) : Item_real_func(pos, a) {}
1380
1381 Item_dec_func(const POS &pos, Item *a, Item *b) : Item_real_func(pos, a, b) {}
1382 bool resolve_type(THD *thd) override;
1383};
1384
1385class Item_func_exp final : public Item_dec_func {
1386 public:
1387 Item_func_exp(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1388 double val_real() override;
1389 const char *func_name() const override { return "exp"; }
1390 enum Functype functype() const override { return EXP_FUNC; }
1391};
1392
1393class Item_func_ln final : public Item_dec_func {
1394 public:
1395 Item_func_ln(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1396 double val_real() override;
1397 const char *func_name() const override { return "ln"; }
1398 enum Functype functype() const override { return LN_FUNC; }
1399};
1400
1401class Item_func_log final : public Item_dec_func {
1402 public:
1403 Item_func_log(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1404 Item_func_log(const POS &pos, Item *a, Item *b) : Item_dec_func(pos, a, b) {}
1405 double val_real() override;
1406 const char *func_name() const override { return "log"; }
1407 enum Functype functype() const override { return LOG_FUNC; }
1408};
1409
1410class Item_func_log2 final : public Item_dec_func {
1411 public:
1412 Item_func_log2(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1413 double val_real() override;
1414 const char *func_name() const override { return "log2"; }
1415};
1416
1417class Item_func_log10 final : public Item_dec_func {
1418 public:
1419 Item_func_log10(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1420 double val_real() override;
1421 const char *func_name() const override { return "log10"; }
1422 enum Functype functype() const override { return LOG10_FUNC; }
1423};
1424
1425class Item_func_sqrt final : public Item_dec_func {
1426 public:
1427 Item_func_sqrt(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1428 double val_real() override;
1429 const char *func_name() const override { return "sqrt"; }
1430 enum Functype functype() const override { return SQRT_FUNC; }
1431};
1432
1433class Item_func_pow final : public Item_dec_func {
1434 public:
1435 Item_func_pow(const POS &pos, Item *a, Item *b) : Item_dec_func(pos, a, b) {}
1436 double val_real() override;
1437 const char *func_name() const override { return "pow"; }
1438 enum Functype functype() const override { return POW_FUNC; }
1439};
1440
1441class Item_func_acos final : public Item_dec_func {
1442 public:
1443 Item_func_acos(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1444 double val_real() override;
1445 const char *func_name() const override { return "acos"; }
1446 enum Functype functype() const override { return ACOS_FUNC; }
1447};
1448
1449class Item_func_asin final : public Item_dec_func {
1450 public:
1451 Item_func_asin(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1452 double val_real() override;
1453 const char *func_name() const override { return "asin"; }
1454 enum Functype functype() const override { return ASIN_FUNC; }
1455};
1456
1457class Item_func_atan final : public Item_dec_func {
1458 public:
1459 Item_func_atan(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1460 Item_func_atan(const POS &pos, Item *a, Item *b) : Item_dec_func(pos, a, b) {}
1461 double val_real() override;
1462 const char *func_name() const override { return "atan"; }
1463 enum Functype functype() const override { return ATAN_FUNC; }
1464};
1465
1466class Item_func_cos final : public Item_dec_func {
1467 public:
1468 Item_func_cos(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1469 double val_real() override;
1470 const char *func_name() const override { return "cos"; }
1471 enum Functype functype() const override { return COS_FUNC; }
1472};
1473
1474class Item_func_sin final : public Item_dec_func {
1475 public:
1476 Item_func_sin(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1477 double val_real() override;
1478 const char *func_name() const override { return "sin"; }
1479 enum Functype functype() const override { return SIN_FUNC; }
1480};
1481
1482class Item_func_tan final : public Item_dec_func {
1483 public:
1484 Item_func_tan(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1485 double val_real() override;
1486 const char *func_name() const override { return "tan"; }
1487 enum Functype functype() const override { return TAN_FUNC; }
1488};
1489
1490class Item_func_cot final : public Item_dec_func {
1491 public:
1492 Item_func_cot(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1493 double val_real() override;
1494 const char *func_name() const override { return "cot"; }
1495 enum Functype functype() const override { return COT_FUNC; }
1496};
1497
1499 public:
1501 Item_func_int_val(const POS &pos, Item *a) : Item_func_num1(pos, a) {}
1502 bool resolve_type_inner(THD *thd) override;
1503};
1504
1506 public:
1508 Item_func_ceiling(const POS &pos, Item *a) : Item_func_int_val(pos, a) {}
1509 const char *func_name() const override { return "ceiling"; }
1510 longlong int_op() override;
1511 double real_op() override;
1512 my_decimal *decimal_op(my_decimal *) override;
1513 bool check_partition_func_processor(uchar *) override { return false; }
1514 bool check_function_as_value_generator(uchar *) override { return false; }
1515 enum Functype functype() const override { return CEILING_FUNC; }
1516};
1517
1519 public:
1521 Item_func_floor(const POS &pos, Item *a) : Item_func_int_val(pos, a) {}
1522 const char *func_name() const override { return "floor"; }
1523 longlong int_op() override;
1524 double real_op() override;
1525 my_decimal *decimal_op(my_decimal *) override;
1526 bool check_partition_func_processor(uchar *) override { return false; }
1527 bool check_function_as_value_generator(uchar *) override { return false; }
1528 enum Functype functype() const override { return FLOOR_FUNC; }
1529};
1530
1531/* This handles round and truncate */
1532
1533class Item_func_round final : public Item_func_num1 {
1535
1536 public:
1537 Item_func_round(Item *a, Item *b, bool trunc_arg)
1538 : Item_func_num1(a, b), truncate(trunc_arg) {}
1539 Item_func_round(const POS &pos, Item *a, Item *b, bool trunc_arg)
1540 : Item_func_num1(pos, a, b), truncate(trunc_arg) {}
1541
1542 const char *func_name() const override {
1543 return truncate ? "truncate" : "round";
1544 }
1545 double real_op() override;
1546 longlong int_op() override;
1547 my_decimal *decimal_op(my_decimal *) override;
1548 bool resolve_type(THD *) override;
1549 enum Functype functype() const override {
1551 }
1552};
1553
1554class Item_func_rand final : public Item_real_func {
1556
1558 bool first_eval{true}; // true if val_real() is called 1st time
1559 public:
1561 Item_func_rand(const POS &pos, Item *a) : Item_real_func(pos, a) {}
1562 explicit Item_func_rand(const POS &pos) : Item_real_func(pos) {}
1563
1564 bool do_itemize(Parse_context *pc, Item **res) override;
1565 double val_real() override;
1566 const char *func_name() const override { return "rand"; }
1567 /**
1568 This function is non-deterministic and hence depends on the
1569 'RAND' pseudo-table.
1570
1571 @returns RAND_TABLE_BIT
1572 */
1574 return RAND_TABLE_BIT;
1575 }
1576 bool fix_fields(THD *thd, Item **ref) override;
1577 bool resolve_type(THD *thd) override;
1578 void cleanup() override {
1579 first_eval = true;
1581 }
1582 bool check_function_as_value_generator(uchar *checker_args) override {
1584 pointer_cast<Check_function_as_value_generator_parameters *>(
1585 checker_args);
1586 func_arg->banned_function_name = func_name();
1587 return ((func_arg->source == VGS_GENERATED_COLUMN) ||
1588 (func_arg->source == VGS_CHECK_CONSTRAINT));
1589 }
1590
1591 private:
1592 void seed_random(Item *val);
1593};
1594
1595class Item_func_sign final : public Item_int_func {
1596 public:
1597 Item_func_sign(const POS &pos, Item *a) : Item_int_func(pos, a) {}
1598 const char *func_name() const override { return "sign"; }
1599 enum Functype functype() const override { return SIGN_FUNC; }
1600 longlong val_int() override;
1601 bool resolve_type(THD *thd) override;
1602};
1603
1604// Common base class for the DEGREES and RADIANS functions.
1606 double mul, add;
1607
1608 protected:
1609 Item_func_units(const POS &pos, Item *a, double mul_arg, double add_arg)
1610 : Item_real_func(pos, a), mul(mul_arg), add(add_arg) {}
1611
1612 public:
1613 double val_real() override;
1614 bool resolve_type(THD *thd) override;
1615};
1616
1618 public:
1620 : Item_func_units(pos, a, 180.0 / M_PI, 0.0) {}
1621 const char *func_name() const override { return "degrees"; }
1622 enum Functype functype() const override { return DEGREES_FUNC; }
1623};
1624
1626 public:
1628 : Item_func_units(pos, a, M_PI / 180.0, 0.0) {}
1629 const char *func_name() const override { return "radians"; }
1630 enum Functype functype() const override { return RADIANS_FUNC; }
1631};
1633 public:
1634 Item_func_min_max(const POS &pos, PT_item_list *opt_list, bool is_least_func)
1635 : Item_func_numhybrid(pos, opt_list),
1636 m_is_least_func(is_least_func),
1638
1639 longlong val_int() override;
1640 double val_real() override;
1641 my_decimal *val_decimal(my_decimal *) override;
1642 longlong int_op() override;
1643 double real_op() override;
1644 my_decimal *decimal_op(my_decimal *) override;
1645 String *str_op(String *) override;
1646 bool date_op(Date_val *date, my_time_flags_t flags) override {
1647 return datetime_op(date, flags);
1648 }
1649 bool time_op(Time_val *time) override;
1650 bool datetime_op(Datetime_val *dt, my_time_flags_t flags) override;
1652 return MYSQL_TYPE_VARCHAR;
1653 }
1654 bool resolve_type(THD *thd) override;
1655 bool resolve_type_inner(THD *thd) override;
1656 void set_numeric_type() override {}
1657 enum Item_result result_type() const override { return hybrid_type; }
1658 TYPELIB *get_typelib() const override;
1659
1660 /**
1661 Make CAST(LEAST_OR_GREATEST(datetime_expr, varchar_expr))
1662 return a number in format YYMMDDhhmmss.
1663 */
1664 enum Item_result cast_to_int_type() const override {
1666 }
1667
1668 /// Returns true if arguments to this function should be compared as dates.
1669 bool compare_as_dates() const;
1670
1671 /// Returns true if at least one of the arguments was of temporal type.
1672 bool has_temporal_arg() const { return temporal_item; }
1673
1674 private:
1675 /// True if LEAST function, false if GREATEST.
1678 /*
1679 Used for determining whether one of the arguments is of temporal type and
1680 for converting arguments to a common output format if arguments are
1681 compared as dates and result type is character string. For example,
1682 LEAST('95-05-05', date '10-10-10') should return '1995-05-05', not
1683 '95-05-05'.
1684 */
1686
1687 /**
1688 Fractional seconds precision to use when converting a time or timestamp
1689 expression into a string.
1690 */
1692 /**
1693 Compare arguments as datetime values.
1694
1695 @param value Pointer to which the datetime value of the winning argument
1696 is written.
1697
1698 @return true if error, false otherwise.
1699 */
1701
1702 /**
1703 Compare arguments as time values.
1704
1705 @param value Pointer to which the time value of the winning argument is
1706 written.
1707
1708 @return true if error, false otherwise.
1709 */
1710 bool cmp_times(Time_val *value);
1711};
1712
1713class Item_func_min final : public Item_func_min_max {
1714 public:
1715 Item_func_min(const POS &pos, PT_item_list *opt_list)
1716 : Item_func_min_max(pos, opt_list, true) {}
1717 const char *func_name() const override { return "least"; }
1718 uint64_t hash() override { return Item_func::hash(true); }
1719 enum Functype functype() const override { return LEAST_FUNC; }
1720};
1721
1722class Item_func_max final : public Item_func_min_max {
1723 public:
1724 Item_func_max(const POS &pos, PT_item_list *opt_list)
1725 : Item_func_min_max(pos, opt_list, false) {}
1726 const char *func_name() const override { return "greatest"; }
1727 enum Functype functype() const override { return GREATEST_FUNC; }
1728};
1729
1730/**
1731 A wrapper Item that normally returns its parameter, but becomes NULL when
1732 processing rows for rollup. Rollup is implemented by AggregateIterator, and
1733 works by means of hierarchical levels -- 0 is the “grand totals” phase, 1 is
1734 where only one group level is active, and so on. E.g., for a query with GROUP
1735 BY a,b, the rows will look like this:
1736
1737 a b rollup level
1738 1 1 2
1739 1 2 2
1740 1 NULL 1
1741 2 1 2
1742 2 NULL 1
1743 NULL NULL 0
1744
1745 Each rollup group item has a minimum level for when it becomes NULL. In the
1746 example above, a would have minimum level 0 and b would have minimum level 1.
1747 For simplicity, the JOIN carries a list of all rollup group items, and they
1748 are being given the current rollup level when it changes. A rollup level of
1749 INT_MAX essentially always disables rollup, which is useful when there are
1750 leftover group items in places that are not relevant for rollup
1751 (e.g., sometimes resolving can leave rollup wrappers in place for temporary
1752 tables that are created before grouping, which should then effectively be
1753 disabled).
1754 */
1755class Item_rollup_group_item final : public Item_func {
1756 public:
1761 // We're going to replace inner_item in the SELECT list, so copy its hidden
1762 // status. (We could have done this in the caller, but it fits naturally in
1763 // with all the other copying done here.)
1765 set_nullable(true);
1767 }
1768 double val_real() override;
1769 longlong val_int() override;
1770 String *val_str(String *str) override;
1772 bool val_json(Json_wrapper *result) override;
1773 bool val_date(Date_val *date, my_time_flags_t flags) override;
1774 bool val_time(Time_val *time) override;
1775 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1776 const char *func_name() const override { return "rollup_group_item"; }
1777 table_map used_tables() const override {
1778 /*
1779 If underlying item is non-constant, return its used_tables value.
1780 Otherwise, ensure it is non-constant by adding RAND_TABLE_BIT.
1781 */
1782 return args[0]->const_for_execution()
1783 ? (args[0]->used_tables() | RAND_TABLE_BIT)
1784 : args[0]->used_tables();
1785 }
1786 void update_used_tables() override {
1789 }
1790 Item_result result_type() const override { return args[0]->result_type(); }
1791 bool resolve_type(THD *) override {
1792 // needn't handle dynamic parameter as its const_item() is false.
1794
1795 // The item could be a NULL constant.
1796 null_value = args[0]->is_null();
1797 return false;
1798 }
1799 Item *inner_item() { return args[0]; }
1800 const Item *inner_item() const { return args[0]; }
1801 bool rollup_null() const {
1803 }
1804 enum Functype functype() const override { return ROLLUP_GROUP_ITEM_FUNC; }
1805 void print(const THD *thd, String *str,
1806 enum_query_type query_type) const override;
1807 uint64_t hash() override;
1808 bool eq_specific(const Item *item) const override;
1809 TYPELIB *get_typelib() const override;
1810
1811 // Used by AggregateIterator.
1813
1814 // Used when cloning the item only.
1815 int min_rollup_level() const { return m_min_rollup_level; }
1816
1817 private:
1820};
1821
1824
1825 public:
1826 Item_func_length(const POS &pos, Item *a) : Item_int_func(pos, a) {}
1827 longlong val_int() override;
1828 const char *func_name() const override { return "length"; }
1829 bool resolve_type(THD *thd) override {
1830 if (param_type_is_default(thd, 0, 1)) return true;
1831 max_length = 10;
1832 return false;
1833 }
1834};
1835
1838
1839 public:
1840 Item_func_vector_dim(const POS &pos, Item *a) : Item_int_func(pos, a) {}
1841 longlong val_int() override;
1842 const char *func_name() const override { return "vector_dim"; }
1843 bool resolve_type(THD *thd) override {
1844 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_VECTOR)) {
1845 return true;
1846 }
1847 bool valid_type = (args[0]->data_type() == MYSQL_TYPE_VECTOR) ||
1848 (args[0]->result_type() == STRING_RESULT &&
1850 if (!valid_type) {
1851 my_error(ER_WRONG_ARGUMENTS, MYF(0), func_name());
1852 return true;
1853 }
1854 max_length = 10;
1855 return false;
1856 }
1857};
1858
1860 public:
1861 Item_func_bit_length(const POS &pos, Item *a) : Item_func_length(pos, a) {}
1862 longlong val_int() override {
1863 assert(fixed);
1864 return Item_func_length::val_int() * 8;
1865 }
1866 const char *func_name() const override { return "bit_length"; }
1867};
1868
1871
1872 public:
1874 Item_func_char_length(const POS &pos, Item *a) : Item_int_func(pos, a) {}
1875 longlong val_int() override;
1876 const char *func_name() const override { return "char_length"; }
1877 bool resolve_type(THD *thd) override {
1878 max_length = 10;
1879 return Item_int_func::resolve_type(thd);
1880 }
1881};
1882
1884 public:
1885 Item_func_coercibility(const POS &pos, Item *a) : Item_int_func(pos, a) {
1886 null_on_null = false;
1887 }
1888 longlong val_int() override;
1889 const char *func_name() const override { return "coercibility"; }
1890 bool resolve_type(THD *thd) override {
1891 max_length = 10;
1892 set_nullable(false);
1893 return Item_int_func::resolve_type(thd);
1894 }
1895};
1896
1899
1900 public:
1902 Item_func_locate(const POS &pos, Item *a, Item *b)
1903 : Item_int_func(pos, a, b) {}
1904 Item_func_locate(const POS &pos, Item *a, Item *b, Item *c)
1905 : Item_int_func(pos, a, b, c) {}
1906
1907 const char *func_name() const override { return "locate"; }
1908 longlong val_int() override;
1909 bool resolve_type(THD *thd) override;
1910 void print(const THD *thd, String *str,
1911 enum_query_type query_type) const override;
1912};
1913
1914class Item_func_instr final : public Item_func_locate {
1915 public:
1916 Item_func_instr(const POS &pos, Item *a, Item *b)
1917 : Item_func_locate(pos, a, b) {}
1918
1919 const char *func_name() const override { return "instr"; }
1920};
1921
1923 public:
1925 : Item_int_func(pos, a) {}
1926 longlong val_int() override;
1927 const char *func_name() const override {
1928 return "validate_password_strength";
1929 }
1930 bool resolve_type(THD *thd) override {
1931 max_length = 10;
1932 set_nullable(true);
1933 return Item_int_func::resolve_type(thd);
1934 }
1935};
1936
1937class Item_func_field final : public Item_int_func {
1940
1941 public:
1942 Item_func_field(const POS &pos, PT_item_list *opt_list)
1943 : Item_int_func(pos, opt_list) {}
1944 longlong val_int() override;
1945 const char *func_name() const override { return "field"; }
1946 bool resolve_type(THD *thd) override;
1947};
1948
1949class Item_func_ascii final : public Item_int_func {
1951
1952 public:
1953 Item_func_ascii(const POS &pos, Item *a) : Item_int_func(pos, a) {}
1954 longlong val_int() override;
1955 const char *func_name() const override { return "ascii"; }
1956 bool resolve_type(THD *thd) override {
1957 max_length = 3;
1958 return Item_int_func::resolve_type(thd);
1959 }
1960};
1961
1962class Item_func_ord final : public Item_int_func {
1964
1965 public:
1966 Item_func_ord(const POS &pos, Item *a) : Item_int_func(pos, a) {}
1967 longlong val_int() override;
1968 const char *func_name() const override { return "ord"; }
1969};
1970
1973 /*
1974 if m_enum_value is non-zero, it indicates the index of the value of
1975 argument 0 in the set in argument 1, given that argument 0 is
1976 a constant value and argument 1 is a field of type SET.
1977 */
1980
1981 public:
1983 : Item_int_func(pos, a, b) {}
1984 longlong val_int() override;
1985 const char *func_name() const override { return "find_in_set"; }
1986 bool resolve_type(THD *) override;
1987 const CHARSET_INFO *compare_collation() const override {
1988 return cmp_collation.collation;
1989 }
1990};
1991
1992/* Base class for all bit functions: '~', '|', '^', '&', '>>', '<<' */
1993
1994class Item_func_bit : public Item_func {
1995 protected:
1996 /// Stores the Item's result type. Can only be INT_RESULT or STRING_RESULT
1998 /// Buffer storing the determined value
2000 /**
2001 @returns true if the second argument should be of binary type for the
2002 result to be of binary type.
2003 */
2005
2006 public:
2007 Item_func_bit(const POS &pos, Item *a, Item *b) : Item_func(pos, a, b) {}
2008 Item_func_bit(const POS &pos, Item *a) : Item_func(pos, a) {}
2009
2010 bool resolve_type(THD *) override;
2011 enum Item_result result_type() const override { return hybrid_type; }
2012
2013 longlong val_int() override;
2014 String *val_str(String *str) override;
2015 double val_real() override;
2016 my_decimal *val_decimal(my_decimal *decimal_value) override;
2017
2018 void print(const THD *thd, String *str,
2019 enum_query_type query_type) const override {
2020 print_op(thd, str, query_type);
2021 }
2022 bool val_date(Date_val *date, my_time_flags_t flags) override {
2023 if (hybrid_type == INT_RESULT)
2024 return get_date_from_int(date, flags);
2025 else
2026 return get_date_from_string(date, flags);
2027 }
2028 bool val_time(Time_val *time) override {
2029 if (hybrid_type == INT_RESULT)
2030 return get_time_from_int(time);
2031 else
2032 return get_time_from_string(time);
2033 }
2035 if (hybrid_type == INT_RESULT)
2036 return get_datetime_from_int(dt, flags);
2037 else
2038 return get_datetime_from_string(dt, flags);
2039 }
2040
2041 private:
2042 /**
2043 @brief Performs the operation on integers to produce a result of type
2044 INT_RESULT.
2045 @return The result of the operation.
2046 */
2047 virtual longlong int_op() = 0;
2048
2049 /**
2050 @brief Performs the operation on binary strings to produce a result of
2051 type STRING_RESULT.
2052 @return The result of the operation.
2053 */
2054 virtual String *str_op(String *) = 0;
2055};
2056
2057/**
2058 Base class for all the bit functions that work with two binary
2059 arguments: '&', '|', '^'.
2060*/
2061
2063 protected:
2065 return true;
2066 }
2067 template <class Char_func, class Int_func>
2068 String *eval_str_op(String *, Char_func char_func, Int_func int_func);
2069 template <class Int_func>
2070 longlong eval_int_op(Int_func int_func);
2071
2072 public:
2074 : Item_func_bit(pos, a, b) {}
2075};
2076
2078 public:
2079 Item_func_bit_or(const POS &pos, Item *a, Item *b)
2080 : Item_func_bit_two_param(pos, a, b) {}
2081 const char *func_name() const override { return "|"; }
2082 uint64_t hash() override { return Item_func::hash(true); }
2083
2084 private:
2085 longlong int_op() override { return eval_int_op(std::bit_or<ulonglong>()); }
2086 String *str_op(String *str) override {
2087 return eval_str_op(str, std::bit_or<char>(), std::bit_or<ulonglong>());
2088 }
2089};
2090
2092 public:
2093 Item_func_bit_and(const POS &pos, Item *a, Item *b)
2094 : Item_func_bit_two_param(pos, a, b) {}
2095 const char *func_name() const override { return "&"; }
2096 uint64_t hash() override { return Item_func::hash(true); }
2097
2098 private:
2099 longlong int_op() override { return eval_int_op(std::bit_and<ulonglong>()); }
2100 String *str_op(String *str) override {
2101 return eval_str_op(str, std::bit_and<char>(), std::bit_and<ulonglong>());
2102 }
2103};
2104
2106 public:
2107 Item_func_bit_xor(const POS &pos, Item *a, Item *b)
2108 : Item_func_bit_two_param(pos, a, b) {}
2109 const char *func_name() const override { return "^"; }
2110 uint64_t hash() override { return Item_func::hash(true); }
2111
2112 private:
2113 longlong int_op() override { return eval_int_op(std::bit_xor<ulonglong>()); }
2114 String *str_op(String *str) override {
2115 return eval_str_op(str, std::bit_xor<char>(), std::bit_xor<ulonglong>());
2116 }
2117};
2118
2120 public:
2121 Item_func_bit_count(const POS &pos, Item *a) : Item_int_func(pos, a) {}
2122 longlong val_int() override;
2123 const char *func_name() const override { return "bit_count"; }
2124 bool resolve_type(THD *thd) override {
2125 // Default: binary string; reprepare if integer
2126 if (args[0]->data_type() == MYSQL_TYPE_INVALID &&
2127 args[0]->propagate_type(
2129 return true;
2131 return false;
2132 }
2133};
2134
2136 protected:
2138 return false;
2139 }
2140 template <bool to_left>
2142 template <bool to_left>
2144
2145 public:
2146 Item_func_shift(const POS &pos, Item *a, Item *b)
2147 : Item_func_bit(pos, a, b) {}
2148};
2149
2151 public:
2152 Item_func_shift_left(const POS &pos, Item *a, Item *b)
2153 : Item_func_shift(pos, a, b) {}
2154 const char *func_name() const override { return "<<"; }
2155
2156 private:
2157 longlong int_op() override;
2158 String *str_op(String *str) override;
2159};
2160
2162 public:
2164 : Item_func_shift(pos, a, b) {}
2165 const char *func_name() const override { return ">>"; }
2166
2167 private:
2168 longlong int_op() override;
2169 String *str_op(String *str) override;
2170};
2171
2172class Item_func_bit_neg final : public Item_func_bit {
2173 protected:
2175 return false;
2176 }
2177
2178 public:
2179 Item_func_bit_neg(const POS &pos, Item *a) : Item_func_bit(pos, a) {}
2180 const char *func_name() const override { return "~"; }
2181 void print(const THD *thd, String *str,
2182 enum_query_type query_type) const override {
2183 Item_func::print(thd, str, query_type);
2184 }
2185 uint64_t hash() override { return Item_func::hash(); }
2186
2187 private:
2188 longlong int_op() override;
2189 String *str_op(String *str) override;
2190};
2191
2194
2195 public:
2197 explicit Item_func_last_insert_id(const POS &pos) : Item_int_func(pos) {}
2198 Item_func_last_insert_id(const POS &pos, Item *a) : Item_int_func(pos, a) {}
2199
2200 bool do_itemize(Parse_context *pc, Item **res) override;
2201 longlong val_int() override;
2202 const char *func_name() const override { return "last_insert_id"; }
2203
2205 return INNER_TABLE_BIT;
2206 }
2207
2208 bool resolve_type(THD *thd) override {
2209 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_LONGLONG)) return true;
2210 unsigned_flag = true;
2211 return false;
2212 }
2213 bool check_function_as_value_generator(uchar *checker_args) override {
2215 pointer_cast<Check_function_as_value_generator_parameters *>(
2216 checker_args);
2217 func_arg->banned_function_name = func_name();
2218 return true;
2219 }
2220};
2221
2224
2225 public:
2226 Item_func_benchmark(const POS &pos, Item *count_expr, Item *expr)
2227 : Item_int_func(pos, count_expr, expr) {}
2228
2229 /// Ensure that "benchmark()" is never optimized away
2231 return RAND_TABLE_BIT;
2232 }
2233
2234 bool do_itemize(Parse_context *pc, Item **res) override;
2235 longlong val_int() override;
2236 const char *func_name() const override { return "benchmark"; }
2237 bool resolve_type(THD *thd) override {
2238 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_LONGLONG)) return true;
2239 if (param_type_is_default(thd, 1, 2)) return true;
2240 max_length = 1;
2241 set_nullable(true);
2242 return false;
2243 }
2244 void print(const THD *thd, String *str,
2245 enum_query_type query_type) const override;
2246 bool check_function_as_value_generator(uchar *checker_args) override {
2248 pointer_cast<Check_function_as_value_generator_parameters *>(
2249 checker_args);
2250 func_arg->banned_function_name = func_name();
2251 return true;
2252 }
2253};
2254
2257
2258class Item_func_sleep final : public Item_int_func {
2260
2261 public:
2262 Item_func_sleep(const POS &pos, Item *a) : Item_int_func(pos, a) {}
2263
2264 bool do_itemize(Parse_context *pc, Item **res) override;
2265 const char *func_name() const override { return "sleep"; }
2266 /**
2267 This function is non-deterministic and hence depends on the
2268 'RAND' pseudo-table.
2269
2270 @returns RAND_TABLE_BIT
2271 */
2273 return RAND_TABLE_BIT;
2274 }
2275 bool check_function_as_value_generator(uchar *checker_args) override {
2277 pointer_cast<Check_function_as_value_generator_parameters *>(
2278 checker_args);
2279 func_arg->banned_function_name = func_name();
2280 return true;
2281 }
2282 bool resolve_type(THD *thd) override {
2283 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_DOUBLE)) return true;
2284 return Item_int_func::resolve_type(thd);
2285 }
2286 longlong val_int() override;
2287};
2288
2289class Item_udf_func : public Item_func {
2291
2292 protected:
2294
2295 public:
2296 Item_udf_func(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
2297 : Item_func(pos, opt_list), udf(udf_arg) {
2298 null_on_null = false;
2299 }
2300 ~Item_udf_func() override = default;
2301
2302 bool do_itemize(Parse_context *pc, Item **res) override;
2303 const char *func_name() const override { return udf.name(); }
2304 enum Functype functype() const override { return UDF_FUNC; }
2307 }
2308 bool fix_fields(THD *thd, Item **ref) override;
2309 void cleanup() override;
2310 Item_result result_type() const override { return udf.result_type(); }
2311 void print(const THD *thd, String *str,
2312 enum_query_type query_type) const override;
2313 bool check_function_as_value_generator(uchar *checker_args) override {
2315 pointer_cast<Check_function_as_value_generator_parameters *>(
2316 checker_args);
2317 func_arg->banned_function_name = func_name();
2318 return true;
2319 }
2320
2321 void compute_cost(CostOfItem *root_cost) const override {
2322 root_cost->MarkExpensive();
2323 }
2324
2325 protected:
2326 bool may_have_named_parameters() const override { return true; }
2327
2328 private:
2329 /**
2330 This member is set during resolving and is used by update_used_tables() and
2331 fix_after_pullout() to preserve the non-deterministic property.
2332 */
2334};
2335
2337 public:
2338 Item_func_udf_float(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
2339 : Item_udf_func(pos, udf_arg, opt_list) {}
2340 longlong val_int() override {
2341 assert(fixed);
2343 }
2344 my_decimal *val_decimal(my_decimal *dec_buf) override {
2345 const double res = val_real();
2346 if (null_value) return nullptr;
2347 double2my_decimal(E_DEC_FATAL_ERROR, res, dec_buf);
2348 return dec_buf;
2349 }
2350 double val_real() override;
2351 String *val_str(String *str) override;
2352 bool val_date(Date_val *date, my_time_flags_t flags) override {
2353 return get_date_from_real(date, flags);
2354 }
2355 bool val_time(Time_val *time) override { return get_time_from_real(time); }
2357 return get_datetime_from_real(dt, flags);
2358 }
2359 bool resolve_type(THD *) override {
2361 fix_num_length_and_dec(); // @todo - needed?
2362 return false;
2363 }
2364};
2365
2366class Item_func_udf_int final : public Item_udf_func {
2367 public:
2368 Item_func_udf_int(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
2369 : Item_udf_func(pos, udf_arg, opt_list) {}
2370 longlong val_int() override;
2371 double val_real() override {
2372 return static_cast<double>(Item_func_udf_int::val_int());
2373 }
2374 String *val_str(String *str) override;
2375 bool val_date(Date_val *date, my_time_flags_t flags) override {
2376 return get_date_from_int(date, flags);
2377 }
2378 bool val_time(Time_val *time) override { return get_time_from_int(time); }
2380 return get_datetime_from_int(dt, flags);
2381 }
2382 enum Item_result result_type() const override { return INT_RESULT; }
2383 bool resolve_type(THD *) override {
2385 return false;
2386 }
2387};
2388
2390 public:
2391 Item_func_udf_decimal(const POS &pos, udf_func *udf_arg,
2392 PT_item_list *opt_list)
2393 : Item_udf_func(pos, udf_arg, opt_list) {}
2394 longlong val_int() override;
2395 double val_real() override;
2396 my_decimal *val_decimal(my_decimal *) override;
2397 String *val_str(String *str) override;
2398 bool val_date(Date_val *date, my_time_flags_t flags) override {
2399 return get_date_from_decimal(date, flags);
2400 }
2401 bool val_time(Time_val *time) override { return get_time_from_decimal(time); }
2403 return get_datetime_from_decimal(dt, flags);
2404 }
2405 enum Item_result result_type() const override { return DECIMAL_RESULT; }
2406 bool resolve_type(THD *thd) override;
2407};
2408
2410 public:
2411 Item_func_udf_str(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
2412 : Item_udf_func(pos, udf_arg, opt_list) {}
2413
2414 String *val_str(String *) override;
2415 double val_real() override {
2416 int err_not_used;
2417 const char *end_not_used;
2418 String *res;
2419 res = val_str(&str_value);
2420 return res ? my_strntod(res->charset(), res->ptr(), res->length(),
2421 &end_not_used, &err_not_used)
2422 : 0.0;
2423 }
2424 longlong val_int() override {
2425 int err_not_used;
2426 String *res;
2427 res = val_str(&str_value);
2428 return res ? my_strntoll(res->charset(), res->ptr(), res->length(), 10,
2429 nullptr, &err_not_used)
2430 : (longlong)0;
2431 }
2432 my_decimal *val_decimal(my_decimal *dec_buf) override {
2433 String *res = val_str(&str_value);
2434 if (!res) return nullptr;
2435 str2my_decimal(E_DEC_FATAL_ERROR, res->ptr(), res->length(), res->charset(),
2436 dec_buf);
2437 return dec_buf;
2438 }
2439 bool val_date(Date_val *date, my_time_flags_t flags) override {
2440 return get_date_from_string(date, flags);
2441 }
2442 bool val_time(Time_val *time) override { return get_time_from_string(time); }
2444 return get_datetime_from_string(dt, flags);
2445 }
2446 enum Item_result result_type() const override { return STRING_RESULT; }
2447 bool resolve_type(THD *thd) override;
2448};
2449
2450void mysql_ull_cleanup(THD *thd);
2452
2453class Item_func_get_lock final : public Item_int_func {
2455
2457
2458 public:
2459 Item_func_get_lock(const POS &pos, Item *a, Item *b)
2460 : Item_int_func(pos, a, b) {}
2461
2462 bool do_itemize(Parse_context *pc, Item **res) override;
2463 longlong val_int() override;
2464 const char *func_name() const override { return "get_lock"; }
2466 return INNER_TABLE_BIT;
2467 }
2468 bool resolve_type(THD *thd) override {
2469 if (param_type_is_default(thd, 0, 1)) return true;
2470 if (param_type_is_default(thd, 1, 2, MYSQL_TYPE_LONGLONG)) return true;
2471 max_length = 1;
2472 set_nullable(true);
2473 return false;
2474 }
2475 bool is_non_const_over_literals(uchar *) override { return true; }
2476 bool check_function_as_value_generator(uchar *checker_args) override {
2478 pointer_cast<Check_function_as_value_generator_parameters *>(
2479 checker_args);
2480 func_arg->banned_function_name = func_name();
2481 return true;
2482 }
2483};
2484
2487
2489
2490 public:
2491 Item_func_release_lock(const POS &pos, Item *a) : Item_int_func(pos, a) {}
2492 bool do_itemize(Parse_context *pc, Item **res) override;
2493
2494 longlong val_int() override;
2495 const char *func_name() const override { return "release_lock"; }
2497 return INNER_TABLE_BIT;
2498 }
2499 bool resolve_type(THD *thd) override {
2500 if (param_type_is_default(thd, 0, 1)) return true;
2501 max_length = 1;
2502 set_nullable(true);
2503 return false;
2504 }
2505 bool is_non_const_over_literals(uchar *) override { return true; }
2506 bool check_function_as_value_generator(uchar *checker_args) override {
2508 pointer_cast<Check_function_as_value_generator_parameters *>(
2509 checker_args);
2510 func_arg->banned_function_name = func_name();
2511 return true;
2512 }
2513};
2514
2517
2518 public:
2519 explicit Item_func_release_all_locks(const POS &pos) : Item_int_func(pos) {}
2520 bool do_itemize(Parse_context *pc, Item **res) override;
2521
2522 longlong val_int() override;
2523 const char *func_name() const override { return "release_all_locks"; }
2525 return INNER_TABLE_BIT;
2526 }
2527 bool resolve_type(THD *) override {
2528 unsigned_flag = true;
2529 return false;
2530 }
2531 bool is_non_const_over_literals(uchar *) override { return true; }
2532 bool check_function_as_value_generator(uchar *checker_args) override {
2534 pointer_cast<Check_function_as_value_generator_parameters *>(
2535 checker_args);
2536 func_arg->banned_function_name = func_name();
2537 return true;
2538 }
2539};
2540
2541/* replication functions */
2542
2546
2547 public:
2548 Item_source_pos_wait(const POS &pos, Item *a, Item *b)
2549 : Item_int_func(pos, a, b) {}
2550 Item_source_pos_wait(const POS &pos, Item *a, Item *b, Item *c)
2551 : Item_int_func(pos, a, b, c) {}
2552 Item_source_pos_wait(const POS &pos, Item *a, Item *b, Item *c, Item *d)
2553 : Item_int_func(pos, a, b, c, d) {}
2554
2555 bool do_itemize(Parse_context *pc, Item **res) override;
2556 longlong val_int() override;
2557 const char *func_name() const override { return "source_pos_wait"; }
2559 return INNER_TABLE_BIT;
2560 }
2561 bool resolve_type(THD *thd) override {
2562 if (param_type_is_default(thd, 0, 1)) return true;
2563 if (param_type_is_default(thd, 1, 3, MYSQL_TYPE_LONGLONG)) return true;
2564 if (param_type_is_default(thd, 3, 4)) return true;
2565 max_length = 21;
2566 set_nullable(true);
2567 return false;
2568 }
2569 bool check_function_as_value_generator(uchar *checker_args) override {
2571 pointer_cast<Check_function_as_value_generator_parameters *>(
2572 checker_args);
2573 func_arg->banned_function_name = func_name();
2574 return true;
2575 }
2576};
2577
2579 public:
2580 Item_master_pos_wait(const POS &pos, Item *a, Item *b)
2581 : Item_source_pos_wait(pos, a, b) {}
2582 Item_master_pos_wait(const POS &pos, Item *a, Item *b, Item *c)
2583 : Item_source_pos_wait(pos, a, b, c) {}
2584 Item_master_pos_wait(const POS &pos, Item *a, Item *b, Item *c, Item *d)
2585 : Item_source_pos_wait(pos, a, b, c, d) {}
2586 longlong val_int() override;
2587};
2588
2589/**
2590 Internal functions used by INFORMATION_SCHEMA implementation to check
2591 if user have access to given database/table/column.
2592*/
2593
2595 public:
2597 : Item_int_func(pos, a) {}
2598 longlong val_int() override;
2599 const char *func_name() const override { return "can_access_database"; }
2600 bool resolve_type(THD *) override {
2601 set_nullable(true);
2602 return false;
2603 }
2604};
2605
2607 public:
2609 : Item_int_func(pos, a, b) {}
2610 longlong val_int() override;
2611 const char *func_name() const override { return "can_access_table"; }
2612 bool resolve_type(THD *) override {
2613 set_nullable(true);
2614 return false;
2615 }
2616};
2617
2619 public:
2621 : Item_int_func(pos, a, b) {}
2622 longlong val_int() override;
2623 const char *func_name() const override { return "can_access_user"; }
2624 bool resolve_type(THD *) override {
2625 set_nullable(true);
2626 return false;
2627 }
2628};
2629
2631 public:
2633 : Item_int_func(pos, a, b) {}
2634 longlong val_int() override;
2635 const char *func_name() const override { return "can_access_trigger"; }
2636 bool resolve_type(THD *) override {
2637 max_length = 4;
2638 set_nullable(true);
2639 return false;
2640 }
2641};
2642
2644 public:
2646 : Item_int_func(pos, list) {}
2647 longlong val_int() override;
2648 const char *func_name() const override { return "can_access_routine"; }
2649 bool resolve_type(THD *) override {
2650 max_length = 4;
2651 set_nullable(true);
2652 return false;
2653 }
2654};
2655
2657 public:
2659 longlong val_int() override;
2660 const char *func_name() const override { return "can_access_event"; }
2661 bool resolve_type(THD *) override {
2662 set_nullable(true);
2663 return false;
2664 }
2665};
2666
2668 public:
2670 : Item_int_func(pos, a) {}
2671 longlong val_int() override;
2672 const char *func_name() const override { return "can_access_resource_group"; }
2673 bool resolve_type(THD *) override {
2674 max_length = 1; // Function can return 0 or 1.
2675 set_nullable(true);
2676 return false;
2677 }
2678};
2679
2681 public:
2682 Item_func_can_access_view(const POS &pos, Item *a, Item *b, Item *c, Item *d)
2683 : Item_int_func(pos, a, b, c, d) {}
2684 longlong val_int() override;
2685 const char *func_name() const override { return "can_access_view"; }
2686 bool resolve_type(THD *) override {
2687 set_nullable(true);
2688 return false;
2689 }
2690};
2691
2693 public:
2695 : Item_int_func(pos, a, b, c) {}
2696 longlong val_int() override;
2697 const char *func_name() const override { return "can_access_column"; }
2698 bool resolve_type(THD *) override {
2699 set_nullable(true);
2700 return false;
2701 }
2702};
2703
2705 public:
2707 : Item_int_func(pos, a) {}
2709 : Item_int_func(pos, a, b) {}
2711 : Item_int_func(pos, a, b, c) {}
2712 longlong val_int() override;
2713 const char *func_name() const override { return "is_visible_dd_object"; }
2714 bool resolve_type(THD *) override {
2715 max_length = 1;
2716 set_nullable(true);
2717 return false;
2718 }
2719};
2720
2722 public:
2724 : Item_int_func(pos, list) {}
2725 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2726 longlong val_int() override;
2727 const char *func_name() const override { return "internal_table_rows"; }
2728 bool resolve_type(THD *) override {
2729 set_nullable(true);
2730 unsigned_flag = true;
2731 null_on_null = false;
2732 return false;
2733 }
2734};
2735
2737 public:
2739 : Item_int_func(pos, list) {}
2740 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2741 longlong val_int() override;
2742 const char *func_name() const override { return "internal_avg_row_length"; }
2743 bool resolve_type(THD *) override {
2744 set_nullable(true);
2745 unsigned_flag = true;
2746 null_on_null = false;
2747 return false;
2748 }
2749};
2750
2752 public:
2754 : Item_int_func(pos, list) {}
2755 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2756 longlong val_int() override;
2757 const char *func_name() const override { return "internal_data_length"; }
2758 bool resolve_type(THD *) override {
2759 set_nullable(true);
2760 unsigned_flag = true;
2761 null_on_null = false;
2762 return false;
2763 }
2764};
2765
2767 public:
2769 : Item_int_func(pos, list) {}
2770 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2771 longlong val_int() override;
2772 const char *func_name() const override { return "internal_max_data_length"; }
2773 bool resolve_type(THD *) override {
2774 set_nullable(true);
2775 unsigned_flag = true;
2776 null_on_null = false;
2777 return false;
2778 }
2779};
2780
2782 public:
2784 : Item_int_func(pos, list) {}
2785 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2786 longlong val_int() override;
2787 const char *func_name() const override { return "internal_index_length"; }
2788 bool resolve_type(THD *) override {
2789 set_nullable(true);
2790 unsigned_flag = true;
2791 null_on_null = false;
2792 return false;
2793 }
2794};
2795
2797 public:
2799 : Item_int_func(pos, list) {}
2800 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2801 longlong val_int() override;
2802 const char *func_name() const override { return "internal_data_free"; }
2803 bool resolve_type(THD *) override {
2804 set_nullable(true);
2805 unsigned_flag = true;
2806 null_on_null = false;
2807 return false;
2808 }
2809};
2810
2812 public:
2814 : Item_int_func(pos, list) {}
2815 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2816 longlong val_int() override;
2817 const char *func_name() const override { return "internal_auto_increment"; }
2818 bool resolve_type(THD *) override {
2819 set_nullable(true);
2820 unsigned_flag = true;
2821 null_on_null = false;
2822 return false;
2823 }
2824};
2825
2827 public:
2829 : Item_int_func(pos, list) {}
2830 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2831 longlong val_int() override;
2832 const char *func_name() const override { return "internal_checksum"; }
2833 bool resolve_type(THD *) override {
2834 set_nullable(true);
2835 null_on_null = false;
2836 return false;
2837 }
2838};
2839
2841 public:
2843 : Item_int_func(pos, a) {}
2844 longlong val_int() override;
2845 const char *func_name() const override { return "internal_keys_disabled"; }
2846 bool resolve_type(THD *) override {
2847 set_nullable(false);
2848 null_on_null = false;
2849 return false;
2850 }
2851};
2852
2854 public:
2857 : Item_int_func(pos, list) {}
2858 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2859 longlong val_int() override;
2860 const char *func_name() const override {
2861 return "internal_index_column_cardinality";
2862 }
2863 bool resolve_type(THD *) override {
2864 set_nullable(true);
2865 null_on_null = false;
2866 return false;
2867 }
2868};
2869
2871 public:
2873 Item *d)
2874 : Item_int_func(pos, a, b, c, d) {}
2875 longlong val_int() override;
2876 const char *func_name() const override { return "internal_dd_char_length"; }
2877 bool resolve_type(THD *) override {
2878 set_nullable(true);
2879 null_on_null = false;
2880 return false;
2881 }
2882};
2883
2885 : public Item_int_func {
2886 public:
2889 : Item_int_func(pos, list) {}
2890 longlong val_int() override;
2891 const char *func_name() const override {
2892 return "internal_get_view_warning_or_error";
2893 }
2894 bool resolve_type(THD *) override {
2895 max_length = 1;
2896 set_nullable(false);
2897 null_on_null = false;
2898 return false;
2899 }
2900};
2901
2903 public:
2905 : Item_int_func(pos, list) {}
2906 longlong val_int() override;
2907 bool resolve_type(THD *) override {
2908 set_nullable(true);
2909 null_on_null = false;
2910 return false;
2911 }
2912 const char *func_name() const override {
2913 return "get_dd_index_sub_part_length";
2914 }
2915};
2916
2918 public:
2920 Item *d)
2921 : Item_int_func(pos, a, b, c, d) {}
2922 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2923 longlong val_int() override;
2924 const char *func_name() const override { return "internal_tablespace_id"; }
2925 bool resolve_type(THD *) override {
2926 set_nullable(true);
2927 null_on_null = false;
2928 return false;
2929 }
2930};
2931
2933 : public Item_int_func {
2934 public:
2936 Item *b, Item *c, Item *d)
2937 : Item_int_func(pos, a, b, c, d) {}
2938
2939 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2940 longlong val_int() override;
2941
2942 const char *func_name() const override {
2943 return "internal_tablespace_logfile_group_number";
2944 }
2945
2946 bool resolve_type(THD *) override {
2947 set_nullable(true);
2948 null_on_null = false;
2949 return false;
2950 }
2951};
2952
2954 public:
2956 Item *c, Item *d)
2957 : Item_int_func(pos, a, b, c, d) {}
2958
2959 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2960 longlong val_int() override;
2961
2962 const char *func_name() const override {
2963 return "internal_tablespace_free_extents";
2964 }
2965
2966 bool resolve_type(THD *) override {
2967 set_nullable(true);
2968 null_on_null = false;
2969 return false;
2970 }
2971};
2972
2974 public:
2976 Item *c, Item *d)
2977 : Item_int_func(pos, a, b, c, d) {}
2978
2979 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2980 longlong val_int() override;
2981
2982 const char *func_name() const override {
2983 return "internal_tablespace_total_extents";
2984 }
2985
2986 bool resolve_type(THD *) override {
2987 set_nullable(true);
2988 null_on_null = false;
2989 return false;
2990 }
2991};
2992
2994 public:
2996 Item *c, Item *d)
2997 : Item_int_func(pos, a, b, c, d) {}
2998
2999 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
3000 longlong val_int() override;
3001
3002 const char *func_name() const override {
3003 return "internal_tablespace_extent_size";
3004 }
3005
3006 bool resolve_type(THD *) override {
3007 set_nullable(true);
3008 null_on_null = false;
3009 return false;
3010 }
3011};
3012
3014 public:
3016 Item *c, Item *d)
3017 : Item_int_func(pos, a, b, c, d) {}
3018
3019 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
3020 longlong val_int() override;
3021
3022 const char *func_name() const override {
3023 return "internal_tablespace_initial_size";
3024 }
3025
3026 bool resolve_type(THD *) override {
3027 set_nullable(true);
3028 null_on_null = false;
3029 return false;
3030 }
3031};
3032
3034 public:
3036 Item *c, Item *d)
3037 : Item_int_func(pos, a, b, c, d) {}
3038
3039 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
3040 longlong val_int() override;
3041
3042 const char *func_name() const override {
3043 return "internal_tablespace_maximum_size";
3044 }
3045
3046 bool resolve_type(THD *) override {
3047 set_nullable(true);
3048 null_on_null = false;
3049 return false;
3050 }
3051};
3052
3054 public:
3056 Item *b, Item *c, Item *d)
3057 : Item_int_func(pos, a, b, c, d) {}
3058
3059 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
3060 longlong val_int() override;
3061
3062 const char *func_name() const override {
3063 return "internal_tablespace_autoextend_size";
3064 }
3065
3066 bool resolve_type(THD *) override {
3067 set_nullable(true);
3068 null_on_null = false;
3069 return false;
3070 }
3071};
3072
3074 public:
3076 Item *c, Item *d)
3077 : Item_int_func(pos, a, b, c, d) {}
3078
3079 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
3080 longlong val_int() override;
3081
3082 const char *func_name() const override {
3083 return "internal_tablespace_version";
3084 }
3085
3086 bool resolve_type(THD *) override {
3087 set_nullable(true);
3088 null_on_null = false;
3089 return false;
3090 }
3091};
3092
3094 public:
3096 Item *c, Item *d)
3097 : Item_int_func(pos, a, b, c, d) {}
3098
3099 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
3100 longlong val_int() override;
3101
3102 const char *func_name() const override {
3103 return "internal_tablespace_data_free";
3104 }
3105
3106 bool resolve_type(THD *) override {
3107 set_nullable(true);
3108 null_on_null = false;
3109 return false;
3110 }
3111};
3112
3113/**
3114 Common class for:
3115 Item_func_get_system_var
3116 Item_func_get_user_var
3117 Item_func_set_user_var
3118*/
3119class Item_var_func : public Item_func {
3120 public:
3122 explicit Item_var_func(const POS &pos) : Item_func(pos) {}
3123
3124 Item_var_func(THD *thd, Item_var_func *item) : Item_func(thd, item) {}
3125
3127 Item_var_func(const POS &pos, Item *a) : Item_func(pos, a) {}
3128
3129 bool val_date(Date_val *date, my_time_flags_t flags) override {
3130 return get_date_from_non_temporal(date, flags);
3131 }
3132 bool val_time(Time_val *time) override {
3133 return get_time_from_non_temporal(time);
3134 }
3137 }
3138 bool check_function_as_value_generator(uchar *checker_args) override {
3140 pointer_cast<Check_function_as_value_generator_parameters *>(
3141 checker_args);
3142 func_arg->err_code = (func_arg->source == VGS_CHECK_CONSTRAINT)
3143 ? ER_CHECK_CONSTRAINT_VARIABLES
3144 : ER_DEFAULT_VAL_GENERATED_VARIABLES;
3145 return true;
3146 }
3147};
3148
3149/* Handling of user definable variables */
3150
3151// this is needed for user_vars hash
3154 m_ptr = nullptr;
3155 m_length = 0;
3156 }
3157 void set_value(char *value, size_t length) {
3158 m_ptr = value;
3159 m_length = length;
3160 }
3161
3162 /**
3163 Position inside a user_var_entry where small values are stored:
3164 double values, longlong values and string values with length
3165 up to extra_size (should be 8 bytes on all platforms).
3166 String values with length longer than 8 are stored in a separate
3167 memory buffer, which is allocated when needed using the method realloc().
3168 */
3170 return pointer_cast<char *>(this) + ALIGN_SIZE(sizeof(user_var_entry));
3171 }
3172
3173 /**
3174 Position inside a user_var_entry where a null-terminates array
3175 of characters representing the variable name is stored.
3176 */
3178
3179 /**
3180 Initialize m_ptr to the internal buffer (if the value is small enough),
3181 or allocate a separate buffer.
3182 @param length - length of the value to be stored.
3183 */
3184 bool mem_realloc(size_t length);
3185
3186 /**
3187 Check if m_ptr points to an external buffer previously allocated by
3188 realloc().
3189 @retval true - an external buffer is allocated.
3190 @retval false - m_ptr is null, or points to the internal buffer.
3191 */
3192 bool alloced() { return m_ptr && m_ptr != internal_buffer_ptr(); }
3193
3194 /**
3195 Free the external value buffer, if it's allocated.
3196 */
3197 void free_value() {
3198 if (alloced()) my_free(m_ptr);
3199 }
3200
3201 /**
3202 Copy the array of characters from the given name into the internal
3203 name buffer and initialize entry_name to point to it.
3204 */
3206 name.strcpy(name_ptr());
3207 entry_name = Name_string(name_ptr(), name.length());
3208 }
3209
3210 /**
3211 Initialize all members
3212
3213 @param thd Current session.
3214 @param name Name of the user_var_entry instance.
3215 @param cs charset information of the user_var_entry instance.
3216 */
3217 void init(THD *thd, const Simple_cstring &name, const CHARSET_INFO *cs);
3218
3219 /**
3220 Store a value of the given type into a user_var_entry instance.
3221 @param from Value
3222 @param length Size of the value
3223 @param type type
3224 @retval false on success
3225 @retval true on memory allocation error
3226 */
3227 bool store(const void *from, size_t length, Item_result type);
3228
3229 /**
3230 Assert the user variable is locked.
3231 This is debug code only.
3232 The thread LOCK_thd_data mutex protects:
3233 - the thd->user_vars hash itself
3234 - the values in the user variable itself.
3235 The protection is required for monitoring,
3236 as a different thread can inspect this session
3237 user variables, on a live session.
3238 */
3239 void assert_locked() const;
3240
3241 static const size_t extra_size = sizeof(double);
3242 char *m_ptr; ///< Value
3243 size_t m_length; ///< Value length
3244 Item_result m_type; ///< Value type
3246 /**
3247 Set to the id of the most recent query that has used the variable.
3248 Used in binlogging: When set, there is no need to add a reference to this
3249 variable to the binlog. Imagine it is this:
3250
3251 INSERT INTO t SELECT @a:=10, @a:=@a+1.
3252
3253 Then we have a Item_func_get_user_var (because of the `@a+1`) so we
3254 think we have to write the value of `@a` to the binlog. But before that,
3255 we have a Item_func_set_user_var to create `@a` (`@a:=10`), in this we mark
3256 the variable as "already logged" so that it won't be logged
3257 by Item_func_get_user_var (because that's not necessary).
3258 */
3260
3261 public:
3262 user_var_entry() = default; /* Remove gcc warning */
3263
3264 THD *owner_session() const { return m_owner; }
3265
3266 Simple_cstring entry_name; // Variable name
3267 DTCollation collation; // Collation with attributes
3268 bool unsigned_flag; // true if unsigned, false if signed
3269
3270 /**
3271 Set value to user variable.
3272
3273 @param ptr pointer to buffer with new value
3274 @param length length of new value
3275 @param type type of new value
3276 @param cs charset info for new value
3277 @param dv derivation for new value
3278 @param unsigned_arg indicates if a value of type INT_RESULT is unsigned
3279
3280 @note Sets error and fatal error if allocation fails.
3281
3282 @retval
3283 false success
3284 @retval
3285 true failure
3286 */
3287 bool store(const void *ptr, size_t length, Item_result type,
3288 const CHARSET_INFO *cs, Derivation dv, bool unsigned_arg);
3289 /**
3290 Set type of to the given value.
3291 @param type Data type.
3292 */
3294 assert_locked();
3295 m_type = type;
3296 }
3297 /**
3298 Set value to NULL
3299 @param type Data type.
3300 */
3301
3303 assert_locked();
3304 free_value();
3305 reset_value();
3306 m_type = type;
3307 }
3308
3309 void set_used_query_id(query_id_t query_id) { m_used_query_id = query_id; }
3311
3312 /**
3313 Allocates and initializes a user variable instance.
3314
3315 @param thd Current session.
3316 @param name Name of the variable.
3317 @param cs Charset of the variable.
3318
3319 @return Address of the allocated and initialized user_var_entry instance.
3320 @retval NULL On allocation error.
3321 */
3322 static user_var_entry *create(THD *thd, const Name_string &name,
3323 const CHARSET_INFO *cs);
3324
3325 /**
3326 Free all memory used by a user_var_entry instance
3327 previously created by create().
3328 */
3329 void destroy() {
3330 assert_locked();
3331 free_value(); // Free the external value buffer
3332 my_free(this); // Free the instance itself
3333 }
3334
3335 void lock();
3336 void unlock();
3337
3338 /* Routines to access the value and its type */
3339 const char *ptr() const { return m_ptr; }
3340 size_t length() const { return m_length; }
3341 /// The data type of this variable.
3342 Item_result type() const { return m_type; }
3343 /* Item-alike routines to access the value */
3344 double val_real(bool *null_value) const;
3345 longlong val_int(bool *null_value) const;
3346 String *val_str(bool *null_value, String *str, uint decimals) const;
3347 my_decimal *val_decimal(bool *null_value, my_decimal *result) const;
3348};
3349
3350/**
3351 This class is used to implement operations like
3352 SET \@variable or \@variable:= expression.
3353*/
3354
3361 union {
3363 double vreal;
3367
3368 public:
3369 Name_string name; // keep it public
3370
3373 : Item_var_func(pos, b), name(a) {}
3374
3376 : Item_var_func(thd, item),
3378 entry(item->entry),
3379 value(item->value),
3381 null_item(item->null_item),
3382 save_result(item->save_result),
3383 name(item->name) {}
3384 enum Functype functype() const override { return SUSERVAR_FUNC; }
3385 double val_real() override;
3386 longlong val_int() override;
3387 String *val_str(String *str) override;
3388 my_decimal *val_decimal(my_decimal *) override;
3389 bool update_hash(const void *ptr, uint length, enum Item_result type,
3390 const CHARSET_INFO *cs, Derivation dv, bool unsigned_arg);
3391 bool send(Protocol *protocol, String *str_arg) override;
3392 void make_field(Send_field *tmp_field) override;
3393 bool check(bool use_result_field);
3394 void save_item_result(Item *item);
3395 bool update();
3396 enum Item_result result_type() const override { return cached_result_type; }
3397 bool fix_fields(THD *thd, Item **ref) override;
3398 bool resolve_type(THD *) override;
3399 void print(const THD *thd, String *str,
3400 enum_query_type query_type) const override;
3401 uint64_t hash() override;
3402 void print_assignment(const THD *thd, String *str,
3403 enum_query_type query_type) const;
3404 const char *func_name() const override { return "set_user_var"; }
3405
3406 type_conversion_status save_in_field(Field *field, bool no_conversions,
3407 bool can_use_result_field);
3408
3409 void save_org_in_field(Field *field) override {
3410 save_in_field(field, true, false);
3411 }
3412
3413 bool set_entry(THD *thd, bool create_if_not_exists);
3414 void cleanup() override;
3415
3416 protected:
3418 bool no_conversions) override {
3419 return save_in_field(field, no_conversions, true);
3420 }
3421};
3422
3427
3428 public:
3429 Name_string name; // keep it public
3430
3435
3436 enum Functype functype() const override { return GUSERVAR_FUNC; }
3437 double val_real() override;
3438 longlong val_int() override;
3439 my_decimal *val_decimal(my_decimal *) override;
3440 String *val_str(String *str) override;
3441 const CHARSET_INFO *charset_for_protocol() override;
3442 bool resolve_type(THD *) override;
3443 bool propagate_type(THD *thd, const Type_properties &type) override;
3444 void cleanup() override;
3445 void update_used_tables() override {} // Keep existing used tables
3446 void print(const THD *thd, String *str,
3447 enum_query_type query_type) const override;
3448 uint64_t hash() override;
3449 enum Item_result result_type() const override;
3450 /*
3451 We must always return variables as strings to guard against selects of type
3452 select @t1:=1,@t1,@t:="hello",@t from foo where (@t1:= t2.b)
3453 */
3454 const char *func_name() const override { return "get_user_var"; }
3455 bool is_non_const_over_literals(uchar *) override { return true; }
3456 bool eq_specific(const Item *item) const override;
3457
3458 private:
3459 bool set_value(THD *thd, sp_rcontext *ctx, Item **it) override;
3460
3461 public:
3463 return this;
3464 }
3465};
3466
3467/*
3468 This item represents user variable used as out parameter (e.g in LOAD DATA),
3469 and it is supposed to be used only for this purprose. So it is simplified
3470 a lot. Actually you should never obtain its value.
3471
3472 The only two reasons for this thing being an Item is possibility to store it
3473 in const mem_root_deque<Item> and desire to place this code somewhere near
3474 other functions working with user variables.
3475*/
3479
3480 public:
3482 : Item(pos), name(a) {
3483 item_name.copy(a);
3484 }
3485 /* We should return something different from FIELD_ITEM here */
3486 enum Type type() const override { return STRING_ITEM; }
3487 double val_real() override;
3488 longlong val_int() override;
3489 String *val_str(String *str) override;
3490 my_decimal *val_decimal(my_decimal *decimal_buffer) override;
3492 assert(false);
3493 return true;
3494 }
3495 bool val_time(Time_val *) override {
3496 assert(false);
3497 return true;
3498 }
3500 assert(false);
3501 return true;
3502 }
3503 /* fix_fields() binds variable name with its entry structure */
3504 bool fix_fields(THD *thd, Item **ref) override;
3505 void print(const THD *thd, String *str,
3506 enum_query_type query_type) const override;
3507 uint64_t hash() override;
3508 void set_null_value(const CHARSET_INFO *cs);
3509 void set_value(const char *str, size_t length, const CHARSET_INFO *cs);
3510};
3511
3512/* A system variable */
3513
3514#define GET_SYS_VAR_CACHE_LONG 1
3515#define GET_SYS_VAR_CACHE_DOUBLE 2
3516#define GET_SYS_VAR_CACHE_STRING 4
3517
3519
3520/** Class to log audit event EVENT_TRACKING_GLOBAL_VARIABLE_GET. */
3522 public:
3526
3527 private:
3528 // Thread handle.
3530
3531 // Item_func_get_system_var instance.
3533
3534 /*
3535 Value conversion type.
3536 Depending on the value conversion type GET_SYS_VAR_CACHE_* is stored in this
3537 member while creating the object. While converting value if there are any
3538 intermediate conversions in the same query then this member is used to avoid
3539 auditing more than once.
3540 */
3542
3543 /*
3544 To indicate event auditing is required or not. Event is not audited if
3545 * scope of the variable is *not* GLOBAL.
3546 * or the event is already audited for global variable for the same query.
3547 */
3549};
3550
3560
3561 template <typename T>
3563
3565
3566 public:
3568 enum_var_type scope);
3569 enum Functype functype() const override { return GSYSVAR_FUNC; }
3571 return INNER_TABLE_BIT;
3572 }
3573 bool resolve_type(THD *) override;
3574 void print(const THD *thd, String *str,
3575 enum_query_type query_type) const override;
3576 uint64_t hash() override;
3577 bool is_non_const_over_literals(uchar *) override { return true; }
3578 enum Item_result result_type() const override {
3579 assert(fixed);
3580 return type_to_result(data_type());
3581 }
3582 double val_real() override;
3583 longlong val_int() override;
3584 String *val_str(String *) override;
3585 my_decimal *val_decimal(my_decimal *dec_buf) override {
3586 return val_decimal_from_real(dec_buf);
3587 }
3588 /* TODO: fix to support views */
3589 const char *func_name() const override { return "get_system_var"; }
3590 bool eq_specific(const Item *item) const override;
3591 bool is_valid_for_pushdown(uchar *arg [[maybe_unused]]) override {
3592 // Expressions which have system variables cannot be pushed as of
3593 // now because Item_func_get_system_var::print does not print the
3594 // original expression which leads to an incorrect clone.
3595 return true;
3596 }
3597
3598 void cleanup() override;
3599};
3600
3601class JOIN;
3602
3603class Item_func_match final : public Item_real_func {
3605
3606 protected:
3607 void add_json_info(Json_object *obj) override;
3608
3609 public:
3611 uint key, flags;
3612 /// True if we are doing a full-text index scan with this MATCH function as a
3613 /// predicate, and the score can be retrieved with get_relevance(). If it is
3614 /// false, the score of the document must be retrieved with find_relevance().
3619 /**
3620 Master item means that if identical items are present in the
3621 statement, they use the same FT handler. FT handler is initialized
3622 only for master item and slave items just use it. FT hints initialized
3623 for master only, slave items HINTS are not accessed.
3624 */
3626 Item *concat_ws; // Item_func_concat_ws
3627 String value; // value of concat_ws
3628 String search_value; // key_item()'s value converted to cmp_collation
3629
3630 /**
3631 Constructor for Item_func_match class.
3632
3633 @param pos Position of token in the parser.
3634 @param a List of arguments.
3635 @param against_arg Expression to match against.
3636 @param b FT Flags.
3637 */
3638 Item_func_match(const POS &pos, PT_item_list *a, Item *against_arg, uint b)
3639 : Item_real_func(pos, a),
3640 against(against_arg),
3641 key(0),
3642 flags(b),
3645 master(nullptr),
3647 hints(nullptr),
3648 simple_expression(false),
3649 used_in_where_only(false) {
3650 null_on_null = false;
3651 }
3652
3653 bool do_itemize(Parse_context *pc, Item **res) override;
3654
3655 void cleanup() override {
3656 DBUG_TRACE;
3658 if (master == nullptr && ft_handler != nullptr) {
3660 }
3661 score_from_index_scan = false;
3662 ft_handler = nullptr;
3663 concat_ws = nullptr;
3664 return;
3665 }
3666 Item *key_item() const override { return against; }
3667 enum Functype functype() const override { return FT_FUNC; }
3668 const char *func_name() const override { return "match"; }
3669 bool fix_fields(THD *thd, Item **ref) override;
3670 void update_used_tables() override;
3671 bool eq_specific(const Item *item) const override;
3672 /* The following should be safe, even if we compare doubles */
3673 longlong val_int() override {
3674 assert(fixed);
3675 return val_real() != 0.0;
3676 }
3677 double val_real() override;
3678 void print(const THD *thd, String *str,
3679 enum_query_type query_type) const override;
3680 uint64_t hash() override;
3681 bool fix_index(const THD *thd);
3682 bool init_search(THD *thd);
3683 bool check_function_as_value_generator(uchar *checker_args) override {
3685 pointer_cast<Check_function_as_value_generator_parameters *>(
3686 checker_args);
3687 func_arg->banned_function_name = func_name();
3688 return true;
3689 }
3690
3691 /**
3692 Get number of matching rows from FT handler.
3693
3694 @note Requires that FT handler supports the extended API
3695
3696 @return Number of matching rows in result
3697 */
3699 assert(ft_handler);
3701
3702 return ((FT_INFO_EXT *)ft_handler)
3703 ->could_you->count_matches((FT_INFO_EXT *)ft_handler);
3704 }
3705
3706 /**
3707 Check whether FT result is ordered on rank
3708
3709 @return true if result is ordered
3710 @return false otherwise
3711 */
3713 assert(!master);
3714 if (hints->get_flags() & FT_SORTED) return true;
3715
3717 return false;
3718
3719 assert(ft_handler);
3720 return ((FT_INFO_EXT *)ft_handler)->could_you->get_flags() &
3722 }
3723
3724 /**
3725 Check whether FT result contains the document ID
3726
3727 @return true if document ID is available
3728 @return false otherwise
3729 */
3731 assert(ft_handler);
3732
3734 return false;
3735
3736 return ((FT_INFO_EXT *)ft_handler)->could_you->get_flags() &
3738 }
3739
3740 float get_filtering_effect(THD *thd, table_map filter_for_table,
3741 table_map read_tables,
3742 const MY_BITMAP *fields_to_ignore,
3743 double rows_in_table) override;
3744
3745 /**
3746 Returns master MATCH function.
3747
3748 @return pointer to master MATCH function.
3749 */
3751 if (master) return master->get_master();
3752 return this;
3753 }
3754
3755 /**
3756 Set master MATCH function and adjust used_in_where_only value.
3757
3758 @param item item for which master should be set.
3759 */
3762 item->master = this;
3763 }
3764
3765 /**
3766 Returns pointer to Ft_hints object belonging to master MATCH function.
3767
3768 @return pointer to Ft_hints object
3769 */
3771 assert(!master);
3772 return hints;
3773 }
3774
3775 /**
3776 Set comparison operation type and and value for master MATCH function.
3777
3778 @param type comparison operation type
3779 @param value_arg comparison operation value
3780 */
3781 void set_hints_op(enum ft_operation type, double value_arg) {
3782 assert(!master);
3783 hints->set_hint_op(type, value_arg);
3784 }
3785
3786 /**
3787 Set FT hints.
3788 */
3789 void set_hints(JOIN *join, uint ft_flag, ha_rows ft_limit, bool no_cond);
3790
3791 /**
3792 Check if ranking is not needed.
3793
3794 @return true if ranking is not needed
3795 @return false otherwise
3796 */
3798 assert(!master);
3799 return (!(hints->get_flags() & FT_SORTED) && // FT_SORTED is no set
3800 used_in_where_only && // MATCH result is not used
3801 // in expression
3802 hints->get_op_type() == FT_OP_NO); // MATCH is single function
3803 }
3804
3805 /**
3806 Set flag that the function is a simple expression.
3807
3808 @param val true if the function is a simple expression, false otherwise
3809 */
3810 void set_simple_expression(bool val) {
3811 assert(!master);
3812 simple_expression = val;
3813 }
3814
3815 /**
3816 Check if this MATCH function is a simple expression in WHERE condition.
3817
3818 @return true if simple expression
3819 @return false otherwise
3820 */
3822 assert(!master);
3823 return simple_expression;
3824 }
3825
3826 private:
3827 /**
3828 Fulltext index hints, initialized for master MATCH function only.
3829 */
3831 /**
3832 Flag is true when MATCH function is used as a simple expression in
3833 WHERE condition, i.e. there is no AND/OR combinations, just simple
3834 MATCH function or [MATCH, rank] comparison operation.
3835 */
3837 /**
3838 true if MATCH function is used in WHERE condition only.
3839 Used to determine what hints can be used for FT handler.
3840 Note that only master MATCH function has valid value.
3841 it's ok since only master function is involved in the hint processing.
3842 */
3844 /**
3845 Check whether storage engine for given table,
3846 allows FTS Boolean search on non-indexed columns.
3847
3848 @todo A flag should be added to the extended fulltext API so that
3849 it may be checked whether search on non-indexed columns are
3850 supported. Currently, it is not possible to check for such a
3851 flag since @c this->ft_handler is not yet set when this function is
3852 called. The current hack is to assume that search on non-indexed
3853 columns are supported for engines that does not support the extended
3854 fulltext API (e.g., MyISAM), while it is not supported for other
3855 engines (e.g., InnoDB)
3856
3857 @param tr Table for which storage engine to check
3858
3859 @retval true if BOOLEAN search on non-indexed columns is supported
3860 @retval false otherwise
3861 */
3863 // Only Boolean search may support non_indexed columns
3864 if (!(flags & FT_BOOL)) return false;
3865
3866 assert(tr && tr->file);
3867
3868 // Assume that if extended fulltext API is not supported,
3869 // non-indexed columns are allowed. This will be true for MyISAM.
3870 if ((tr->file->ha_table_flags() & HA_CAN_FULLTEXT_EXT) == 0) return true;
3871
3872 return false;
3873 }
3874};
3875
3876/**
3877 A visitor that calls the specified function on every non-aggregated full-text
3878 search function (Item_func_match) it encounters when it is used in a
3879 PREFIX+POSTFIX walk with WalkItem(). It skips every item that is wrapped in an
3880 aggregate function, and also every item wrapped in a reference, as the items
3881 behind the reference are already handled elsewhere (in another query block or
3882 in another element of the SELECT list).
3883 */
3885 public:
3887 std::function<bool(Item_func_match *)> func);
3888 bool operator()(Item *item);
3889
3890 private:
3891 std::function<bool(Item_func_match *)> m_func;
3892};
3893
3896
3898
3899 public:
3900 Item_func_is_free_lock(const POS &pos, Item *a) : Item_int_func(pos, a) {}
3901
3902 bool do_itemize(Parse_context *pc, Item **res) override;
3903 longlong val_int() override;
3904 const char *func_name() const override { return "is_free_lock"; }
3906 return INNER_TABLE_BIT;
3907 }
3908 bool resolve_type(THD *thd) override {
3909 if (param_type_is_default(thd, 0, 1)) return true;
3910 max_length = 1;
3911 set_nullable(true);
3912 return false;
3913 }
3914 bool is_non_const_over_literals(uchar *) override { return true; }
3915 bool check_function_as_value_generator(uchar *checker_args) override {
3917 pointer_cast<Check_function_as_value_generator_parameters *>(
3918 checker_args);
3919 func_arg->banned_function_name = func_name();
3920 return true;
3921 }
3922};
3923
3926
3928
3929 public:
3930 Item_func_is_used_lock(const POS &pos, Item *a) : Item_int_func(pos, a) {}
3931
3932 bool do_itemize(Parse_context *pc, Item **res) override;
3933 longlong val_int() override;
3934 const char *func_name() const override { return "is_used_lock"; }
3936 return INNER_TABLE_BIT;
3937 }
3938 bool resolve_type(THD *thd) override {
3939 if (param_type_is_default(thd, 0, 1)) return true;
3940 unsigned_flag = true;
3941 set_nullable(true);
3942 return false;
3943 }
3944 bool is_non_const_over_literals(uchar *) override { return true; }
3945 bool check_function_as_value_generator(uchar *checker_args) override {
3947 pointer_cast<Check_function_as_value_generator_parameters *>(
3948 checker_args);
3949 func_arg->banned_function_name = func_name();
3950 return true;
3951 }
3952};
3953
3956
3957 public:
3958 explicit Item_func_row_count(const POS &pos) : Item_int_func(pos) {}
3959
3960 bool do_itemize(Parse_context *pc, Item **res) override;
3961
3962 longlong val_int() override;
3963 const char *func_name() const override { return "row_count"; }
3964 bool resolve_type(THD *) override {
3965 set_nullable(false);
3966 return false;
3967 }
3968 bool check_function_as_value_generator(uchar *checker_args) override {
3970 pointer_cast<Check_function_as_value_generator_parameters *>(
3971 checker_args);
3972 func_arg->banned_function_name = func_name();
3973 return true;
3974 }
3975};
3976
3977/*
3978 *
3979 * Stored FUNCTIONs
3980 *
3981 */
3982
3983class sp_head;
3984class sp_name;
3985
3986class Item_func_sp final : public Item_func {
3988
3989 private:
3990 /// Holds the security definer context(if defined with SQL SECURITY DEFINER)
3991 /// and the error the handler.
3993 /// The name of the stored function
3994 sp_name *m_name{nullptr};
3995 /// Pointer to actual function instance (null when not resolved or executing)
3996 sp_head *m_sp{nullptr};
3997 /// The result field of the concrete stored function.
3999 /// true when function execution is deterministic
4000 bool m_deterministic{false};
4001
4002 bool execute();
4003 bool execute_impl(THD *thd);
4004 bool init_result_field(THD *thd);
4005
4006 protected:
4007 public:
4008 Item_func_sp(const POS &pos, const LEX_STRING &db_name,
4009 const LEX_STRING &fn_name, bool use_explicit_name,
4010 PT_item_list *opt_list);
4011
4012 bool do_itemize(Parse_context *pc, Item **res) override;
4013 /**
4014 Must not be called before the procedure is resolved,
4015 i.e. @c init_result_field().
4016 */
4017 table_map get_initial_pseudo_tables() const override;
4018 void update_used_tables() override;
4019 void fix_after_pullout(Query_block *parent_query_block,
4020 Query_block *removed_query_block) override;
4021 void cleanup() override;
4022
4023 const char *func_name() const override;
4024
4025 Field *tmp_table_field(TABLE *t_arg) override;
4026
4027 void make_field(Send_field *tmp_field) override;
4028
4029 Item_result result_type() const override;
4030
4031 longlong val_int() override;
4032 double val_real() override;
4033 bool val_date(Date_val *date, my_time_flags_t flags) override;
4034 bool val_time(Time_val *time) override;
4035 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
4036 my_decimal *val_decimal(my_decimal *dec_buf) override;
4037 String *val_str(String *str) override;
4038 bool val_json(Json_wrapper *result) override;
4039
4040 bool change_context_processor(uchar *arg) override {
4042 pointer_cast<Item_ident::Change_context *>(arg)->m_context;
4043 return false;
4044 }
4045
4046 bool sp_check_access(THD *thd);
4047 sp_head *get_sp() { return m_sp; }
4048 const sp_name *get_name() { return m_name; }
4049 enum Functype functype() const override { return FUNC_SP; }
4050
4051 bool fix_fields(THD *thd, Item **ref) override;
4052 bool resolve_type(THD *thd) override;
4053
4055 bool check_function_as_value_generator(uchar *checker_args) override {
4057 pointer_cast<Check_function_as_value_generator_parameters *>(
4058 checker_args);
4059 func_arg->banned_function_name = func_name();
4060 return true;
4061 }
4062
4063 void compute_cost(CostOfItem *root_cost) const override {
4064 root_cost->MarkExpensive();
4065 }
4066};
4067
4070
4071 public:
4072 explicit Item_func_found_rows(const POS &pos) : Item_int_func(pos) {}
4073
4074 bool do_itemize(Parse_context *pc, Item **res) override;
4075 longlong val_int() override;
4076 const char *func_name() const override { return "found_rows"; }
4077 bool resolve_type(THD *) override {
4078 set_nullable(false);
4079 return false;
4080 }
4081 bool check_function_as_value_generator(uchar *checker_args) override {
4083 pointer_cast<Check_function_as_value_generator_parameters *>(
4084 checker_args);
4085 func_arg->banned_function_name = func_name();
4086 return true;
4087 }
4088};
4089
4090void uuid_short_init();
4091
4094
4095 public:
4097
4098 bool do_itemize(Parse_context *pc, Item **res) override;
4099 const char *func_name() const override { return "uuid_short"; }
4100 longlong val_int() override;
4101 bool resolve_type(THD *) override {
4102 unsigned_flag = true;
4103 return false;
4104 }
4105 bool check_partition_func_processor(uchar *) override { return false; }
4106 bool check_function_as_value_generator(uchar *checker_args) override {
4108 pointer_cast<Check_function_as_value_generator_parameters *>(
4109 checker_args);
4110 func_arg->banned_function_name = func_name();
4111 return ((func_arg->source == VGS_GENERATED_COLUMN) ||
4112 (func_arg->source == VGS_CHECK_CONSTRAINT));
4113 }
4114 // This function is random, see uuid_short_init().
4116 return RAND_TABLE_BIT;
4117 }
4118};
4119
4122
4123 public:
4124 explicit Item_func_version(const POS &pos);
4125
4126 bool do_itemize(Parse_context *pc, Item **res) override;
4127};
4128
4129/**
4130 Internal function used by INFORMATION_SCHEMA implementation to check
4131 if a role is a mandatory role.
4132*/
4133
4135 public:
4137 : Item_int_func(pos, a, b) {}
4138 longlong val_int() override;
4139 const char *func_name() const override {
4140 return "internal_is_mandatory_role";
4141 }
4142 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
4143 bool resolve_type(THD *) override {
4144 set_nullable(true);
4145 return false;
4146 }
4147};
4148
4150 public:
4152 : Item_int_func(pos) {}
4153 longlong val_int() override;
4154 const char *func_name() const override {
4155 return "internal_use_terminology_previous";
4156 }
4157 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
4158 bool resolve_type(THD *) override {
4159 set_nullable(true);
4160 return false;
4161 }
4162};
4163
4164/**
4165 Internal function used by INFORMATION_SCHEMA implementation to check
4166 if a role is enabled.
4167*/
4168
4170 public:
4172 : Item_int_func(pos, a, b) {}
4173 longlong val_int() override;
4174 const char *func_name() const override { return "internal_is_enabled_role"; }
4175 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
4176 bool resolve_type(THD *) override {
4177 set_nullable(true);
4178 return false;
4179 }
4180};
4181
4182/**
4183 Create new Item_func_get_system_var object
4184
4185 @param pc Parse context
4186
4187 @param scope Scope of the variable (GLOBAL, SESSION, PERSISTENT ...)
4188
4189 @param prefix Empty LEX_CSTRING{} or the left hand side of the composite
4190 variable name, e.g.:
4191 * component name of the component-registered variable
4192 * name of MyISAM Multiple Key Cache.
4193
4194 @param suffix Name of the variable (if prefix is empty) or the right
4195 hand side of the composite variable name, e.g.:
4196 * name of the component-registered variable
4197 * property name of MyISAM Multiple Key Cache variable.
4198
4199 @param unsafe_for_replication force writing this system variable to binlog
4200 (if not written yet)
4201
4202 @returns new item on success, otherwise nullptr
4203*/
4205 const LEX_CSTRING &prefix, const LEX_CSTRING &suffix,
4206 bool unsafe_for_replication);
4207
4209 const LEX_CSTRING &trivial_name,
4210 bool unsafe_for_replication) {
4211 return get_system_variable(pc, scope, {}, trivial_name,
4212 unsafe_for_replication);
4213}
4214
4215extern bool check_reserved_words(const char *name);
4216extern enum_field_types agg_field_type(Item **items, uint nitems);
4217double my_double_round(double value, longlong dec, bool dec_unsigned,
4218 bool truncate);
4219bool eval_const_cond(THD *thd, Item *cond, bool *value);
4221 Field **found = nullptr);
4222
4223void retrieve_tablespace_statistics(THD *thd, Item **args, bool *null_value);
4224
4226
4227extern bool volatile mqh_used;
4228
4229/// Checks if "item" is a function of the specified type.
4231
4232/// Checks if "item" contains a function of the specified type.
4234
4235#endif /* ITEM_FUNC_INCLUDED */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
int64 query_id_t
Definition: binlog.h:72
Class to log audit event EVENT_TRACKING_GLOBAL_VARIABLE_GET.
Definition: item_func.h:3521
Audit_global_variable_get_event(THD *thd, Item_func_get_system_var *item, uchar cache_type)
Definition: item_func.cc:7320
THD * m_thd
Definition: item_func.h:3529
~Audit_global_variable_get_event()
Definition: item_func.cc:7333
bool m_audit_event
Definition: item_func.h:3548
Item_func_get_system_var * m_item
Definition: item_func.h:3532
uchar m_val_type
Definition: item_func.h:3541
This class represents the cost of evaluating an Item.
Definition: item.h:789
void MarkExpensive()
Definition: item.h:798
Definition: item.h:183
void set_numeric()
Definition: item.h:219
const CHARSET_INFO * collation
Definition: item.h:185
Definition: my_temporal.h:395
Definition: my_temporal.h:339
Definition: field.h:570
Wrapper for struct ft_hints.
Definition: handler.h:4308
uint get_flags() const
Get Ft_hints flags.
Definition: handler.h:4371
enum ft_operation get_op_type() const
Get Ft_hints operation type.
Definition: handler.h:4364
void set_hint_op(enum ft_operation type, double value)
Set comparison operation type and and value for master MATCH function.
Definition: handler.h:4326
Definition: item_func.h:1376
Item_dec_func(const POS &pos, Item *a)
Definition: item_func.h:1379
Item_dec_func(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1381
Item_dec_func(Item *a)
Definition: item_func.h:1378
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:2886
Definition: item.h:4467
Definition: item_func.h:1361
enum Functype functype() const override
Definition: item_func.h:1371
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:2855
bool check_function_as_value_generator(uchar *) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:1370
my_decimal * decimal_op(my_decimal *) override
Evaluates item when resulting data type is DECIMAL.
Definition: item_func.cc:2870
const char * func_name() const override
Definition: item_func.h:1367
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1369
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:2861
Item_func_abs(const POS &pos, Item *a)
Definition: item_func.h:1363
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:2880
Definition: item_func.h:1441
const char * func_name() const override
Definition: item_func.h:1445
double val_real() override
Definition: item_func.cc:2984
enum Functype functype() const override
Definition: item_func.h:1446
Item_func_acos(const POS &pos, Item *a)
Definition: item_func.h:1443
Definition: item_func.h:1230
Item_func_additive_op(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1233
Item_func_additive_op(Item *a, Item *b)
Definition: item_func.h:1232
void result_precision() override
Set precision of results for additive operations (+ and -)
Definition: item_func.cc:2267
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1237
bool check_function_as_value_generator(uchar *) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:1238
Definition: item_func.h:1949
const char * func_name() const override
Definition: item_func.h:1955
longlong val_int() override
Definition: item_func.cc:4472
String value
Definition: item_func.h:1950
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1956
Item_func_ascii(const POS &pos, Item *a)
Definition: item_func.h:1953
Definition: item_func.h:1449
double val_real() override
Definition: item_func.cc:2994
enum Functype functype() const override
Definition: item_func.h:1454
const char * func_name() const override
Definition: item_func.h:1453
Item_func_asin(const POS &pos, Item *a)
Definition: item_func.h:1451
Definition: item_func.h:1457
enum Functype functype() const override
Definition: item_func.h:1463
double val_real() override
Definition: item_func.cc:3002
Item_func_atan(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1460
Item_func_atan(const POS &pos, Item *a)
Definition: item_func.h:1459
const char * func_name() const override
Definition: item_func.h:1462
Definition: item_func.h:2222
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:5981
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2237
table_map get_initial_pseudo_tables() const override
Ensure that "benchmark()" is never optimized away.
Definition: item_func.h:2230
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:5910
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:2246
Item_int_func super
Definition: item_func.h:2223
Item_func_benchmark(const POS &pos, Item *count_expr, Item *expr)
Definition: item_func.h:2226
longlong val_int() override
Definition: item_func.cc:5919
const char * func_name() const override
Definition: item_func.h:2236
Definition: item_func.h:2091
longlong int_op() override
Performs the operation on integers to produce a result of type INT_RESULT.
Definition: item_func.h:2099
const char * func_name() const override
Definition: item_func.h:2095
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.h:2096
Item_func_bit_and(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2093
String * str_op(String *str) override
Performs the operation on binary strings to produce a result of type STRING_RESULT.
Definition: item_func.h:2100
Definition: item_func.h:2119
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2124
longlong val_int() override
Definition: item_func.cc:4612
const char * func_name() const override
Definition: item_func.h:2123
Item_func_bit_count(const POS &pos, Item *a)
Definition: item_func.h:2121
Definition: item_func.h:1859
const char * func_name() const override
Definition: item_func.h:1866
longlong val_int() override
Definition: item_func.h:1862
Item_func_bit_length(const POS &pos, Item *a)
Definition: item_func.h:1861
Definition: item_func.h:2172
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.h:2181
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.h:2185
Item_func_bit_neg(const POS &pos, Item *a)
Definition: item_func.h:2179
longlong int_op() override
Performs the operation on integers to produce a result of type INT_RESULT.
Definition: item_func.cc:3236
bool binary_result_requires_binary_second_arg() const override
Definition: item_func.h:2174
String * str_op(String *str) override
Performs the operation on binary strings to produce a result of type STRING_RESULT.
Definition: item_func.cc:3244
const char * func_name() const override
Definition: item_func.h:2180
Definition: item_func.h:2077
const char * func_name() const override
Definition: item_func.h:2081
String * str_op(String *str) override
Performs the operation on binary strings to produce a result of type STRING_RESULT.
Definition: item_func.h:2086
longlong int_op() override
Performs the operation on integers to produce a result of type INT_RESULT.
Definition: item_func.h:2085
Item_func_bit_or(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2079
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.h:2082
Base class for all the bit functions that work with two binary arguments: '&', '|',...
Definition: item_func.h:2062
String * eval_str_op(String *, Char_func char_func, Int_func int_func)
Template function that evaluates the bitwise operation over binary arguments.
Definition: item_func.cc:3302
bool binary_result_requires_binary_second_arg() const override
Definition: item_func.h:2064
longlong eval_int_op(Int_func int_func)
Template function used to evaluate the bitwise operation over int arguments.
Definition: item_func.cc:3276
Item_func_bit_two_param(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2073
Definition: item_func.h:2105
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.h:2110
const char * func_name() const override
Definition: item_func.h:2109
Item_func_bit_xor(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2107
longlong int_op() override
Performs the operation on integers to produce a result of type INT_RESULT.
Definition: item_func.h:2113
String * str_op(String *str) override
Performs the operation on binary strings to produce a result of type STRING_RESULT.
Definition: item_func.h:2114
Definition: item_func.h:1994
virtual longlong int_op()=0
Performs the operation on integers to produce a result of type INT_RESULT.
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_func.h:2022
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.h:2018
String tmp_value
Buffer storing the determined value.
Definition: item_func.h:1999
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_func.h:2034
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:3048
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:2028
virtual bool binary_result_requires_binary_second_arg() const =0
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_func.cc:3109
double val_real() override
Definition: item_func.cc:3093
String * val_str(String *str) override
Definition: item_func.cc:3117
Item_result hybrid_type
Stores the Item's result type. Can only be INT_RESULT or STRING_RESULT.
Definition: item_func.h:1997
longlong val_int() override
Definition: item_func.cc:3077
Item_func_bit(const POS &pos, Item *a)
Definition: item_func.h:2008
virtual String * str_op(String *)=0
Performs the operation on binary strings to produce a result of type STRING_RESULT.
enum Item_result result_type() const override
Definition: item_func.h:2011
Item_func_bit(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2007
Definition: item_func.h:2692
const char * func_name() const override
Definition: item_func.h:2697
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:9320
Item_func_can_access_column(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_func.h:2694
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2698
Internal functions used by INFORMATION_SCHEMA implementation to check if user have access to given da...
Definition: item_func.h:2594
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2600
Item_func_can_access_database(const POS &pos, Item *a)
Definition: item_func.h:2596
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:8901
const char * func_name() const override
Definition: item_func.h:2599
Definition: item_func.h:2656
Item_func_can_access_event(const POS &pos, Item *a)
Definition: item_func.h:2658
const char * func_name() const override
Definition: item_func.h:2660
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2661
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:9205
Definition: item_func.h:2667
const char * func_name() const override
Definition: item_func.h:2672
Item_func_can_access_resource_group(const POS &pos, Item *a)
Definition: item_func.h:2669
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:9257
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2673
Definition: item_func.h:2643
Item_func_can_access_routine(const POS &pos, PT_item_list *list)
Definition: item_func.h:2645
const char * func_name() const override
Definition: item_func.h:2648
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:9111
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2649
Definition: item_func.h:2606
const char * func_name() const override
Definition: item_func.h:2611
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2612
Item_func_can_access_table(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2608
longlong val_int() override
INFORMATION_SCHEMA picks metadata from new DD using system views.
Definition: item_func.cc:9025
Definition: item_func.h:2630
Item_func_can_access_trigger(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2632
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2636
longlong val_int() override
INFORMATION_SCHEMA picks metadata from new DD using system views.
Definition: item_func.cc:9089
const char * func_name() const override
Definition: item_func.h:2635
Definition: item_func.h:2618
const char * func_name() const override
Definition: item_func.h:2623
Item_func_can_access_user(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2620
longlong val_int() override
INFORMATION_SCHEMA picks metadata from new DD using system views.
Definition: item_func.cc:9048
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2624
Definition: item_func.h:2680
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:9395
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2686
Item_func_can_access_view(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2682
const char * func_name() const override
Definition: item_func.h:2685
Definition: item_func.h:1505
bool check_function_as_value_generator(uchar *) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:1514
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1513
const char * func_name() const override
Definition: item_func.h:1509
enum Functype functype() const override
Definition: item_func.h:1515
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:3463
my_decimal * decimal_op(my_decimal *) override
Evaluates item when resulting data type is DECIMAL.
Definition: item_func.cc:3469
Item_func_ceiling(const POS &pos, Item *a)
Definition: item_func.h:1508
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:3442
Item_func_ceiling(Item *a)
Definition: item_func.h:1507
Definition: item_func.h:1869
Item_func_char_length(Item *a)
Definition: item_func.h:1873
Item_func_char_length(const POS &pos, Item *a)
Definition: item_func.h:1874
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1877
longlong val_int() override
Definition: item_func.cc:4324
const char * func_name() const override
Definition: item_func.h:1876
String value
Definition: item_func.h:1870
Definition: item_func.h:1883
const char * func_name() const override
Definition: item_func.h:1889
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1890
longlong val_int() override
Definition: item_func.cc:4335
Item_func_coercibility(const POS &pos, Item *a)
Definition: item_func.h:1885
Definition: item_func.h:1109
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:1522
table_map get_initial_pseudo_tables() const override
Returns the pseudo tables depended upon in order to evaluate this function expression.
Definition: item_func.h:1115
Item_int_func super
Definition: item_func.h:1110
const char * func_name() const override
Definition: item_func.h:1119
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:1123
Item_func_connection_id(const POS &pos)
Definition: item_func.h:1113
longlong val_int() override
Definition: item_func.cc:1534
bool fix_fields(THD *thd, Item **ref) override
Definition: item_func.cc:1528
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:1515
Definition: item_func.h:1466
enum Functype functype() const override
Definition: item_func.h:1471
const char * func_name() const override
Definition: item_func.h:1470
double val_real() override
Definition: item_func.cc:3014
Item_func_cos(const POS &pos, Item *a)
Definition: item_func.h:1468
Definition: item_func.h:1490
const char * func_name() const override
Definition: item_func.h:1494
enum Functype functype() const override
Definition: item_func.h:1495
double val_real() override
Definition: item_func.cc:3035
Item_func_cot(const POS &pos, Item *a)
Definition: item_func.h:1492
Definition: item_func.h:1617
Item_func_degrees(const POS &pos, Item *a)
Definition: item_func.h:1619
const char * func_name() const override
Definition: item_func.h:1621
enum Functype functype() const override
Definition: item_func.h:1622
Definition: item_func.h:1290
Item_func_div_base(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1292
Item_func_div_base(Item *a, Item *b)
Definition: item_func.h:1294
uint m_prec_increment
Definition: item_func.h:1301
my_decimal * decimal_op(my_decimal *) override
Evaluates item when resulting data type is DECIMAL.
Definition: item_func.cc:2523
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:2508
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:2613
enum Functype functype() const override
Definition: item_func.h:1298
Definition: item_func.h:1313
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:2675
void set_numeric_type() override
Check arguments to determine the data type for a numeric function of two arguments.
Definition: item_func.cc:2686
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1325
Item_func_div_int(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1316
enum_field_types default_data_type() const override
Get the default data (output) type for the specific item.
Definition: item_func.h:1319
bool check_function_as_value_generator(uchar *) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:1326
void result_precision() override
Definition: item_func.cc:2559
const char * func_name() const override
Definition: item_func.h:1318
Item_func_div_int(Item *a, Item *b)
Definition: item_func.h:1315
Definition: item_func.h:1304
void result_precision() override
Definition: item_func.cc:2542
Item_func_div(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1306
const char * func_name() const override
Definition: item_func.h:1308
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:2579
Definition: item_func.h:1385
double val_real() override
Definition: item_func.cc:2957
enum Functype functype() const override
Definition: item_func.h:1390
const char * func_name() const override
Definition: item_func.h:1389
Item_func_exp(const POS &pos, Item *a)
Definition: item_func.h:1387
Definition: item_func.h:1937
String value
Definition: item_func.h:1938
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:4457
const char * func_name() const override
Definition: item_func.h:1945
String tmp
Definition: item_func.h:1938
Item_func_field(const POS &pos, PT_item_list *opt_list)
Definition: item_func.h:1942
longlong val_int() override
Definition: item_func.cc:4414
Item_result cmp_type
Definition: item_func.h:1939
Definition: item_func.h:1971
const CHARSET_INFO * compare_collation() const override
Definition: item_func.h:1987
const char * func_name() const override
Definition: item_func.h:1985
Item_func_find_in_set(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1982
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:4506
longlong val_int() override
Definition: item_func.cc:4534
String value2
Definition: item_func.h:1972
DTCollation cmp_collation
Definition: item_func.h:1979
uint m_enum_value
Definition: item_func.h:1978
String value
Definition: item_func.h:1972
Definition: item_func.h:1518
my_decimal * decimal_op(my_decimal *) override
Evaluates item when resulting data type is DECIMAL.
Definition: item_func.cc:3505
const char * func_name() const override
Definition: item_func.h:1522
bool check_function_as_value_generator(uchar *) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:1527
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:3499
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1526
Item_func_floor(const POS &pos, Item *a)
Definition: item_func.h:1521
Item_func_floor(Item *a)
Definition: item_func.h:1520
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:3478
enum Functype functype() const override
Definition: item_func.h:1528
Definition: item_func.h:4068
Item_func_found_rows(const POS &pos)
Definition: item_func.h:4072
longlong val_int() override
Definition: item_func.cc:8616
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:4081
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:8605
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:4077
Item_int_func super
Definition: item_func.h:4069
const char * func_name() const override
Definition: item_func.h:4076
Definition: item_func.h:2902
const char * func_name() const override
Definition: item_func.h:2912
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:10238
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2907
Item_func_get_dd_index_sub_part_length(const POS &pos, PT_item_list *list)
Definition: item_func.h:2904
Definition: item_func.h:2453
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:2476
table_map get_initial_pseudo_tables() const override
Returns the pseudo tables depended upon in order to evaluate this function expression.
Definition: item_func.h:2465
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2468
Item_int_func super
Definition: item_func.h:2454
Item_func_get_lock(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2459
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:5586
const char * func_name() const override
Definition: item_func.h:2464
String value
Definition: item_func.h:2456
bool is_non_const_over_literals(uchar *) override
Definition: item_func.h:2475
longlong val_int() override
Get a user level lock.
Definition: item_func.cc:5611
Definition: item_func.h:3551
const enum_var_type var_scope
Definition: item_func.h:3552
table_map get_initial_pseudo_tables() const override
Returns the pseudo tables depended upon in order to evaluate this function expression.
Definition: item_func.h:3570
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.cc:7316
longlong get_sys_var_safe(THD *thd, sys_var *var)
Definition: item_func.cc:7368
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_func.cc:7648
longlong cached_llval
Definition: item_func.h:3553
enum Functype functype() const override
Definition: item_func.h:3569
Item_func_get_system_var(const System_variable_tracker &, enum_var_type scope)
Definition: item_func.cc:7265
double val_real() override
Definition: item_func.cc:7561
String cached_strval
Definition: item_func.h:3555
const char * func_name() const override
Definition: item_func.h:3589
longlong val_int() override
Definition: item_func.cc:7383
const System_variable_tracker var_tracker
Definition: item_func.h:3559
query_id_t used_query_id
Definition: item_func.h:3557
bool is_valid_for_pushdown(uchar *arg) override
Check if all the columns present in this expression are from the derived table.
Definition: item_func.h:3591
bool cached_null_value
Definition: item_func.h:3556
uchar cache_present
Definition: item_func.h:3558
double cached_dval
Definition: item_func.h:3554
enum Item_result result_type() const override
Definition: item_func.h:3578
bool is_non_const_over_literals(uchar *) override
Definition: item_func.h:3577
String * val_str(String *) override
Definition: item_func.cc:7468
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:7271
my_decimal * val_decimal(my_decimal *dec_buf) override
Definition: item_func.h:3585
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_func.cc:7654
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:7312
Definition: item_func.h:3424
Name_string name
Definition: item_func.h:3429
enum Item_result result_type() const override
Definition: item_func.cc:7163
double val_real() override
Definition: item_func.cc:6813
const CHARSET_INFO * charset_for_protocol() override
Definition: item_func.cc:6847
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:7011
Item_func_get_user_var(Name_string a)
Definition: item_func.h:3431
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.cc:7174
String * val_str(String *str) override
Definition: item_func.cc:6785
bool propagate_type(THD *thd, const Type_properties &type) override
Default implementation for all functions: Propagate base_item's type into all arguments.
Definition: item_func.cc:7070
enum Functype functype() const override
Definition: item_func.h:3436
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:7167
Settable_routine_parameter * get_settable_routine_parameter() override
Definition: item_func.h:3462
user_var_entry * var_entry
Definition: item_func.h:3425
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_func.cc:7154
const char * func_name() const override
Definition: item_func.h:3454
bool set_value(THD *thd, sp_rcontext *ctx, Item **it) override
Definition: item_func.cc:7185
longlong val_int() override
Definition: item_func.cc:6833
Item_result m_cached_result_type
Definition: item_func.h:3426
my_decimal * val_decimal(my_decimal *) override
Definition: item_func.cc:6823
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_func.cc:7179
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_func.h:3445
Item_func_get_user_var(const POS &pos, Name_string a)
Definition: item_func.h:3433
bool is_non_const_over_literals(uchar *) override
Definition: item_func.h:3455
Definition: item_func.h:1914
Item_func_instr(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1916
const char * func_name() const override
Definition: item_func.h:1919
Definition: item_func.h:1498
bool resolve_type_inner(THD *thd) override
Resolve type of function after all arguments have had their data types resolved.
Definition: item_func.cc:3380
Item_func_int_val(const POS &pos, Item *a)
Definition: item_func.h:1501
Item_func_int_val(Item *a)
Definition: item_func.h:1500
Definition: item_func.h:2811
longlong val_int() override
Definition: item_func.cc:9745
Item_func_internal_auto_increment(const POS &pos, PT_item_list *list)
Definition: item_func.h:2813
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2818
const char * func_name() const override
Definition: item_func.h:2817
enum Functype functype() const override
Definition: item_func.h:2815
Definition: item_func.h:2736
const char * func_name() const override
Definition: item_func.h:2742
Item_func_internal_avg_row_length(const POS &pos, PT_item_list *list)
Definition: item_func.h:2738
longlong val_int() override
Definition: item_func.cc:9696
enum Functype functype() const override
Definition: item_func.h:2740
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2743
Definition: item_func.h:2826
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2833
const char * func_name() const override
Definition: item_func.h:2832
Item_func_internal_checksum(const POS &pos, PT_item_list *list)
Definition: item_func.h:2828
longlong val_int() override
Definition: item_func.cc:9757
enum Functype functype() const override
Definition: item_func.h:2830
Definition: item_func.h:2796
enum Functype functype() const override
Definition: item_func.h:2800
const char * func_name() const override
Definition: item_func.h:2802
Item_func_internal_data_free(const POS &pos, PT_item_list *list)
Definition: item_func.h:2798
longlong val_int() override
Definition: item_func.cc:9733
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2803
Definition: item_func.h:2751
longlong val_int() override
Definition: item_func.cc:9706
const char * func_name() const override
Definition: item_func.h:2757
Item_func_internal_data_length(const POS &pos, PT_item_list *list)
Definition: item_func.h:2753
enum Functype functype() const override
Definition: item_func.h:2755
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2758
Definition: item_func.h:2870
longlong val_int() override
Definition: item_func.cc:10099
Item_func_internal_dd_char_length(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2872
const char * func_name() const override
Definition: item_func.h:2876
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2877
Item_func_internal_get_view_warning_or_error(const POS &pos, PT_item_list *list)
Definition: item_func.h:2887
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2894
longlong val_int() override
Definition: item_func.cc:10178
const char * func_name() const override
Definition: item_func.h:2891
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:9832
Item_func_internal_index_column_cardinality(const POS &pos, PT_item_list *list)
Definition: item_func.h:2855
enum Functype functype() const override
Definition: item_func.h:2858
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2863
const char * func_name() const override
Definition: item_func.h:2860
Definition: item_func.h:2781
Item_func_internal_index_length(const POS &pos, PT_item_list *list)
Definition: item_func.h:2783
longlong val_int() override
Definition: item_func.cc:9724
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2788
enum Functype functype() const override
Definition: item_func.h:2785
const char * func_name() const override
Definition: item_func.h:2787
Internal function used by INFORMATION_SCHEMA implementation to check if a role is enabled.
Definition: item_func.h:4169
longlong val_int() override
Internal function used by INFORMATION_SCHEMA implementation to check if a role enabled.
Definition: item_func.cc:10358
enum Functype functype() const override
Definition: item_func.h:4175
Item_func_internal_is_enabled_role(const POS &pos, Item *a, Item *b)
Definition: item_func.h:4171
const char * func_name() const override
Definition: item_func.h:4174
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:4176
Internal function used by INFORMATION_SCHEMA implementation to check if a role is a mandatory role.
Definition: item_func.h:4134
longlong val_int() override
Internal function used by INFORMATION_SCHEMA implementation to check if a role is a mandatory role.
Definition: item_func.cc:10295
Item_func_internal_is_mandatory_role(const POS &pos, Item *a, Item *b)
Definition: item_func.h:4136
const char * func_name() const override
Definition: item_func.h:4139
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:4143
enum Functype functype() const override
Definition: item_func.h:4142
Definition: item_func.h:2840
Item_func_internal_keys_disabled(const POS &pos, Item *a)
Definition: item_func.h:2842
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2846
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:9784
const char * func_name() const override
Definition: item_func.h:2845
Definition: item_func.h:2766
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2773
const char * func_name() const override
Definition: item_func.h:2772
Item_func_internal_max_data_length(const POS &pos, PT_item_list *list)
Definition: item_func.h:2768
enum Functype functype() const override
Definition: item_func.h:2770
longlong val_int() override
Definition: item_func.cc:9715
Definition: item_func.h:2721
enum Functype functype() const override
Definition: item_func.h:2725
longlong val_int() override
Definition: item_func.cc:9684
Item_func_internal_table_rows(const POS &pos, PT_item_list *list)
Definition: item_func.h:2723
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2728
const char * func_name() const override
Definition: item_func.h:2727
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3066
Item_func_internal_tablespace_autoextend_size(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:3055
longlong val_int() override
Definition: item_func.cc:10042
enum Functype functype() const override
Definition: item_func.h:3059
const char * func_name() const override
Definition: item_func.h:3062
Definition: item_func.h:3093
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3106
Item_func_internal_tablespace_data_free(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:3095
longlong val_int() override
Definition: item_func.cc:10075
const char * func_name() const override
Definition: item_func.h:3102
enum Functype functype() const override
Definition: item_func.h:3099
Definition: item_func.h:2993
Item_func_internal_tablespace_extent_size(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2995
enum Functype functype() const override
Definition: item_func.h:2999
longlong val_int() override
Definition: item_func.cc:9995
const char * func_name() const override
Definition: item_func.h:3002
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3006
Definition: item_func.h:2953
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2966
enum Functype functype() const override
Definition: item_func.h:2959
const char * func_name() const override
Definition: item_func.h:2962
Item_func_internal_tablespace_free_extents(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2955
longlong val_int() override
Definition: item_func.cc:9965
Definition: item_func.h:2917
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2925
enum Functype functype() const override
Definition: item_func.h:2922
Item_func_internal_tablespace_id(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2919
longlong val_int() override
Definition: item_func.cc:9932
const char * func_name() const override
Definition: item_func.h:2924
Definition: item_func.h:3013
longlong val_int() override
Definition: item_func.cc:10010
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3026
const char * func_name() const override
Definition: item_func.h:3022
Item_func_internal_tablespace_initial_size(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:3015
enum Functype functype() const override
Definition: item_func.h:3019
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2946
enum Functype functype() const override
Definition: item_func.h:2939
longlong val_int() override
Definition: item_func.cc:9947
Item_func_internal_tablespace_logfile_group_number(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2935
const char * func_name() const override
Definition: item_func.h:2942
Definition: item_func.h:3033
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3046
Item_func_internal_tablespace_maximum_size(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:3035
const char * func_name() const override
Definition: item_func.h:3042
longlong val_int() override
Definition: item_func.cc:10025
enum Functype functype() const override
Definition: item_func.h:3039
longlong val_int() override
Definition: item_func.cc:9980
enum Functype functype() const override
Definition: item_func.h:2979
Item_func_internal_tablespace_total_extents(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2975
const char * func_name() const override
Definition: item_func.h:2982
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2986
Definition: item_func.h:3073
Item_func_internal_tablespace_version(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:3075
longlong val_int() override
Definition: item_func.cc:10058
const char * func_name() const override
Definition: item_func.h:3082
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3086
enum Functype functype() const override
Definition: item_func.h:3079
const char * func_name() const override
Definition: item_func.h:4154
longlong val_int() override
Definition: item_func.cc:10329
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:4158
Item_func_internal_use_terminology_previous(const POS &pos)
Definition: item_func.h:4151
enum Functype functype() const override
Definition: item_func.h:4157
Definition: item_func.h:3894
longlong val_int() override
Check if user level lock is free.
Definition: item_func.cc:5814
Item_func_is_free_lock(const POS &pos, Item *a)
Definition: item_func.h:3900
const char * func_name() const override
Definition: item_func.h:3904
Item_int_func super
Definition: item_func.h:3895
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3908
bool is_non_const_over_literals(uchar *) override
Definition: item_func.h:3914
table_map get_initial_pseudo_tables() const override
Returns the pseudo tables depended upon in order to evaluate this function expression.
Definition: item_func.h:3905
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:5790
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:3915
String value
Definition: item_func.h:3897
Definition: item_func.h:3924
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3938
Item_func_is_used_lock(const POS &pos, Item *a)
Definition: item_func.h:3930
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:3945
Item_int_func super
Definition: item_func.h:3925
String value
Definition: item_func.h:3927
const char * func_name() const override
Definition: item_func.h:3934
longlong val_int() override
Check if user level lock is used and return connection id of owner.
Definition: item_func.cc:5857
table_map get_initial_pseudo_tables() const override
Returns the pseudo tables depended upon in order to evaluate this function expression.
Definition: item_func.h:3935
bool is_non_const_over_literals(uchar *) override
Definition: item_func.h:3944
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:5836
Definition: item_func.h:2704
Item_func_is_visible_dd_object(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2708
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2714
Item_func_is_visible_dd_object(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_func.h:2710
const char * func_name() const override
Definition: item_func.h:2713
longlong val_int() override
Skip hidden tables, columns, indexes and index elements.
Definition: item_func.cc:9528
Item_func_is_visible_dd_object(const POS &pos, Item *a)
Definition: item_func.h:2706
Definition: item_func.h:2192
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2208
const char * func_name() const override
Definition: item_func.h:2202
Item_func_last_insert_id(const POS &pos, Item *a)
Definition: item_func.h:2198
Item_func_last_insert_id()
Definition: item_func.h:2196
table_map get_initial_pseudo_tables() const override
Returns the pseudo tables depended upon in order to evaluate this function expression.
Definition: item_func.h:2204
longlong val_int() override
Definition: item_func.cc:5889
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:2213
Item_int_func super
Definition: item_func.h:2193
Item_func_last_insert_id(const POS &pos)
Definition: item_func.h:2197
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:5881
Definition: item_func.h:1822
Item_func_length(const POS &pos, Item *a)
Definition: item_func.h:1826
String value
Definition: item_func.h:1823
const char * func_name() const override
Definition: item_func.h:1828
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1829
longlong val_int() override
Definition: item_func.cc:4298
Definition: item_func.h:1393
double val_real() override
Gateway to natural LOG function.
Definition: item_func.cc:2897
enum Functype functype() const override
Definition: item_func.h:1398
const char * func_name() const override
Definition: item_func.h:1397
Item_func_ln(const POS &pos, Item *a)
Definition: item_func.h:1395
Definition: item_func.h:1897
String value1
Definition: item_func.h:1898
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:4393
longlong val_int() override
Definition: item_func.cc:4355
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:4341
Item_func_locate(Item *a, Item *b)
Definition: item_func.h:1901
Item_func_locate(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_func.h:1904
const char * func_name() const override
Definition: item_func.h:1907
Item_func_locate(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1902
String value2
Definition: item_func.h:1898
Definition: item_func.h:1417
double val_real() override
Definition: item_func.cc:2946
enum Functype functype() const override
Definition: item_func.h:1422
const char * func_name() const override
Definition: item_func.h:1421
Item_func_log10(const POS &pos, Item *a)
Definition: item_func.h:1419
Definition: item_func.h:1410
double val_real() override
Definition: item_func.cc:2934
const char * func_name() const override
Definition: item_func.h:1414
Item_func_log2(const POS &pos, Item *a)
Definition: item_func.h:1412
Definition: item_func.h:1401
Item_func_log(const POS &pos, Item *a)
Definition: item_func.h:1403
double val_real() override
Extended but so slower LOG function.
Definition: item_func.cc:2914
Item_func_log(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1404
const char * func_name() const override
Definition: item_func.h:1406
enum Functype functype() const override
Definition: item_func.h:1407
Definition: item_func.h:3603
uint flags
Definition: item_func.h:3611
FT_INFO * ft_handler
Definition: item_func.h:3617
DTCollation cmp_collation
Definition: item_func.h:3616
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_func.cc:7917
bool fix_index(const THD *thd)
Definition: item_func.cc:7924
Item * key_item() const override
Definition: item_func.h:3666
uint key
Definition: item_func.h:3611
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:8056
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:3683
bool allows_search_on_non_indexed_columns(const TABLE *tr)
Check whether storage engine for given table, allows FTS Boolean search on non-indexed columns.
Definition: item_func.h:3862
void set_master(Item_func_match *item)
Set master MATCH function and adjust used_in_where_only value.
Definition: item_func.h:3760
longlong val_int() override
Definition: item_func.h:3673
Item_func_match * master
Master item means that if identical items are present in the statement, they use the same FT handler.
Definition: item_func.h:3625
Ft_hints * hints
Fulltext index hints, initialized for master MATCH function only.
Definition: item_func.h:3830
const char * func_name() const override
Definition: item_func.h:3668
bool docid_in_result()
Check whether FT result contains the document ID.
Definition: item_func.h:3730
Item * concat_ws
Definition: item_func.h:3626
bool can_skip_ranking()
Check if ranking is not needed.
Definition: item_func.h:3797
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_func.h:3655
void set_hints_op(enum ft_operation type, double value_arg)
Set comparison operation type and and value for master MATCH function.
Definition: item_func.h:3781
Table_ref * table_ref
Definition: item_func.h:3618
bool ordered_result()
Check whether FT result is ordered on rank.
Definition: item_func.h:3712
bool init_search(THD *thd)
Initialize searching within full-text index.
Definition: item_func.cc:7688
String value
Definition: item_func.h:3627
enum Functype functype() const override
Definition: item_func.h:3667
void set_hints(JOIN *join, uint ft_flag, ha_rows ft_limit, bool no_cond)
Set FT hints.
Definition: item_func.cc:8096
Item_func_match(const POS &pos, PT_item_list *a, Item *against_arg, uint b)
Constructor for Item_func_match class.
Definition: item_func.h:3638
Item * against
Definition: item_func.h:3610
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table 'filter_for_table' for this item.
Definition: item_func.cc:7764
bool fix_fields(THD *thd, Item **ref) override
Definition: item_func.cc:7793
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:7660
bool used_in_where_only
true if MATCH function is used in WHERE condition only.
Definition: item_func.h:3843
String search_value
Definition: item_func.h:3628
bool is_simple_expression()
Check if this MATCH function is a simple expression in WHERE condition.
Definition: item_func.h:3821
Ft_hints * get_hints()
Returns pointer to Ft_hints object belonging to master MATCH function.
Definition: item_func.h:3770
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_func.cc:8077
bool score_from_index_scan
True if we are doing a full-text index scan with this MATCH function as a predicate,...
Definition: item_func.h:3615
void set_simple_expression(bool val)
Set flag that the function is a simple expression.
Definition: item_func.h:3810
double val_real() override
Definition: item_func.cc:8024
bool simple_expression
Flag is true when MATCH function is used as a simple expression in WHERE condition,...
Definition: item_func.h:3836
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.cc:8069
Item_func_match * get_master()
Returns master MATCH function.
Definition: item_func.h:3750
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_func.cc:8007
Item_real_func super
Definition: item_func.h:3604
ulonglong get_count()
Get number of matching rows from FT handler.
Definition: item_func.h:3698
Definition: item_func.h:1722
Item_func_max(const POS &pos, PT_item_list *opt_list)
Definition: item_func.h:1724
const char * func_name() const override
Definition: item_func.h:1726
enum Functype functype() const override
Definition: item_func.h:1727
Definition: item_func.h:1632
bool compare_as_dates() const
Returns true if arguments to this function should be compared as dates.
Definition: item_func.cc:3964
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:4110
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:3848
TYPELIB * get_typelib() const override
Get the typelib information for an item of type set or enum.
Definition: item_func.cc:3862
bool date_op(Date_val *date, my_time_flags_t flags) override
Evaluates item when resulting data type is DATE.
Definition: item_func.h:1646
my_decimal * val_decimal(my_decimal *) override
Definition: item_func.cc:4174
bool time_op(Time_val *time) override
Evaluates item when resulting data type is TIME.
Definition: item_func.cc:4075
String * str_op(String *) override
Evaluates item when resulting data type is a string type.
Definition: item_func.cc:4006
uint8 fsp_for_string
Fractional seconds precision to use when converting a time or timestamp expression into a string.
Definition: item_func.h:1691
double val_real() override
Definition: item_func.cc:4160
longlong val_int() override
Definition: item_func.cc:4167
bool resolve_type_inner(THD *thd) override
Resolve type of function after all arguments have had their data types resolved.
Definition: item_func.cc:3896
Item_func_min_max(const POS &pos, PT_item_list *opt_list, bool is_least_func)
Definition: item_func.h:1634
bool has_temporal_arg() const
Returns true if at least one of the arguments was of temporal type.
Definition: item_func.h:1672
String m_string_buf
Definition: item_func.h:1677
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:4091
bool cmp_times(Time_val *value)
Compare arguments as time values.
Definition: item_func.cc:3990
bool datetime_op(Datetime_val *dt, my_time_flags_t flags) override
Evaluates item when resulting data type is DATETIME or TIMESTAMP.
Definition: item_func.cc:4066
bool cmp_datetimes(longlong *value)
Compare arguments as datetime values.
Definition: item_func.cc:3969
Item * temporal_item
Definition: item_func.h:1685
enum Item_result result_type() const override
Definition: item_func.h:1657
const bool m_is_least_func
True if LEAST function, false if GREATEST.
Definition: item_func.h:1676
enum Item_result cast_to_int_type() const override
Make CAST(LEAST_OR_GREATEST(datetime_expr, varchar_expr)) return a number in format YYMMDDhhmmss.
Definition: item_func.h:1664
my_decimal * decimal_op(my_decimal *) override
Evaluates item when resulting data type is DECIMAL.
Definition: item_func.cc:4135
enum_field_types default_data_type() const override
Get the default data (output) type for the specific item.
Definition: item_func.h:1651
void set_numeric_type() override
Definition: item_func.h:1656
Definition: item_func.h:1713
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.h:1718
enum Functype functype() const override
Definition: item_func.h:1719
const char * func_name() const override
Definition: item_func.h:1717
Item_func_min(const POS &pos, PT_item_list *opt_list)
Definition: item_func.h:1715
Definition: item_func.h:1257
enum Functype functype() const override
Definition: item_func.h:1271
my_decimal * decimal_op(my_decimal *) override
See Item_func_plus::decimal_op for comments.
Definition: item_func.cc:2356
longlong int_op() override SUPPRESS_UBSAN
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:2305
bool resolve_type(THD *thd) override
The following function is here to allow the user to force subtraction of UNSIGNED BIGINT/DECIMAL to r...
Definition: item_func.cc:2287
Item_func_minus(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1260
Item_func_minus(Item *a, Item *b)
Definition: item_func.h:1259
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:2294
const char * func_name() const override
Definition: item_func.h:1263
Definition: item_func.h:1329
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1340
bool check_function_as_value_generator(uchar *) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:1341
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:2780
void result_precision() override
Definition: item_func.cc:2764
Item_func_mod(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1332
const char * func_name() const override
Definition: item_func.h:1337
enum Functype functype() const override
Definition: item_func.h:1342
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:2727
Item_func_mod(Item *a, Item *b)
Definition: item_func.h:1331
my_decimal * decimal_op(my_decimal *) override
Evaluates item when resulting data type is DECIMAL.
Definition: item_func.cc:2742
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:2692
Definition: item_func.h:1274
const char * func_name() const override
Definition: item_func.h:1279
bool check_function_as_value_generator(uchar *) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:1286
void result_precision() override
Definition: item_func.cc:2494
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:2381
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1285
my_decimal * decimal_op(my_decimal *) override
See Item_func_plus::decimal_op for comments.
Definition: item_func.cc:2479
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:2393
Item_func_mul(Item *a, Item *b)
Definition: item_func.h:1276
enum Functype functype() const override
Definition: item_func.h:1287
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.h:1282
Item_func_mul(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1277
Definition: item_func.h:1345
Item_func_neg(const POS &pos, Item *a)
Definition: item_func.h:1348
const char * func_name() const override
Definition: item_func.h:1353
enum Functype functype() const override
Definition: item_func.h:1354
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:2825
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:2787
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:2793
bool check_function_as_value_generator(uchar *) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:1358
my_decimal * decimal_op(my_decimal *) override
Evaluates item when resulting data type is DECIMAL.
Definition: item_func.cc:2808
void fix_num_length_and_dec() override
Definition: item_func.cc:2818
Item_func_neg(Item *a)
Definition: item_func.h:1347
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1357
Definition: item_func.h:984
Item_func_num1(Item *a, Item *b)
Definition: item_func.h:989
Item_func_num1(const POS &pos, Item *a)
Definition: item_func.h:987
bool date_op(Date_val *, my_time_flags_t) override
Evaluates item when resulting data type is DATE.
Definition: item_func.h:999
void fix_num_length_and_dec() override
Definition: item_func.cc:1613
String * str_op(String *) override
Evaluates item when resulting data type is a string type.
Definition: item_func.h:995
Item_func_num1(Item *a)
Definition: item_func.h:986
void set_numeric_type() override
Set data type for a numeric function with one argument (can be also used by a numeric function with m...
Definition: item_func.cc:1585
bool datetime_op(Datetime_val *, my_time_flags_t) override
Evaluates item when resulting data type is DATETIME or TIMESTAMP.
Definition: item_func.h:1007
Item_func_num1(const POS &pos, Item *a, Item *b)
Definition: item_func.h:990
bool time_op(Time_val *) override
Evaluates item when resulting data type is TIME.
Definition: item_func.h:1003
Definition: item_func.h:883
virtual void set_numeric_type()=0
longlong val_int() override
Definition: item_func.cc:1812
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_func.cc:1903
virtual longlong int_op()=0
Evaluates item when resulting data type is integer type.
virtual bool date_op(Date_val *date, my_time_flags_t flags)=0
Evaluates item when resulting data type is DATE.
String * val_str(String *str) override
Definition: item_func.cc:1729
Item_func_numhybrid(const POS &pos, Item *a)
Definition: item_func.h:891
Item_func_numhybrid(mem_root_deque< Item * > *list)
Definition: item_func.h:905
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.cc:1920
enum_field_types default_data_type() const override
Get the default data (output) type for the specific item.
Definition: item_func.h:915
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_func.cc:1899
bool resolve_type_inner(THD *thd) override
Resolve type of function after all arguments have had their data types resolved.
Definition: item_func.cc:1721
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item_func.h:980
Item_func_numhybrid(Item *a)
Definition: item_func.h:888
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:1693
my_decimal * val_decimal(my_decimal *) override
Definition: item_func.cc:1853
enum Item_result result_type() const override
Definition: item_func.h:914
double val_real() override
Definition: item_func.cc:1771
Item_func_numhybrid(const POS &pos, PT_item_list *list)
Definition: item_func.h:909
void fix_num_length_and_dec() override
Definition: item_func.cc:911
Item_func_numhybrid(const POS &pos, Item *a, Item *b)
Definition: item_func.h:900
Item_result hybrid_type
Definition: item_func.h:885
virtual my_decimal * decimal_op(my_decimal *decimal_value)=0
Evaluates item when resulting data type is DECIMAL.
virtual double real_op()=0
Evaluates item when resulting data type is floating point type.
virtual String * str_op(String *string)=0
Evaluates item when resulting data type is a string type.
virtual bool datetime_op(Datetime_val *dt, my_time_flags_t flags)=0
Evaluates item when resulting data type is DATETIME or TIMESTAMP.
virtual bool time_op(Time_val *time)=0
Evaluates item when resulting data type is TIME.
Item_func_numhybrid(Item *a, Item *b)
Definition: item_func.h:896
Definition: item_func.h:1962
const char * func_name() const override
Definition: item_func.h:1968
longlong val_int() override
Definition: item_func.cc:4483
String value
Definition: item_func.h:1963
Item_func_ord(const POS &pos, Item *a)
Definition: item_func.h:1966
Definition: item_func.h:1241
const char * func_name() const override
Definition: item_func.h:1247
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.h:1251
Item_func_plus(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1244
Item_func_plus(Item *a, Item *b)
Definition: item_func.h:1243
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:2182
longlong int_op() override SUPPRESS_UBSAN
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:2193
my_decimal * decimal_op(my_decimal *) override
Calculate plus of two decimals.
Definition: item_func.cc:2249
enum Functype functype() const override
Definition: item_func.h:1254
Definition: item_func.h:1433
double val_real() override
Definition: item_func.cc:2972
Item_func_pow(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1435
const char * func_name() const override
Definition: item_func.h:1437
enum Functype functype() const override
Definition: item_func.h:1438
Definition: item_func.h:1625
Item_func_radians(const POS &pos, Item *a)
Definition: item_func.h:1627
const char * func_name() const override
Definition: item_func.h:1629
enum Functype functype() const override
Definition: item_func.h:1630
Definition: item_func.h:1554
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:3719
double val_real() override
Definition: item_func.cc:3784
void seed_random(Item *val)
Definition: item_func.cc:3736
bool fix_fields(THD *thd, Item **ref) override
Definition: item_func.cc:3754
const char * func_name() const override
Definition: item_func.h:1566
bool first_eval
Definition: item_func.h:1558
Item_real_func super
Definition: item_func.h:1555
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:1582
rand_struct * m_rand
Definition: item_func.h:1557
Item_func_rand()
Definition: item_func.h:1560
Item_func_rand(const POS &pos)
Definition: item_func.h:1562
table_map get_initial_pseudo_tables() const override
This function is non-deterministic and hence depends on the 'RAND' pseudo-table.
Definition: item_func.h:1573
Item_func_rand(const POS &pos, Item *a)
Definition: item_func.h:1561
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:3746
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_func.h:1578
Definition: item_func.h:2515
longlong val_int() override
Release all user level lock held by connection.
Definition: item_func.cc:5773
Item_int_func super
Definition: item_func.h:2516
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2527
table_map get_initial_pseudo_tables() const override
Returns the pseudo tables depended upon in order to evaluate this function expression.
Definition: item_func.h:2524
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:5759
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:2532
Item_func_release_all_locks(const POS &pos)
Definition: item_func.h:2519
const char * func_name() const override
Definition: item_func.h:2523
bool is_non_const_over_literals(uchar *) override
Definition: item_func.h:2531
Definition: item_func.h:2485
Item_int_func super
Definition: item_func.h:2486
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:5691
table_map get_initial_pseudo_tables() const override
Returns the pseudo tables depended upon in order to evaluate this function expression.
Definition: item_func.h:2496
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:2506
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2499
String value
Definition: item_func.h:2488
const char * func_name() const override
Definition: item_func.h:2495
longlong val_int() override
Release a user level lock.
Definition: item_func.cc:5715
bool is_non_const_over_literals(uchar *) override
Definition: item_func.h:2505
Item_func_release_lock(const POS &pos, Item *a)
Definition: item_func.h:2491
Definition: item_func.h:1533
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:3514
my_decimal * decimal_op(my_decimal *) override
Evaluates item when resulting data type is DECIMAL.
Definition: item_func.cc:3704
bool truncate
Definition: item_func.h:1534
Item_func_round(Item *a, Item *b, bool trunc_arg)
Definition: item_func.h:1537
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:3638
enum Functype functype() const override
Definition: item_func.h:1549
const char * func_name() const override
Definition: item_func.h:1542
Item_func_round(const POS &pos, Item *a, Item *b, bool trunc_arg)
Definition: item_func.h:1539
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:3610
Definition: item_func.h:3954
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3964
Item_func_row_count(const POS &pos)
Definition: item_func.h:3958
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:8241
const char * func_name() const override
Definition: item_func.h:3963
Item_int_func super
Definition: item_func.h:3955
longlong val_int() override
Definition: item_func.cc:8251
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:3968
This class is used to implement operations like SET @variable or @variable:= expression.
Definition: item_func.h:3355
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_func.cc:6129
void print_assignment(const THD *thd, String *str, enum_query_type query_type) const
Definition: item_func.cc:6655
type_conversion_status save_in_field(Field *field, bool no_conversions, bool can_use_result_field)
Definition: item_func.cc:6736
enum Item_result result_type() const override
Definition: item_func.h:3396
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:6185
Item_func_set_user_var(const POS &pos, Name_string a, Item *b)
Definition: item_func.h:3372
enum Item_result cached_result_type
Definition: item_func.h:3356
enum Functype functype() const override
Definition: item_func.h:3384
Item_func_set_user_var(Name_string a, Item *b)
Definition: item_func.h:3371
type_conversion_status save_in_field_inner(Field *field, bool no_conversions) override
Helper function which does all of the work for save_in_field(Field*, bool), except some error checkin...
Definition: item_func.h:3417
void make_field(Send_field *tmp_field) override
Definition: item_func.cc:6688
String * val_str(String *str) override
Definition: item_func.cc:6640
void save_org_in_field(Field *field) override
Definition: item_func.h:3409
bool set_entry(THD *thd, bool create_if_not_exists)
Definition: item_func.cc:6143
bool fix_fields(THD *thd, Item **ref) override
Definition: item_func.cc:6171
bool null_item
Definition: item_func.h:3360
bool update()
Update user variable from value in save_result.
Definition: item_func.cc:6578
void save_item_result(Item *item)
Evaluate and store item's result.
Definition: item_func.cc:6547
bool update_hash(const void *ptr, uint length, enum Item_result type, const CHARSET_INFO *cs, Derivation dv, bool unsigned_arg)
Definition: item_func.cc:6331
union Item_func_set_user_var::@62 save_result
longlong val_int() override
Definition: item_func.cc:6633
my_decimal * val_decimal(my_decimal *) override
Definition: item_func.cc:6647
double vreal
Definition: item_func.h:3363
my_decimal decimal_buff
Definition: item_func.h:3359
bool send(Protocol *protocol, String *str_arg) override
This is only called from items that is not of type item_field.
Definition: item_func.cc:6676
my_decimal * vdec
Definition: item_func.h:3365
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.cc:6670
String value
Definition: item_func.h:3358
double val_real() override
Definition: item_func.cc:6626
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:6664
bool check(bool use_result_field)
This functions is invoked on SET @variable or @variable:= expression.
Definition: item_func.cc:6503
const char * func_name() const override
Definition: item_func.h:3404
Name_string name
Definition: item_func.h:3369
Item_func_set_user_var(THD *thd, Item_func_set_user_var *item)
Definition: item_func.h:3375
String * vstr
Definition: item_func.h:3364
longlong vint
Definition: item_func.h:3362
Definition: item_func.h:2150
Item_func_shift_left(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2152
const char * func_name() const override
Definition: item_func.h:2154
longlong int_op() override
Performs the operation on integers to produce a result of type INT_RESULT.
Definition: item_func.cc:3152
String * str_op(String *str) override
Performs the operation on binary strings to produce a result of type STRING_RESULT.
Definition: item_func.cc:3226
Definition: item_func.h:2161
String * str_op(String *str) override
Performs the operation on binary strings to produce a result of type STRING_RESULT.
Definition: item_func.cc:3230
Item_func_shift_right(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2163
longlong int_op() override
Performs the operation on integers to produce a result of type INT_RESULT.
Definition: item_func.cc:3153
const char * func_name() const override
Definition: item_func.h:2165
Definition: item_func.h:2135
String * eval_str_op(String *str)
Template function that evaluates the bitwise shift operation over binary string arguments.
Definition: item_func.cc:3161
longlong eval_int_op()
Template function that evaluates the bitwise shift operation over integer arguments.
Definition: item_func.cc:3136
bool binary_result_requires_binary_second_arg() const override
Definition: item_func.h:2137
Item_func_shift(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2146
Definition: item_func.h:1595
longlong val_int() override
Definition: item_func.cc:3825
Item_func_sign(const POS &pos, Item *a)
Definition: item_func.h:1597
enum Functype functype() const override
Definition: item_func.h:1599
const char * func_name() const override
Definition: item_func.h:1598
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:3817
Definition: item_func.h:1474
Item_func_sin(const POS &pos, Item *a)
Definition: item_func.h:1476
double val_real() override
Definition: item_func.cc:3021
const char * func_name() const override
Definition: item_func.h:1478
enum Functype functype() const override
Definition: item_func.h:1479
Definition: item_func.h:2258
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2282
Item_func_sleep(const POS &pos, Item *a)
Definition: item_func.h:2262
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:6030
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:2275
const char * func_name() const override
Definition: item_func.h:2265
table_map get_initial_pseudo_tables() const override
This function is non-deterministic and hence depends on the 'RAND' pseudo-table.
Definition: item_func.h:2272
Item_int_func super
Definition: item_func.h:2259
longlong val_int() override
This function is just used to create tests with time gaps.
Definition: item_func.cc:6040
Definition: item_func.h:3986
sp_head * get_sp()
Definition: item_func.h:4047
void fix_after_pullout(Query_block *parent_query_block, Query_block *removed_query_block) override
Fix after tables have been moved from one query_block level to the parent level, e....
Definition: item_func.cc:8793
void compute_cost(CostOfItem *root_cost) const override
Compute the cost of evaluating this Item.
Definition: item_func.h:4063
double val_real() override
Definition: item_func.cc:8434
bool change_context_processor(uchar *arg) override
Definition: item_func.h:4040
longlong val_int() override
Definition: item_func.cc:8428
String * val_str(String *str) override
Definition: item_func.cc:8461
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_func.cc:8298
my_decimal * val_decimal(my_decimal *dec_buf) override
Definition: item_func.cc:8455
bool m_deterministic
true when function execution is deterministic
Definition: item_func.h:4000
const char * func_name() const override
Definition: item_func.cc:8307
Field * sp_result_field
The result field of the concrete stored function.
Definition: item_func.h:3998
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:4055
bool init_result_field(THD *thd)
Initialize the result field by creating a temporary dummy table and assign it to a newly created fiel...
Definition: item_func.cc:8365
bool val_json(Json_wrapper *result) override
Get a JSON value from an Item.
Definition: item_func.cc:8476
Field * tmp_table_field(TABLE *t_arg) override
Definition: item_func.cc:8621
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_func.cc:8445
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_func.cc:8440
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.cc:8450
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_func.cc:8786
const sp_name * get_name()
Definition: item_func.h:4048
Name_resolution_context * m_name_resolution_ctx
Holds the security definer context(if defined with SQL SECURITY DEFINER) and the error the handler.
Definition: item_func.h:3992
Item_result result_type() const override
Definition: item_func.cc:8598
Field * get_sp_result_field()
Definition: item_func.h:4054
Item_func_sp(const POS &pos, const LEX_STRING &db_name, const LEX_STRING &fn_name, bool use_explicit_name, PT_item_list *opt_list)
Definition: item_func.cc:8258
bool execute_impl(THD *thd)
Execute function and store the return value in the field.
Definition: item_func.cc:8546
bool resolve_type(THD *thd) override
Initialize local members with values from the Field interface.
Definition: item_func.cc:8414
Item_func super
Definition: item_func.h:3987
void make_field(Send_field *tmp_field) override
Definition: item_func.cc:8591
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:8274
bool execute()
Execute function & store value in field.
Definition: item_func.cc:8501
bool sp_check_access(THD *thd)
Checks if requested access to function can be granted to user.
Definition: item_func.cc:8642
enum Functype functype() const override
Definition: item_func.h:4049
sp_name * m_name
The name of the stored function.
Definition: item_func.h:3994
table_map get_initial_pseudo_tables() const override
Must not be called before the procedure is resolved, i.e.
Definition: item_func.cc:8329
bool fix_fields(THD *thd, Item **ref) override
Definition: item_func.cc:8652
sp_head * m_sp
Pointer to actual function instance (null when not resolved or executing)
Definition: item_func.h:3996
Definition: item_func.h:1425
Item_func_sqrt(const POS &pos, Item *a)
Definition: item_func.h:1427
const char * func_name() const override
Definition: item_func.h:1429
double val_real() override
Definition: item_func.cc:2964
enum Functype functype() const override
Definition: item_func.h:1430
Definition: item_func.h:1482
enum Functype functype() const override
Definition: item_func.h:1487
double val_real() override
Definition: item_func.cc:3028
Item_func_tan(const POS &pos, Item *a)
Definition: item_func.h:1484
const char * func_name() const override
Definition: item_func.h:1486
Definition: item_func.h:2389
double val_real() override
Definition: item_func.cc:5235
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:2401
Item_func_udf_decimal(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
Definition: item_func.h:2391
longlong val_int() override
Definition: item_func.cc:5227
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_func.h:2402
enum Item_result result_type() const override
Definition: item_func.h:2405
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_func.h:2398
String * val_str(String *str) override
Definition: item_func.cc:5248
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:5258
my_decimal * val_decimal(my_decimal *) override
Definition: item_func.cc:5243
Definition: item_func.h:2336
Item_func_udf_float(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
Definition: item_func.h:2338
my_decimal * val_decimal(my_decimal *dec_buf) override
Definition: item_func.h:2344
longlong val_int() override
Definition: item_func.h:2340
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:2355
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2359
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_func.h:2352
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_func.h:2356
double val_real() override
Definition: item_func.cc:5197
String * val_str(String *str) override
Definition: item_func.cc:5205
Definition: item_func.h:2366
enum Item_result result_type() const override
Definition: item_func.h:2382
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_func.h:2379
String * val_str(String *str) override
Definition: item_func.cc:5219
Item_func_udf_int(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
Definition: item_func.h:2368
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_func.h:2375
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2383
double val_real() override
Definition: item_func.h:2371
longlong val_int() override
Definition: item_func.cc:5213
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:2378
Definition: item_func.h:2409
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:5266
Item_func_udf_str(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
Definition: item_func.h:2411
String * val_str(String *) override
Definition: item_func.cc:5275
my_decimal * val_decimal(my_decimal *dec_buf) override
Definition: item_func.h:2432
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_func.h:2443
enum Item_result result_type() const override
Definition: item_func.h:2446
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:2442
longlong val_int() override
Definition: item_func.h:2424
double val_real() override
Definition: item_func.h:2415
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_func.h:2439
Definition: item_func.h:1605
Item_func_units(const POS &pos, Item *a, double mul_arg, double add_arg)
Definition: item_func.h:1609
double add
Definition: item_func.h:1606
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:3832
double val_real() override
Definition: item_func.cc:3841
double mul
Definition: item_func.h:1606
Definition: item_func.h:4092
table_map get_initial_pseudo_tables() const override
Returns the pseudo tables depended upon in order to evaluate this function expression.
Definition: item_func.h:4115
Item_int_func super
Definition: item_func.h:4093
longlong val_int() override
Definition: item_func.cc:8831
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:8823
Item_func_uuid_short(const POS &pos)
Definition: item_func.h:4096
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:4106
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:4101
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:4105
const char * func_name() const override
Definition: item_func.h:4099
Definition: item_func.h:1922
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1930
const char * func_name() const override
Definition: item_func.h:1927
Item_func_validate_password_strength(const POS &pos, Item *a)
Definition: item_func.h:1924
longlong val_int() override
Definition: item_func.cc:4406
Definition: item_func.h:1836
const char * func_name() const override
Definition: item_func.h:1842
String value
Definition: item_func.h:1837
Item_func_vector_dim(const POS &pos, Item *a)
Definition: item_func.h:1840
longlong val_int() override
Definition: item_func.cc:4309
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1843
Definition: item_func.h:4120
Item_static_string_func super
Definition: item_func.h:4121
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:8839
Item_func_version(const POS &pos)
Definition: item_func.cc:10090
Definition: item_func.h:101
bool param_type_is_rejected(uint start, uint end)
For arguments of this Item_func ("args" array), in range [start,end[ : sends error if they're a dynam...
Definition: item_func.cc:546
bool param_type_uses_non_param(THD *thd, enum_field_types def=MYSQL_TYPE_VARCHAR)
Definition: item_func.cc:619
Item_func(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_func.h:413
int check_decimal_overflow(int error)
Throw an error if the error code of a DECIMAL operation is E_DEC_OVERFLOW.
Definition: item_func.h:666
Item_func()
Definition: item_func.h:375
my_decimal * val_decimal(my_decimal *) override
Definition: item_func.cc:871
bool val_arg0_date(Date_val *date, my_time_flags_t flags)
Definition: item_func.h:567
bool replace_equal_field_checker(uchar **arg) override
Definition: item_func.h:615
virtual bool have_rev_func() const
Definition: item_func.h:544
Item ** args
Array of pointers to arguments.
Definition: item_func.h:108
virtual enum Functype functype() const
Definition: item_func.h:374
bool check_column_in_window_functions(uchar *arg) override
Check if all the columns present in this expression are present in PARTITION clause of window functio...
Definition: item_func.cc:1061
bool val_arg0_datetime(Datetime_val *dt, my_time_flags_t flags)
Definition: item_func.h:570
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:824
Item_func(const POS &pos)
Definition: item_func.h:377
bool reject_vector_args()
Definition: item_func.cc:1632
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_func.cc:736
bool check_valid_arguments_processor(uchar *) override
Definition: item_func.h:720
Item_func(Item *a, Item *b)
Definition: item_func.h:389
bool fix_func_arg(THD *, Item **arg)
Definition: item_func.cc:440
bool alloc_args(MEM_ROOT *mem_root, unsigned num_args)
Allocates space for the given number of arguments, if needed.
Definition: item_func.h:115
virtual Item * get_arg(uint i)
Get the i'th argument of the function that this object represents.
Definition: item_func.h:502
bool split_sum_func(THD *thd, Ref_item_array ref_item_array, mem_root_deque< Item * > *fields) override
See comments in Item_cmp_func::split_sum_func()
Definition: item_func.cc:725
longlong val_int_from_real()
Definition: item_func.cc:2137
void traverse_cond(Cond_traverser traverser, void *arg, traverse_order order) override
Definition: item_func.cc:644
virtual table_map get_initial_pseudo_tables() const
Returns the pseudo tables depended upon in order to evaluate this function expression.
Definition: item_func.h:532
Item * compile(Item_analyzer analyzer, uchar **arg_p, Item_transformer transformer, uchar *arg_t) override
Compile Item_func object with a processor and a transformer callback functions.
Definition: item_func.cc:702
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item_func.h:576
Item_func(const POS &pos, Item *a)
Definition: item_func.h:384
Item * replace_equal_field(uchar *arg) override
Definition: item_func.h:621
Functype
Definition: item_func.h:214
@ DATEADD_FUNC
Definition: item_func.h:322
@ TRIG_COND_FUNC
Definition: item_func.h:258
@ JSON_VALUE_FUNC
Definition: item_func.h:360
@ JSON_SCHEMA_VALIDATION_REPORT_FUNC
Definition: item_func.h:362
@ SP_CROSSES_FUNC
Definition: item_func.h:242
@ ROLLUP_GROUP_ITEM_FUNC
Definition: item_func.h:269
@ JSON_STORAGE_SIZE_FUNC
Definition: item_func.h:358
@ NOT_ALL_FUNC
Definition: item_func.h:255
@ LIKE_FUNC
Definition: item_func.h:225
@ FALSE_FUNC
Definition: item_func.h:339
@ SP_EXTERIORRING
Definition: item_func.h:250
@ PLUS_FUNC
Definition: item_func.h:272
@ JSON_SEARCH_FUNC
Definition: item_func.h:361
@ SIGN_FUNC
Definition: item_func.h:282
@ JSON_STORAGE_FREE_FUNC
Definition: item_func.h:359
@ NULLIF_FUNC
Definition: item_func.h:300
@ YEAR_FUNC
Definition: item_func.h:302
@ NOT_FUNC
Definition: item_func.h:254
@ MINUS_FUNC
Definition: item_func.h:273
@ HOUR_FUNC
Definition: item_func.h:313
@ TIME_TO_SEC_FUNC
Definition: item_func.h:327
@ LOG_FUNC
Definition: item_func.h:284
@ PERIODDIFF_FUNC
Definition: item_func.h:343
@ XOR_FUNC
Definition: item_func.h:231
@ COND_OR_FUNC
Definition: item_func.h:230
@ JSON_CONTAINS
Definition: item_func.h:333
@ JSON_VALID_FUNC
Definition: item_func.h:353
@ JSON_UNQUOTE_FUNC
Definition: item_func.h:335
@ GREATEST_FUNC
Definition: item_func.h:330
@ SP_EQUALS_FUNC
Definition: item_func.h:237
@ LN_FUNC
Definition: item_func.h:285
@ FROM_UNIXTIME_FUNC
Definition: item_func.h:323
@ COND_AND_FUNC
Definition: item_func.h:229
@ EQ_FUNC
Definition: item_func.h:216
@ MAKETIME_FUNC
Definition: item_func.h:305
@ FUNC_SP
Definition: item_func.h:264
@ ROUND_FUNC
Definition: item_func.h:277
@ JSON_CONTAINS_PATH_FUNC
Definition: item_func.h:357
@ NOW_FUNC
Definition: item_func.h:256
@ FROM_DAYS_FUNC
Definition: item_func.h:257
@ TRUE_FUNC
Definition: item_func.h:338
@ LEAST_FUNC
Definition: item_func.h:332
@ IN_FUNC
Definition: item_func.h:233
@ CONVERT_TZ_FUNC
Definition: item_func.h:324
@ LE_FUNC
Definition: item_func.h:220
@ COLLATE_FUNC
Definition: item_func.h:261
@ GSYSVAR_FUNC
Definition: item_func.h:267
@ MATCH_FUNC
Definition: item_func.h:224
@ MULTI_EQ_FUNC
Definition: item_func.h:234
@ FT_FUNC
Definition: item_func.h:223
@ GUSERVAR_FUNC
Definition: item_func.h:260
@ LT_FUNC
Definition: item_func.h:219
@ MOD_FUNC
Definition: item_func.h:297
@ SP_COVEREDBY_FUNC
Definition: item_func.h:245
@ NEG_FUNC
Definition: item_func.h:266
@ DD_INTERNAL_FUNC
Definition: item_func.h:271
@ ISNULL_FUNC
Definition: item_func.h:226
@ JSON_ARRAY_FUNC
Definition: item_func.h:352
@ SP_TOUCHES_FUNC
Definition: item_func.h:241
@ JSON_SCHEMA_VALID_FUNC
Definition: item_func.h:363
@ SP_DISJOINT_FUNC
Definition: item_func.h:238
@ ISNOTNULLTEST_FUNC
Definition: item_func.h:236
@ DAY_FUNC
Definition: item_func.h:308
@ LOG10_FUNC
Definition: item_func.h:286
@ UDF_FUNC
Definition: item_func.h:265
@ MAKEDATE_FUNC
Definition: item_func.h:304
@ COT_FUNC
Definition: item_func.h:290
@ ISTRUTH_FUNC
Definition: item_func.h:228
@ SEC_TO_TIME_FUNC
Definition: item_func.h:344
@ DATE_FUNC
Definition: item_func.h:312
@ TIMESTAMPDIFF_FUNC
Definition: item_func.h:328
@ SECOND_FUNC
Definition: item_func.h:315
@ EXP_FUNC
Definition: item_func.h:293
@ SP_STARTPOINT
Definition: item_func.h:248
@ JSON_DEPTH_FUNC
Definition: item_func.h:348
@ JSON_QUOTE_FUNC
Definition: item_func.h:356
@ ETAG_FUNC
Definition: item_func.h:364
@ PERIODADD_FUNC
Definition: item_func.h:342
@ SP_POINTN
Definition: item_func.h:251
@ EXTRACT_FUNC
Definition: item_func.h:262
@ MONTH_FUNC
Definition: item_func.h:306
@ TO_SECONDS_FUNC
Definition: item_func.h:311
@ ABS_FUNC
Definition: item_func.h:280
@ BETWEEN
Definition: item_func.h:232
@ IF_FUNC
Definition: item_func.h:298
@ JSON_OBJECT_FUNC
Definition: item_func.h:350
@ JSON_TYPE_FUNC
Definition: item_func.h:354
@ MICROSECOND_FUNC
Definition: item_func.h:316
@ ANY_VALUE_FUNC
Definition: item_func.h:346
@ STRCMP_FUNC
Definition: item_func.h:337
@ JSON_PRETTY_FUNC
Definition: item_func.h:355
@ QUARTER_FUNC
Definition: item_func.h:319
@ NE_FUNC
Definition: item_func.h:218
@ TIMEDIFF_FUNC
Definition: item_func.h:341
@ BOOL_IF_FUNC
Definition: item_func.h:299
@ JSON_EXTRACT_FUNC
Definition: item_func.h:349
@ TABLE_FUNC
Definition: item_func.h:270
@ MEMBER_OF_FUNC
Definition: item_func.h:336
@ POW_FUNC
Definition: item_func.h:281
@ GE_FUNC
Definition: item_func.h:221
@ SP_GEOMETRYN
Definition: item_func.h:252
@ SYSDATE_FUNC
Definition: item_func.h:340
@ MONTHNAME_FUNC
Definition: item_func.h:307
@ TYPECAST_FUNC
Definition: item_func.h:263
@ SUSERVAR_FUNC
Definition: item_func.h:259
@ EQUAL_FUNC
Definition: item_func.h:217
@ GT_FUNC
Definition: item_func.h:222
@ RADIANS_FUNC
Definition: item_func.h:292
@ UNKNOWN_FUNC
Definition: item_func.h:215
@ SP_DISTANCE_FUNC
Definition: item_func.h:239
@ SP_WITHIN_FUNC
Definition: item_func.h:243
@ SP_INTERIORRINGN
Definition: item_func.h:253
@ SIN_FUNC
Definition: item_func.h:287
@ SP_INTERSECTS_FUNC
Definition: item_func.h:240
@ LAST_DAY_FUNC
Definition: item_func.h:325
@ WEEKDAY_FUNC
Definition: item_func.h:321
@ ADDTIME_FUNC
Definition: item_func.h:318
@ DEGREES_FUNC
Definition: item_func.h:291
@ JSON_OVERLAPS
Definition: item_func.h:334
@ DAYOFYEAR_FUNC
Definition: item_func.h:317
@ JSON_DUALITY_OBJECT_FUNC
Definition: item_func.h:351
@ SQRT_FUNC
Definition: item_func.h:279
@ GROUPING_FUNC
Definition: item_func.h:268
@ ISNOTNULL_FUNC
Definition: item_func.h:227
@ ASIN_FUNC
Definition: item_func.h:294
@ TRUNCATE_FUNC
Definition: item_func.h:278
@ TAN_FUNC
Definition: item_func.h:288
@ GET_FORMAT_FUNC
Definition: item_func.h:345
@ ATAN_FUNC
Definition: item_func.h:295
@ JSON_LENGTH_FUNC
Definition: item_func.h:347
@ DAYNAME_FUNC
Definition: item_func.h:309
@ DATETIME_LITERAL
Definition: item_func.h:329
@ MINUTE_FUNC
Definition: item_func.h:314
@ ACOS_FUNC
Definition: item_func.h:296
@ COS_FUNC
Definition: item_func.h:289
@ INTERVAL_FUNC
Definition: item_func.h:235
@ MUL_FUNC
Definition: item_func.h:274
@ SP_COVERS_FUNC
Definition: item_func.h:246
@ CEILING_FUNC
Definition: item_func.h:276
@ TO_DAYS_FUNC
Definition: item_func.h:310
@ WEEK_FUNC
Definition: item_func.h:320
@ YEARWEEK_FUNC
Definition: item_func.h:303
@ SP_CONTAINS_FUNC
Definition: item_func.h:244
@ FLOOR_FUNC
Definition: item_func.h:283
@ CASE_FUNC
Definition: item_func.h:301
@ COALESCE_FUNC
Definition: item_func.h:331
@ SP_ENDPOINT
Definition: item_func.h:249
@ DIV_FUNC
Definition: item_func.h:275
@ SP_OVERLAPS_FUNC
Definition: item_func.h:247
@ UNIX_TIMESTAMP_FUNC
Definition: item_func.h:326
Item * m_embedded_arguments[2]
Definition: item_func.h:111
virtual uint argument_count() const
Definition: item_func.h:132
longlong check_integer_overflow(longlong value, bool val_unsigned)
Throw an error if the input BIGINT value represented by the (longlong value, bool unsigned flag) pair...
Definition: item_func.h:656
bool val_arg0_time(Time_val *time)
Definition: item_func.h:573
Item * replace_func_call(uchar *) override
Definition: item_func.cc:624
void print_op(const THD *thd, String *str, enum_query_type query_type) const
Definition: item_func.cc:800
bool agg_arg_charsets_for_comparison(DTCollation &c, Item **items, uint nitems)
Definition: item_func.h:601
virtual bool eq_specific(const Item *) const
Provide a more specific equality check for a function.
Definition: item_func.h:542
bool check_column_in_group_by(uchar *arg) override
Check if all the columns present in this expression are present in GROUP BY clause of the derived tab...
Definition: item_func.cc:1079
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.cc:798
Item_func(const POS &pos, Item *a, Item *b, Item *c, Item *d, Item *e)
Definition: item_func.h:456
virtual enum_const_item_cache can_cache_json_arg(Item *arg)
Whether an arg of a JSON function can be cached to avoid repetitive string->JSON conversion.
Definition: item_func.h:743
Item * gc_subst_transformer(uchar *arg) override
Transformer function for GC substitution.
Definition: item_func.cc:1367
table_map used_tables_cache
Value used in calculation of result of used_tables()
Definition: item_func.h:194
bool param_type_is_default(THD *thd, uint start, uint end, enum_field_types def=MYSQL_TYPE_VARCHAR)
Definition: item_func.h:170
optimize_type
Definition: item_func.h:366
@ OPTIMIZE_NONE
Definition: item_func.h:367
@ OPTIMIZE_EQUAL
Definition: item_func.h:371
@ OPTIMIZE_NULL
Definition: item_func.h:370
@ OPTIMIZE_KEY
Definition: item_func.h:368
@ OPTIMIZE_OP
Definition: item_func.h:369
void set_used_tables(table_map map)
Definition: item_func.h:536
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:363
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:726
virtual const char * func_name() const =0
const Item_field * contributes_to_filter(THD *thd, table_map read_tables, table_map filter_for_table, const MY_BITMAP *fields_to_ignore) const
Whether or not an item should contribute to the filtering effect (.
Definition: item_func.cc:951
bool has_timestamp_args()
Definition: item_func.h:670
virtual bool is_deprecated() const
Definition: item_func.h:566
Item_func(const POS &pos, Item *a, Item *b, Item *c, Item *d, Item *e, Item *f)
Definition: item_func.h:481
enum Type type() const override
Definition: item_func.h:373
virtual Item * key_item() const
Definition: item_func.h:545
bool param_type_is_default(THD *thd, uint start, uint end, uint step, enum_field_types def)
For arguments of this Item_func ("args" array), in range [start, start+step, start+2*step,...
Definition: item_func.cc:530
Item_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:434
virtual bool may_have_named_parameters() const
Named parameters are allowed in a parameter list.
Definition: item_func.h:821
bool is_valid_for_pushdown(uchar *arg) override
Check if all the columns present in this expression are from the derived table.
Definition: item_func.cc:1053
uint num_vector_args()
Definition: item_func.cc:1618
bool propagate_type(THD *thd, const Type_properties &type) override
Default implementation for all functions: Propagate base_item's type into all arguments.
Definition: item_func.cc:506
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:765
Item_func(Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:421
bool reject_geometry_args()
Definition: item_func.cc:1644
bool fix_fields(THD *, Item **ref) override
Definition: item_func.cc:408
uint64_t hash_args(bool commutative) const
Definition: item_func.cc:781
void fix_after_pullout(Query_block *parent_query_block, Query_block *removed_query_block) override
Fix after tables have been moved from one query_block level to the parent level, e....
Definition: item_func.cc:462
bool set_arguments(mem_root_deque< Item * > *list, bool context_free)
Copy arguments from list to args array.
Definition: item_func.cc:331
virtual bool allow_replacement(Item_field *const original, Item *const subst)
Check whether a function allows replacement of a field with another item: In particular,...
Definition: item_func.h:639
Item_func(const POS &pos, Item *a, Item *b)
Definition: item_func.h:396
virtual optimize_type select_optimize(const THD *)
Definition: item_func.h:543
bool has_date_args()
Definition: item_func.h:680
void raise_temporal_overflow(const char *type_name)
Definition: item_func.cc:750
virtual const Item * get_arg(uint i) const
Get the i'th argument of the function that this object represents.
Definition: item_func.h:505
uint arg_count
How many arguments in 'args'.
Definition: item_func.h:131
Item_func(Item *a, Item *b, Item *c, Item *d, Item *e)
Definition: item_func.h:442
Item ** arguments() const
Definition: item_func.h:133
Field * tmp_table_field(TABLE *t_arg) override
Definition: item_func.cc:829
bool agg_arg_charsets_for_string_result(DTCollation &c, Item **items, uint nitems)
Definition: item_func.h:592
bool is_null_on_null() const
Definition: item_func.h:203
bool has_time_args()
Definition: item_func.h:691
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item_func.cc:813
bool is_non_const_over_literals(uchar *) override
Definition: item_func.h:822
virtual void fix_num_length_and_dec()
Definition: item_func.cc:897
Item * get_tmp_table_item(THD *thd) override
If an Item is materialized in a temporary table, a different Item may have to be used in the part of ...
Definition: item_func.cc:929
void signal_invalid_argument_for_log()
Definition: item_func.cc:921
bool has_datetime_args()
Definition: item_func.h:702
void signal_divide_by_null()
Definition: item_func.cc:913
double check_float_overflow(double value)
Throw an error if the input double number is not finite, i.e.
Definition: item_func.h:648
Item_func(Item *a)
Definition: item_func.h:380
Item_func(mem_root_deque< Item * > *list)
Definition: item_func.h:492
table_map not_null_tables() const override
Return table map of tables that can't be NULL tables (tables that are used in a context where if they...
Definition: item_func.h:534
table_map not_null_tables_cache
Value used in calculation of result of not_null_tables()
Definition: item_func.h:196
virtual Item * set_arg(THD *, uint, Item *)
Definition: item_func.h:506
bool null_on_null
Affects how to determine that NULL argument implies a NULL function return.
Definition: item_func.h:187
void print_args(const THD *thd, String *str, uint from, enum_query_type query_type) const
Definition: item_func.cc:773
Item_func(Item *a, Item *b, Item *c, Item *d, Item *e, Item *f)
Definition: item_func.h:465
table_map used_tables() const override
Definition: item_func.h:533
virtual bool contains_only_equi_join_condition() const
Whether this Item is an equi-join condition.
Definition: item_func.h:753
bool walk(Item_processor processor, enum_walk walk, uchar *arg) override
Traverses a tree of Items in prefix and/or postfix order.
Definition: item_func.cc:633
Item * transform(Item_transformer transformer, uchar *arg) override
Transform an Item_func object with a transformer callback function.
Definition: item_func.cc:677
virtual bool resolve_type_inner(THD *)
Resolve type of function after all arguments have had their data types resolved.
Definition: item_func.h:522
Item_func(Item *a, Item *b, Item *c)
Definition: item_func.h:402
uint allowed_arg_cols
Definition: item_func.h:192
Definition: item_func.h:1046
String * val_str(String *str) override
Definition: item_func.cc:1507
Item_int_func(const POS &pos, Item *a)
Definition: item_func.h:1054
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_func.h:1098
Item_int_func(Item *a, Item *b, Item *c)
Definition: item_func.h:1065
Item_int_func(const POS &pos)
Definition: item_func.h:1049
Item_int_func(Item *a, Item *b)
Definition: item_func.h:1058
Item_int_func(const POS &pos, PT_item_list *opt_list)
Definition: item_func.h:1084
double val_real() override
Definition: item_func.cc:1501
Item_int_func(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_func.h:1068
Item_int_func()
Definition: item_func.h:1048
Item_int_func(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1061
Item_int_func(Item *a)
Definition: item_func.h:1053
Item_int_func(mem_root_deque< Item * > *list)
Definition: item_func.h:1081
Item_int_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:1076
enum Item_result result_type() const override
Definition: item_func.h:1101
Item_int_func(Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:1073
Item_int_func(THD *thd, Item_int_func *item)
Definition: item_func.h:1089
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_func.h:1094
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:1097
Definition: item_func.h:2578
Item_master_pos_wait(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2580
Item_master_pos_wait(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_func.h:2582
Item_master_pos_wait(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2584
longlong val_int() override
Wait until we are at or past the given position in the master binlog on the slave.
Definition: item_func.cc:5354
void copy(const char *str_arg, size_t length_arg, const CHARSET_INFO *cs_arg, bool is_autogenerated_arg)
Copy name together with autogenerated flag.
Definition: item.cc:1450
Definition: item_func.h:1014
String * str_op(String *) override
Evaluates item when resulting data type is a string type.
Definition: item_func.h:1028
Item_num_op(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1017
virtual void result_precision()=0
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.h:1022
bool datetime_op(Datetime_val *, my_time_flags_t) override
Evaluates item when resulting data type is DATETIME or TIMESTAMP.
Definition: item_func.h:1040
bool time_op(Time_val *) override
Evaluates item when resulting data type is TIME.
Definition: item_func.h:1036
Item_num_op(Item *a, Item *b)
Definition: item_func.h:1016
bool date_op(Date_val *, my_time_flags_t) override
Evaluates item when resulting data type is DATE.
Definition: item_func.h:1032
void set_numeric_type() override
Check arguments to determine the data type for a numeric function of two arguments.
Definition: item_func.cc:1544
Definition: item_func.h:841
longlong val_int() override
Definition: item_func.h:869
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_func.cc:889
Item_real_func(Item *a, Item *b)
Definition: item_func.h:853
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_func.h:873
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:876
String * val_str(String *str) override
Definition: item_func.cc:880
Item_real_func(mem_root_deque< Item * > *list)
Definition: item_func.h:859
Item_real_func(const POS &pos)
Definition: item_func.h:844
Item_real_func(const POS &pos, Item *a)
Definition: item_func.h:849
enum Item_result result_type() const override
Definition: item_func.h:880
Item_real_func()
Definition: item_func.h:843
Item_real_func(const POS &pos, PT_item_list *list)
Definition: item_func.h:863
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_func.h:877
Item_real_func(Item *a)
Definition: item_func.h:848
Item_real_func(const POS &pos, Item *a, Item *b)
Definition: item_func.h:855
Item with result field.
Definition: item.h:5947
int raise_decimal_overflow()
Definition: item.h:6006
longlong raise_integer_overflow()
Definition: item.h:6001
longlong llrint_with_overflow_check(double realval)
Definition: item.h:5986
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item.cc:11279
double raise_float_overflow()
Definition: item.h:5996
A wrapper Item that normally returns its parameter, but becomes NULL when processing rows for rollup.
Definition: item_func.h:1755
const char * func_name() const override
Definition: item_func.h:1776
bool rollup_null() const
Definition: item_func.h:1801
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.cc:4201
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:4265
table_map used_tables() const override
Definition: item_func.h:1777
TYPELIB * get_typelib() const override
Get the typelib information for an item of type set or enum.
Definition: item_func.cc:4294
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.cc:4282
String * val_str(String *str) override
Definition: item_func.cc:4232
bool val_json(Json_wrapper *result) override
Get a JSON value from an Item.
Definition: item_func.cc:4254
const int m_min_rollup_level
Definition: item_func.h:1818
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_func.cc:4289
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1791
my_decimal * val_decimal(my_decimal *dec) override
Definition: item_func.cc:4243
Item_result result_type() const override
Definition: item_func.h:1790
Item_rollup_group_item(int min_rollup_level, Item *inner_item)
Definition: item_func.h:1757
void set_current_rollup_level(int level)
Definition: item_func.h:1812
int min_rollup_level() const
Definition: item_func.h:1815
int m_current_rollup_level
Definition: item_func.h:1819
longlong val_int() override
Definition: item_func.cc:4221
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_func.cc:4191
Item * inner_item()
Definition: item_func.h:1799
const Item * inner_item() const
Definition: item_func.h:1800
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_func.cc:4182
enum Functype functype() const override
Definition: item_func.h:1804
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_func.h:1786
double val_real() override
Definition: item_func.cc:4210
Definition: item_func.h:2543
const char * func_name() const override
Definition: item_func.h:2557
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:2569
Item_source_pos_wait(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2552
Item_source_pos_wait(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_func.h:2550
table_map get_initial_pseudo_tables() const override
Returns the pseudo tables depended upon in order to evaluate this function expression.
Definition: item_func.h:2558
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2561
longlong val_int() override
Wait until we are at or past the given position in the master binlog on the slave.
Definition: item_func.cc:5296
String value
Definition: item_func.h:2545
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:5283
Item_int_func super
Definition: item_func.h:2544
Item_source_pos_wait(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2548
Definition: item.h:5777
Utility mixin class to be able to walk() only parts of item trees.
Definition: item.h:736
Definition: item_func.h:1159
Item_typecast_decimal(const POS &pos, Item *a, int len, int dec)
Definition: item_func.h:1164
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:1174
longlong val_int() override
Definition: item_func.cc:2048
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.cc:2102
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_func.h:1171
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:2088
const char * func_name() const override
Definition: item_func.h:1186
enum Item_result result_type() const override
Definition: item_func.h:1179
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_func.cc:2112
String * val_str(String *str) override
Definition: item_func.cc:2031
my_decimal * val_decimal(my_decimal *) override
Definition: item_func.cc:2056
double val_real() override
Definition: item_func.cc:2040
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_func.h:1175
enum Functype functype() const override
Definition: item_func.h:1187
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1180
Class used to implement CAST to floating-point data types.
Definition: item_func.h:1196
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:2174
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_func.h:1198
enum Item_result result_type() const override
Definition: item_func.h:1219
Item_typecast_real(const POS &pos, Item *a, bool as_double)
Definition: item_func.h:1204
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1220
Item_typecast_real(Item *a)
Definition: item_func.h:1211
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_func.cc:2154
String * val_str(String *str) override
Definition: item_func.cc:2119
double val_real() override
Definition: item_func.cc:2123
longlong val_int() override
Definition: item_func.h:1214
const char * func_name() const override
Definition: item_func.h:1224
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_func.cc:2158
enum Functype functype() const override
Definition: item_func.h:1225
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.cc:2162
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_func.cc:2166
Definition: item_func.h:1133
const char * func_name() const override
Definition: item_func.h:1138
Item_typecast_signed(const POS &pos, Item *a)
Definition: item_func.h:1135
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:1937
longlong val_int() override
Definition: item_func.cc:1965
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:1944
enum Functype functype() const override
Definition: item_func.h:1143
Definition: item_func.h:1146
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:1994
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:2001
Item_typecast_unsigned(const POS &pos, Item *a)
Definition: item_func.h:1148
longlong val_int() override
Definition: item_func.cc:2007
const char * func_name() const override
Definition: item_func.h:1151
enum Functype functype() const override
Definition: item_func.h:1156
Definition: item_func.h:2289
Item_func super
Definition: item_func.h:2290
Item_udf_func(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
Definition: item_func.h:2296
const char * func_name() const override
Definition: item_func.h:2303
bool may_have_named_parameters() const override
Named parameters are allowed in a parameter list.
Definition: item_func.h:2326
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:2313
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:5168
bool fix_fields(THD *thd, Item **ref) override
Definition: item_func.cc:4691
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_func.cc:5162
table_map get_initial_pseudo_tables() const override
Returns the pseudo tables depended upon in order to evaluate this function expression.
Definition: item_func.h:2305
~Item_udf_func() override=default
Item_result result_type() const override
Definition: item_func.h:2310
udf_handler udf
Definition: item_func.h:2293
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:5153
enum Functype functype() const override
Definition: item_func.h:2304
void compute_cost(CostOfItem *root_cost) const override
Compute the cost of evaluating this Item.
Definition: item_func.h:2321
bool m_non_deterministic
This member is set during resolving and is used by update_used_tables() and fix_after_pullout() to pr...
Definition: item_func.h:2333
Definition: item_func.h:3476
double val_real() override
Definition: item_func.cc:7235
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.cc:7261
void set_value(const char *str, size_t length, const CHARSET_INFO *cs)
Definition: item_func.cc:7227
longlong val_int() override
Definition: item_func.cc:7240
bool val_time(Time_val *) override
Evaluate the item and return result as a time value.
Definition: item_func.h:3495
bool fix_fields(THD *thd, Item **ref) override
Definition: item_func.cc:7196
String * val_str(String *str) override
Definition: item_func.cc:7245
Name_string name
Definition: item_func.h:3477
Item_user_var_as_out_param(const POS &pos, Name_string a)
Definition: item_func.h:3481
enum Type type() const override
Definition: item_func.h:3486
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:7255
bool val_datetime(Datetime_val *, my_time_flags_t) override
Evaluate the item and return result as a datetime value.
Definition: item_func.h:3499
bool val_date(Date_val *, my_time_flags_t) override
Evaluate the item and return result as a date value.
Definition: item_func.h:3491
void set_null_value(const CHARSET_INFO *cs)
Definition: item_func.cc:7221
my_decimal * val_decimal(my_decimal *decimal_buffer) override
Definition: item_func.cc:7250
user_var_entry * entry
Definition: item_func.h:3478
Common class for: Item_func_get_system_var Item_func_get_user_var Item_func_set_user_var.
Definition: item_func.h:3119
Item_var_func(const POS &pos, Item *a)
Definition: item_func.h:3127
Item_var_func()
Definition: item_func.h:3121
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_func.h:3135
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_func.h:3138
Item_var_func(THD *thd, Item_var_func *item)
Definition: item_func.h:3124
Item_var_func(Item *a)
Definition: item_func.h:3126
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_func.h:3129
Item_var_func(const POS &pos)
Definition: item_func.h:3122
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:3132
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:928
virtual double val_real()=0
String str_value
str_values's main purpose is to cache the value in save_in_field
Definition: item.h:3637
void set_nullable(bool nullable)
Definition: item.h:3749
DTCollation collation
Character set and collation properties assigned for this Item.
Definition: item.h:3644
bool get_date_from_int(Date_val *date, my_time_flags_t flags)
Convert val_int() to date.
Definition: item.cc:1599
bool is_nullable() const
Definition: item.h:3748
virtual bool propagate_type(THD *thd, const Type_properties &type)
Propagate data type specifications into parameters and user variables.
Definition: item.h:1313
bool get_time_from_decimal(Time_val *time)
Convert val_decimal() to time.
Definition: item.cc:1715
void set_data_type_float()
Set the data type of the Item to be single precision floating point.
Definition: item.h:1586
static Item_result type_to_result(enum_field_types type)
Definition: item.h:1041
virtual table_map used_tables() const
Definition: item.h:2380
bool get_datetime_from_non_temporal(Datetime_val *dt, my_time_flags_t flags)
Convert a non-temporal type to datetime.
Definition: item.cc:1664
virtual bool val_date(Date_val *date, my_time_flags_t flags)=0
Evaluate the item and return result as a date value.
void add_accum_properties(const Item *item)
Add more accumulated properties to an Item.
Definition: item.h:3496
void set_data_type_double()
Set the data type of the Item to be double precision floating point.
Definition: item.h:1578
enum_field_types data_type() const
Retrieve the derived data type of the Item.
Definition: item.h:1480
Item_name_string item_name
Name from query.
Definition: item.h:3645
bool fixed
True if item has been resolved.
Definition: item.h:3737
enum_const_item_cache
How to cache constant JSON data.
Definition: item.h:997
@ CACHE_NONE
Don't cache.
Definition: item.h:999
virtual Item_result result_type() const
Definition: item.h:1450
bool null_value
True if item is null.
Definition: item.h:3774
Type
Definition: item.h:963
@ FIELD_ITEM
A reference to a field (column) in a table.
Definition: item.h:965
@ FUNC_ITEM
A function call reference.
Definition: item.h:966
@ STRING_ITEM
A string literal value.
Definition: item.h:969
bool get_datetime_from_string(Datetime_val *dt, my_time_flags_t flags)
Convert val_str() to datetime.
Definition: item.cc:1555
bool get_datetime_from_int(Datetime_val *dt, my_time_flags_t flags)
Convert val_int() to datetime.
Definition: item.cc:1593
uint8 m_accum_properties
Definition: item.h:3815
void set_accum_properties(const Item *item)
Set accumulated properties for an Item.
Definition: item.h:3491
bool get_datetime_from_real(Datetime_val *dt, my_time_flags_t flags)
Convert val_real() to datetime.
Definition: item.cc:1573
my_decimal * val_decimal_from_real(my_decimal *decimal_value)
Definition: item.cc:362
void set_group_by_modifier()
Set the property: this item (tree) contains a reference to a GROUP BY modifier (such as ROLLUP)
Definition: item.h:3542
bool get_date_from_real(Date_val *date, my_time_flags_t flags)
Convert val_real() to date.
Definition: item.cc:1567
bool get_time_from_int(Time_val *time)
Convert val_int() to time.
Definition: item.cc:1722
bool unsigned_flag
Definition: item.h:3775
bool get_date_from_string(Date_val *date, my_time_flags_t flags)
Convert val_str() to date.
Definition: item.cc:1563
virtual bool is_null()
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item.h:2599
bool const_for_execution() const
Returns true if item is constant during one query execution.
Definition: item.h:2453
bool get_time_from_non_temporal(Time_val *time)
Convert a non-temporal type to time.
Definition: item.cc:1769
traverse_order
Definition: item.h:994
virtual bool val_datetime(Datetime_val *dt, my_time_flags_t flags)=0
Evaluate the item and return result as a datetime value.
bool get_time_from_real(Time_val *time)
Convert val_real() to time.
Definition: item.cc:1709
virtual bool val_time(Time_val *time)=0
Evaluate the item and return result as a time value.
virtual String * val_str(String *str)=0
bool hidden
If the item is in a SELECT list (Query_block::fields) and hidden is true, the item wasn't actually in...
Definition: item.h:3785
void set_data_type_from_item(const Item *item)
Set data type properties of the item from the properties of another item.
Definition: item.h:1798
bool get_datetime_from_decimal(Datetime_val *dt, my_time_flags_t flags)
Convert val_decimal() to datetime.
Definition: item.cc:1586
uint32 max_length
Maximum length of result of evaluating this item, in number of bytes.
Definition: item.h:3662
bool get_date_from_decimal(Date_val *date, my_time_flags_t flags)
Convert val_decimal() to date.
Definition: item.cc:1579
void set_data_type_longlong()
Set the data type of the Item to be longlong.
Definition: item.h:1554
bool update_null_value()
Make sure the null_value member has a correct value.
Definition: item.cc:7876
void set_data_type_decimal(uint8 precision, uint8 scale)
Set the data type of the Item to be decimal.
Definition: item.h:1568
bool get_time_from_string(Time_val *time)
Convert val_str() to time.
Definition: item.cc:1701
bool get_date_from_non_temporal(Date_val *date, my_time_flags_t flags)
Convert a non-temporal type to date.
Definition: item.cc:1683
Definition: sql_optimizer.h:133
Represents a JSON container value of type "object" (ECMA), type J_OBJECT here.
Definition: json_dom.h:373
bool add_alias(std::string_view key, Json_dom *value)
Insert the value into the object.
Definition: json_dom.h:415
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1225
Definition: sql_list.h:494
Storage for name strings.
Definition: item.h:296
A visitor that calls the specified function on every non-aggregated full-text search function (Item_f...
Definition: item_func.h:3884
std::function< bool(Item_func_match *)> m_func
Definition: item_func.h:3891
bool operator()(Item *item)
Definition: item_func.cc:8130
NonAggregatedFullTextSearchVisitor(std::function< bool(Item_func_match *)> func)
Definition: item_func.cc:8126
Wrapper class for an Item list head, used to allocate Item lists in the parser in a context-independe...
Definition: parse_tree_helpers.h:109
void error(Context *pc, const POS &pos) const
syntax_error() function replacement for deferred reporting of syntax errors
Definition: parse_tree_node_base.h:346
Definition: protocol.h:33
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1179
Definition: field.h:4481
Definition: item.h:662
A wrapper class for null-terminated constant strings.
Definition: sql_string.h:74
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:169
const CHARSET_INFO * charset() const
Definition: sql_string.h:242
const char * ptr() const
Definition: sql_string.h:251
size_t length() const
Definition: sql_string.h:243
Wrapper interface for all kinds of system variables.
Definition: set_var.h:580
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: table.h:2952
TABLE * table
Definition: table.h:3741
Time_val is a temporal type that represents only time.
Definition: my_temporal.h:55
Type properties, used to collect type information for later assignment to an Item object.
Definition: item.h:625
Table_flags ha_table_flags() const
The cached_table_flags is set at ha_open and ha_external_lock.
Definition: handler.h:5101
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:111
my_decimal class limits 'decimal_t' type to what we need in MySQL.
Definition: my_decimal.h:97
sp_head represents one instance of a stored program.
Definition: sp_head.h:389
Base class for every SP-instruction.
Definition: sp_instr.h:105
Definition: sp_head.h:124
Definition: sp_rcontext.h:77
A class representing one system variable - that is something that can be accessed as @global....
Definition: set_var.h:107
Definition: sql_udf.h:83
Item_result result_type() const
Definition: sql_udf.h:119
const char * name() const
Definition: sql_udf.h:118
Definition: item_func.h:3152
char * internal_buffer_ptr()
Position inside a user_var_entry where small values are stored: double values, longlong values and st...
Definition: item_func.h:3169
static const size_t extra_size
Definition: item_func.h:3241
Simple_cstring entry_name
Definition: item_func.h:3266
Item_result m_type
Value type.
Definition: item_func.h:3244
size_t m_length
Value length.
Definition: item_func.h:3243
longlong val_int(bool *null_value) const
Get the value of a variable as an integer.
Definition: item_func.cc:6391
bool unsigned_flag
Definition: item_func.h:3268
THD * m_owner
Definition: item_func.h:3245
size_t length() const
Definition: item_func.h:3340
query_id_t used_query_id() const
Definition: item_func.h:3310
THD * owner_session() const
Definition: item_func.h:3264
static user_var_entry * create(THD *thd, const Name_string &name, const CHARSET_INFO *cs)
Allocates and initializes a user variable instance.
Definition: item_func.cc:6234
void set_value(char *value, size_t length)
Definition: item_func.h:3157
String * val_str(bool *null_value, String *str, uint decimals) const
Get the value of a variable as a string.
Definition: item_func.cc:6430
user_var_entry()=default
const char * ptr() const
Definition: item_func.h:3339
void free_value()
Free the external value buffer, if it's allocated.
Definition: item_func.h:3197
bool store(const void *from, size_t length, Item_result type)
Store a value of the given type into a user_var_entry instance.
Definition: item_func.cc:6281
void init(THD *thd, const Simple_cstring &name, const CHARSET_INFO *cs)
Initialize all members.
Definition: item_func.cc:6269
Item_result type() const
The data type of this variable.
Definition: item_func.h:3342
void destroy()
Free all memory used by a user_var_entry instance previously created by create().
Definition: item_func.h:3329
bool alloced()
Check if m_ptr points to an external buffer previously allocated by realloc().
Definition: item_func.h:3192
void lock()
Definition: item_func.cc:6321
void unlock()
Definition: item_func.cc:6326
void set_null_value(Item_result type)
Set value to NULL.
Definition: item_func.h:3302
void copy_name(const Simple_cstring &name)
Copy the array of characters from the given name into the internal name buffer and initialize entry_n...
Definition: item_func.h:3205
DTCollation collation
Definition: item_func.h:3267
void set_type(Item_result type)
Set type of to the given value.
Definition: item_func.h:3293
char * m_ptr
Value.
Definition: item_func.h:3242
query_id_t m_used_query_id
Set to the id of the most recent query that has used the variable.
Definition: item_func.h:3259
void assert_locked() const
Assert the user variable is locked.
Definition: item_func.cc:6306
void reset_value()
Definition: item_func.h:3153
char * name_ptr()
Position inside a user_var_entry where a null-terminates array of characters representing the variabl...
Definition: item_func.h:3177
double val_real(bool *null_value) const
Get the value of a variable as a double.
Definition: item_func.cc:6362
my_decimal * val_decimal(bool *null_value, my_decimal *result) const
Get the value of a variable as a decimal.
Definition: item_func.cc:6462
bool mem_realloc(size_t length)
Initialize m_ptr to the internal buffer (if the value is small enough), or allocate a separate buffer...
Definition: item_func.cc:6251
void set_used_query_id(query_id_t query_id)
Definition: item_func.h:3309
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
#define E_DEC_FATAL_ERROR
Definition: decimal.h:154
#define E_DEC_OVERFLOW
Definition: decimal.h:149
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:31
This file contains the field type.
enum_field_types
Column types for MySQL Note: Keep include/mysql/components/services/bits/stored_program_bits....
Definition: field_types.h:55
@ MYSQL_TYPE_VARCHAR
Definition: field_types.h:71
@ MYSQL_TYPE_LONGLONG
Definition: field_types.h:64
@ MYSQL_TYPE_TIME
Definition: field_types.h:67
@ MYSQL_TYPE_VECTOR
Definition: field_types.h:77
@ MYSQL_TYPE_INVALID
Definition: field_types.h:78
@ MYSQL_TYPE_NEWDECIMAL
Definition: field_types.h:81
@ MYSQL_TYPE_DOUBLE
Definition: field_types.h:61
@ MYSQL_TYPE_DATE
Definition: field_types.h:66
@ MYSQL_TYPE_TIMESTAMP
Definition: field_types.h:63
@ MYSQL_TYPE_DATETIME
Definition: field_types.h:68
static const std::string dec("DECRYPTION")
Some definitions for full-text indices.
ft_operation
Operation types, used in FT_HINTS.
Definition: ft_global.h:99
@ FT_OP_NO
Operation undefined, use of hints is impossible.
Definition: ft_global.h:101
#define FTS_DOCID_IN_RESULT
Definition: ft_global.h:66
#define FT_SORTED
Definition: ft_global.h:108
#define FTS_ORDERED_RESULT
Definition: ft_global.h:65
#define FT_BOOL
Definition: ft_global.h:107
cache_type
Definition: my_sys.h:287
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:217
static int flags[50]
Definition: hp_test1.cc:40
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:180
bool agg_item_charsets_for_comparison(DTCollation &c, const char *name, Item **items, uint nitems)
Definition: item.h:4177
bool agg_item_charsets_for_string_result(DTCollation &c, const char *name, Item **items, uint nitems)
Definition: item.h:4170
bool(Item::* Item_analyzer)(uchar **argp)
Definition: item.h:710
void(* Cond_traverser)(const Item *item, void *arg)
Definition: item.h:720
Item *(Item::* Item_transformer)(uchar *arg)
Type for transformers used by Item::transform and Item::compile.
Definition: item.h:719
bool check_reserved_words(const char *name)
Definition: item_func.cc:168
void report_conversion_error(const CHARSET_INFO *to_cs, const char *from, size_t from_length, const CHARSET_INFO *from_cs)
Definition: item_func.cc:176
Item_field * get_gc_for_expr(const Item *func, Field *fld, Item_result type, Field **found=nullptr)
Return new Item_field if given expression matches GC.
Definition: item_func.cc:1109
bool is_function_of_type(const Item *item, Item_func::Functype type)
Checks if "item" is a function of the specified type.
Definition: item_func.cc:1083
bool simplify_string_args(THD *thd, const DTCollation &c, Item **items, uint nitems)
Simplify the string arguments to a function, if possible.
Definition: item_func.cc:200
void unsupported_json_comparison(size_t arg_count, Item **args, const char *msg)
Go through the arguments of a function and check if any of them are JSON.
Definition: item_func.cc:1680
bool eval_const_cond(THD *thd, Item *cond, bool *value)
Evaluate a constant condition, represented by an Item tree.
Definition: item_func.cc:317
enum_field_types agg_field_type(Item **items, uint nitems)
Aggregates field types from the array of items.
Definition: item_cmpfunc.cc:185
void item_func_sleep_free()
Definition: item_func.cc:6023
void mysql_ull_set_explicit_lock_duration(THD *thd)
Set explicit duration for metadata locks corresponding to user level locks to protect them from being...
Definition: item_func.cc:5479
double my_double_round(double value, longlong dec, bool dec_unsigned, bool truncate)
Definition: item_func.cc:3585
String * eval_string_arg_noinline(const CHARSET_INFO *to_cs, Item *arg, String *buffer)
Evaluate an argument string and return it in the desired character set.
Definition: item_func.cc:267
String * eval_string_arg(const CHARSET_INFO *to_cs, Item *arg, String *buffer)
Definition: item_func.h:94
void item_func_sleep_init()
Definition: item_func.cc:6013
void mysql_ull_cleanup(THD *thd)
Release all user level locks for this THD.
Definition: item_func.cc:5461
void retrieve_tablespace_statistics(THD *thd, Item **args, bool *null_value)
Retrieve tablespace statistics from SE.
Definition: item_func.cc:9899
bool volatile mqh_used
Definition: mysqld.cc:1332
Item * get_system_variable(Parse_context *pc, enum_var_type scope, const LEX_CSTRING &prefix, const LEX_CSTRING &suffix, bool unsafe_for_replication)
Create new Item_func_get_system_var object.
Definition: item_func.cc:8197
bool contains_function_of_type(Item *item, Item_func::Functype type)
Checks if "item" contains a function of the specified type.
Definition: item_func.cc:1088
void uuid_short_init()
Definition: item_func.cc:8818
A better implementation of the UNIX ctype(3) library.
MYSQL_STRINGS_EXPORT CHARSET_INFO my_charset_bin
Definition: ctype-bin.cc:499
int64_t my_strntoll(const CHARSET_INFO *cs, const char *str, size_t length, int base, const char **end, int *err)
Definition: m_ctype.h:747
double my_strntod(const CHARSET_INFO *cs, const char *str, size_t length, const char **end, int *err)
Definition: m_ctype.h:759
bool my_charset_same(const CHARSET_INFO *cs1, const CHARSET_INFO *cs2)
Definition: m_ctype.h:514
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1228
Header for compiler-dependent features.
#define SUPPRESS_UBSAN
Definition: my_compiler.h:120
#define DBUG_TRACE
Definition: my_dbug.h:146
int str2my_decimal(uint mask, const char *from, size_t length, const CHARSET_INFO *charset, my_decimal *decimal_value)
Definition: my_decimal.cc:257
It is interface module to fixed precision decimals library.
int double2my_decimal(uint mask, double val, my_decimal *d)
Definition: my_decimal.h:326
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
uint8_t uint8
Definition: my_inttypes.h:63
unsigned char uchar
Definition: my_inttypes.h:52
long long int longlong
Definition: my_inttypes.h:55
#define MYF(v)
Definition: my_inttypes.h:97
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:81
Some macros for dealing with pointer arithmetic, e.g., aligning of buffers to a given size.
#define ALIGN_SIZE(A)
Definition: my_pointer_arithmetic.h:36
uint64_t table_map
Definition: my_table_map.h:30
Interface for low level time utilities.
unsigned int my_time_flags_t
Flags to str_to_datetime and number_to_datetime.
Definition: my_time.h:85
#define MAX_BIGINT_WIDTH
Max width for a LONGLONG.
Definition: mysql_com.h:903
thread_local MEM_ROOT ** THR_MALLOC
Definition: mysqld.cc:1592
static bool replace
Definition: mysqlimport.cc:70
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1077
Definition: commit_order_queue.h:34
PT & ref(PT *tp)
Definition: tablespace_impl.cc:359
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
std::string_view type_name()
Return the name of the given type (not demangled).
Definition: object_lifetime_tracker.h:57
std::string join(const detail::range auto &rng, std::string_view delim)
join elements of a range into a string separated by a delimiter.
Definition: string.h:74
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
const char * db_name
Definition: rules_table_service.cc:55
std::string truncate(const std::string &str, const size_t max_length)
Truncates the given string to max_length code points.
Definition: utils_string.cc:418
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2898
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2884
required string type
Definition: replication_group_member_actions.proto:34
"public" interface to sys_var - server configuration variables.
enum_var_type
Definition: set_var.h:92
type_conversion_status
Status when storing a value in a field or converting from one datatype to another.
Definition: field.h:197
@ VGS_CHECK_CONSTRAINT
Definition: field.h:471
@ VGS_GENERATED_COLUMN
Definition: field.h:469
Derivation
For use.
Definition: field.h:173
#define HA_CAN_FULLTEXT_EXT
Definition: handler.h:430
File containing constants that can be used throughout the server.
constexpr const table_map RAND_TABLE_BIT
Definition: sql_const.h:113
enum_walk
Enumeration for {Item,Query_block[_UNIT],Table_function}walk.
Definition: sql_const.h:289
bool(Item::*)(unsigned char *) Item_processor
Processor type for {Item,Query_block[_UNIT],Table_function}walk.
Definition: sql_const.h:307
constexpr const table_map INNER_TABLE_BIT
Definition: sql_const.h:111
Our own string classes, used pervasively throughout the executor.
case opt name
Definition: sslopt-case.h:29
Definition: m_ctype.h:421
Struct used to pass around arguments to/from check_function_as_value_generator.
Definition: item.h:486
int err_code
the error code found during check(if any)
Definition: item.h:493
const char * banned_function_name
the name of the function which is not allowed
Definition: item.h:500
Value_generator_source source
Definition: item.h:498
Definition: ft_global.h:77
Definition: ft_global.h:72
struct _ft_vft * please
Definition: ft_global.h:73
Definition: item.h:3125
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
T * ArrayAlloc(size_t num, Args... args)
Allocate 'num' objects of type T, and initialize them to a default value that is created by passing t...
Definition: my_alloc.h:180
Definition: mysql_lex_string.h:40
Definition: mysql_lex_string.h:35
Definition: my_bitmap.h:43
Bison "location" class.
Definition: parse_location.h:43
Instances of Name_resolution_context store the information necessary for name resolution of Items and...
Definition: item.h:413
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:422
Definition: table.h:1450
handler * file
Definition: table.h:1452
Definition: typelib.h:35
Definition: completion_hash.h:35
void(* close_search)(FT_INFO *)
Definition: ft_global.h:51
Definition: mysql_com.h:1110
Definition: result.h:30
Definition: sql_udf.h:44
Item_result
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:39
@ STRING_RESULT
not valid for UDFs
Definition: udf_registration_types.h:41
@ DECIMAL_RESULT
not valid for UDFs
Definition: udf_registration_types.h:45
@ REAL_RESULT
char *
Definition: udf_registration_types.h:42
@ INT_RESULT
double
Definition: udf_registration_types.h:43
#define array_elements(A)
Definition: validate_password_imp.cc:50