MySQL 9.7.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, 2026, 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 {
367 };
374 };
375 enum Type type() const override { return FUNC_ITEM; }
376 virtual enum Functype functype() const { return UNKNOWN_FUNC; }
378
379 explicit Item_func(const POS &pos)
381
383 args[0] = a;
385 }
386 Item_func(const POS &pos, Item *a)
388 args[0] = a;
389 }
390
392 args[0] = a;
393 args[1] = b;
397 }
398 Item_func(const POS &pos, Item *a, Item *b)
400 args[0] = a;
401 args[1] = b;
402 }
403
404 Item_func(Item *a, Item *b, Item *c) {
405 if (alloc_args(*THR_MALLOC, 3)) return;
406 args[0] = a;
407 args[1] = b;
408 args[2] = c;
413 }
414
415 Item_func(const POS &pos, Item *a, Item *b, Item *c)
416 : Item_result_field(pos) {
417 if (alloc_args(*THR_MALLOC, 3)) return;
418 args[0] = a;
419 args[1] = b;
420 args[2] = c;
421 }
422
423 Item_func(Item *a, Item *b, Item *c, Item *d) {
424 if (alloc_args(*THR_MALLOC, 4)) return;
425 args[0] = a;
426 args[1] = b;
427 args[2] = c;
428 args[3] = d;
434 }
435
436 Item_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
437 : Item_result_field(pos) {
438 if (alloc_args(*THR_MALLOC, 4)) return;
439 args[0] = a;
440 args[1] = b;
441 args[2] = c;
442 args[3] = d;
443 }
444 Item_func(Item *a, Item *b, Item *c, Item *d, Item *e) {
445 if (alloc_args(*THR_MALLOC, 5)) return;
446 args[0] = a;
447 args[1] = b;
448 args[2] = c;
449 args[3] = d;
450 args[4] = e;
457 }
458 Item_func(const POS &pos, Item *a, Item *b, Item *c, Item *d, Item *e)
459 : Item_result_field(pos) {
460 if (alloc_args(*THR_MALLOC, 5)) return;
461 args[0] = a;
462 args[1] = b;
463 args[2] = c;
464 args[3] = d;
465 args[4] = e;
466 }
467 Item_func(Item *a, Item *b, Item *c, Item *d, Item *e, Item *f) {
468 if (alloc_args(*THR_MALLOC, 6)) return;
469 args[0] = a;
470 args[1] = b;
471 args[2] = c;
472 args[3] = d;
473 args[4] = e;
474 args[5] = f;
482 }
483 Item_func(const POS &pos, Item *a, Item *b, Item *c, Item *d, Item *e,
484 Item *f)
485 : Item_result_field(pos) {
486 if (alloc_args(*THR_MALLOC, 6)) return;
487 args[0] = a;
488 args[1] = b;
489 args[2] = c;
490 args[3] = d;
491 args[4] = e;
492 args[5] = f;
493 }
495 set_arguments(list, false);
496 }
497
498 Item_func(const POS &pos, PT_item_list *opt_list);
499
500 // Constructor used for Item_cond_and/or (see Item comment)
501 Item_func(THD *thd, const Item_func *item);
502
503 /// Get the i'th argument of the function that this object represents.
504 virtual Item *get_arg(uint i) { return args[i]; }
505
506 /// Get the i'th argument of the function that this object represents.
507 virtual const Item *get_arg(uint i) const { return args[i]; }
508 virtual Item *set_arg(THD *, uint, Item *) {
509 assert(0);
510 return nullptr;
511 }
512
513 bool do_itemize(Parse_context *pc, Item **res) override;
514
515 bool fix_fields(THD *, Item **ref) override;
516 bool fix_func_arg(THD *, Item **arg);
517 void fix_after_pullout(Query_block *parent_query_block,
518 Query_block *removed_query_block) override;
519 /**
520 Resolve type of function after all arguments have had their data types
521 resolved. Called from resolve_type() when no dynamic parameters
522 are used and from propagate_type() otherwise.
523 */
524 virtual bool resolve_type_inner(THD *) {
525 assert(false);
526 return false;
527 }
528 bool propagate_type(THD *thd, const Type_properties &type) override;
529 /**
530 Returns the pseudo tables depended upon in order to evaluate this
531 function expression. The default implementation returns the empty
532 set.
533 */
534 virtual table_map get_initial_pseudo_tables() const { return 0; }
535 table_map used_tables() const override { return used_tables_cache; }
537 void update_used_tables() override;
539 bool eq(const Item *item) const override;
540 /**
541 Provide a more specific equality check for a function.
542 Combine with Item::eq() to implement a complete equality check.
543 */
544 virtual bool eq_specific(const Item *) const { return true; }
545 virtual optimize_type select_optimize(const THD *) { return OPTIMIZE_NONE; }
546 virtual bool have_rev_func() const { return false; }
547 virtual Item *key_item() const { return args[0]; }
548 /**
549 Copy arguments from list to args array
550
551 @param list function argument list
552 @param context_free true: for use in context-independent
553 constructors (Item_func(POS,...)) i.e. for use
554 in the parser
555 @return true on OOM, false otherwise
556 */
557 bool set_arguments(mem_root_deque<Item *> *list, bool context_free);
558 bool split_sum_func(THD *thd, Ref_item_array ref_item_array,
559 mem_root_deque<Item *> *fields) override;
560 void print(const THD *thd, String *str,
561 enum_query_type query_type) const override;
562
563 uint64_t hash() override;
564 void print_op(const THD *thd, String *str, enum_query_type query_type) const;
565 void print_args(const THD *thd, String *str, uint from,
566 enum_query_type query_type) const;
567 virtual void fix_num_length_and_dec();
568 virtual bool is_deprecated() const { return false; }
570 return (null_value = args[0]->val_date(date, flags));
571 }
573 return (null_value = args[0]->val_datetime(dt, flags));
574 }
576 return (null_value = args[0]->val_time(time));
577 }
578 bool is_null() override { return update_null_value() || null_value; }
581 friend class udf_handler;
582 Field *tmp_table_field(TABLE *t_arg) override;
583 Item *get_tmp_table_item(THD *thd) override;
584
585 void raise_temporal_overflow(const char *type_name);
586
587 my_decimal *val_decimal(my_decimal *) override;
588
589 /*
590 Aggregate arguments for string result, e.g: CONCAT(a,b)
591 - convert to @@character_set_connection if all arguments are numbers
592 - allow DERIVATION_NONE
593 */
595 uint nitems) {
596 return agg_item_charsets_for_string_result(c, func_name(), items, nitems);
597 }
598 /*
599 Aggregate arguments for comparison, e.g: a=b, a LIKE b, a RLIKE b
600 - don't convert to @@character_set_connection if all arguments are numbers
601 - don't allow DERIVATION_NONE
602 */
604 uint nitems) {
605 return agg_item_charsets_for_comparison(c, func_name(), items, nitems);
606 }
607
608 Item *replace_func_call(uchar *) override;
609
610 bool walk(Item_processor processor, enum_walk walk, uchar *arg) override;
611 Item *transform(Item_transformer transformer, uchar *arg) override;
612 Item *compile(Item_analyzer analyzer, uchar **arg_p,
613 Item_transformer transformer, uchar *arg_t) override;
614 void traverse_cond(Cond_traverser traverser, void *arg,
615 traverse_order order) override;
616
617 bool replace_equal_field_checker(uchar **arg) override {
618 Replace_equal *replace = pointer_cast<Replace_equal *>(*arg);
619 replace->stack.push_front(this);
620 return true;
621 }
622
624 pointer_cast<Replace_equal *>(arg)->stack.pop();
625 return this;
626 }
627
628 /**
629 Check whether a function allows replacement of a field with another item:
630 In particular, a replacement that changes the metadata of some Item
631 from non-nullable to nullable is not allowed.
632 Notice that e.g. changing the nullability of an operand of a comparison
633 operator in a WHERE clause that ignores UNKNOWN values is allowed,
634 according to this criterion.
635
636 @param original the field that could be replaced
637 @param subst the item that could be the replacement
638
639 @returns true if replacement is allowed, false otherwise
640 */
641 virtual bool allow_replacement(Item_field *const original,
642 Item *const subst) {
643 return original->is_nullable() || !subst->is_nullable();
644 }
645
646 /**
647 Throw an error if the input double number is not finite, i.e. is either
648 +/-INF or NAN.
649 */
650 inline double check_float_overflow(double value) {
651 return std::isfinite(value) ? value : raise_float_overflow();
652 }
653 /**
654 Throw an error if the input BIGINT value represented by the
655 (longlong value, bool unsigned flag) pair cannot be returned by the
656 function, i.e. is not compatible with this Item's unsigned_flag.
657 */
658 inline longlong check_integer_overflow(longlong value, bool val_unsigned) {
659 if ((unsigned_flag && !val_unsigned && value < 0) ||
660 (!unsigned_flag && val_unsigned &&
661 (ulonglong)value > (ulonglong)LLONG_MAX))
662 return raise_integer_overflow();
663 return value;
664 }
665 /**
666 Throw an error if the error code of a DECIMAL operation is E_DEC_OVERFLOW.
667 */
670 }
671
673 assert(fixed);
674 for (uint i = 0; i < arg_count; i++) {
675 if (args[i]->type() == Item::FIELD_ITEM &&
677 return true;
678 }
679 return false;
680 }
681
683 assert(fixed);
684 for (uint i = 0; i < arg_count; i++) {
685 if (args[i]->type() == Item::FIELD_ITEM &&
686 (args[i]->data_type() == MYSQL_TYPE_DATE ||
688 return true;
689 }
690 return false;
691 }
692
694 assert(fixed);
695 for (uint i = 0; i < arg_count; i++) {
696 if (args[i]->type() == Item::FIELD_ITEM &&
697 (args[i]->data_type() == MYSQL_TYPE_TIME ||
699 return true;
700 }
701 return false;
702 }
703
705 assert(fixed);
706 for (uint i = 0; i < arg_count; i++) {
707 if (args[i]->type() == Item::FIELD_ITEM &&
709 return true;
710 }
711 return false;
712 }
713
714 /*
715 We assume the result of any function that has a TIMESTAMP argument to be
716 timezone-dependent, since a TIMESTAMP value in both numeric and string
717 contexts is interpreted according to the current timezone.
718 The only exception is UNIX_TIMESTAMP() which returns the internal
719 representation of a TIMESTAMP argument verbatim, and thus does not depend on
720 the timezone.
721 */
723 return has_timestamp_args();
724 }
725
726 Item *gc_subst_transformer(uchar *arg) override;
727
728 bool resolve_type(THD *thd) override {
729 // By default, pick PS-param's type from other arguments, or VARCHAR
730 return param_type_uses_non_param(thd);
731 }
732
733 /**
734 Whether an arg of a JSON function can be cached to avoid repetitive
735 string->JSON conversion. This function returns true only for those args,
736 which are the source of JSON data. JSON path args are cached independently
737 and for them this function returns false. Same as for all other type of
738 args.
739
740 @param arg the arg to cache
741
742 @retval true arg can be cached
743 @retval false otherwise
744 */
745 virtual enum_const_item_cache can_cache_json_arg(Item *arg [[maybe_unused]]) {
746 return CACHE_NONE;
747 }
748
749 /// Whether this Item is an equi-join condition. If this Item is a compound
750 /// item (i.e. multiple condition AND'ed together), it will only return true
751 /// if the Item contains only equi-join conditions AND'ed together. This is
752 /// used to determine whether the condition can be used as a join condition
753 /// for hash join (join conditions in hash join must be equi-join conditions),
754 /// or if it should be placed as a filter after the join.
755 virtual bool contains_only_equi_join_condition() const { return false; }
756
757 protected:
758 /**
759 Whether or not an item should contribute to the filtering effect
760 (@see get_filtering_effect()). First it verifies that table
761 requirements are satisfied as follows:
762
763 1) The item must refer to a field in 'filter_for_table' in some
764 way. This reference may be indirect through any number of
765 intermediate items. For example, this item may be an
766 Item_cond_and which refers to an Item_func_eq which refers to
767 the field.
768 2) The item must not refer to other tables than those already
769 read and the table in 'filter_for_table'
770
771 Then it contines to other properties as follows:
772
773 Item_funcs represent "<operand1> OP <operand2> [OP ...]". If the
774 Item_func is to contribute to the filtering effect, then
775
776 1) one of the operands must be a field from 'filter_for_table' that is not
777 in 'fields_to_ignore', and
778 2) depending on the Item_func type filtering effect is calculated
779 for, one or all [1] of the other operand(s) must be an available
780 value, i.e.:
781 - a constant, or
782 - a constant subquery, or
783 - a field value read from a table in 'read_tables', or
784 - a second field in 'filter_for_table', or
785 - a function that only refers to constants or tables in
786 'read_tables', or
787 - special case: an implicit value like NULL in the case of
788 "field IS NULL". Such Item_funcs have arg_count==1.
789
790 [1] "At least one" for multiple equality (X = Y = Z = ...), "all"
791 for the rest (e.g. BETWEEN)
792
793 @param thd The current thread.
794 @param read_tables Tables earlier in the join sequence.
795 Predicates for table 'filter_for_table' that
796 rely on values from these tables can be part of
797 the filter effect.
798 @param filter_for_table The table we are calculating filter effect for
799 @param fields_to_ignore Columns that should be ignored.
800
801
802 @return Item_field that participates in the predicate if none of the
803 requirements are broken, NULL otherwise
804
805 @note: This function only applies to items doing comparison, i.e.
806 boolean predicates. Unfortunately, some of those items do not
807 inherit from Item_bool_func so the member function has to be
808 placed in Item_func.
809 */
811 THD *thd, table_map read_tables, table_map filter_for_table,
812 const MY_BITMAP *fields_to_ignore) const;
813 /**
814 Named parameters are allowed in a parameter list
815
816 The syntax to name parameters in a function call is as follow:
817 <code>foo(expr AS named, expr named, expr AS "named", expr "named")</code>
818 where "AS" is optional.
819 Only UDF function support that syntax.
820
821 @return true if the function item can have named parameters
822 */
823 virtual bool may_have_named_parameters() const { return false; }
824 bool is_non_const_over_literals(uchar *) override { return false; }
825
826 bool check_function_as_value_generator(uchar *checker_args) override {
827 if (is_deprecated()) {
829 pointer_cast<Check_function_as_value_generator_parameters *>(
830 checker_args);
831 func_arg->banned_function_name = func_name();
832 return true;
833 }
834 return false;
835 }
836 bool is_valid_for_pushdown(uchar *arg) override;
837 bool check_column_in_window_functions(uchar *arg) override;
838 bool check_column_in_group_by(uchar *arg) override;
839
841};
842
843class Item_real_func : public Item_func {
844 public:
846 explicit Item_real_func(const POS &pos) : Item_func(pos) {
848 }
849
851 Item_real_func(const POS &pos, Item *a) : Item_func(pos, a) {
853 }
854
856
857 Item_real_func(const POS &pos, Item *a, Item *b) : Item_func(pos, a, b) {
859 }
860
863 }
864
867 }
868
869 String *val_str(String *str) override;
870 my_decimal *val_decimal(my_decimal *decimal_value) override;
871 longlong val_int() override {
872 assert(fixed);
874 }
875 bool val_date(Date_val *date, my_time_flags_t flags) override {
876 return get_date_from_real(date, flags);
877 }
878 bool val_time(Time_val *time) override { return get_time_from_real(time); }
880 return get_datetime_from_real(dt, flags);
881 }
882 enum Item_result result_type() const override { return REAL_RESULT; }
883};
884
886 protected:
888
889 public:
892 }
894 : Item_func(pos, a), hybrid_type(REAL_RESULT) {
896 }
897
901 }
902 Item_func_numhybrid(const POS &pos, Item *a, Item *b)
903 : Item_func(pos, a, b), hybrid_type(REAL_RESULT) {
905 }
906
910 }
914 }
915
916 enum Item_result result_type() const override { return hybrid_type; }
918 return MYSQL_TYPE_DOUBLE;
919 }
920 bool resolve_type(THD *thd) override;
921 bool resolve_type_inner(THD *thd) override;
922 void fix_num_length_and_dec() override;
923 virtual void set_numeric_type() = 0; // To be called from resolve_type()
924
925 double val_real() override;
926 longlong val_int() override;
927 my_decimal *val_decimal(my_decimal *) override;
928 String *val_str(String *str) override;
929 bool val_date(Date_val *date, my_time_flags_t flags) override;
930 bool val_time(Time_val *time) override;
932 /**
933 Evaluates item when resulting data type is integer type
934
935 @returns The result of the operation (0 when error or result is NULL)
936 */
937 virtual longlong int_op() = 0;
938 /**
939 Evaluates item when resulting data type is floating point type
940
941 @returns The result of the operation (0.0 when error or result is NULL)
942 */
943 virtual double real_op() = 0;
944 /**
945 Evaluates item when resulting data type is DECIMAL
946
947 @param[out] decimal_value Buffer into which decimal value is stored
948 @returns nullptr if error or result is NULL, otherwise pointer to result
949 */
950 virtual my_decimal *decimal_op(my_decimal *decimal_value) = 0;
951 /**
952 Evaluates item when resulting data type is a string type
953
954 @param[out] string string evaluation buffer
955 @returns nullptr if error or result is NULL, otherwise pointer to result
956 */
957 virtual String *str_op(String *string) = 0;
958 /**
959 Evaluates item when resulting data type is DATE
960
961 @param[out] date resulting date value when return value is false
962 @param flags flags for handling invalid date values
963 @returns true if error or result is NULL, false if non-NULL result
964 */
965 virtual bool date_op(Date_val *date, my_time_flags_t flags) = 0;
966 /**
967 Evaluates item when resulting data type is TIME
968
969 @param[out] time resulting time value when return value is false
970 @returns true if error or result is NULL, false if non-NULL result
971 */
972 virtual bool time_op(Time_val *time) = 0;
973 /**
974 Evaluates item when resulting data type is DATETIME or TIMESTAMP
975
976 @param[out] dt resulting datetime value when return value is false
977 @param flags flags for handling invalid date values
978 @returns true if error or result is NULL, false if non-NULL result
979 */
981
982 bool is_null() override { return update_null_value() || null_value; }
983};
984
985/* function where type of result detected by first argument */
987 public:
989 Item_func_num1(const POS &pos, Item *a) : Item_func_numhybrid(pos, a) {}
990
992 Item_func_num1(const POS &pos, Item *a, Item *b)
993 : Item_func_numhybrid(pos, a, b) {}
994
995 void fix_num_length_and_dec() override;
996 void set_numeric_type() override;
997 String *str_op(String *) override {
998 assert(false);
999 return nullptr;
1000 }
1002 assert(false);
1003 return false;
1004 }
1005 bool time_op(Time_val *) override {
1006 assert(false);
1007 return false;
1008 }
1010 assert(false);
1011 return false;
1012 }
1013};
1014
1015/* Base class for operations like '+', '-', '*' */
1017 public:
1019 Item_num_op(const POS &pos, Item *a, Item *b)
1020 : Item_func_numhybrid(pos, a, b) {}
1021
1022 virtual void result_precision() = 0;
1023
1024 void print(const THD *thd, String *str,
1025 enum_query_type query_type) const override {
1026 print_op(thd, str, query_type);
1027 }
1028
1029 void set_numeric_type() override;
1030 String *str_op(String *) override {
1031 assert(false);
1032 return nullptr;
1033 }
1035 assert(false);
1036 return false;
1037 }
1038 bool time_op(Time_val *) override {
1039 assert(false);
1040 return false;
1041 }
1043 assert(false);
1044 return false;
1045 }
1046};
1047
1048class Item_int_func : public Item_func {
1049 public:
1051 explicit Item_int_func(const POS &pos) : Item_func(pos) {
1053 }
1054
1056 Item_int_func(const POS &pos, Item *a) : Item_func(pos, a) {
1058 }
1059
1062 }
1063 Item_int_func(const POS &pos, Item *a, Item *b) : Item_func(pos, a, b) {
1065 }
1066
1067 Item_int_func(Item *a, Item *b, Item *c) : Item_func(a, b, c) {
1069 }
1070 Item_int_func(const POS &pos, Item *a, Item *b, Item *c)
1071 : Item_func(pos, a, b, c) {
1073 }
1074
1075 Item_int_func(Item *a, Item *b, Item *c, Item *d) : Item_func(a, b, c, d) {
1077 }
1078 Item_int_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
1079 : Item_func(pos, a, b, c, d) {
1081 }
1082
1085 }
1086 Item_int_func(const POS &pos, PT_item_list *opt_list)
1087 : Item_func(pos, opt_list) {
1089 }
1090
1091 Item_int_func(THD *thd, Item_int_func *item) : Item_func(thd, item) {
1093 }
1094 double val_real() override;
1095 String *val_str(String *str) override;
1096 bool val_date(Date_val *date, my_time_flags_t flags) override {
1097 return get_date_from_int(date, flags);
1098 }
1099 bool val_time(Time_val *time) override { return get_time_from_int(time); }
1101 return get_datetime_from_int(dt, flags);
1102 }
1103 enum Item_result result_type() const override { return INT_RESULT; }
1104 /*
1105 Concerning PS-param types,
1106 resolve_type(THD *) is not overridden here, as experience shows that for
1107 most child classes of this class, VARCHAR is the best default
1108 */
1109};
1110
1113
1114 public:
1116
1118 return INNER_TABLE_BIT;
1119 }
1120 bool do_itemize(Parse_context *pc, Item **res) override;
1121 const char *func_name() const override { return "connection_id"; }
1122 bool resolve_type(THD *thd) override;
1123 bool fix_fields(THD *thd, Item **ref) override;
1124 longlong val_int() override;
1125 bool check_function_as_value_generator(uchar *checker_args) override {
1127 pointer_cast<Check_function_as_value_generator_parameters *>(
1128 checker_args);
1129 func_arg->banned_function_name = func_name();
1130 return ((func_arg->source == VGS_GENERATED_COLUMN) ||
1131 (func_arg->source == VGS_CHECK_CONSTRAINT));
1132 }
1133};
1134
1136 public:
1137 Item_typecast_signed(const POS &pos, Item *a) : Item_int_func(pos, a) {
1138 unsigned_flag = false;
1139 }
1140 const char *func_name() const override { return "cast_as_signed"; }
1141 longlong val_int() override;
1142 bool resolve_type(THD *thd) override;
1143 void print(const THD *thd, String *str,
1144 enum_query_type query_type) const override;
1145 enum Functype functype() const override { return TYPECAST_FUNC; }
1146};
1147
1149 public:
1150 Item_typecast_unsigned(const POS &pos, Item *a) : Item_int_func(pos, a) {
1151 unsigned_flag = true;
1152 }
1153 const char *func_name() const override { return "cast_as_unsigned"; }
1154 longlong val_int() override;
1155 bool resolve_type(THD *thd) override;
1156 void print(const THD *thd, String *str,
1157 enum_query_type query_type) const override;
1158 enum Functype functype() const override { return TYPECAST_FUNC; }
1159};
1160
1161class Item_typecast_decimal final : public Item_func {
1162 protected:
1163 void add_json_info(Json_object *obj) override;
1164
1165 public:
1166 Item_typecast_decimal(const POS &pos, Item *a, int len, int dec)
1167 : Item_func(pos, a) {
1169 }
1170 String *val_str(String *str) override;
1171 double val_real() override;
1172 longlong val_int() override;
1173 bool val_date(Date_val *date, my_time_flags_t flags) override {
1174 return get_date_from_decimal(date, flags);
1175 }
1176 bool val_time(Time_val *time) override { return get_time_from_decimal(time); }
1178 return get_datetime_from_decimal(dt, flags);
1179 }
1180 my_decimal *val_decimal(my_decimal *) override;
1181 enum Item_result result_type() const override { return DECIMAL_RESULT; }
1182 bool resolve_type(THD *thd) override {
1183 if (reject_vector_args()) return true;
1184 if (args[0]->propagate_type(thd, MYSQL_TYPE_NEWDECIMAL, false, true))
1185 return true;
1186 return false;
1187 }
1188 const char *func_name() const override { return "cast_as_decimal"; }
1189 enum Functype functype() const override { return TYPECAST_FUNC; }
1190 void print(const THD *thd, String *str,
1191 enum_query_type query_type) const override;
1192 uint64_t hash() override;
1193};
1194
1195/**
1196 Class used to implement CAST to floating-point data types.
1197*/
1198class Item_typecast_real final : public Item_func {
1199 protected:
1200 void add_json_info(Json_object *obj) override {
1201 obj->add_alias("is_double", create_dom_ptr<Json_boolean>(
1203 }
1204
1205 public:
1206 Item_typecast_real(const POS &pos, Item *a, bool as_double)
1207 : Item_func(pos, a) {
1208 if (as_double)
1210 else
1212 }
1214 String *val_str(String *str) override;
1215 double val_real() override;
1216 longlong val_int() override { return val_int_from_real(); }
1217 bool val_date(Date_val *date, my_time_flags_t flags) override;
1218 bool val_time(Time_val *time) override;
1219 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1220 my_decimal *val_decimal(my_decimal *decimal_value) override;
1221 enum Item_result result_type() const override { return REAL_RESULT; }
1222 bool resolve_type(THD *thd) override {
1223 if (reject_vector_args()) return true;
1224 return args[0]->propagate_type(thd, MYSQL_TYPE_DOUBLE, false, true);
1225 }
1226 const char *func_name() const override { return "cast_as_real"; }
1227 enum Functype functype() const override { return TYPECAST_FUNC; }
1228 void print(const THD *thd, String *str,
1229 enum_query_type query_type) const override;
1230};
1231
1233 public:
1236 : Item_num_op(pos, a, b) {}
1237
1238 void result_precision() override;
1239 bool check_partition_func_processor(uchar *) override { return false; }
1240 bool check_function_as_value_generator(uchar *) override { return false; }
1241};
1242
1244 public:
1246 Item_func_plus(const POS &pos, Item *a, Item *b)
1247 : Item_func_additive_op(pos, a, b) {}
1248
1249 const char *func_name() const override { return "+"; }
1250
1251 // SUPPRESS_UBSAN: signed integer overflow
1252 longlong int_op() override SUPPRESS_UBSAN;
1253 uint64_t hash() override { return Item_func::hash(true); }
1254 double real_op() override;
1255 my_decimal *decimal_op(my_decimal *) override;
1256 enum Functype functype() const override { return PLUS_FUNC; }
1257};
1258
1260 public:
1262 Item_func_minus(const POS &pos, Item *a, Item *b)
1263 : Item_func_additive_op(pos, a, b) {}
1264
1265 const char *func_name() const override { return "-"; }
1266
1267 // SUPPRESS_UBSAN: signed integer overflow
1268 longlong int_op() override SUPPRESS_UBSAN;
1269
1270 double real_op() override;
1271 my_decimal *decimal_op(my_decimal *) override;
1272 bool resolve_type(THD *thd) override;
1273 enum Functype functype() const override { return MINUS_FUNC; }
1274};
1275
1276class Item_func_mul final : public Item_num_op {
1277 public:
1279 Item_func_mul(const POS &pos, Item *a, Item *b) : Item_num_op(pos, a, b) {}
1280
1281 const char *func_name() const override { return "*"; }
1282 longlong int_op() override;
1283 double real_op() override;
1284 uint64_t hash() override { return Item_func::hash(true); }
1285 my_decimal *decimal_op(my_decimal *) override;
1286 void result_precision() override;
1287 bool check_partition_func_processor(uchar *) override { return false; }
1288 bool check_function_as_value_generator(uchar *) override { return false; }
1289 enum Functype functype() const override { return MUL_FUNC; }
1290};
1291
1293 public:
1294 Item_func_div_base(const POS &pos, Item *a, Item *b)
1295 : Item_num_op(pos, a, b) {}
1297 longlong int_op() override;
1298 double real_op() override;
1299 my_decimal *decimal_op(my_decimal *) override;
1300 enum Functype functype() const override { return DIV_FUNC; }
1301
1302 protected:
1304};
1305
1306class Item_func_div final : public Item_func_div_base {
1307 public:
1308 Item_func_div(const POS &pos, Item *a, Item *b)
1309 : Item_func_div_base(pos, a, b) {}
1310 const char *func_name() const override { return "/"; }
1311 bool resolve_type(THD *thd) override;
1312 void result_precision() override;
1313};
1314
1316 public:
1318 Item_func_div_int(const POS &pos, Item *a, Item *b)
1319 : Item_func_div_base(pos, a, b) {}
1320 const char *func_name() const override { return "DIV"; }
1322 return MYSQL_TYPE_LONGLONG;
1323 }
1324 bool resolve_type(THD *thd) override;
1325 void result_precision() override;
1326 void set_numeric_type() override;
1327 bool check_partition_func_processor(uchar *) override { return false; }
1328 bool check_function_as_value_generator(uchar *) override { return false; }
1329};
1330
1331class Item_func_mod final : public Item_num_op {
1332 public:
1334 Item_func_mod(const POS &pos, Item *a, Item *b) : Item_num_op(pos, a, b) {}
1335
1336 longlong int_op() override;
1337 double real_op() override;
1338 my_decimal *decimal_op(my_decimal *) override;
1339 const char *func_name() const override { return "%"; }
1340 void result_precision() override;
1341 bool resolve_type(THD *thd) override;
1342 bool check_partition_func_processor(uchar *) override { return false; }
1343 bool check_function_as_value_generator(uchar *) override { return false; }
1344 enum Functype functype() const override { return MOD_FUNC; }
1345};
1346
1347class Item_func_neg final : public Item_func_num1 {
1348 public:
1350 Item_func_neg(const POS &pos, Item *a) : Item_func_num1(pos, a) {}
1351
1352 double real_op() override;
1353 longlong int_op() override;
1354 my_decimal *decimal_op(my_decimal *) override;
1355 const char *func_name() const override { return "-"; }
1356 enum Functype functype() const override { return NEG_FUNC; }
1357 bool resolve_type(THD *thd) override;
1358 void fix_num_length_and_dec() override;
1359 bool check_partition_func_processor(uchar *) override { return false; }
1360 bool check_function_as_value_generator(uchar *) override { return false; }
1361};
1362
1363class Item_func_abs final : public Item_func_num1 {
1364 public:
1365 Item_func_abs(const POS &pos, Item *a) : Item_func_num1(pos, a) {}
1366 double real_op() override;
1367 longlong int_op() override;
1368 my_decimal *decimal_op(my_decimal *) override;
1369 const char *func_name() const override { return "abs"; }
1370 bool resolve_type(THD *) override;
1371 bool check_partition_func_processor(uchar *) override { return false; }
1372 bool check_function_as_value_generator(uchar *) override { return false; }
1373 enum Functype functype() const override { return ABS_FUNC; }
1374};
1375
1376// A class to handle logarithmic and trigonometric functions
1377
1379 public:
1381 Item_dec_func(const POS &pos, Item *a) : Item_real_func(pos, a) {}
1382
1383 Item_dec_func(const POS &pos, Item *a, Item *b) : Item_real_func(pos, a, b) {}
1384 bool resolve_type(THD *thd) override;
1385};
1386
1387class Item_func_exp final : public Item_dec_func {
1388 public:
1389 Item_func_exp(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1390 double val_real() override;
1391 const char *func_name() const override { return "exp"; }
1392 enum Functype functype() const override { return EXP_FUNC; }
1393};
1394
1395class Item_func_ln final : public Item_dec_func {
1396 public:
1397 Item_func_ln(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1398 double val_real() override;
1399 const char *func_name() const override { return "ln"; }
1400 enum Functype functype() const override { return LN_FUNC; }
1401};
1402
1403class Item_func_log final : public Item_dec_func {
1404 public:
1405 Item_func_log(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1406 Item_func_log(const POS &pos, Item *a, Item *b) : Item_dec_func(pos, a, b) {}
1407 double val_real() override;
1408 const char *func_name() const override { return "log"; }
1409 enum Functype functype() const override { return LOG_FUNC; }
1410};
1411
1412class Item_func_log2 final : public Item_dec_func {
1413 public:
1414 Item_func_log2(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1415 double val_real() override;
1416 const char *func_name() const override { return "log2"; }
1417};
1418
1419class Item_func_log10 final : public Item_dec_func {
1420 public:
1421 Item_func_log10(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1422 double val_real() override;
1423 const char *func_name() const override { return "log10"; }
1424 enum Functype functype() const override { return LOG10_FUNC; }
1425};
1426
1427class Item_func_sqrt final : public Item_dec_func {
1428 public:
1429 Item_func_sqrt(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1430 double val_real() override;
1431 const char *func_name() const override { return "sqrt"; }
1432 enum Functype functype() const override { return SQRT_FUNC; }
1433};
1434
1435class Item_func_pow final : public Item_dec_func {
1436 public:
1437 Item_func_pow(const POS &pos, Item *a, Item *b) : Item_dec_func(pos, a, b) {}
1438 double val_real() override;
1439 const char *func_name() const override { return "pow"; }
1440 enum Functype functype() const override { return POW_FUNC; }
1441};
1442
1443class Item_func_acos final : public Item_dec_func {
1444 public:
1445 Item_func_acos(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1446 double val_real() override;
1447 const char *func_name() const override { return "acos"; }
1448 enum Functype functype() const override { return ACOS_FUNC; }
1449};
1450
1451class Item_func_asin final : public Item_dec_func {
1452 public:
1453 Item_func_asin(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1454 double val_real() override;
1455 const char *func_name() const override { return "asin"; }
1456 enum Functype functype() const override { return ASIN_FUNC; }
1457};
1458
1459class Item_func_atan final : public Item_dec_func {
1460 public:
1461 Item_func_atan(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1462 Item_func_atan(const POS &pos, Item *a, Item *b) : Item_dec_func(pos, a, b) {}
1463 double val_real() override;
1464 const char *func_name() const override { return "atan"; }
1465 enum Functype functype() const override { return ATAN_FUNC; }
1466};
1467
1468class Item_func_cos final : public Item_dec_func {
1469 public:
1470 Item_func_cos(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1471 double val_real() override;
1472 const char *func_name() const override { return "cos"; }
1473 enum Functype functype() const override { return COS_FUNC; }
1474};
1475
1476class Item_func_sin final : public Item_dec_func {
1477 public:
1478 Item_func_sin(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1479 double val_real() override;
1480 const char *func_name() const override { return "sin"; }
1481 enum Functype functype() const override { return SIN_FUNC; }
1482};
1483
1484class Item_func_tan final : public Item_dec_func {
1485 public:
1486 Item_func_tan(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1487 double val_real() override;
1488 const char *func_name() const override { return "tan"; }
1489 enum Functype functype() const override { return TAN_FUNC; }
1490};
1491
1492class Item_func_cot final : public Item_dec_func {
1493 public:
1494 Item_func_cot(const POS &pos, Item *a) : Item_dec_func(pos, a) {}
1495 double val_real() override;
1496 const char *func_name() const override { return "cot"; }
1497 enum Functype functype() const override { return COT_FUNC; }
1498};
1499
1501 public:
1503 Item_func_int_val(const POS &pos, Item *a) : Item_func_num1(pos, a) {}
1504 bool resolve_type_inner(THD *thd) override;
1505};
1506
1508 public:
1510 Item_func_ceiling(const POS &pos, Item *a) : Item_func_int_val(pos, a) {}
1511 const char *func_name() const override { return "ceiling"; }
1512 longlong int_op() override;
1513 double real_op() override;
1514 my_decimal *decimal_op(my_decimal *) override;
1515 bool check_partition_func_processor(uchar *) override { return false; }
1516 bool check_function_as_value_generator(uchar *) override { return false; }
1517 enum Functype functype() const override { return CEILING_FUNC; }
1518};
1519
1521 public:
1523 Item_func_floor(const POS &pos, Item *a) : Item_func_int_val(pos, a) {}
1524 const char *func_name() const override { return "floor"; }
1525 longlong int_op() override;
1526 double real_op() override;
1527 my_decimal *decimal_op(my_decimal *) override;
1528 bool check_partition_func_processor(uchar *) override { return false; }
1529 bool check_function_as_value_generator(uchar *) override { return false; }
1530 enum Functype functype() const override { return FLOOR_FUNC; }
1531};
1532
1533/* This handles round and truncate */
1534
1535class Item_func_round final : public Item_func_num1 {
1537
1538 public:
1539 Item_func_round(Item *a, Item *b, bool trunc_arg)
1540 : Item_func_num1(a, b), truncate(trunc_arg) {}
1541 Item_func_round(const POS &pos, Item *a, Item *b, bool trunc_arg)
1542 : Item_func_num1(pos, a, b), truncate(trunc_arg) {}
1543
1544 const char *func_name() const override {
1545 return truncate ? "truncate" : "round";
1546 }
1547 double real_op() override;
1548 longlong int_op() override;
1549 my_decimal *decimal_op(my_decimal *) override;
1550 bool resolve_type(THD *) override;
1551 enum Functype functype() const override {
1553 }
1554};
1555
1556class Item_func_rand final : public Item_real_func {
1558
1560 bool first_eval{true}; // true if val_real() is called 1st time
1561 public:
1563 Item_func_rand(const POS &pos, Item *a) : Item_real_func(pos, a) {}
1564 explicit Item_func_rand(const POS &pos) : Item_real_func(pos) {}
1565
1566 bool do_itemize(Parse_context *pc, Item **res) override;
1567 double val_real() override;
1568 const char *func_name() const override { return "rand"; }
1569 /**
1570 This function is non-deterministic and hence depends on the
1571 'RAND' pseudo-table.
1572
1573 @returns RAND_TABLE_BIT
1574 */
1576 return RAND_TABLE_BIT;
1577 }
1578 bool fix_fields(THD *thd, Item **ref) override;
1579 bool resolve_type(THD *thd) override;
1580 void cleanup() override {
1581 first_eval = true;
1583 }
1584 bool check_function_as_value_generator(uchar *checker_args) override {
1586 pointer_cast<Check_function_as_value_generator_parameters *>(
1587 checker_args);
1588 func_arg->banned_function_name = func_name();
1589 return ((func_arg->source == VGS_GENERATED_COLUMN) ||
1590 (func_arg->source == VGS_CHECK_CONSTRAINT));
1591 }
1592
1593 private:
1594 void seed_random(Item *val);
1595};
1596
1597class Item_func_sign final : public Item_int_func {
1598 public:
1599 Item_func_sign(const POS &pos, Item *a) : Item_int_func(pos, a) {}
1600 const char *func_name() const override { return "sign"; }
1601 enum Functype functype() const override { return SIGN_FUNC; }
1602 longlong val_int() override;
1603 bool resolve_type(THD *thd) override;
1604};
1605
1606// Common base class for the DEGREES and RADIANS functions.
1608 double mul, add;
1609
1610 protected:
1611 Item_func_units(const POS &pos, Item *a, double mul_arg, double add_arg)
1612 : Item_real_func(pos, a), mul(mul_arg), add(add_arg) {}
1613
1614 public:
1615 double val_real() override;
1616 bool resolve_type(THD *thd) override;
1617};
1618
1620 public:
1622 : Item_func_units(pos, a, 180.0 / M_PI, 0.0) {}
1623 const char *func_name() const override { return "degrees"; }
1624 enum Functype functype() const override { return DEGREES_FUNC; }
1625};
1626
1628 public:
1630 : Item_func_units(pos, a, M_PI / 180.0, 0.0) {}
1631 const char *func_name() const override { return "radians"; }
1632 enum Functype functype() const override { return RADIANS_FUNC; }
1633};
1635 public:
1636 Item_func_min_max(const POS &pos, PT_item_list *opt_list, bool is_least_func)
1637 : Item_func_numhybrid(pos, opt_list),
1638 m_is_least_func(is_least_func),
1640
1641 longlong val_int() override;
1642 double val_real() override;
1643 my_decimal *val_decimal(my_decimal *) override;
1644 longlong int_op() override;
1645 double real_op() override;
1646 my_decimal *decimal_op(my_decimal *) override;
1647 String *str_op(String *) override;
1648 bool date_op(Date_val *date, my_time_flags_t flags) override;
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 ? INT_RESULT
1667 : result_type();
1668 }
1669
1670 /// Returns true if at least one of the arguments was of temporal type.
1671 bool has_temporal_arg() const { return temporal_item; }
1672
1673 private:
1674 /// True if LEAST function, false if GREATEST.
1677 /**
1678 Evaluation type, ie. the data type that the comparison function uses.
1679 This is the same as the data_type(), except in the case where the result
1680 type is a string type and at least one of the arguments is a DATE
1681 or DATETIME temporal value, in which it is a derived temporal type.
1682 */
1684 /**
1685 Used for determining whether one of the arguments is of temporal type and
1686 for converting arguments to a common output format if arguments are
1687 compared as dates and result type is character string. For example,
1688 LEAST('95-05-05', date '10-10-10') should return '1995-05-05', not
1689 '95-05-05'.
1690 */
1692
1693 /**
1694 Fractional seconds precision to use when converting a time or timestamp
1695 expression into a string.
1696 */
1698 /**
1699 Compare arguments as datetime values.
1700
1701 @param flags Flags used when evaluating date
1702 @param[out] value Smallest/largest datetime value from comparison
1703
1704 @return true if error, false otherwise.
1705 */
1707
1708 /**
1709 Compare arguments as time values.
1710
1711 @param[out] value Smallest/largest time value from comparison
1712
1713 @return true if error, false otherwise.
1714 */
1715 bool cmp_times(Time_val *value);
1716
1717 /**
1718 Compare arguments as date values.
1719
1720 @param flags Flags used when evaluating date
1721 @param[out] value Smallest/largest date value from comparison
1722
1723 @return true if error, false otherwise.
1724 */
1726};
1727
1728class Item_func_min final : public Item_func_min_max {
1729 public:
1730 Item_func_min(const POS &pos, PT_item_list *opt_list)
1731 : Item_func_min_max(pos, opt_list, true) {}
1732 const char *func_name() const override { return "least"; }
1733 uint64_t hash() override { return Item_func::hash(true); }
1734 enum Functype functype() const override { return LEAST_FUNC; }
1735};
1736
1737class Item_func_max final : public Item_func_min_max {
1738 public:
1739 Item_func_max(const POS &pos, PT_item_list *opt_list)
1740 : Item_func_min_max(pos, opt_list, false) {}
1741 const char *func_name() const override { return "greatest"; }
1742 enum Functype functype() const override { return GREATEST_FUNC; }
1743};
1744
1745/**
1746 A wrapper Item that normally returns its parameter, but becomes NULL when
1747 processing rows for rollup. Rollup is implemented by AggregateIterator, and
1748 works by means of hierarchical levels -- 0 is the “grand totals” phase, 1 is
1749 where only one group level is active, and so on. E.g., for a query with GROUP
1750 BY a,b, the rows will look like this:
1751
1752 a b rollup level
1753 1 1 2
1754 1 2 2
1755 1 NULL 1
1756 2 1 2
1757 2 NULL 1
1758 NULL NULL 0
1759
1760 Each rollup group item has a minimum level for when it becomes NULL. In the
1761 example above, a would have minimum level 0 and b would have minimum level 1.
1762 For simplicity, the JOIN carries a list of all rollup group items, and they
1763 are being given the current rollup level when it changes. A rollup level of
1764 INT_MAX essentially always disables rollup, which is useful when there are
1765 leftover group items in places that are not relevant for rollup
1766 (e.g., sometimes resolving can leave rollup wrappers in place for temporary
1767 tables that are created before grouping, which should then effectively be
1768 disabled).
1769 */
1770class Item_rollup_group_item final : public Item_func {
1771 public:
1776 // We're going to replace inner_item in the SELECT list, so copy its hidden
1777 // status. (We could have done this in the caller, but it fits naturally in
1778 // with all the other copying done here.)
1780 set_nullable(true);
1782 }
1783 double val_real() override;
1784 longlong val_int() override;
1785 String *val_str(String *str) override;
1787 bool val_json(Json_wrapper *result) override;
1788 bool val_date(Date_val *date, my_time_flags_t flags) override;
1789 bool val_time(Time_val *time) override;
1790 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1791 const char *func_name() const override { return "rollup_group_item"; }
1792 table_map used_tables() const override {
1793 /*
1794 If underlying item is non-constant, return its used_tables value.
1795 Otherwise, ensure it is non-constant by adding RAND_TABLE_BIT.
1796 */
1797 return args[0]->const_for_execution()
1798 ? (args[0]->used_tables() | RAND_TABLE_BIT)
1799 : args[0]->used_tables();
1800 }
1801 void update_used_tables() override {
1804 }
1805 Item_result result_type() const override { return args[0]->result_type(); }
1806 bool resolve_type(THD *) override {
1807 // needn't handle dynamic parameter as its const_item() is false.
1809
1810 // The item could be a NULL constant.
1811 null_value = args[0]->is_null();
1812 return false;
1813 }
1814 Item *inner_item() { return args[0]; }
1815 const Item *inner_item() const { return args[0]; }
1816 bool rollup_null() const {
1818 }
1819 enum Functype functype() const override { return ROLLUP_GROUP_ITEM_FUNC; }
1820 void print(const THD *thd, String *str,
1821 enum_query_type query_type) const override;
1822 uint64_t hash() override;
1823 bool eq_specific(const Item *item) const override;
1824 TYPELIB *get_typelib() const override;
1825
1826 // Used by AggregateIterator.
1828
1829 // Used when cloning the item only.
1830 int min_rollup_level() const { return m_min_rollup_level; }
1831
1832 private:
1835};
1836
1839
1840 public:
1841 Item_func_length(const POS &pos, Item *a) : Item_int_func(pos, a) {}
1842 longlong val_int() override;
1843 const char *func_name() const override { return "length"; }
1844 bool resolve_type(THD *thd) override {
1845 if (param_type_is_default(thd, 0, 1)) return true;
1846 max_length = 10;
1847 return false;
1848 }
1849};
1850
1853
1854 public:
1855 Item_func_vector_dim(const POS &pos, Item *a) : Item_int_func(pos, a) {}
1856 longlong val_int() override;
1857 const char *func_name() const override { return "vector_dim"; }
1858 bool resolve_type(THD *thd) override {
1859 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_VECTOR)) {
1860 return true;
1861 }
1862 bool valid_type = (args[0]->data_type() == MYSQL_TYPE_VECTOR) ||
1863 (args[0]->result_type() == STRING_RESULT &&
1865 if (!valid_type) {
1866 my_error(ER_WRONG_ARGUMENTS, MYF(0), func_name());
1867 return true;
1868 }
1869 max_length = 10;
1870 return false;
1871 }
1872};
1873
1875 public:
1876 Item_func_bit_length(const POS &pos, Item *a) : Item_func_length(pos, a) {}
1877 longlong val_int() override {
1878 assert(fixed);
1879 return Item_func_length::val_int() * 8;
1880 }
1881 const char *func_name() const override { return "bit_length"; }
1882};
1883
1886
1887 public:
1889 Item_func_char_length(const POS &pos, Item *a) : Item_int_func(pos, a) {}
1890 longlong val_int() override;
1891 const char *func_name() const override { return "char_length"; }
1892 bool resolve_type(THD *thd) override {
1893 max_length = 10;
1894 return Item_int_func::resolve_type(thd);
1895 }
1896};
1897
1899 public:
1900 Item_func_coercibility(const POS &pos, Item *a) : Item_int_func(pos, a) {
1901 null_on_null = false;
1902 }
1903 longlong val_int() override;
1904 const char *func_name() const override { return "coercibility"; }
1905 bool resolve_type(THD *thd) override {
1906 max_length = 10;
1907 set_nullable(false);
1908 return Item_int_func::resolve_type(thd);
1909 }
1910};
1911
1914
1915 public:
1917 Item_func_locate(const POS &pos, Item *a, Item *b)
1918 : Item_int_func(pos, a, b) {}
1919 Item_func_locate(const POS &pos, Item *a, Item *b, Item *c)
1920 : Item_int_func(pos, a, b, c) {}
1921
1922 const char *func_name() const override { return "locate"; }
1923 longlong val_int() override;
1924 bool resolve_type(THD *thd) override;
1925 void print(const THD *thd, String *str,
1926 enum_query_type query_type) const override;
1927};
1928
1929class Item_func_instr final : public Item_func_locate {
1930 public:
1931 Item_func_instr(const POS &pos, Item *a, Item *b)
1932 : Item_func_locate(pos, a, b) {}
1933
1934 const char *func_name() const override { return "instr"; }
1935};
1936
1938 public:
1940 : Item_int_func(pos, a) {}
1941 longlong val_int() override;
1942 const char *func_name() const override {
1943 return "validate_password_strength";
1944 }
1945 bool resolve_type(THD *thd) override {
1946 max_length = 10;
1947 set_nullable(true);
1948 return Item_int_func::resolve_type(thd);
1949 }
1950};
1951
1952class Item_func_field final : public Item_int_func {
1955
1956 public:
1957 Item_func_field(const POS &pos, PT_item_list *opt_list)
1958 : Item_int_func(pos, opt_list) {}
1959 longlong val_int() override;
1960 const char *func_name() const override { return "field"; }
1961 bool resolve_type(THD *thd) override;
1962};
1963
1964class Item_func_ascii final : public Item_int_func {
1966
1967 public:
1968 Item_func_ascii(const POS &pos, Item *a) : Item_int_func(pos, a) {}
1969 longlong val_int() override;
1970 const char *func_name() const override { return "ascii"; }
1971 bool resolve_type(THD *thd) override {
1972 max_length = 3;
1973 return Item_int_func::resolve_type(thd);
1974 }
1975};
1976
1977class Item_func_ord final : public Item_int_func {
1979
1980 public:
1981 Item_func_ord(const POS &pos, Item *a) : Item_int_func(pos, a) {}
1982 longlong val_int() override;
1983 const char *func_name() const override { return "ord"; }
1984};
1985
1988 /*
1989 if m_enum_value is non-zero, it indicates the index of the value of
1990 argument 0 in the set in argument 1, given that argument 0 is
1991 a constant value and argument 1 is a field of type SET.
1992 */
1995
1996 public:
1998 : Item_int_func(pos, a, b) {}
1999 longlong val_int() override;
2000 const char *func_name() const override { return "find_in_set"; }
2001 bool resolve_type(THD *) override;
2002 const CHARSET_INFO *compare_collation() const override {
2003 return cmp_collation.collation;
2004 }
2005};
2006
2007/* Base class for all bit functions: '~', '|', '^', '&', '>>', '<<' */
2008
2009class Item_func_bit : public Item_func {
2010 protected:
2011 /// Stores the Item's result type. Can only be INT_RESULT or STRING_RESULT
2013 /// Buffer storing the determined value
2015 /**
2016 @returns true if the second argument should be of binary type for the
2017 result to be of binary type.
2018 */
2020
2021 public:
2022 Item_func_bit(const POS &pos, Item *a, Item *b) : Item_func(pos, a, b) {}
2023 Item_func_bit(const POS &pos, Item *a) : Item_func(pos, a) {}
2024
2025 bool resolve_type(THD *) override;
2026 enum Item_result result_type() const override { return hybrid_type; }
2027
2028 longlong val_int() override;
2029 String *val_str(String *str) override;
2030 double val_real() override;
2031 my_decimal *val_decimal(my_decimal *decimal_value) override;
2032
2033 void print(const THD *thd, String *str,
2034 enum_query_type query_type) const override {
2035 print_op(thd, str, query_type);
2036 }
2037 bool val_date(Date_val *date, my_time_flags_t flags) override {
2038 if (hybrid_type == INT_RESULT)
2039 return get_date_from_int(date, flags);
2040 else
2041 return get_date_from_string(date, flags);
2042 }
2043 bool val_time(Time_val *time) override {
2044 if (hybrid_type == INT_RESULT)
2045 return get_time_from_int(time);
2046 else
2047 return get_time_from_string(time);
2048 }
2050 if (hybrid_type == INT_RESULT)
2051 return get_datetime_from_int(dt, flags);
2052 else
2053 return get_datetime_from_string(dt, flags);
2054 }
2055
2056 private:
2057 /**
2058 @brief Performs the operation on integers to produce a result of type
2059 INT_RESULT.
2060 @return The result of the operation.
2061 */
2062 virtual longlong int_op() = 0;
2063
2064 /**
2065 @brief Performs the operation on binary strings to produce a result of
2066 type STRING_RESULT.
2067 @return The result of the operation.
2068 */
2069 virtual String *str_op(String *) = 0;
2070};
2071
2072/**
2073 Base class for all the bit functions that work with two binary
2074 arguments: '&', '|', '^'.
2075*/
2076
2078 protected:
2080 return true;
2081 }
2082 template <class Char_func, class Int_func>
2083 String *eval_str_op(String *, Char_func char_func, Int_func int_func);
2084 template <class Int_func>
2085 longlong eval_int_op(Int_func int_func);
2086
2087 public:
2089 : Item_func_bit(pos, a, b) {}
2090};
2091
2093 public:
2094 Item_func_bit_or(const POS &pos, Item *a, Item *b)
2095 : Item_func_bit_two_param(pos, a, b) {}
2096 const char *func_name() const override { return "|"; }
2097 uint64_t hash() override { return Item_func::hash(true); }
2098
2099 private:
2100 longlong int_op() override { return eval_int_op(std::bit_or<ulonglong>()); }
2101 String *str_op(String *str) override {
2102 return eval_str_op(str, std::bit_or<char>(), std::bit_or<ulonglong>());
2103 }
2104};
2105
2107 public:
2108 Item_func_bit_and(const POS &pos, Item *a, Item *b)
2109 : Item_func_bit_two_param(pos, a, b) {}
2110 const char *func_name() const override { return "&"; }
2111 uint64_t hash() override { return Item_func::hash(true); }
2112
2113 private:
2114 longlong int_op() override { return eval_int_op(std::bit_and<ulonglong>()); }
2115 String *str_op(String *str) override {
2116 return eval_str_op(str, std::bit_and<char>(), std::bit_and<ulonglong>());
2117 }
2118};
2119
2121 public:
2122 Item_func_bit_xor(const POS &pos, Item *a, Item *b)
2123 : Item_func_bit_two_param(pos, a, b) {}
2124 const char *func_name() const override { return "^"; }
2125 uint64_t hash() override { return Item_func::hash(true); }
2126
2127 private:
2128 longlong int_op() override { return eval_int_op(std::bit_xor<ulonglong>()); }
2129 String *str_op(String *str) override {
2130 return eval_str_op(str, std::bit_xor<char>(), std::bit_xor<ulonglong>());
2131 }
2132};
2133
2135 public:
2136 Item_func_bit_count(const POS &pos, Item *a) : Item_int_func(pos, a) {}
2137 longlong val_int() override;
2138 const char *func_name() const override { return "bit_count"; }
2139 bool resolve_type(THD *thd) override {
2140 // Default: binary string; reprepare if integer
2141 if (args[0]->data_type() == MYSQL_TYPE_INVALID &&
2142 args[0]->propagate_type(
2144 return true;
2146 return false;
2147 }
2148};
2149
2151 protected:
2153 return false;
2154 }
2155 template <bool to_left>
2157 template <bool to_left>
2159
2160 public:
2161 Item_func_shift(const POS &pos, Item *a, Item *b)
2162 : Item_func_bit(pos, a, b) {}
2163};
2164
2166 public:
2167 Item_func_shift_left(const POS &pos, Item *a, Item *b)
2168 : Item_func_shift(pos, a, b) {}
2169 const char *func_name() const override { return "<<"; }
2170
2171 private:
2172 longlong int_op() override;
2173 String *str_op(String *str) override;
2174};
2175
2177 public:
2179 : Item_func_shift(pos, a, b) {}
2180 const char *func_name() const override { return ">>"; }
2181
2182 private:
2183 longlong int_op() override;
2184 String *str_op(String *str) override;
2185};
2186
2187class Item_func_bit_neg final : public Item_func_bit {
2188 protected:
2190 return false;
2191 }
2192
2193 public:
2194 Item_func_bit_neg(const POS &pos, Item *a) : Item_func_bit(pos, a) {}
2195 const char *func_name() const override { return "~"; }
2196 void print(const THD *thd, String *str,
2197 enum_query_type query_type) const override {
2198 Item_func::print(thd, str, query_type);
2199 }
2200 uint64_t hash() override { return Item_func::hash(); }
2201
2202 private:
2203 longlong int_op() override;
2204 String *str_op(String *str) override;
2205};
2206
2209
2210 public:
2212 explicit Item_func_last_insert_id(const POS &pos) : Item_int_func(pos) {}
2213 Item_func_last_insert_id(const POS &pos, Item *a) : Item_int_func(pos, a) {}
2214
2215 bool do_itemize(Parse_context *pc, Item **res) override;
2216 longlong val_int() override;
2217 const char *func_name() const override { return "last_insert_id"; }
2218
2220 return INNER_TABLE_BIT;
2221 }
2222
2223 bool resolve_type(THD *thd) override {
2224 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_LONGLONG)) return true;
2225 unsigned_flag = true;
2226 return false;
2227 }
2228 bool check_function_as_value_generator(uchar *checker_args) override {
2230 pointer_cast<Check_function_as_value_generator_parameters *>(
2231 checker_args);
2232 func_arg->banned_function_name = func_name();
2233 return true;
2234 }
2235};
2236
2239
2240 public:
2241 Item_func_benchmark(const POS &pos, Item *count_expr, Item *expr)
2242 : Item_int_func(pos, count_expr, expr) {}
2243
2244 /// Ensure that "benchmark()" is never optimized away
2246 return RAND_TABLE_BIT;
2247 }
2248
2249 bool do_itemize(Parse_context *pc, Item **res) override;
2250 longlong val_int() override;
2251 const char *func_name() const override { return "benchmark"; }
2252 bool resolve_type(THD *thd) override {
2253 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_LONGLONG)) return true;
2254 if (param_type_is_default(thd, 1, 2)) return true;
2255 max_length = 1;
2256 set_nullable(true);
2257 return false;
2258 }
2259 void print(const THD *thd, String *str,
2260 enum_query_type query_type) const override;
2261 bool check_function_as_value_generator(uchar *checker_args) override {
2263 pointer_cast<Check_function_as_value_generator_parameters *>(
2264 checker_args);
2265 func_arg->banned_function_name = func_name();
2266 return true;
2267 }
2268};
2269
2272
2273class Item_func_sleep final : public Item_int_func {
2275
2276 public:
2277 Item_func_sleep(const POS &pos, Item *a) : Item_int_func(pos, a) {}
2278
2279 bool do_itemize(Parse_context *pc, Item **res) override;
2280 const char *func_name() const override { return "sleep"; }
2281 /**
2282 This function is non-deterministic and hence depends on the
2283 'RAND' pseudo-table.
2284
2285 @returns RAND_TABLE_BIT
2286 */
2288 return RAND_TABLE_BIT;
2289 }
2290 bool check_function_as_value_generator(uchar *checker_args) override {
2292 pointer_cast<Check_function_as_value_generator_parameters *>(
2293 checker_args);
2294 func_arg->banned_function_name = func_name();
2295 return true;
2296 }
2297 bool resolve_type(THD *thd) override {
2298 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_DOUBLE)) return true;
2299 return Item_int_func::resolve_type(thd);
2300 }
2301 longlong val_int() override;
2302};
2303
2304class Item_udf_func : public Item_func {
2306
2307 protected:
2309
2310 public:
2311 Item_udf_func(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
2312 : Item_func(pos, opt_list), udf(udf_arg) {
2313 null_on_null = false;
2314 }
2315 ~Item_udf_func() override = default;
2316
2317 bool do_itemize(Parse_context *pc, Item **res) override;
2318 const char *func_name() const override { return udf.name(); }
2319 enum Functype functype() const override { return UDF_FUNC; }
2322 }
2323 bool fix_fields(THD *thd, Item **ref) override;
2324 void cleanup() override;
2325 Item_result result_type() const override { return udf.result_type(); }
2326 void print(const THD *thd, String *str,
2327 enum_query_type query_type) const override;
2328 bool check_function_as_value_generator(uchar *checker_args) override {
2330 pointer_cast<Check_function_as_value_generator_parameters *>(
2331 checker_args);
2332 func_arg->banned_function_name = func_name();
2333 return true;
2334 }
2335
2336 void compute_cost(CostOfItem *root_cost) const override {
2337 root_cost->MarkExpensive();
2338 }
2339
2340 protected:
2341 bool may_have_named_parameters() const override { return true; }
2342
2343 private:
2344 /**
2345 This member is set during resolving and is used by update_used_tables() and
2346 fix_after_pullout() to preserve the non-deterministic property.
2347 */
2349};
2350
2352 public:
2353 Item_func_udf_float(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
2354 : Item_udf_func(pos, udf_arg, opt_list) {}
2355 longlong val_int() override {
2356 assert(fixed);
2358 }
2359 my_decimal *val_decimal(my_decimal *dec_buf) override {
2360 const double res = val_real();
2361 if (null_value) return nullptr;
2362 double2my_decimal(E_DEC_FATAL_ERROR, res, dec_buf);
2363 return dec_buf;
2364 }
2365 double val_real() override;
2366 String *val_str(String *str) override;
2367 bool val_date(Date_val *date, my_time_flags_t flags) override {
2368 return get_date_from_real(date, flags);
2369 }
2370 bool val_time(Time_val *time) override { return get_time_from_real(time); }
2372 return get_datetime_from_real(dt, flags);
2373 }
2374 bool resolve_type(THD *) override {
2376 fix_num_length_and_dec(); // @todo - needed?
2377 return false;
2378 }
2379};
2380
2381class Item_func_udf_int final : public Item_udf_func {
2382 public:
2383 Item_func_udf_int(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
2384 : Item_udf_func(pos, udf_arg, opt_list) {}
2385 longlong val_int() override;
2386 double val_real() override {
2387 return static_cast<double>(Item_func_udf_int::val_int());
2388 }
2389 String *val_str(String *str) override;
2390 bool val_date(Date_val *date, my_time_flags_t flags) override {
2391 return get_date_from_int(date, flags);
2392 }
2393 bool val_time(Time_val *time) override { return get_time_from_int(time); }
2395 return get_datetime_from_int(dt, flags);
2396 }
2397 enum Item_result result_type() const override { return INT_RESULT; }
2398 bool resolve_type(THD *) override {
2400 return false;
2401 }
2402};
2403
2405 public:
2406 Item_func_udf_decimal(const POS &pos, udf_func *udf_arg,
2407 PT_item_list *opt_list)
2408 : Item_udf_func(pos, udf_arg, opt_list) {}
2409 longlong val_int() override;
2410 double val_real() override;
2411 my_decimal *val_decimal(my_decimal *) override;
2412 String *val_str(String *str) override;
2413 bool val_date(Date_val *date, my_time_flags_t flags) override {
2414 return get_date_from_decimal(date, flags);
2415 }
2416 bool val_time(Time_val *time) override { return get_time_from_decimal(time); }
2418 return get_datetime_from_decimal(dt, flags);
2419 }
2420 enum Item_result result_type() const override { return DECIMAL_RESULT; }
2421 bool resolve_type(THD *thd) override;
2422};
2423
2425 public:
2426 Item_func_udf_str(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
2427 : Item_udf_func(pos, udf_arg, opt_list) {}
2428
2429 String *val_str(String *) override;
2430 double val_real() override {
2431 int err_not_used;
2432 const char *end_not_used;
2433 String *res;
2434 res = val_str(&str_value);
2435 return res ? my_strntod(res->charset(), res->ptr(), res->length(),
2436 &end_not_used, &err_not_used)
2437 : 0.0;
2438 }
2439 longlong val_int() override {
2440 int err_not_used;
2441 String *res;
2442 res = val_str(&str_value);
2443 return res ? my_strntoll(res->charset(), res->ptr(), res->length(), 10,
2444 nullptr, &err_not_used)
2445 : (longlong)0;
2446 }
2447 my_decimal *val_decimal(my_decimal *dec_buf) override {
2448 String *res = val_str(&str_value);
2449 if (!res) return nullptr;
2450 str2my_decimal(E_DEC_FATAL_ERROR, res->ptr(), res->length(), res->charset(),
2451 dec_buf);
2452 return dec_buf;
2453 }
2454 bool val_date(Date_val *date, my_time_flags_t flags) override {
2455 return get_date_from_string(date, flags);
2456 }
2457 bool val_time(Time_val *time) override { return get_time_from_string(time); }
2459 return get_datetime_from_string(dt, flags);
2460 }
2461 enum Item_result result_type() const override { return STRING_RESULT; }
2462 bool resolve_type(THD *thd) override;
2463};
2464
2465void mysql_ull_cleanup(THD *thd);
2467
2468class Item_func_get_lock final : public Item_int_func {
2470
2472
2473 public:
2474 Item_func_get_lock(const POS &pos, Item *a, Item *b)
2475 : Item_int_func(pos, a, b) {}
2476
2477 bool do_itemize(Parse_context *pc, Item **res) override;
2478 longlong val_int() override;
2479 const char *func_name() const override { return "get_lock"; }
2481 return INNER_TABLE_BIT;
2482 }
2483 bool resolve_type(THD *thd) override {
2484 if (param_type_is_default(thd, 0, 1)) return true;
2485 if (param_type_is_default(thd, 1, 2, MYSQL_TYPE_LONGLONG)) return true;
2486 max_length = 1;
2487 set_nullable(true);
2488 return false;
2489 }
2490 bool is_non_const_over_literals(uchar *) override { return true; }
2491 bool check_function_as_value_generator(uchar *checker_args) override {
2493 pointer_cast<Check_function_as_value_generator_parameters *>(
2494 checker_args);
2495 func_arg->banned_function_name = func_name();
2496 return true;
2497 }
2498};
2499
2502
2504
2505 public:
2506 Item_func_release_lock(const POS &pos, Item *a) : Item_int_func(pos, a) {}
2507 bool do_itemize(Parse_context *pc, Item **res) override;
2508
2509 longlong val_int() override;
2510 const char *func_name() const override { return "release_lock"; }
2512 return INNER_TABLE_BIT;
2513 }
2514 bool resolve_type(THD *thd) override {
2515 if (param_type_is_default(thd, 0, 1)) return true;
2516 max_length = 1;
2517 set_nullable(true);
2518 return false;
2519 }
2520 bool is_non_const_over_literals(uchar *) override { return true; }
2521 bool check_function_as_value_generator(uchar *checker_args) override {
2523 pointer_cast<Check_function_as_value_generator_parameters *>(
2524 checker_args);
2525 func_arg->banned_function_name = func_name();
2526 return true;
2527 }
2528};
2529
2532
2533 public:
2534 explicit Item_func_release_all_locks(const POS &pos) : Item_int_func(pos) {}
2535 bool do_itemize(Parse_context *pc, Item **res) override;
2536
2537 longlong val_int() override;
2538 const char *func_name() const override { return "release_all_locks"; }
2540 return INNER_TABLE_BIT;
2541 }
2542 bool resolve_type(THD *) override {
2543 unsigned_flag = true;
2544 return false;
2545 }
2546 bool is_non_const_over_literals(uchar *) override { return true; }
2547 bool check_function_as_value_generator(uchar *checker_args) override {
2549 pointer_cast<Check_function_as_value_generator_parameters *>(
2550 checker_args);
2551 func_arg->banned_function_name = func_name();
2552 return true;
2553 }
2554};
2555
2556/* replication functions */
2557
2561
2562 public:
2563 Item_source_pos_wait(const POS &pos, Item *a, Item *b)
2564 : Item_int_func(pos, a, b) {}
2565 Item_source_pos_wait(const POS &pos, Item *a, Item *b, Item *c)
2566 : Item_int_func(pos, a, b, c) {}
2567 Item_source_pos_wait(const POS &pos, Item *a, Item *b, Item *c, Item *d)
2568 : Item_int_func(pos, a, b, c, d) {}
2569
2570 bool do_itemize(Parse_context *pc, Item **res) override;
2571 longlong val_int() override;
2572 const char *func_name() const override { return "source_pos_wait"; }
2574 return INNER_TABLE_BIT;
2575 }
2576 bool resolve_type(THD *thd) override {
2577 if (param_type_is_default(thd, 0, 1)) return true;
2578 if (param_type_is_default(thd, 1, 3, MYSQL_TYPE_LONGLONG)) return true;
2579 if (param_type_is_default(thd, 3, 4)) return true;
2580 max_length = 21;
2581 set_nullable(true);
2582 return false;
2583 }
2584 bool check_function_as_value_generator(uchar *checker_args) override {
2586 pointer_cast<Check_function_as_value_generator_parameters *>(
2587 checker_args);
2588 func_arg->banned_function_name = func_name();
2589 return true;
2590 }
2591};
2592
2594 public:
2595 Item_master_pos_wait(const POS &pos, Item *a, Item *b)
2596 : Item_source_pos_wait(pos, a, b) {}
2597 Item_master_pos_wait(const POS &pos, Item *a, Item *b, Item *c)
2598 : Item_source_pos_wait(pos, a, b, c) {}
2599 Item_master_pos_wait(const POS &pos, Item *a, Item *b, Item *c, Item *d)
2600 : Item_source_pos_wait(pos, a, b, c, d) {}
2601 longlong val_int() override;
2602};
2603
2604/**
2605 Internal functions used by INFORMATION_SCHEMA implementation to check
2606 if user have access to given database/table/column.
2607*/
2608
2610 public:
2612 : Item_int_func(pos, a) {}
2613 longlong val_int() override;
2614 const char *func_name() const override { return "can_access_database"; }
2615 bool resolve_type(THD *) override {
2616 set_nullable(true);
2617 return false;
2618 }
2619};
2620
2622 public:
2624 : Item_int_func(pos, a, b) {}
2625 longlong val_int() override;
2626 const char *func_name() const override { return "can_access_table"; }
2627 bool resolve_type(THD *) override {
2628 set_nullable(true);
2629 return false;
2630 }
2631};
2632
2634 public:
2636 : Item_int_func(pos, a, b) {}
2637 longlong val_int() override;
2638 const char *func_name() const override { return "can_access_user"; }
2639 bool resolve_type(THD *) override {
2640 set_nullable(true);
2641 return false;
2642 }
2643};
2644
2646 public:
2648 : Item_int_func(pos, a, b) {}
2649 longlong val_int() override;
2650 const char *func_name() const override { return "can_access_trigger"; }
2651 bool resolve_type(THD *) override {
2652 max_length = 4;
2653 set_nullable(true);
2654 return false;
2655 }
2656};
2657
2659 public:
2661 : Item_int_func(pos, list) {}
2662 longlong val_int() override;
2663 const char *func_name() const override { return "can_access_routine"; }
2664 bool resolve_type(THD *) override {
2665 max_length = 4;
2666 set_nullable(true);
2667 return false;
2668 }
2669};
2670
2672 public:
2674 longlong val_int() override;
2675 const char *func_name() const override { return "can_access_event"; }
2676 bool resolve_type(THD *) override {
2677 set_nullable(true);
2678 return false;
2679 }
2680};
2681
2683 public:
2685 : Item_int_func(pos, a) {}
2686 longlong val_int() override;
2687 const char *func_name() const override { return "can_access_resource_group"; }
2688 bool resolve_type(THD *) override {
2689 max_length = 1; // Function can return 0 or 1.
2690 set_nullable(true);
2691 return false;
2692 }
2693};
2694
2696 public:
2697 Item_func_can_access_view(const POS &pos, Item *a, Item *b, Item *c, Item *d)
2698 : Item_int_func(pos, a, b, c, d) {}
2699 longlong val_int() override;
2700 const char *func_name() const override { return "can_access_view"; }
2701 bool resolve_type(THD *) override {
2702 set_nullable(true);
2703 return false;
2704 }
2705};
2706
2708 public:
2710 : Item_int_func(pos, a, b, c) {}
2711 longlong val_int() override;
2712 const char *func_name() const override { return "can_access_column"; }
2713 bool resolve_type(THD *) override {
2714 set_nullable(true);
2715 return false;
2716 }
2717};
2718
2720 public:
2722 : Item_int_func(pos, a) {}
2724 : Item_int_func(pos, a, b) {}
2726 : Item_int_func(pos, a, b, c) {}
2727 longlong val_int() override;
2728 const char *func_name() const override { return "is_visible_dd_object"; }
2729 bool resolve_type(THD *) override {
2730 max_length = 1;
2731 set_nullable(true);
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_table_rows"; }
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_avg_row_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_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_max_data_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_index_length"; }
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_data_free"; }
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_auto_increment"; }
2833 bool resolve_type(THD *) override {
2834 set_nullable(true);
2835 unsigned_flag = true;
2836 null_on_null = false;
2837 return false;
2838 }
2839};
2840
2842 public:
2844 : Item_int_func(pos, list) {}
2845 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2846 longlong val_int() override;
2847 const char *func_name() const override { return "internal_checksum"; }
2848 bool resolve_type(THD *) override {
2849 set_nullable(true);
2850 null_on_null = false;
2851 return false;
2852 }
2853};
2854
2856 public:
2858 : Item_int_func(pos, a) {}
2859 longlong val_int() override;
2860 const char *func_name() const override { return "internal_keys_disabled"; }
2861 bool resolve_type(THD *) override {
2862 set_nullable(false);
2863 null_on_null = false;
2864 return false;
2865 }
2866};
2867
2869 public:
2872 : Item_int_func(pos, list) {}
2873 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2874 longlong val_int() override;
2875 const char *func_name() const override {
2876 return "internal_index_column_cardinality";
2877 }
2878 bool resolve_type(THD *) override {
2879 set_nullable(true);
2880 null_on_null = false;
2881 return false;
2882 }
2883};
2884
2886 public:
2888 Item *d)
2889 : Item_int_func(pos, a, b, c, d) {}
2890 longlong val_int() override;
2891 const char *func_name() const override { return "internal_dd_char_length"; }
2892 bool resolve_type(THD *) override {
2893 set_nullable(true);
2894 null_on_null = false;
2895 return false;
2896 }
2897};
2898
2900 : public Item_int_func {
2901 public:
2904 : Item_int_func(pos, list) {}
2905 longlong val_int() override;
2906 const char *func_name() const override {
2907 return "internal_get_view_warning_or_error";
2908 }
2909 bool resolve_type(THD *) override {
2910 max_length = 1;
2911 set_nullable(false);
2912 null_on_null = false;
2913 return false;
2914 }
2915};
2916
2918 public:
2920 : Item_int_func(pos, list) {}
2921 longlong val_int() override;
2922 bool resolve_type(THD *) override {
2923 set_nullable(true);
2924 null_on_null = false;
2925 return false;
2926 }
2927 const char *func_name() const override {
2928 return "get_dd_index_sub_part_length";
2929 }
2930};
2931
2933 public:
2935 Item *d)
2936 : Item_int_func(pos, a, b, c, d) {}
2937 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2938 longlong val_int() override;
2939 const char *func_name() const override { return "internal_tablespace_id"; }
2940 bool resolve_type(THD *) override {
2941 set_nullable(true);
2942 null_on_null = false;
2943 return false;
2944 }
2945};
2946
2948 : public Item_int_func {
2949 public:
2951 Item *b, Item *c, Item *d)
2952 : Item_int_func(pos, a, b, c, d) {}
2953
2954 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2955 longlong val_int() override;
2956
2957 const char *func_name() const override {
2958 return "internal_tablespace_logfile_group_number";
2959 }
2960
2961 bool resolve_type(THD *) override {
2962 set_nullable(true);
2963 null_on_null = false;
2964 return false;
2965 }
2966};
2967
2969 public:
2971 Item *c, Item *d)
2972 : Item_int_func(pos, a, b, c, d) {}
2973
2974 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2975 longlong val_int() override;
2976
2977 const char *func_name() const override {
2978 return "internal_tablespace_free_extents";
2979 }
2980
2981 bool resolve_type(THD *) override {
2982 set_nullable(true);
2983 null_on_null = false;
2984 return false;
2985 }
2986};
2987
2989 public:
2991 Item *c, Item *d)
2992 : Item_int_func(pos, a, b, c, d) {}
2993
2994 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
2995 longlong val_int() override;
2996
2997 const char *func_name() const override {
2998 return "internal_tablespace_total_extents";
2999 }
3000
3001 bool resolve_type(THD *) override {
3002 set_nullable(true);
3003 null_on_null = false;
3004 return false;
3005 }
3006};
3007
3009 public:
3011 Item *c, Item *d)
3012 : Item_int_func(pos, a, b, c, d) {}
3013
3014 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
3015 longlong val_int() override;
3016
3017 const char *func_name() const override {
3018 return "internal_tablespace_extent_size";
3019 }
3020
3021 bool resolve_type(THD *) override {
3022 set_nullable(true);
3023 null_on_null = false;
3024 return false;
3025 }
3026};
3027
3029 public:
3031 Item *c, Item *d)
3032 : Item_int_func(pos, a, b, c, d) {}
3033
3034 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
3035 longlong val_int() override;
3036
3037 const char *func_name() const override {
3038 return "internal_tablespace_initial_size";
3039 }
3040
3041 bool resolve_type(THD *) override {
3042 set_nullable(true);
3043 null_on_null = false;
3044 return false;
3045 }
3046};
3047
3049 public:
3051 Item *c, Item *d)
3052 : Item_int_func(pos, a, b, c, d) {}
3053
3054 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
3055 longlong val_int() override;
3056
3057 const char *func_name() const override {
3058 return "internal_tablespace_maximum_size";
3059 }
3060
3061 bool resolve_type(THD *) override {
3062 set_nullable(true);
3063 null_on_null = false;
3064 return false;
3065 }
3066};
3067
3069 public:
3071 Item *b, Item *c, Item *d)
3072 : Item_int_func(pos, a, b, c, d) {}
3073
3074 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
3075 longlong val_int() override;
3076
3077 const char *func_name() const override {
3078 return "internal_tablespace_autoextend_size";
3079 }
3080
3081 bool resolve_type(THD *) override {
3082 set_nullable(true);
3083 null_on_null = false;
3084 return false;
3085 }
3086};
3087
3089 public:
3091 Item *c, Item *d)
3092 : Item_int_func(pos, a, b, c, d) {}
3093
3094 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
3095 longlong val_int() override;
3096
3097 const char *func_name() const override {
3098 return "internal_tablespace_version";
3099 }
3100
3101 bool resolve_type(THD *) override {
3102 set_nullable(true);
3103 null_on_null = false;
3104 return false;
3105 }
3106};
3107
3109 public:
3111 Item *c, Item *d)
3112 : Item_int_func(pos, a, b, c, d) {}
3113
3114 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
3115 longlong val_int() override;
3116
3117 const char *func_name() const override {
3118 return "internal_tablespace_data_free";
3119 }
3120
3121 bool resolve_type(THD *) override {
3122 set_nullable(true);
3123 null_on_null = false;
3124 return false;
3125 }
3126};
3127
3128/**
3129 Common class for:
3130 Item_func_get_system_var
3131 Item_func_get_user_var
3132 Item_func_set_user_var
3133*/
3134class Item_var_func : public Item_func {
3135 public:
3137 explicit Item_var_func(const POS &pos) : Item_func(pos) {}
3138
3139 Item_var_func(THD *thd, Item_var_func *item) : Item_func(thd, item) {}
3140
3142 Item_var_func(const POS &pos, Item *a) : Item_func(pos, a) {}
3143
3144 bool val_date(Date_val *date, my_time_flags_t flags) override {
3145 return get_date_from_non_temporal(date, flags);
3146 }
3147 bool val_time(Time_val *time) override {
3148 return get_time_from_non_temporal(time);
3149 }
3152 }
3153 bool check_function_as_value_generator(uchar *checker_args) override {
3155 pointer_cast<Check_function_as_value_generator_parameters *>(
3156 checker_args);
3157 func_arg->err_code = (func_arg->source == VGS_CHECK_CONSTRAINT)
3158 ? ER_CHECK_CONSTRAINT_VARIABLES
3159 : ER_DEFAULT_VAL_GENERATED_VARIABLES;
3160 return true;
3161 }
3162};
3163
3164/* Handling of user definable variables */
3165
3166// this is needed for user_vars hash
3169 m_ptr = nullptr;
3170 m_length = 0;
3171 }
3172 void set_value(char *value, size_t length) {
3173 m_ptr = value;
3174 m_length = length;
3175 }
3176
3177 /**
3178 Position inside a user_var_entry where small values are stored:
3179 double values, longlong values and string values with length
3180 up to extra_size (should be 8 bytes on all platforms).
3181 String values with length longer than 8 are stored in a separate
3182 memory buffer, which is allocated when needed using the method realloc().
3183 */
3185 return pointer_cast<char *>(this) + ALIGN_SIZE(sizeof(user_var_entry));
3186 }
3187
3188 /**
3189 Position inside a user_var_entry where a null-terminates array
3190 of characters representing the variable name is stored.
3191 */
3193
3194 /**
3195 Initialize m_ptr to the internal buffer (if the value is small enough),
3196 or allocate a separate buffer.
3197 @param length - length of the value to be stored.
3198 */
3199 bool mem_realloc(size_t length);
3200
3201 /**
3202 Check if m_ptr points to an external buffer previously allocated by
3203 realloc().
3204 @retval true - an external buffer is allocated.
3205 @retval false - m_ptr is null, or points to the internal buffer.
3206 */
3207 bool alloced() { return m_ptr && m_ptr != internal_buffer_ptr(); }
3208
3209 /**
3210 Free the external value buffer, if it's allocated.
3211 */
3212 void free_value() {
3213 if (alloced()) my_free(m_ptr);
3214 }
3215
3216 /**
3217 Copy the array of characters from the given name into the internal
3218 name buffer and initialize entry_name to point to it.
3219 */
3221 name.strcpy(name_ptr());
3222 entry_name = Name_string(name_ptr(), name.length());
3223 }
3224
3225 /**
3226 Initialize all members
3227
3228 @param thd Current session.
3229 @param name Name of the user_var_entry instance.
3230 @param cs charset information of the user_var_entry instance.
3231 */
3232 void init(THD *thd, const Simple_cstring &name, const CHARSET_INFO *cs);
3233
3234 /**
3235 Store a value of the given type into a user_var_entry instance.
3236 @param from Value
3237 @param length Size of the value
3238 @param type type
3239 @retval false on success
3240 @retval true on memory allocation error
3241 */
3242 bool store(const void *from, size_t length, Item_result type);
3243
3244 /**
3245 Assert the user variable is locked.
3246 This is debug code only.
3247 The thread LOCK_thd_data mutex protects:
3248 - the thd->user_vars hash itself
3249 - the values in the user variable itself.
3250 The protection is required for monitoring,
3251 as a different thread can inspect this session
3252 user variables, on a live session.
3253 */
3254 void assert_locked() const;
3255
3256 static const size_t extra_size = sizeof(double);
3257 char *m_ptr; ///< Value
3258 size_t m_length; ///< Value length
3259 Item_result m_type; ///< Value type
3261 /**
3262 Set to the id of the most recent query that has used the variable.
3263 Used in binlogging: When set, there is no need to add a reference to this
3264 variable to the binlog. Imagine it is this:
3265
3266 INSERT INTO t SELECT @a:=10, @a:=@a+1.
3267
3268 Then we have a Item_func_get_user_var (because of the `@a+1`) so we
3269 think we have to write the value of `@a` to the binlog. But before that,
3270 we have a Item_func_set_user_var to create `@a` (`@a:=10`), in this we mark
3271 the variable as "already logged" so that it won't be logged
3272 by Item_func_get_user_var (because that's not necessary).
3273 */
3275
3276 public:
3277 user_var_entry() = default; /* Remove gcc warning */
3278
3279 THD *owner_session() const { return m_owner; }
3280
3281 Simple_cstring entry_name; // Variable name
3282 DTCollation collation; // Collation with attributes
3283 bool unsigned_flag; // true if unsigned, false if signed
3284
3285 /**
3286 Set value to user variable.
3287
3288 @param ptr pointer to buffer with new value
3289 @param length length of new value
3290 @param type type of new value
3291 @param cs charset info for new value
3292 @param dv derivation for new value
3293 @param unsigned_arg indicates if a value of type INT_RESULT is unsigned
3294
3295 @note Sets error and fatal error if allocation fails.
3296
3297 @retval
3298 false success
3299 @retval
3300 true failure
3301 */
3302 bool store(const void *ptr, size_t length, Item_result type,
3303 const CHARSET_INFO *cs, Derivation dv, bool unsigned_arg);
3304 /**
3305 Set type of to the given value.
3306 @param type Data type.
3307 */
3309 assert_locked();
3310 m_type = type;
3311 }
3312 /**
3313 Set value to NULL
3314 @param type Data type.
3315 */
3316
3318 assert_locked();
3319 free_value();
3320 reset_value();
3321 m_type = type;
3322 }
3323
3324 void set_used_query_id(query_id_t query_id) { m_used_query_id = query_id; }
3326
3327 /**
3328 Allocates and initializes a user variable instance.
3329
3330 @param thd Current session.
3331 @param name Name of the variable.
3332 @param cs Charset of the variable.
3333
3334 @return Address of the allocated and initialized user_var_entry instance.
3335 @retval NULL On allocation error.
3336 */
3337 static user_var_entry *create(THD *thd, const Name_string &name,
3338 const CHARSET_INFO *cs);
3339
3340 /**
3341 Free all memory used by a user_var_entry instance
3342 previously created by create().
3343 */
3344 void destroy() {
3345 assert_locked();
3346 free_value(); // Free the external value buffer
3347 my_free(this); // Free the instance itself
3348 }
3349
3350 void lock();
3351 void unlock();
3352
3353 /* Routines to access the value and its type */
3354 const char *ptr() const { return m_ptr; }
3355 size_t length() const { return m_length; }
3356 /// The data type of this variable.
3357 Item_result type() const { return m_type; }
3358 /* Item-alike routines to access the value */
3359 double val_real(bool *null_value) const;
3360 longlong val_int(bool *null_value) const;
3361 String *val_str(bool *null_value, String *str, uint decimals) const;
3362 my_decimal *val_decimal(bool *null_value, my_decimal *result) const;
3363};
3364
3365/**
3366 This class is used to implement operations like
3367 SET \@variable or \@variable:= expression.
3368*/
3369
3376 union {
3378 double vreal;
3382
3383 public:
3384 Name_string name; // keep it public
3385
3388 : Item_var_func(pos, b), name(a) {}
3389
3391 : Item_var_func(thd, item),
3393 entry(item->entry),
3394 value(item->value),
3396 null_item(item->null_item),
3397 save_result(item->save_result),
3398 name(item->name) {}
3399 enum Functype functype() const override { return SUSERVAR_FUNC; }
3400 double val_real() override;
3401 longlong val_int() override;
3402 String *val_str(String *str) override;
3403 my_decimal *val_decimal(my_decimal *) override;
3404 bool update_hash(const void *ptr, uint length, enum Item_result type,
3405 const CHARSET_INFO *cs, Derivation dv, bool unsigned_arg);
3406 bool send(Protocol *protocol, String *str_arg) override;
3407 void make_field(Send_field *tmp_field) override;
3408 bool check(bool use_result_field);
3409 void save_item_result(Item *item);
3410 bool update();
3411 enum Item_result result_type() const override { return cached_result_type; }
3412 bool fix_fields(THD *thd, Item **ref) override;
3413 bool resolve_type(THD *) override;
3414 void print(const THD *thd, String *str,
3415 enum_query_type query_type) const override;
3416 uint64_t hash() override;
3417 void print_assignment(const THD *thd, String *str,
3418 enum_query_type query_type) const;
3419 const char *func_name() const override { return "set_user_var"; }
3420
3421 type_conversion_status save_in_field(Field *field, bool no_conversions,
3422 bool can_use_result_field);
3423
3424 void save_org_in_field(Field *field) override {
3425 save_in_field(field, true, false);
3426 }
3427
3428 bool set_entry(THD *thd, bool create_if_not_exists);
3429 void cleanup() override;
3430
3431 protected:
3433 bool no_conversions) override {
3434 return save_in_field(field, no_conversions, true);
3435 }
3436};
3437
3442
3443 public:
3444 Name_string name; // keep it public
3445
3450
3451 enum Functype functype() const override { return GUSERVAR_FUNC; }
3452 double val_real() override;
3453 longlong val_int() override;
3454 my_decimal *val_decimal(my_decimal *) override;
3455 String *val_str(String *str) override;
3456 const CHARSET_INFO *charset_for_protocol() override;
3457 bool resolve_type(THD *) override;
3458 bool propagate_type(THD *thd, const Type_properties &type) override;
3459 void cleanup() override;
3460 void update_used_tables() override {} // Keep existing used tables
3461 void print(const THD *thd, String *str,
3462 enum_query_type query_type) const override;
3463 uint64_t hash() override;
3464 enum Item_result result_type() const override;
3465 /*
3466 We must always return variables as strings to guard against selects of type
3467 select @t1:=1,@t1,@t:="hello",@t from foo where (@t1:= t2.b)
3468 */
3469 const char *func_name() const override { return "get_user_var"; }
3470 bool is_non_const_over_literals(uchar *) override { return true; }
3471 bool eq_specific(const Item *item) const override;
3472
3473 private:
3474 bool set_value(THD *thd, sp_rcontext *ctx, Item **it) override;
3475
3476 public:
3478 return this;
3479 }
3480};
3481
3482/*
3483 This item represents user variable used as out parameter (e.g in LOAD DATA),
3484 and it is supposed to be used only for this purprose. So it is simplified
3485 a lot. Actually you should never obtain its value.
3486
3487 The only two reasons for this thing being an Item is possibility to store it
3488 in const mem_root_deque<Item> and desire to place this code somewhere near
3489 other functions working with user variables.
3490*/
3494
3495 public:
3497 : Item(pos), name(a) {
3498 item_name.copy(a);
3499 }
3500 /* We should return something different from FIELD_ITEM here */
3501 enum Type type() const override { return STRING_ITEM; }
3502 double val_real() override;
3503 longlong val_int() override;
3504 String *val_str(String *str) override;
3505 my_decimal *val_decimal(my_decimal *decimal_buffer) override;
3507 assert(false);
3508 return true;
3509 }
3510 bool val_time(Time_val *) override {
3511 assert(false);
3512 return true;
3513 }
3515 assert(false);
3516 return true;
3517 }
3518 /* fix_fields() binds variable name with its entry structure */
3519 bool fix_fields(THD *thd, Item **ref) override;
3520 void print(const THD *thd, String *str,
3521 enum_query_type query_type) const override;
3522 uint64_t hash() override;
3523 void set_null_value(const CHARSET_INFO *cs);
3524 void set_value(const char *str, size_t length, const CHARSET_INFO *cs);
3525};
3526
3527/* A system variable */
3528
3529#define GET_SYS_VAR_CACHE_LONG 1
3530#define GET_SYS_VAR_CACHE_DOUBLE 2
3531#define GET_SYS_VAR_CACHE_STRING 4
3532
3534
3535/** Class to log audit event EVENT_TRACKING_GLOBAL_VARIABLE_GET. */
3537 public:
3541
3542 private:
3543 // Thread handle.
3545
3546 // Item_func_get_system_var instance.
3548
3549 /*
3550 Value conversion type.
3551 Depending on the value conversion type GET_SYS_VAR_CACHE_* is stored in this
3552 member while creating the object. While converting value if there are any
3553 intermediate conversions in the same query then this member is used to avoid
3554 auditing more than once.
3555 */
3557
3558 /*
3559 To indicate event auditing is required or not. Event is not audited if
3560 * scope of the variable is *not* GLOBAL.
3561 * or the event is already audited for global variable for the same query.
3562 */
3564};
3565
3575
3576 template <typename T>
3578
3580
3581 public:
3583 enum_var_type scope);
3584 enum Functype functype() const override { return GSYSVAR_FUNC; }
3586 return INNER_TABLE_BIT;
3587 }
3588 bool resolve_type(THD *) override;
3589 void print(const THD *thd, String *str,
3590 enum_query_type query_type) const override;
3591 uint64_t hash() override;
3592 bool is_non_const_over_literals(uchar *) override { return true; }
3593 enum Item_result result_type() const override {
3594 assert(fixed);
3595 return type_to_result(data_type());
3596 }
3597 double val_real() override;
3598 longlong val_int() override;
3599 String *val_str(String *) override;
3600 my_decimal *val_decimal(my_decimal *dec_buf) override {
3601 return val_decimal_from_real(dec_buf);
3602 }
3603 /* TODO: fix to support views */
3604 const char *func_name() const override { return "get_system_var"; }
3605 bool eq_specific(const Item *item) const override;
3606 bool is_valid_for_pushdown(uchar *arg [[maybe_unused]]) override {
3607 // Expressions which have system variables cannot be pushed as of
3608 // now because Item_func_get_system_var::print does not print the
3609 // original expression which leads to an incorrect clone.
3610 return true;
3611 }
3612
3613 void cleanup() override;
3614};
3615
3616class JOIN;
3617
3618class Item_func_match final : public Item_real_func {
3620
3621 protected:
3622 void add_json_info(Json_object *obj) override;
3623
3624 public:
3626 uint key, flags;
3627 /// True if we are doing a full-text index scan with this MATCH function as a
3628 /// predicate, and the score can be retrieved with get_relevance(). If it is
3629 /// false, the score of the document must be retrieved with find_relevance().
3634 /**
3635 Master item means that if identical items are present in the
3636 statement, they use the same FT handler. FT handler is initialized
3637 only for master item and slave items just use it. FT hints initialized
3638 for master only, slave items HINTS are not accessed.
3639 */
3641 Item *concat_ws; // Item_func_concat_ws
3642 String value; // value of concat_ws
3643 String search_value; // key_item()'s value converted to cmp_collation
3644
3645 /**
3646 Constructor for Item_func_match class.
3647
3648 @param pos Position of token in the parser.
3649 @param a List of arguments.
3650 @param against_arg Expression to match against.
3651 @param b FT Flags.
3652 */
3653 Item_func_match(const POS &pos, PT_item_list *a, Item *against_arg, uint b)
3654 : Item_real_func(pos, a),
3655 against(against_arg),
3656 key(0),
3657 flags(b),
3660 master(nullptr),
3662 hints(nullptr),
3663 simple_expression(false),
3664 used_in_where_only(false) {
3665 null_on_null = false;
3666 }
3667
3668 bool do_itemize(Parse_context *pc, Item **res) override;
3669
3670 void cleanup() override {
3671 DBUG_TRACE;
3673 if (master == nullptr && ft_handler != nullptr) {
3675 }
3676 score_from_index_scan = false;
3677 ft_handler = nullptr;
3678 concat_ws = nullptr;
3679 return;
3680 }
3681 Item *key_item() const override { return against; }
3682 enum Functype functype() const override { return FT_FUNC; }
3683 const char *func_name() const override { return "match"; }
3684 bool fix_fields(THD *thd, Item **ref) override;
3685 void update_used_tables() override;
3686 bool eq_specific(const Item *item) const override;
3687 /* The following should be safe, even if we compare doubles */
3688 longlong val_int() override {
3689 assert(fixed);
3690 return val_real() != 0.0;
3691 }
3692 double val_real() override;
3693 void print(const THD *thd, String *str,
3694 enum_query_type query_type) const override;
3695 uint64_t hash() override;
3696 bool fix_index(const THD *thd);
3697 bool init_search(THD *thd);
3698 bool check_function_as_value_generator(uchar *checker_args) override {
3700 pointer_cast<Check_function_as_value_generator_parameters *>(
3701 checker_args);
3702 func_arg->banned_function_name = func_name();
3703 return true;
3704 }
3705
3706 /**
3707 Get number of matching rows from FT handler.
3708
3709 @note Requires that FT handler supports the extended API
3710
3711 @return Number of matching rows in result
3712 */
3714 assert(ft_handler);
3716
3717 return ((FT_INFO_EXT *)ft_handler)
3718 ->could_you->count_matches((FT_INFO_EXT *)ft_handler);
3719 }
3720
3721 /**
3722 Check whether FT result is ordered on rank
3723
3724 @return true if result is ordered
3725 @return false otherwise
3726 */
3728 assert(!master);
3729 if (hints->get_flags() & FT_SORTED) return true;
3730
3732 return false;
3733
3734 assert(ft_handler);
3735 return ((FT_INFO_EXT *)ft_handler)->could_you->get_flags() &
3737 }
3738
3739 /**
3740 Check whether FT result contains the document ID
3741
3742 @return true if document ID is available
3743 @return false otherwise
3744 */
3746 assert(ft_handler);
3747
3749 return false;
3750
3751 return ((FT_INFO_EXT *)ft_handler)->could_you->get_flags() &
3753 }
3754
3755 float get_filtering_effect(THD *thd, table_map filter_for_table,
3756 table_map read_tables,
3757 const MY_BITMAP *fields_to_ignore,
3758 double rows_in_table) override;
3759
3760 /**
3761 Returns master MATCH function.
3762
3763 @return pointer to master MATCH function.
3764 */
3766 if (master) return master->get_master();
3767 return this;
3768 }
3769
3770 /**
3771 Set master MATCH function and adjust used_in_where_only value.
3772
3773 @param item item for which master should be set.
3774 */
3777 item->master = this;
3778 }
3779
3780 /**
3781 Returns pointer to Ft_hints object belonging to master MATCH function.
3782
3783 @return pointer to Ft_hints object
3784 */
3786 assert(!master);
3787 return hints;
3788 }
3789
3790 /**
3791 Set comparison operation type and and value for master MATCH function.
3792
3793 @param type comparison operation type
3794 @param value_arg comparison operation value
3795 */
3796 void set_hints_op(enum ft_operation type, double value_arg) {
3797 assert(!master);
3798 hints->set_hint_op(type, value_arg);
3799 }
3800
3801 /**
3802 Set FT hints.
3803 */
3804 void set_hints(JOIN *join, uint ft_flag, ha_rows ft_limit, bool no_cond);
3805
3806 /**
3807 Check if ranking is not needed.
3808
3809 @return true if ranking is not needed
3810 @return false otherwise
3811 */
3813 assert(!master);
3814 return (!(hints->get_flags() & FT_SORTED) && // FT_SORTED is no set
3815 used_in_where_only && // MATCH result is not used
3816 // in expression
3817 hints->get_op_type() == FT_OP_NO); // MATCH is single function
3818 }
3819
3820 /**
3821 Set flag that the function is a simple expression.
3822
3823 @param val true if the function is a simple expression, false otherwise
3824 */
3825 void set_simple_expression(bool val) {
3826 assert(!master);
3827 simple_expression = val;
3828 }
3829
3830 /**
3831 Check if this MATCH function is a simple expression in WHERE condition.
3832
3833 @return true if simple expression
3834 @return false otherwise
3835 */
3837 assert(!master);
3838 return simple_expression;
3839 }
3840
3841 private:
3842 /**
3843 Fulltext index hints, initialized for master MATCH function only.
3844 */
3846 /**
3847 Flag is true when MATCH function is used as a simple expression in
3848 WHERE condition, i.e. there is no AND/OR combinations, just simple
3849 MATCH function or [MATCH, rank] comparison operation.
3850 */
3852 /**
3853 true if MATCH function is used in WHERE condition only.
3854 Used to determine what hints can be used for FT handler.
3855 Note that only master MATCH function has valid value.
3856 it's ok since only master function is involved in the hint processing.
3857 */
3859 /**
3860 Check whether storage engine for given table,
3861 allows FTS Boolean search on non-indexed columns.
3862
3863 @todo A flag should be added to the extended fulltext API so that
3864 it may be checked whether search on non-indexed columns are
3865 supported. Currently, it is not possible to check for such a
3866 flag since @c this->ft_handler is not yet set when this function is
3867 called. The current hack is to assume that search on non-indexed
3868 columns are supported for engines that does not support the extended
3869 fulltext API (e.g., MyISAM), while it is not supported for other
3870 engines (e.g., InnoDB)
3871
3872 @param tr Table for which storage engine to check
3873
3874 @retval true if BOOLEAN search on non-indexed columns is supported
3875 @retval false otherwise
3876 */
3878 // Only Boolean search may support non_indexed columns
3879 if (!(flags & FT_BOOL)) return false;
3880
3881 assert(tr && tr->file);
3882
3883 // Assume that if extended fulltext API is not supported,
3884 // non-indexed columns are allowed. This will be true for MyISAM.
3885 if ((tr->file->ha_table_flags() & HA_CAN_FULLTEXT_EXT) == 0) return true;
3886
3887 return false;
3888 }
3889};
3890
3891/**
3892 A visitor that calls the specified function on every non-aggregated full-text
3893 search function (Item_func_match) it encounters when it is used in a
3894 PREFIX+POSTFIX walk with WalkItem(). It skips every item that is wrapped in an
3895 aggregate function, and also every item wrapped in a reference, as the items
3896 behind the reference are already handled elsewhere (in another query block or
3897 in another element of the SELECT list).
3898 */
3900 public:
3902 std::function<bool(Item_func_match *)> func);
3903 bool operator()(Item *item);
3904
3905 private:
3906 std::function<bool(Item_func_match *)> m_func;
3907};
3908
3911
3913
3914 public:
3915 Item_func_is_free_lock(const POS &pos, Item *a) : Item_int_func(pos, a) {}
3916
3917 bool do_itemize(Parse_context *pc, Item **res) override;
3918 longlong val_int() override;
3919 const char *func_name() const override { return "is_free_lock"; }
3921 return INNER_TABLE_BIT;
3922 }
3923 bool resolve_type(THD *thd) override {
3924 if (param_type_is_default(thd, 0, 1)) return true;
3925 max_length = 1;
3926 set_nullable(true);
3927 return false;
3928 }
3929 bool is_non_const_over_literals(uchar *) override { return true; }
3930 bool check_function_as_value_generator(uchar *checker_args) override {
3932 pointer_cast<Check_function_as_value_generator_parameters *>(
3933 checker_args);
3934 func_arg->banned_function_name = func_name();
3935 return true;
3936 }
3937};
3938
3941
3943
3944 public:
3945 Item_func_is_used_lock(const POS &pos, Item *a) : Item_int_func(pos, a) {}
3946
3947 bool do_itemize(Parse_context *pc, Item **res) override;
3948 longlong val_int() override;
3949 const char *func_name() const override { return "is_used_lock"; }
3951 return INNER_TABLE_BIT;
3952 }
3953 bool resolve_type(THD *thd) override {
3954 if (param_type_is_default(thd, 0, 1)) return true;
3955 unsigned_flag = true;
3956 set_nullable(true);
3957 return false;
3958 }
3959 bool is_non_const_over_literals(uchar *) override { return true; }
3960 bool check_function_as_value_generator(uchar *checker_args) override {
3962 pointer_cast<Check_function_as_value_generator_parameters *>(
3963 checker_args);
3964 func_arg->banned_function_name = func_name();
3965 return true;
3966 }
3967};
3968
3971
3972 public:
3973 explicit Item_func_row_count(const POS &pos) : Item_int_func(pos) {}
3974
3975 bool do_itemize(Parse_context *pc, Item **res) override;
3976
3977 longlong val_int() override;
3978 const char *func_name() const override { return "row_count"; }
3979 bool resolve_type(THD *) override {
3980 set_nullable(false);
3981 return false;
3982 }
3983 bool check_function_as_value_generator(uchar *checker_args) override {
3985 pointer_cast<Check_function_as_value_generator_parameters *>(
3986 checker_args);
3987 func_arg->banned_function_name = func_name();
3988 return true;
3989 }
3990};
3991
3992/*
3993 *
3994 * Stored FUNCTIONs
3995 *
3996 */
3997
3998class sp_head;
3999class sp_name;
4000
4001class Item_func_sp final : public Item_func {
4003
4004 private:
4005 /// Holds the security definer context(if defined with SQL SECURITY DEFINER)
4006 /// and the error the handler.
4008 /// The name of the stored function
4009 sp_name *m_name{nullptr};
4010 /// Pointer to actual function instance (null when not resolved or executing)
4011 sp_head *m_sp{nullptr};
4012 /// The result field of the concrete stored function.
4014 /// true when function execution is deterministic
4015 bool m_deterministic{false};
4016
4017 bool execute();
4018 bool execute_impl(THD *thd);
4019 bool init_result_field(THD *thd);
4020
4021 protected:
4022 public:
4023 Item_func_sp(const POS &pos, const LEX_STRING &db_name,
4024 const LEX_STRING &fn_name, bool use_explicit_name,
4025 PT_item_list *opt_list);
4026
4027 bool do_itemize(Parse_context *pc, Item **res) override;
4028 /**
4029 Must not be called before the procedure is resolved,
4030 i.e. @c init_result_field().
4031 */
4032 table_map get_initial_pseudo_tables() const override;
4033 void update_used_tables() override;
4034 void fix_after_pullout(Query_block *parent_query_block,
4035 Query_block *removed_query_block) override;
4036 void cleanup() override;
4037
4038 const char *func_name() const override;
4039
4040 Field *tmp_table_field(TABLE *t_arg) override;
4041
4042 void make_field(Send_field *tmp_field) override;
4043
4044 Item_result result_type() const override;
4045
4046 longlong val_int() override;
4047 double val_real() override;
4048 bool val_date(Date_val *date, my_time_flags_t flags) override;
4049 bool val_time(Time_val *time) override;
4050 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
4051 my_decimal *val_decimal(my_decimal *dec_buf) override;
4052 String *val_str(String *str) override;
4053 bool val_json(Json_wrapper *result) override;
4054
4055 bool change_context_processor(uchar *arg) override {
4057 pointer_cast<Item_ident::Change_context *>(arg)->m_context;
4058 return false;
4059 }
4060
4061 bool sp_check_access(THD *thd);
4062 sp_head *get_sp() { return m_sp; }
4063 const sp_name *get_name() { return m_name; }
4064 enum Functype functype() const override { return FUNC_SP; }
4065
4066 bool fix_fields(THD *thd, Item **ref) override;
4067 bool resolve_type(THD *thd) override;
4068
4070 bool check_function_as_value_generator(uchar *checker_args) override {
4072 pointer_cast<Check_function_as_value_generator_parameters *>(
4073 checker_args);
4074 func_arg->banned_function_name = func_name();
4075 return true;
4076 }
4077
4078 void compute_cost(CostOfItem *root_cost) const override {
4079 root_cost->MarkExpensive();
4080 }
4081};
4082
4085
4086 public:
4087 explicit Item_func_found_rows(const POS &pos) : Item_int_func(pos) {}
4088
4089 bool do_itemize(Parse_context *pc, Item **res) override;
4090 longlong val_int() override;
4091 const char *func_name() const override { return "found_rows"; }
4092 bool resolve_type(THD *) override {
4093 set_nullable(false);
4094 return false;
4095 }
4096 bool check_function_as_value_generator(uchar *checker_args) override {
4098 pointer_cast<Check_function_as_value_generator_parameters *>(
4099 checker_args);
4100 func_arg->banned_function_name = func_name();
4101 return true;
4102 }
4103};
4104
4105void uuid_short_init();
4106
4109
4110 public:
4112
4113 bool do_itemize(Parse_context *pc, Item **res) override;
4114 const char *func_name() const override { return "uuid_short"; }
4115 longlong val_int() override;
4116 bool resolve_type(THD *) override {
4117 unsigned_flag = true;
4118 return false;
4119 }
4120 bool check_partition_func_processor(uchar *) override { return false; }
4121 bool check_function_as_value_generator(uchar *checker_args) override {
4123 pointer_cast<Check_function_as_value_generator_parameters *>(
4124 checker_args);
4125 func_arg->banned_function_name = func_name();
4126 return ((func_arg->source == VGS_GENERATED_COLUMN) ||
4127 (func_arg->source == VGS_CHECK_CONSTRAINT));
4128 }
4129 // This function is random, see uuid_short_init().
4131 return RAND_TABLE_BIT;
4132 }
4133};
4134
4137
4138 public:
4139 explicit Item_func_version(const POS &pos);
4140
4141 bool do_itemize(Parse_context *pc, Item **res) override;
4142};
4143
4144/**
4145 Internal function used by INFORMATION_SCHEMA implementation to check
4146 if a role is a mandatory role.
4147*/
4148
4150 public:
4152 : Item_int_func(pos, a, b) {}
4153 longlong val_int() override;
4154 const char *func_name() const override {
4155 return "internal_is_mandatory_role";
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
4165 public:
4167 : Item_int_func(pos) {}
4168 longlong val_int() override;
4169 const char *func_name() const override {
4170 return "internal_use_terminology_previous";
4171 }
4172 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
4173 bool resolve_type(THD *) override {
4174 set_nullable(true);
4175 return false;
4176 }
4177};
4178
4179/**
4180 Internal function used by INFORMATION_SCHEMA implementation to check
4181 if a role is enabled.
4182*/
4183
4185 public:
4187 : Item_int_func(pos, a, b) {}
4188 longlong val_int() override;
4189 const char *func_name() const override { return "internal_is_enabled_role"; }
4190 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
4191 bool resolve_type(THD *) override {
4192 set_nullable(true);
4193 return false;
4194 }
4195};
4196
4197/**
4198 Create new Item_func_get_system_var object
4199
4200 @param pc Parse context
4201
4202 @param scope Scope of the variable (GLOBAL, SESSION, PERSISTENT ...)
4203
4204 @param prefix Empty LEX_CSTRING{} or the left hand side of the composite
4205 variable name, e.g.:
4206 * component name of the component-registered variable
4207 * name of MyISAM Multiple Key Cache.
4208
4209 @param suffix Name of the variable (if prefix is empty) or the right
4210 hand side of the composite variable name, e.g.:
4211 * name of the component-registered variable
4212 * property name of MyISAM Multiple Key Cache variable.
4213
4214 @param unsafe_for_replication force writing this system variable to binlog
4215 (if not written yet)
4216
4217 @returns new item on success, otherwise nullptr
4218*/
4220 const LEX_CSTRING &prefix, const LEX_CSTRING &suffix,
4221 bool unsafe_for_replication);
4222
4224 const LEX_CSTRING &trivial_name,
4225 bool unsafe_for_replication) {
4226 return get_system_variable(pc, scope, {}, trivial_name,
4227 unsafe_for_replication);
4228}
4229
4230extern bool check_reserved_words(const char *name);
4231extern enum_field_types agg_field_type(Item **items, uint nitems);
4232double my_double_round(double value, longlong dec, bool dec_unsigned,
4233 bool truncate);
4234bool eval_const_cond(THD *thd, Item *cond, bool *value);
4236 Field **found = nullptr);
4237
4238void retrieve_tablespace_statistics(THD *thd, Item **args, bool *null_value);
4239
4241
4242extern bool volatile mqh_used;
4243
4244/// Checks if "item" is a function of the specified type.
4246
4247/// Checks if "item" contains a function of the specified type.
4249
4250#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:3536
Audit_global_variable_get_event(THD *thd, Item_func_get_system_var *item, uchar cache_type)
Definition: item_func.cc:7505
THD * m_thd
Definition: item_func.h:3544
~Audit_global_variable_get_event()
Definition: item_func.cc:7518
bool m_audit_event
Definition: item_func.h:3563
Item_func_get_system_var * m_item
Definition: item_func.h:3547
uchar m_val_type
Definition: item_func.h:3556
This class represents the cost of evaluating an Item.
Definition: item.h:790
void MarkExpensive()
Definition: item.h:799
Definition: item.h:184
void set_numeric()
Definition: item.h:220
const CHARSET_INFO * collation
Definition: item.h:186
Date_val is a temporal type that represents dates within the range 0000-01-01 and 9999-12-31.
Definition: my_temporal.h:421
Definition: my_temporal.h:341
Definition: field.h:573
Wrapper for struct ft_hints.
Definition: handler.h:4306
uint get_flags() const
Get Ft_hints flags.
Definition: handler.h:4369
enum ft_operation get_op_type() const
Get Ft_hints operation type.
Definition: handler.h:4362
void set_hint_op(enum ft_operation type, double value)
Set comparison operation type and and value for master MATCH function.
Definition: handler.h:4324
Definition: item_func.h:1378
Item_dec_func(const POS &pos, Item *a)
Definition: item_func.h:1381
Item_dec_func(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1383
Item_dec_func(Item *a)
Definition: item_func.h:1380
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:2970
Definition: item.h:4529
Definition: item_func.h:1363
enum Functype functype() const override
Definition: item_func.h:1373
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:2934
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:1372
my_decimal * decimal_op(my_decimal *) override
Evaluates item when resulting data type is DECIMAL.
Definition: item_func.cc:2949
const char * func_name() const override
Definition: item_func.h:1369
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1371
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:2940
Item_func_abs(const POS &pos, Item *a)
Definition: item_func.h:1365
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:2964
Definition: item_func.h:1443
const char * func_name() const override
Definition: item_func.h:1447
double val_real() override
Definition: item_func.cc:3072
enum Functype functype() const override
Definition: item_func.h:1448
Item_func_acos(const POS &pos, Item *a)
Definition: item_func.h:1445
Definition: item_func.h:1232
Item_func_additive_op(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1235
Item_func_additive_op(Item *a, Item *b)
Definition: item_func.h:1234
void result_precision() override
Set precision of results for additive operations (+ and -)
Definition: item_func.cc:2315
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1239
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:1240
Definition: item_func.h:1964
const char * func_name() const override
Definition: item_func.h:1970
longlong val_int() override
Definition: item_func.cc:4650
String value
Definition: item_func.h:1965
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1971
Item_func_ascii(const POS &pos, Item *a)
Definition: item_func.h:1968
Definition: item_func.h:1451
double val_real() override
Definition: item_func.cc:3082
enum Functype functype() const override
Definition: item_func.h:1456
const char * func_name() const override
Definition: item_func.h:1455
Item_func_asin(const POS &pos, Item *a)
Definition: item_func.h:1453
Definition: item_func.h:1459
enum Functype functype() const override
Definition: item_func.h:1465
double val_real() override
Definition: item_func.cc:3090
Item_func_atan(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1462
Item_func_atan(const POS &pos, Item *a)
Definition: item_func.h:1461
const char * func_name() const override
Definition: item_func.h:1464
Definition: item_func.h:2237
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:6166
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2252
table_map get_initial_pseudo_tables() const override
Ensure that "benchmark()" is never optimized away.
Definition: item_func.h:2245
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:6096
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:2261
Item_int_func super
Definition: item_func.h:2238
Item_func_benchmark(const POS &pos, Item *count_expr, Item *expr)
Definition: item_func.h:2241
longlong val_int() override
Definition: item_func.cc:6105
const char * func_name() const override
Definition: item_func.h:2251
Definition: item_func.h:2106
longlong int_op() override
Performs the operation on integers to produce a result of type INT_RESULT.
Definition: item_func.h:2114
const char * func_name() const override
Definition: item_func.h:2110
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.h:2111
Item_func_bit_and(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2108
String * str_op(String *str) override
Performs the operation on binary strings to produce a result of type STRING_RESULT.
Definition: item_func.h:2115
Definition: item_func.h:2134
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2139
longlong val_int() override
Definition: item_func.cc:4789
const char * func_name() const override
Definition: item_func.h:2138
Item_func_bit_count(const POS &pos, Item *a)
Definition: item_func.h:2136
Definition: item_func.h:1874
const char * func_name() const override
Definition: item_func.h:1881
longlong val_int() override
Definition: item_func.h:1877
Item_func_bit_length(const POS &pos, Item *a)
Definition: item_func.h:1876
Definition: item_func.h:2187
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.h:2196
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.h:2200
Item_func_bit_neg(const POS &pos, Item *a)
Definition: item_func.h:2194
longlong int_op() override
Performs the operation on integers to produce a result of type INT_RESULT.
Definition: item_func.cc:3324
bool binary_result_requires_binary_second_arg() const override
Definition: item_func.h:2189
String * str_op(String *str) override
Performs the operation on binary strings to produce a result of type STRING_RESULT.
Definition: item_func.cc:3332
const char * func_name() const override
Definition: item_func.h:2195
Definition: item_func.h:2092
const char * func_name() const override
Definition: item_func.h:2096
String * str_op(String *str) override
Performs the operation on binary strings to produce a result of type STRING_RESULT.
Definition: item_func.h:2101
longlong int_op() override
Performs the operation on integers to produce a result of type INT_RESULT.
Definition: item_func.h:2100
Item_func_bit_or(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2094
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.h:2097
Base class for all the bit functions that work with two binary arguments: '&', '|',...
Definition: item_func.h:2077
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:3390
bool binary_result_requires_binary_second_arg() const override
Definition: item_func.h:2079
longlong eval_int_op(Int_func int_func)
Template function used to evaluate the bitwise operation over int arguments.
Definition: item_func.cc:3364
Item_func_bit_two_param(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2088
Definition: item_func.h:2120
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.h:2125
const char * func_name() const override
Definition: item_func.h:2124
Item_func_bit_xor(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2122
longlong int_op() override
Performs the operation on integers to produce a result of type INT_RESULT.
Definition: item_func.h:2128
String * str_op(String *str) override
Performs the operation on binary strings to produce a result of type STRING_RESULT.
Definition: item_func.h:2129
Definition: item_func.h:2009
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:2037
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.h:2033
String tmp_value
Buffer storing the determined value.
Definition: item_func.h:2014
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:2049
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:3136
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:2043
virtual bool binary_result_requires_binary_second_arg() const =0
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_func.cc:3197
double val_real() override
Definition: item_func.cc:3181
String * val_str(String *str) override
Definition: item_func.cc:3205
Item_result hybrid_type
Stores the Item's result type. Can only be INT_RESULT or STRING_RESULT.
Definition: item_func.h:2012
longlong val_int() override
Definition: item_func.cc:3165
Item_func_bit(const POS &pos, Item *a)
Definition: item_func.h:2023
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:2026
Item_func_bit(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2022
Definition: item_func.h:2707
const char * func_name() const override
Definition: item_func.h:2712
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:9504
Item_func_can_access_column(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_func.h:2709
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2713
Internal functions used by INFORMATION_SCHEMA implementation to check if user have access to given da...
Definition: item_func.h:2609
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2615
Item_func_can_access_database(const POS &pos, Item *a)
Definition: item_func.h:2611
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:9085
const char * func_name() const override
Definition: item_func.h:2614
Definition: item_func.h:2671
Item_func_can_access_event(const POS &pos, Item *a)
Definition: item_func.h:2673
const char * func_name() const override
Definition: item_func.h:2675
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2676
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:9389
Definition: item_func.h:2682
const char * func_name() const override
Definition: item_func.h:2687
Item_func_can_access_resource_group(const POS &pos, Item *a)
Definition: item_func.h:2684
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:9441
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2688
Definition: item_func.h:2658
Item_func_can_access_routine(const POS &pos, PT_item_list *list)
Definition: item_func.h:2660
const char * func_name() const override
Definition: item_func.h:2663
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:9295
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2664
Definition: item_func.h:2621
const char * func_name() const override
Definition: item_func.h:2626
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2627
Item_func_can_access_table(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2623
longlong val_int() override
INFORMATION_SCHEMA picks metadata from new DD using system views.
Definition: item_func.cc:9209
Definition: item_func.h:2645
Item_func_can_access_trigger(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2647
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2651
longlong val_int() override
INFORMATION_SCHEMA picks metadata from new DD using system views.
Definition: item_func.cc:9273
const char * func_name() const override
Definition: item_func.h:2650
Definition: item_func.h:2633
const char * func_name() const override
Definition: item_func.h:2638
Item_func_can_access_user(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2635
longlong val_int() override
INFORMATION_SCHEMA picks metadata from new DD using system views.
Definition: item_func.cc:9232
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2639
Definition: item_func.h:2695
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:9579
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2701
Item_func_can_access_view(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2697
const char * func_name() const override
Definition: item_func.h:2700
Definition: item_func.h:1507
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:1516
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1515
const char * func_name() const override
Definition: item_func.h:1511
enum Functype functype() const override
Definition: item_func.h:1517
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:3553
my_decimal * decimal_op(my_decimal *) override
Evaluates item when resulting data type is DECIMAL.
Definition: item_func.cc:3559
Item_func_ceiling(const POS &pos, Item *a)
Definition: item_func.h:1510
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:3530
Item_func_ceiling(Item *a)
Definition: item_func.h:1509
Definition: item_func.h:1884
Item_func_char_length(Item *a)
Definition: item_func.h:1888
Item_func_char_length(const POS &pos, Item *a)
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:1892
longlong val_int() override
Definition: item_func.cc:4501
const char * func_name() const override
Definition: item_func.h:1891
String value
Definition: item_func.h:1885
Definition: item_func.h:1898
const char * func_name() const override
Definition: item_func.h:1904
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1905
longlong val_int() override
Definition: item_func.cc:4512
Item_func_coercibility(const POS &pos, Item *a)
Definition: item_func.h:1900
Definition: item_func.h:1111
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:1526
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:1117
Item_int_func super
Definition: item_func.h:1112
const char * func_name() const override
Definition: item_func.h:1121
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:1125
Item_func_connection_id(const POS &pos)
Definition: item_func.h:1115
longlong val_int() override
Definition: item_func.cc:1538
bool fix_fields(THD *thd, Item **ref) override
Definition: item_func.cc:1532
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:1519
Definition: item_func.h:1468
enum Functype functype() const override
Definition: item_func.h:1473
const char * func_name() const override
Definition: item_func.h:1472
double val_real() override
Definition: item_func.cc:3102
Item_func_cos(const POS &pos, Item *a)
Definition: item_func.h:1470
Definition: item_func.h:1492
const char * func_name() const override
Definition: item_func.h:1496
enum Functype functype() const override
Definition: item_func.h:1497
double val_real() override
Definition: item_func.cc:3123
Item_func_cot(const POS &pos, Item *a)
Definition: item_func.h:1494
Definition: item_func.h:1619
Item_func_degrees(const POS &pos, Item *a)
Definition: item_func.h:1621
const char * func_name() const override
Definition: item_func.h:1623
enum Functype functype() const override
Definition: item_func.h:1624
Definition: item_func.h:1292
Item_func_div_base(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1294
Item_func_div_base(Item *a, Item *b)
Definition: item_func.h:1296
uint m_prec_increment
Definition: item_func.h:1303
my_decimal * decimal_op(my_decimal *) override
Evaluates item when resulting data type is DECIMAL.
Definition: item_func.cc:2581
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:2566
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:2676
enum Functype functype() const override
Definition: item_func.h:1300
Definition: item_func.h:1315
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:2742
void set_numeric_type() override
Check arguments to determine the data type for a numeric function of two arguments.
Definition: item_func.cc:2753
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1327
Item_func_div_int(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1318
enum_field_types default_data_type() const override
Get the default data (output) type for the specific item.
Definition: item_func.h:1321
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:1328
void result_precision() override
Definition: item_func.cc:2622
const char * func_name() const override
Definition: item_func.h:1320
Item_func_div_int(Item *a, Item *b)
Definition: item_func.h:1317
Definition: item_func.h:1306
void result_precision() override
Definition: item_func.cc:2605
Item_func_div(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1308
const char * func_name() const override
Definition: item_func.h:1310
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:2642
Definition: item_func.h:1387
double val_real() override
Definition: item_func.cc:3041
enum Functype functype() const override
Definition: item_func.h:1392
const char * func_name() const override
Definition: item_func.h:1391
Item_func_exp(const POS &pos, Item *a)
Definition: item_func.h:1389
Definition: item_func.h:1952
String value
Definition: item_func.h:1953
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:4635
const char * func_name() const override
Definition: item_func.h:1960
String tmp
Definition: item_func.h:1953
Item_func_field(const POS &pos, PT_item_list *opt_list)
Definition: item_func.h:1957
longlong val_int() override
Definition: item_func.cc:4591
Item_result cmp_type
Definition: item_func.h:1954
Definition: item_func.h:1986
const CHARSET_INFO * compare_collation() const override
Definition: item_func.h:2002
const char * func_name() const override
Definition: item_func.h:2000
Item_func_find_in_set(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1997
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:4684
longlong val_int() override
Definition: item_func.cc:4712
String value2
Definition: item_func.h:1987
DTCollation cmp_collation
Definition: item_func.h:1994
uint m_enum_value
Definition: item_func.h:1993
String value
Definition: item_func.h:1987
Definition: item_func.h:1520
my_decimal * decimal_op(my_decimal *) override
Evaluates item when resulting data type is DECIMAL.
Definition: item_func.cc:3605
const char * func_name() const override
Definition: item_func.h:1524
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:1529
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:3599
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1528
Item_func_floor(const POS &pos, Item *a)
Definition: item_func.h:1523
Item_func_floor(Item *a)
Definition: item_func.h:1522
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:3576
enum Functype functype() const override
Definition: item_func.h:1530
Definition: item_func.h:4083
Item_func_found_rows(const POS &pos)
Definition: item_func.h:4087
longlong val_int() override
Definition: item_func.cc:8800
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:4096
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:8789
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:4092
Item_int_func super
Definition: item_func.h:4084
const char * func_name() const override
Definition: item_func.h:4091
Definition: item_func.h:2917
const char * func_name() const override
Definition: item_func.h:2927
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:10422
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2922
Item_func_get_dd_index_sub_part_length(const POS &pos, PT_item_list *list)
Definition: item_func.h:2919
Definition: item_func.h:2468
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:2491
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:2480
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2483
Item_int_func super
Definition: item_func.h:2469
Item_func_get_lock(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2474
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:5772
const char * func_name() const override
Definition: item_func.h:2479
String value
Definition: item_func.h:2471
bool is_non_const_over_literals(uchar *) override
Definition: item_func.h:2490
longlong val_int() override
Get a user level lock.
Definition: item_func.cc:5797
Definition: item_func.h:3566
const enum_var_type var_scope
Definition: item_func.h:3567
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:3585
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.cc:7501
longlong get_sys_var_safe(THD *thd, sys_var *var)
Definition: item_func.cc:7553
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_func.cc:7833
longlong cached_llval
Definition: item_func.h:3568
enum Functype functype() const override
Definition: item_func.h:3584
Item_func_get_system_var(const System_variable_tracker &, enum_var_type scope)
Definition: item_func.cc:7450
double val_real() override
Definition: item_func.cc:7746
String cached_strval
Definition: item_func.h:3570
const char * func_name() const override
Definition: item_func.h:3604
longlong val_int() override
Definition: item_func.cc:7568
const System_variable_tracker var_tracker
Definition: item_func.h:3574
query_id_t used_query_id
Definition: item_func.h:3572
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:3606
bool cached_null_value
Definition: item_func.h:3571
uchar cache_present
Definition: item_func.h:3573
double cached_dval
Definition: item_func.h:3569
enum Item_result result_type() const override
Definition: item_func.h:3593
bool is_non_const_over_literals(uchar *) override
Definition: item_func.h:3592
String * val_str(String *) override
Definition: item_func.cc:7653
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:7456
my_decimal * val_decimal(my_decimal *dec_buf) override
Definition: item_func.h:3600
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_func.cc:7839
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:7497
Definition: item_func.h:3439
Name_string name
Definition: item_func.h:3444
enum Item_result result_type() const override
Definition: item_func.cc:7348
double val_real() override
Definition: item_func.cc:6998
const CHARSET_INFO * charset_for_protocol() override
Definition: item_func.cc:7032
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:7196
Item_func_get_user_var(Name_string a)
Definition: item_func.h:3446
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.cc:7359
String * val_str(String *str) override
Definition: item_func.cc:6970
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:7255
enum Functype functype() const override
Definition: item_func.h:3451
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:7352
Settable_routine_parameter * get_settable_routine_parameter() override
Definition: item_func.h:3477
user_var_entry * var_entry
Definition: item_func.h:3440
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_func.cc:7339
const char * func_name() const override
Definition: item_func.h:3469
bool set_value(THD *thd, sp_rcontext *ctx, Item **it) override
Definition: item_func.cc:7370
longlong val_int() override
Definition: item_func.cc:7018
Item_result m_cached_result_type
Definition: item_func.h:3441
my_decimal * val_decimal(my_decimal *) override
Definition: item_func.cc:7008
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_func.cc:7364
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_func.h:3460
Item_func_get_user_var(const POS &pos, Name_string a)
Definition: item_func.h:3448
bool is_non_const_over_literals(uchar *) override
Definition: item_func.h:3470
Definition: item_func.h:1929
Item_func_instr(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1931
const char * func_name() const override
Definition: item_func.h:1934
Definition: item_func.h:1500
bool resolve_type_inner(THD *thd) override
Resolve type of function after all arguments have had their data types resolved.
Definition: item_func.cc:3468
Item_func_int_val(const POS &pos, Item *a)
Definition: item_func.h:1503
Item_func_int_val(Item *a)
Definition: item_func.h:1502
Definition: item_func.h:2826
longlong val_int() override
Definition: item_func.cc:9929
Item_func_internal_auto_increment(const POS &pos, PT_item_list *list)
Definition: item_func.h:2828
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
enum Functype functype() const override
Definition: item_func.h:2830
Definition: item_func.h:2751
const char * func_name() const override
Definition: item_func.h:2757
Item_func_internal_avg_row_length(const POS &pos, PT_item_list *list)
Definition: item_func.h:2753
longlong val_int() override
Definition: item_func.cc:9880
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:2841
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2848
const char * func_name() const override
Definition: item_func.h:2847
Item_func_internal_checksum(const POS &pos, PT_item_list *list)
Definition: item_func.h:2843
longlong val_int() override
Definition: item_func.cc:9941
enum Functype functype() const override
Definition: item_func.h:2845
Definition: item_func.h:2811
enum Functype functype() const override
Definition: item_func.h:2815
const char * func_name() const override
Definition: item_func.h:2817
Item_func_internal_data_free(const POS &pos, PT_item_list *list)
Definition: item_func.h:2813
longlong val_int() override
Definition: item_func.cc:9917
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2818
Definition: item_func.h:2766
longlong val_int() override
Definition: item_func.cc:9890
const char * func_name() const override
Definition: item_func.h:2772
Item_func_internal_data_length(const POS &pos, PT_item_list *list)
Definition: item_func.h:2768
enum Functype functype() const override
Definition: item_func.h:2770
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2773
Definition: item_func.h:2885
longlong val_int() override
Definition: item_func.cc:10283
Item_func_internal_dd_char_length(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2887
const char * func_name() const override
Definition: item_func.h:2891
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2892
Item_func_internal_get_view_warning_or_error(const POS &pos, PT_item_list *list)
Definition: item_func.h:2902
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2909
longlong val_int() override
Definition: item_func.cc:10362
const char * func_name() const override
Definition: item_func.h:2906
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:10016
Item_func_internal_index_column_cardinality(const POS &pos, PT_item_list *list)
Definition: item_func.h:2870
enum Functype functype() const override
Definition: item_func.h:2873
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2878
const char * func_name() const override
Definition: item_func.h:2875
Definition: item_func.h:2796
Item_func_internal_index_length(const POS &pos, PT_item_list *list)
Definition: item_func.h:2798
longlong val_int() override
Definition: item_func.cc:9908
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2803
enum Functype functype() const override
Definition: item_func.h:2800
const char * func_name() const override
Definition: item_func.h:2802
Internal function used by INFORMATION_SCHEMA implementation to check if a role is enabled.
Definition: item_func.h:4184
longlong val_int() override
Internal function used by INFORMATION_SCHEMA implementation to check if a role enabled.
Definition: item_func.cc:10542
enum Functype functype() const override
Definition: item_func.h:4190
Item_func_internal_is_enabled_role(const POS &pos, Item *a, Item *b)
Definition: item_func.h:4186
const char * func_name() const override
Definition: item_func.h:4189
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:4191
Internal function used by INFORMATION_SCHEMA implementation to check if a role is a mandatory role.
Definition: item_func.h:4149
longlong val_int() override
Internal function used by INFORMATION_SCHEMA implementation to check if a role is a mandatory role.
Definition: item_func.cc:10479
Item_func_internal_is_mandatory_role(const POS &pos, Item *a, Item *b)
Definition: item_func.h:4151
const char * func_name() const override
Definition: item_func.h:4154
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:4158
enum Functype functype() const override
Definition: item_func.h:4157
Definition: item_func.h:2855
Item_func_internal_keys_disabled(const POS &pos, Item *a)
Definition: item_func.h:2857
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2861
longlong val_int() override
INFORMATION_SCHEMA picks metadata from DD using system views.
Definition: item_func.cc:9968
const char * func_name() const override
Definition: item_func.h:2860
Definition: item_func.h:2781
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2788
const char * func_name() const override
Definition: item_func.h:2787
Item_func_internal_max_data_length(const POS &pos, PT_item_list *list)
Definition: item_func.h:2783
enum Functype functype() const override
Definition: item_func.h:2785
longlong val_int() override
Definition: item_func.cc:9899
Definition: item_func.h:2736
enum Functype functype() const override
Definition: item_func.h:2740
longlong val_int() override
Definition: item_func.cc:9868
Item_func_internal_table_rows(const POS &pos, PT_item_list *list)
Definition: item_func.h:2738
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2743
const char * func_name() const override
Definition: item_func.h:2742
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3081
Item_func_internal_tablespace_autoextend_size(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:3070
longlong val_int() override
Definition: item_func.cc:10226
enum Functype functype() const override
Definition: item_func.h:3074
const char * func_name() const override
Definition: item_func.h:3077
Definition: item_func.h:3108
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3121
Item_func_internal_tablespace_data_free(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:3110
longlong val_int() override
Definition: item_func.cc:10259
const char * func_name() const override
Definition: item_func.h:3117
enum Functype functype() const override
Definition: item_func.h:3114
Definition: item_func.h:3008
Item_func_internal_tablespace_extent_size(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:3010
enum Functype functype() const override
Definition: item_func.h:3014
longlong val_int() override
Definition: item_func.cc:10179
const char * func_name() const override
Definition: item_func.h:3017
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3021
Definition: item_func.h:2968
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2981
enum Functype functype() const override
Definition: item_func.h:2974
const char * func_name() const override
Definition: item_func.h:2977
Item_func_internal_tablespace_free_extents(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2970
longlong val_int() override
Definition: item_func.cc:10149
Definition: item_func.h:2932
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2940
enum Functype functype() const override
Definition: item_func.h:2937
Item_func_internal_tablespace_id(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2934
longlong val_int() override
Definition: item_func.cc:10116
const char * func_name() const override
Definition: item_func.h:2939
Definition: item_func.h:3028
longlong val_int() override
Definition: item_func.cc:10194
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3041
const char * func_name() const override
Definition: item_func.h:3037
Item_func_internal_tablespace_initial_size(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:3030
enum Functype functype() const override
Definition: item_func.h:3034
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2961
enum Functype functype() const override
Definition: item_func.h:2954
longlong val_int() override
Definition: item_func.cc:10131
Item_func_internal_tablespace_logfile_group_number(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2950
const char * func_name() const override
Definition: item_func.h:2957
Definition: item_func.h:3048
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3061
Item_func_internal_tablespace_maximum_size(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:3050
const char * func_name() const override
Definition: item_func.h:3057
longlong val_int() override
Definition: item_func.cc:10209
enum Functype functype() const override
Definition: item_func.h:3054
longlong val_int() override
Definition: item_func.cc:10164
enum Functype functype() const override
Definition: item_func.h:2994
Item_func_internal_tablespace_total_extents(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2990
const char * func_name() const override
Definition: item_func.h:2997
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3001
Definition: item_func.h:3088
Item_func_internal_tablespace_version(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:3090
longlong val_int() override
Definition: item_func.cc:10242
const char * func_name() const override
Definition: item_func.h:3097
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3101
enum Functype functype() const override
Definition: item_func.h:3094
const char * func_name() const override
Definition: item_func.h:4169
longlong val_int() override
Definition: item_func.cc:10513
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:4173
Item_func_internal_use_terminology_previous(const POS &pos)
Definition: item_func.h:4166
enum Functype functype() const override
Definition: item_func.h:4172
Definition: item_func.h:3909
longlong val_int() override
Check if user level lock is free.
Definition: item_func.cc:6000
Item_func_is_free_lock(const POS &pos, Item *a)
Definition: item_func.h:3915
const char * func_name() const override
Definition: item_func.h:3919
Item_int_func super
Definition: item_func.h:3910
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3923
bool is_non_const_over_literals(uchar *) override
Definition: item_func.h:3929
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:3920
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:5976
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:3930
String value
Definition: item_func.h:3912
Definition: item_func.h:3939
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3953
Item_func_is_used_lock(const POS &pos, Item *a)
Definition: item_func.h:3945
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:3960
Item_int_func super
Definition: item_func.h:3940
String value
Definition: item_func.h:3942
const char * func_name() const override
Definition: item_func.h:3949
longlong val_int() override
Check if user level lock is used and return connection id of owner.
Definition: item_func.cc:6043
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:3950
bool is_non_const_over_literals(uchar *) override
Definition: item_func.h:3959
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:6022
Definition: item_func.h:2719
Item_func_is_visible_dd_object(const POS &pos, Item *a, Item *b)
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:2729
Item_func_is_visible_dd_object(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_func.h:2725
const char * func_name() const override
Definition: item_func.h:2728
longlong val_int() override
Skip hidden tables, columns, indexes and index elements.
Definition: item_func.cc:9712
Item_func_is_visible_dd_object(const POS &pos, Item *a)
Definition: item_func.h:2721
Definition: item_func.h:2207
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2223
const char * func_name() const override
Definition: item_func.h:2217
Item_func_last_insert_id(const POS &pos, Item *a)
Definition: item_func.h:2213
Item_func_last_insert_id()
Definition: item_func.h:2211
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:2219
longlong val_int() override
Definition: item_func.cc:6075
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:2228
Item_int_func super
Definition: item_func.h:2208
Item_func_last_insert_id(const POS &pos)
Definition: item_func.h:2212
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:6067
Definition: item_func.h:1837
Item_func_length(const POS &pos, Item *a)
Definition: item_func.h:1841
String value
Definition: item_func.h:1838
const char * func_name() const override
Definition: item_func.h:1843
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1844
longlong val_int() override
Definition: item_func.cc:4475
Definition: item_func.h:1395
double val_real() override
Gateway to natural LOG function.
Definition: item_func.cc:2981
enum Functype functype() const override
Definition: item_func.h:1400
const char * func_name() const override
Definition: item_func.h:1399
Item_func_ln(const POS &pos, Item *a)
Definition: item_func.h:1397
Definition: item_func.h:1912
String value1
Definition: item_func.h:1913
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:4570
longlong val_int() override
Definition: item_func.cc:4532
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:4518
Item_func_locate(Item *a, Item *b)
Definition: item_func.h:1916
Item_func_locate(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_func.h:1919
const char * func_name() const override
Definition: item_func.h:1922
Item_func_locate(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1917
String value2
Definition: item_func.h:1913
Definition: item_func.h:1419
double val_real() override
Definition: item_func.cc:3030
enum Functype functype() const override
Definition: item_func.h:1424
const char * func_name() const override
Definition: item_func.h:1423
Item_func_log10(const POS &pos, Item *a)
Definition: item_func.h:1421
Definition: item_func.h:1412
double val_real() override
Definition: item_func.cc:3018
const char * func_name() const override
Definition: item_func.h:1416
Item_func_log2(const POS &pos, Item *a)
Definition: item_func.h:1414
Definition: item_func.h:1403
Item_func_log(const POS &pos, Item *a)
Definition: item_func.h:1405
double val_real() override
Extended but so slower LOG function.
Definition: item_func.cc:2998
Item_func_log(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1406
const char * func_name() const override
Definition: item_func.h:1408
enum Functype functype() const override
Definition: item_func.h:1409
Definition: item_func.h:3618
uint flags
Definition: item_func.h:3626
FT_INFO * ft_handler
Definition: item_func.h:3632
DTCollation cmp_collation
Definition: item_func.h:3631
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_func.cc:8102
bool fix_index(const THD *thd)
Definition: item_func.cc:8109
Item * key_item() const override
Definition: item_func.h:3681
uint key
Definition: item_func.h:3626
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:8241
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:3698
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:3877
void set_master(Item_func_match *item)
Set master MATCH function and adjust used_in_where_only value.
Definition: item_func.h:3775
longlong val_int() override
Definition: item_func.h:3688
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:3640
Ft_hints * hints
Fulltext index hints, initialized for master MATCH function only.
Definition: item_func.h:3845
const char * func_name() const override
Definition: item_func.h:3683
bool docid_in_result()
Check whether FT result contains the document ID.
Definition: item_func.h:3745
Item * concat_ws
Definition: item_func.h:3641
bool can_skip_ranking()
Check if ranking is not needed.
Definition: item_func.h:3812
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_func.h:3670
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:3796
Table_ref * table_ref
Definition: item_func.h:3633
bool ordered_result()
Check whether FT result is ordered on rank.
Definition: item_func.h:3727
bool init_search(THD *thd)
Initialize searching within full-text index.
Definition: item_func.cc:7873
String value
Definition: item_func.h:3642
enum Functype functype() const override
Definition: item_func.h:3682
void set_hints(JOIN *join, uint ft_flag, ha_rows ft_limit, bool no_cond)
Set FT hints.
Definition: item_func.cc:8281
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:3653
Item * against
Definition: item_func.h:3625
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:7949
bool fix_fields(THD *thd, Item **ref) override
Definition: item_func.cc:7978
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:7845
bool used_in_where_only
true if MATCH function is used in WHERE condition only.
Definition: item_func.h:3858
String search_value
Definition: item_func.h:3643
bool is_simple_expression()
Check if this MATCH function is a simple expression in WHERE condition.
Definition: item_func.h:3836
Ft_hints * get_hints()
Returns pointer to Ft_hints object belonging to master MATCH function.
Definition: item_func.h:3785
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_func.cc:8262
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:3630
void set_simple_expression(bool val)
Set flag that the function is a simple expression.
Definition: item_func.h:3825
double val_real() override
Definition: item_func.cc:8209
bool simple_expression
Flag is true when MATCH function is used as a simple expression in WHERE condition,...
Definition: item_func.h:3851
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.cc:8254
Item_func_match * get_master()
Returns master MATCH function.
Definition: item_func.h:3765
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_func.cc:8192
Item_real_func super
Definition: item_func.h:3619
ulonglong get_count()
Get number of matching rows from FT handler.
Definition: item_func.h:3713
Definition: item_func.h:1737
Item_func_max(const POS &pos, PT_item_list *opt_list)
Definition: item_func.h:1739
const char * func_name() const override
Definition: item_func.h:1741
enum Functype functype() const override
Definition: item_func.h:1742
Definition: item_func.h:1634
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:4271
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:3974
bool cmp_datetimes(longlong *value, my_time_flags_t flags)
Compare arguments as datetime values.
Definition: item_func.cc:4095
TYPELIB * get_typelib() const override
Get the typelib information for an item of type set or enum.
Definition: item_func.cc:3988
bool date_op(Date_val *date, my_time_flags_t flags) override
Evaluates item when resulting data type is DATE.
Definition: item_func.cc:4241
my_decimal * val_decimal(my_decimal *) override
Definition: item_func.cc:4351
bool time_op(Time_val *time) override
Evaluates item when resulting data type is TIME.
Definition: item_func.cc:4234
String * str_op(String *) override
Evaluates item when resulting data type is a string type.
Definition: item_func.cc:4148
uint8 fsp_for_string
Fractional seconds precision to use when converting a time or timestamp expression into a string.
Definition: item_func.h:1697
double val_real() override
Definition: item_func.cc:4337
enum_field_types m_eval_type
Evaluation type, ie.
Definition: item_func.h:1683
longlong val_int() override
Definition: item_func.cc:4344
bool resolve_type_inner(THD *thd) override
Resolve type of function after all arguments have had their data types resolved.
Definition: item_func.cc:4022
Item_func_min_max(const POS &pos, PT_item_list *opt_list, bool is_least_func)
Definition: item_func.h:1636
bool has_temporal_arg() const
Returns true if at least one of the arguments was of temporal type.
Definition: item_func.h:1671
String m_string_buf
Definition: item_func.h:1676
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:4248
bool cmp_times(Time_val *value)
Compare arguments as time values.
Definition: item_func.cc:4116
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:4223
Item * temporal_item
Used for determining whether one of the arguments is of temporal type and for converting arguments to...
Definition: item_func.h:1691
enum Item_result result_type() const override
Definition: item_func.h:1657
bool cmp_dates(Date_val *value, my_time_flags_t flags)
Compare arguments as date values.
Definition: item_func.cc:4132
const bool m_is_least_func
True if LEAST function, false if GREATEST.
Definition: item_func.h:1675
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:4300
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:1728
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.h:1733
enum Functype functype() const override
Definition: item_func.h:1734
const char * func_name() const override
Definition: item_func.h:1732
Item_func_min(const POS &pos, PT_item_list *opt_list)
Definition: item_func.h:1730
Definition: item_func.h:1259
enum Functype functype() const override
Definition: item_func.h:1273
my_decimal * decimal_op(my_decimal *) override
See Item_func_plus::decimal_op for comments.
Definition: item_func.cc:2404
longlong int_op() override SUPPRESS_UBSAN
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:2353
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:2335
Item_func_minus(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1262
Item_func_minus(Item *a, Item *b)
Definition: item_func.h:1261
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:2342
const char * func_name() const override
Definition: item_func.h:1265
Definition: item_func.h:1331
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1342
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:1343
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:2855
void result_precision() override
Definition: item_func.cc:2839
Item_func_mod(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1334
const char * func_name() const override
Definition: item_func.h:1339
enum Functype functype() const override
Definition: item_func.h:1344
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:2794
Item_func_mod(Item *a, Item *b)
Definition: item_func.h:1333
my_decimal * decimal_op(my_decimal *) override
Evaluates item when resulting data type is DECIMAL.
Definition: item_func.cc:2809
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:2759
Definition: item_func.h:1276
const char * func_name() const override
Definition: item_func.h:1281
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:1288
void result_precision() override
Definition: item_func.cc:2552
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:2433
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1287
my_decimal * decimal_op(my_decimal *) override
See Item_func_plus::decimal_op for comments.
Definition: item_func.cc:2531
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:2445
Item_func_mul(Item *a, Item *b)
Definition: item_func.h:1278
enum Functype functype() const override
Definition: item_func.h:1289
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.h:1284
Item_func_mul(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1279
Definition: item_func.h:1347
Item_func_neg(const POS &pos, Item *a)
Definition: item_func.h:1350
const char * func_name() const override
Definition: item_func.h:1355
enum Functype functype() const override
Definition: item_func.h:1356
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:2904
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:2862
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:2868
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:1360
my_decimal * decimal_op(my_decimal *) override
Evaluates item when resulting data type is DECIMAL.
Definition: item_func.cc:2883
void fix_num_length_and_dec() override
Definition: item_func.cc:2897
Item_func_neg(Item *a)
Definition: item_func.h:1349
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:1359
Definition: item_func.h:986
Item_func_num1(Item *a, Item *b)
Definition: item_func.h:991
Item_func_num1(const POS &pos, Item *a)
Definition: item_func.h:989
bool date_op(Date_val *, my_time_flags_t) override
Evaluates item when resulting data type is DATE.
Definition: item_func.h:1001
void fix_num_length_and_dec() override
Definition: item_func.cc:1617
String * str_op(String *) override
Evaluates item when resulting data type is a string type.
Definition: item_func.h:997
Item_func_num1(Item *a)
Definition: item_func.h:988
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:1589
bool datetime_op(Datetime_val *, my_time_flags_t) override
Evaluates item when resulting data type is DATETIME or TIMESTAMP.
Definition: item_func.h:1009
Item_func_num1(const POS &pos, Item *a, Item *b)
Definition: item_func.h:992
bool time_op(Time_val *) override
Evaluates item when resulting data type is TIME.
Definition: item_func.h:1005
Definition: item_func.h:885
virtual void set_numeric_type()=0
longlong val_int() override
Definition: item_func.cc:1816
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:1932
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:1733
Item_func_numhybrid(const POS &pos, Item *a)
Definition: item_func.h:893
Item_func_numhybrid(mem_root_deque< Item * > *list)
Definition: item_func.h:907
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.cc:1950
enum_field_types default_data_type() const override
Get the default data (output) type for the specific item.
Definition: item_func.h:917
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:1911
bool resolve_type_inner(THD *thd) override
Resolve type of function after all arguments have had their data types resolved.
Definition: item_func.cc:1725
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item_func.h:982
Item_func_numhybrid(Item *a)
Definition: item_func.h:890
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:1697
my_decimal * val_decimal(my_decimal *) override
Definition: item_func.cc:1857
enum Item_result result_type() const override
Definition: item_func.h:916
double val_real() override
Definition: item_func.cc:1775
Item_func_numhybrid(const POS &pos, PT_item_list *list)
Definition: item_func.h:911
void fix_num_length_and_dec() override
Definition: item_func.cc:915
Item_func_numhybrid(const POS &pos, Item *a, Item *b)
Definition: item_func.h:902
Item_result hybrid_type
Definition: item_func.h:887
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:898
Definition: item_func.h:1977
const char * func_name() const override
Definition: item_func.h:1983
longlong val_int() override
Definition: item_func.cc:4661
String value
Definition: item_func.h:1978
Item_func_ord(const POS &pos, Item *a)
Definition: item_func.h:1981
Definition: item_func.h:1243
const char * func_name() const override
Definition: item_func.h:1249
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.h:1253
Item_func_plus(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1246
Item_func_plus(Item *a, Item *b)
Definition: item_func.h:1245
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:2224
longlong int_op() override SUPPRESS_UBSAN
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:2235
my_decimal * decimal_op(my_decimal *) override
Calculate plus of two decimals.
Definition: item_func.cc:2291
enum Functype functype() const override
Definition: item_func.h:1256
Definition: item_func.h:1435
double val_real() override
Definition: item_func.cc:3056
Item_func_pow(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1437
const char * func_name() const override
Definition: item_func.h:1439
enum Functype functype() const override
Definition: item_func.h:1440
Definition: item_func.h:1627
Item_func_radians(const POS &pos, Item *a)
Definition: item_func.h:1629
const char * func_name() const override
Definition: item_func.h:1631
enum Functype functype() const override
Definition: item_func.h:1632
Definition: item_func.h:1556
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:3845
double val_real() override
Definition: item_func.cc:3910
void seed_random(Item *val)
Definition: item_func.cc:3862
bool fix_fields(THD *thd, Item **ref) override
Definition: item_func.cc:3880
const char * func_name() const override
Definition: item_func.h:1568
bool first_eval
Definition: item_func.h:1560
Item_real_func super
Definition: item_func.h:1557
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:1584
rand_struct * m_rand
Definition: item_func.h:1559
Item_func_rand()
Definition: item_func.h:1562
Item_func_rand(const POS &pos)
Definition: item_func.h:1564
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:1575
Item_func_rand(const POS &pos, Item *a)
Definition: item_func.h:1563
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:3872
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_func.h:1580
Definition: item_func.h:2530
longlong val_int() override
Release all user level lock held by connection.
Definition: item_func.cc:5959
Item_int_func super
Definition: item_func.h:2531
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2542
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:2539
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:5945
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:2547
Item_func_release_all_locks(const POS &pos)
Definition: item_func.h:2534
const char * func_name() const override
Definition: item_func.h:2538
bool is_non_const_over_literals(uchar *) override
Definition: item_func.h:2546
Definition: item_func.h:2500
Item_int_func super
Definition: item_func.h:2501
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:5877
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:2511
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:2521
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2514
String value
Definition: item_func.h:2503
const char * func_name() const override
Definition: item_func.h:2510
longlong val_int() override
Release a user level lock.
Definition: item_func.cc:5901
bool is_non_const_over_literals(uchar *) override
Definition: item_func.h:2520
Item_func_release_lock(const POS &pos, Item *a)
Definition: item_func.h:2506
Definition: item_func.h:1535
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:3622
my_decimal * decimal_op(my_decimal *) override
Evaluates item when resulting data type is DECIMAL.
Definition: item_func.cc:3819
bool truncate
Definition: item_func.h:1536
Item_func_round(Item *a, Item *b, bool trunc_arg)
Definition: item_func.h:1539
longlong int_op() override
Evaluates item when resulting data type is integer type.
Definition: item_func.cc:3748
enum Functype functype() const override
Definition: item_func.h:1551
const char * func_name() const override
Definition: item_func.h:1544
Item_func_round(const POS &pos, Item *a, Item *b, bool trunc_arg)
Definition: item_func.h:1541
double real_op() override
Evaluates item when resulting data type is floating point type.
Definition: item_func.cc:3718
Definition: item_func.h:3969
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:3979
Item_func_row_count(const POS &pos)
Definition: item_func.h:3973
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:8426
const char * func_name() const override
Definition: item_func.h:3978
Item_int_func super
Definition: item_func.h:3970
longlong val_int() override
Definition: item_func.cc:8436
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:3983
This class is used to implement operations like SET @variable or @variable:= expression.
Definition: item_func.h:3370
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_func.cc:6314
void print_assignment(const THD *thd, String *str, enum_query_type query_type) const
Definition: item_func.cc:6840
type_conversion_status save_in_field(Field *field, bool no_conversions, bool can_use_result_field)
Definition: item_func.cc:6921
enum Item_result result_type() const override
Definition: item_func.h:3411
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:6370
Item_func_set_user_var(const POS &pos, Name_string a, Item *b)
Definition: item_func.h:3387
enum Item_result cached_result_type
Definition: item_func.h:3371
enum Functype functype() const override
Definition: item_func.h:3399
Item_func_set_user_var(Name_string a, Item *b)
Definition: item_func.h:3386
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:3432
void make_field(Send_field *tmp_field) override
Definition: item_func.cc:6873
String * val_str(String *str) override
Definition: item_func.cc:6825
void save_org_in_field(Field *field) override
Definition: item_func.h:3424
bool set_entry(THD *thd, bool create_if_not_exists)
Definition: item_func.cc:6328
bool fix_fields(THD *thd, Item **ref) override
Definition: item_func.cc:6356
bool null_item
Definition: item_func.h:3375
bool update()
Update user variable from value in save_result.
Definition: item_func.cc:6763
void save_item_result(Item *item)
Evaluate and store item's result.
Definition: item_func.cc:6732
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:6516
union Item_func_set_user_var::@62 save_result
longlong val_int() override
Definition: item_func.cc:6818
my_decimal * val_decimal(my_decimal *) override
Definition: item_func.cc:6832
double vreal
Definition: item_func.h:3378
my_decimal decimal_buff
Definition: item_func.h:3374
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:6861
my_decimal * vdec
Definition: item_func.h:3380
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.cc:6855
String value
Definition: item_func.h:3373
double val_real() override
Definition: item_func.cc:6811
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:6849
bool check(bool use_result_field)
This functions is invoked on SET @variable or @variable:= expression.
Definition: item_func.cc:6688
const char * func_name() const override
Definition: item_func.h:3419
Name_string name
Definition: item_func.h:3384
Item_func_set_user_var(THD *thd, Item_func_set_user_var *item)
Definition: item_func.h:3390
String * vstr
Definition: item_func.h:3379
longlong vint
Definition: item_func.h:3377
Definition: item_func.h:2165
Item_func_shift_left(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2167
const char * func_name() const override
Definition: item_func.h:2169
longlong int_op() override
Performs the operation on integers to produce a result of type INT_RESULT.
Definition: item_func.cc:3240
String * str_op(String *str) override
Performs the operation on binary strings to produce a result of type STRING_RESULT.
Definition: item_func.cc:3314
Definition: item_func.h:2176
String * str_op(String *str) override
Performs the operation on binary strings to produce a result of type STRING_RESULT.
Definition: item_func.cc:3318
Item_func_shift_right(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2178
longlong int_op() override
Performs the operation on integers to produce a result of type INT_RESULT.
Definition: item_func.cc:3241
const char * func_name() const override
Definition: item_func.h:2180
Definition: item_func.h:2150
String * eval_str_op(String *str)
Template function that evaluates the bitwise shift operation over binary string arguments.
Definition: item_func.cc:3249
longlong eval_int_op()
Template function that evaluates the bitwise shift operation over integer arguments.
Definition: item_func.cc:3224
bool binary_result_requires_binary_second_arg() const override
Definition: item_func.h:2152
Item_func_shift(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2161
Definition: item_func.h:1597
longlong val_int() override
Definition: item_func.cc:3951
Item_func_sign(const POS &pos, Item *a)
Definition: item_func.h:1599
enum Functype functype() const override
Definition: item_func.h:1601
const char * func_name() const override
Definition: item_func.h:1600
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:3943
Definition: item_func.h:1476
Item_func_sin(const POS &pos, Item *a)
Definition: item_func.h:1478
double val_real() override
Definition: item_func.cc:3109
const char * func_name() const override
Definition: item_func.h:1480
enum Functype functype() const override
Definition: item_func.h:1481
Definition: item_func.h:2273
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2297
Item_func_sleep(const POS &pos, Item *a)
Definition: item_func.h:2277
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:6215
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:2290
const char * func_name() const override
Definition: item_func.h:2280
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:2287
Item_int_func super
Definition: item_func.h:2274
longlong val_int() override
This function is just used to create tests with time gaps.
Definition: item_func.cc:6225
Definition: item_func.h:4001
sp_head * get_sp()
Definition: item_func.h:4062
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:8977
void compute_cost(CostOfItem *root_cost) const override
Compute the cost of evaluating this Item.
Definition: item_func.h:4078
double val_real() override
Definition: item_func.cc:8619
bool change_context_processor(uchar *arg) override
Definition: item_func.h:4055
longlong val_int() override
Definition: item_func.cc:8613
String * val_str(String *str) override
Definition: item_func.cc:8645
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_func.cc:8483
my_decimal * val_decimal(my_decimal *dec_buf) override
Definition: item_func.cc:8640
bool m_deterministic
true when function execution is deterministic
Definition: item_func.h:4015
const char * func_name() const override
Definition: item_func.cc:8492
Field * sp_result_field
The result field of the concrete stored function.
Definition: item_func.h:4013
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:4070
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:8550
bool val_json(Json_wrapper *result) override
Get a JSON value from an Item.
Definition: item_func.cc:8660
Field * tmp_table_field(TABLE *t_arg) override
Definition: item_func.cc:8805
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:8630
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:8625
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.cc:8635
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_func.cc:8970
const sp_name * get_name()
Definition: item_func.h:4063
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:4007
Item_result result_type() const override
Definition: item_func.cc:8782
Field * get_sp_result_field()
Definition: item_func.h:4069
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:8443
bool execute_impl(THD *thd)
Execute function and store the return value in the field.
Definition: item_func.cc:8730
bool resolve_type(THD *thd) override
Initialize local members with values from the Field interface.
Definition: item_func.cc:8599
Item_func super
Definition: item_func.h:4002
void make_field(Send_field *tmp_field) override
Definition: item_func.cc:8775
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:8459
bool execute()
Execute function & store value in field.
Definition: item_func.cc:8685
bool sp_check_access(THD *thd)
Checks if requested access to function can be granted to user.
Definition: item_func.cc:8826
enum Functype functype() const override
Definition: item_func.h:4064
sp_name * m_name
The name of the stored function.
Definition: item_func.h:4009
table_map get_initial_pseudo_tables() const override
Must not be called before the procedure is resolved, i.e.
Definition: item_func.cc:8514
bool fix_fields(THD *thd, Item **ref) override
Definition: item_func.cc:8836
sp_head * m_sp
Pointer to actual function instance (null when not resolved or executing)
Definition: item_func.h:4011
Definition: item_func.h:1427
Item_func_sqrt(const POS &pos, Item *a)
Definition: item_func.h:1429
const char * func_name() const override
Definition: item_func.h:1431
double val_real() override
Definition: item_func.cc:3048
enum Functype functype() const override
Definition: item_func.h:1432
Definition: item_func.h:1484
enum Functype functype() const override
Definition: item_func.h:1489
double val_real() override
Definition: item_func.cc:3116
Item_func_tan(const POS &pos, Item *a)
Definition: item_func.h:1486
const char * func_name() const override
Definition: item_func.h:1488
Definition: item_func.h:2404
double val_real() override
Definition: item_func.cc:5415
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:2416
Item_func_udf_decimal(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
Definition: item_func.h:2406
longlong val_int() override
Definition: item_func.cc:5405
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:2417
enum Item_result result_type() const override
Definition: item_func.h:2420
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:2413
String * val_str(String *str) override
Definition: item_func.cc:5431
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:5444
my_decimal * val_decimal(my_decimal *) override
Definition: item_func.cc:5425
Definition: item_func.h:2351
Item_func_udf_float(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
Definition: item_func.h:2353
my_decimal * val_decimal(my_decimal *dec_buf) override
Definition: item_func.h:2359
longlong val_int() override
Definition: item_func.h:2355
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:2370
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2374
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:2367
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:2371
double val_real() override
Definition: item_func.cc:5375
String * val_str(String *str) override
Definition: item_func.cc:5383
Definition: item_func.h:2381
enum Item_result result_type() const override
Definition: item_func.h:2397
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:2394
String * val_str(String *str) override
Definition: item_func.cc:5397
Item_func_udf_int(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
Definition: item_func.h:2383
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:2390
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2398
double val_real() override
Definition: item_func.h:2386
longlong val_int() override
Definition: item_func.cc:5391
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:2393
Definition: item_func.h:2424
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:5452
Item_func_udf_str(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
Definition: item_func.h:2426
String * val_str(String *) override
Definition: item_func.cc:5461
my_decimal * val_decimal(my_decimal *dec_buf) override
Definition: item_func.h:2447
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:2458
enum Item_result result_type() const override
Definition: item_func.h:2461
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:2457
longlong val_int() override
Definition: item_func.h:2439
double val_real() override
Definition: item_func.h:2430
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:2454
Definition: item_func.h:1607
Item_func_units(const POS &pos, Item *a, double mul_arg, double add_arg)
Definition: item_func.h:1611
double add
Definition: item_func.h:1608
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:3958
double val_real() override
Definition: item_func.cc:3967
double mul
Definition: item_func.h:1608
Definition: item_func.h:4107
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:4130
Item_int_func super
Definition: item_func.h:4108
longlong val_int() override
Definition: item_func.cc:9015
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:9007
Item_func_uuid_short(const POS &pos)
Definition: item_func.h:4111
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:4121
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:4116
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_func.h:4120
const char * func_name() const override
Definition: item_func.h:4114
Definition: item_func.h:1937
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1945
const char * func_name() const override
Definition: item_func.h:1942
Item_func_validate_password_strength(const POS &pos, Item *a)
Definition: item_func.h:1939
longlong val_int() override
Definition: item_func.cc:4583
Definition: item_func.h:1851
const char * func_name() const override
Definition: item_func.h:1857
String value
Definition: item_func.h:1852
Item_func_vector_dim(const POS &pos, Item *a)
Definition: item_func.h:1855
longlong val_int() override
Definition: item_func.cc:4486
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1858
Definition: item_func.h:4135
Item_static_string_func super
Definition: item_func.h:4136
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:9023
Item_func_version(const POS &pos)
Definition: item_func.cc:10274
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:415
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:668
Item_func()
Definition: item_func.h:377
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:569
bool replace_equal_field_checker(uchar **arg) override
Definition: item_func.h:617
virtual bool have_rev_func() const
Definition: item_func.h:546
Item ** args
Array of pointers to arguments.
Definition: item_func.h:108
virtual enum Functype functype() const
Definition: item_func.h:376
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:1065
bool val_arg0_datetime(Datetime_val *dt, my_time_flags_t flags)
Definition: item_func.h:572
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:826
Item_func(const POS &pos)
Definition: item_func.h:379
bool reject_vector_args()
Definition: item_func.cc:1636
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:722
Item_func(Item *a, Item *b)
Definition: item_func.h:391
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:504
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:2177
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:534
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:578
Item_func(const POS &pos, Item *a)
Definition: item_func.h:386
Item * replace_equal_field(uchar *arg) override
Definition: item_func.h:623
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
@ CURRENT_USER_IN_FUNC
Definition: item_func.h:365
@ 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
@ CURRENT_ROLE_IN_FUNC
Definition: item_func.h:366
@ 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:658
bool val_arg0_time(Time_val *time)
Definition: item_func.h:575
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:603
virtual bool eq_specific(const Item *) const
Provide a more specific equality check for a function.
Definition: item_func.h:544
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:1083
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:458
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:745
Item * gc_subst_transformer(uchar *arg) override
Transformer function for GC substitution.
Definition: item_func.cc:1371
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:368
@ OPTIMIZE_NONE
Definition: item_func.h:369
@ OPTIMIZE_EQUAL
Definition: item_func.h:373
@ OPTIMIZE_NULL
Definition: item_func.h:372
@ OPTIMIZE_KEY
Definition: item_func.h:370
@ OPTIMIZE_OP
Definition: item_func.h:371
void set_used_tables(table_map map)
Definition: item_func.h:538
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:728
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:955
bool has_timestamp_args()
Definition: item_func.h:672
virtual bool is_deprecated() const
Definition: item_func.h:568
Item_func(const POS &pos, Item *a, Item *b, Item *c, Item *d, Item *e, Item *f)
Definition: item_func.h:483
enum Type type() const override
Definition: item_func.h:375
virtual Item * key_item() const
Definition: item_func.h:547
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:436
virtual bool may_have_named_parameters() const
Named parameters are allowed in a parameter list.
Definition: item_func.h:823
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:1057
uint num_vector_args()
Definition: item_func.cc:1622
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:423
bool reject_geometry_args()
Definition: item_func.cc:1648
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:641
Item_func(const POS &pos, Item *a, Item *b)
Definition: item_func.h:398
virtual optimize_type select_optimize(const THD *)
Definition: item_func.h:545
bool has_date_args()
Definition: item_func.h:682
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:507
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:444
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:594
bool is_null_on_null() const
Definition: item_func.h:203
bool has_time_args()
Definition: item_func.h:693
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:824
virtual void fix_num_length_and_dec()
Definition: item_func.cc:901
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:933
void signal_invalid_argument_for_log()
Definition: item_func.cc:925
bool has_datetime_args()
Definition: item_func.h:704
void signal_divide_by_null()
Definition: item_func.cc:917
double check_float_overflow(double value)
Throw an error if the input double number is not finite, i.e.
Definition: item_func.h:650
Item_func(Item *a)
Definition: item_func.h:382
Item_func(mem_root_deque< Item * > *list)
Definition: item_func.h:494
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:536
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:508
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:467
table_map used_tables() const override
Definition: item_func.h:535
virtual bool contains_only_equi_join_condition() const
Whether this Item is an equi-join condition.
Definition: item_func.h:755
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:524
Item_func(Item *a, Item *b, Item *c)
Definition: item_func.h:404
uint allowed_arg_cols
Definition: item_func.h:192
Definition: item_func.h:1048
String * val_str(String *str) override
Definition: item_func.cc:1511
Item_int_func(const POS &pos, Item *a)
Definition: item_func.h:1056
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:1100
Item_int_func(Item *a, Item *b, Item *c)
Definition: item_func.h:1067
Item_int_func(const POS &pos)
Definition: item_func.h:1051
Item_int_func(Item *a, Item *b)
Definition: item_func.h:1060
Item_int_func(const POS &pos, PT_item_list *opt_list)
Definition: item_func.h:1086
double val_real() override
Definition: item_func.cc:1505
Item_int_func(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_func.h:1070
Item_int_func()
Definition: item_func.h:1050
Item_int_func(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1063
Item_int_func(Item *a)
Definition: item_func.h:1055
Item_int_func(mem_root_deque< Item * > *list)
Definition: item_func.h:1083
Item_int_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:1078
enum Item_result result_type() const override
Definition: item_func.h:1103
Item_int_func(Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:1075
Item_int_func(THD *thd, Item_int_func *item)
Definition: item_func.h:1091
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:1096
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:1099
Definition: item_func.h:2593
Item_master_pos_wait(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2595
Item_master_pos_wait(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_func.h:2597
Item_master_pos_wait(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2599
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:5540
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:1500
Definition: item_func.h:1016
String * str_op(String *) override
Evaluates item when resulting data type is a string type.
Definition: item_func.h:1030
Item_num_op(const POS &pos, Item *a, Item *b)
Definition: item_func.h:1019
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:1024
bool datetime_op(Datetime_val *, my_time_flags_t) override
Evaluates item when resulting data type is DATETIME or TIMESTAMP.
Definition: item_func.h:1042
bool time_op(Time_val *) override
Evaluates item when resulting data type is TIME.
Definition: item_func.h:1038
Item_num_op(Item *a, Item *b)
Definition: item_func.h:1018
bool date_op(Date_val *, my_time_flags_t) override
Evaluates item when resulting data type is DATE.
Definition: item_func.h:1034
void set_numeric_type() override
Check arguments to determine the data type for a numeric function of two arguments.
Definition: item_func.cc:1548
Definition: item_func.h:843
longlong val_int() override
Definition: item_func.h:871
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_func.cc:891
Item_real_func(Item *a, Item *b)
Definition: item_func.h:855
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:875
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:878
String * val_str(String *str) override
Definition: item_func.cc:881
Item_real_func(mem_root_deque< Item * > *list)
Definition: item_func.h:861
Item_real_func(const POS &pos)
Definition: item_func.h:846
Item_real_func(const POS &pos, Item *a)
Definition: item_func.h:851
enum Item_result result_type() const override
Definition: item_func.h:882
Item_real_func()
Definition: item_func.h:845
Item_real_func(const POS &pos, PT_item_list *list)
Definition: item_func.h:865
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:879
Item_real_func(Item *a)
Definition: item_func.h:850
Item_real_func(const POS &pos, Item *a, Item *b)
Definition: item_func.h:857
Item with result field.
Definition: item.h:6020
int raise_decimal_overflow()
Definition: item.h:6079
longlong raise_integer_overflow()
Definition: item.h:6074
longlong llrint_with_overflow_check(double realval)
Definition: item.h:6059
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item.cc:11580
double raise_float_overflow()
Definition: item.h:6069
A wrapper Item that normally returns its parameter, but becomes NULL when processing rows for rollup.
Definition: item_func.h:1770
const char * func_name() const override
Definition: item_func.h:1791
bool rollup_null() const
Definition: item_func.h:1816
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.cc:4378
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:4442
table_map used_tables() const override
Definition: item_func.h:1792
TYPELIB * get_typelib() const override
Get the typelib information for an item of type set or enum.
Definition: item_func.cc:4471
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.cc:4459
String * val_str(String *str) override
Definition: item_func.cc:4409
bool val_json(Json_wrapper *result) override
Get a JSON value from an Item.
Definition: item_func.cc:4431
const int m_min_rollup_level
Definition: item_func.h:1833
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_func.cc:4466
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1806
my_decimal * val_decimal(my_decimal *dec) override
Definition: item_func.cc:4420
Item_result result_type() const override
Definition: item_func.h:1805
Item_rollup_group_item(int min_rollup_level, Item *inner_item)
Definition: item_func.h:1772
void set_current_rollup_level(int level)
Definition: item_func.h:1827
int min_rollup_level() const
Definition: item_func.h:1830
int m_current_rollup_level
Definition: item_func.h:1834
longlong val_int() override
Definition: item_func.cc:4398
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:4368
Item * inner_item()
Definition: item_func.h:1814
const Item * inner_item() const
Definition: item_func.h:1815
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:4359
enum Functype functype() const override
Definition: item_func.h:1819
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_func.h:1801
double val_real() override
Definition: item_func.cc:4387
Definition: item_func.h:2558
const char * func_name() const override
Definition: item_func.h:2572
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:2584
Item_source_pos_wait(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_func.h:2567
Item_source_pos_wait(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_func.h:2565
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:2573
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:2576
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:5482
String value
Definition: item_func.h:2560
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:5469
Item_int_func super
Definition: item_func.h:2559
Item_source_pos_wait(const POS &pos, Item *a, Item *b)
Definition: item_func.h:2563
Definition: item.h:5850
Utility mixin class to be able to walk() only parts of item trees.
Definition: item.h:737
Definition: item_func.h:1161
Item_typecast_decimal(const POS &pos, Item *a, int len, int dec)
Definition: item_func.h:1166
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:1176
longlong val_int() override
Definition: item_func.cc:2083
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.cc:2142
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:1173
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:2128
const char * func_name() const override
Definition: item_func.h:1188
enum Item_result result_type() const override
Definition: item_func.h:1181
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_func.cc:2152
String * val_str(String *str) override
Definition: item_func.cc:2064
my_decimal * val_decimal(my_decimal *) override
Definition: item_func.cc:2094
double val_real() override
Definition: item_func.cc:2072
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:1177
enum Functype functype() const override
Definition: item_func.h:1189
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1182
Class used to implement CAST to floating-point data types.
Definition: item_func.h:1198
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:2216
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_func.h:1200
enum Item_result result_type() const override
Definition: item_func.h:1221
Item_typecast_real(const POS &pos, Item *a, bool as_double)
Definition: item_func.h:1206
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:1222
Item_typecast_real(Item *a)
Definition: item_func.h:1213
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:2194
String * val_str(String *str) override
Definition: item_func.cc:2159
double val_real() override
Definition: item_func.cc:2163
longlong val_int() override
Definition: item_func.h:1216
const char * func_name() const override
Definition: item_func.h:1226
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:2198
enum Functype functype() const override
Definition: item_func.h:1227
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.cc:2202
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_func.cc:2206
Definition: item_func.h:1135
const char * func_name() const override
Definition: item_func.h:1140
Item_typecast_signed(const POS &pos, Item *a)
Definition: item_func.h:1137
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:1967
longlong val_int() override
Definition: item_func.cc:1995
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:1974
enum Functype functype() const override
Definition: item_func.h:1145
Definition: item_func.h:1148
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:2024
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.cc:2031
Item_typecast_unsigned(const POS &pos, Item *a)
Definition: item_func.h:1150
longlong val_int() override
Definition: item_func.cc:2037
const char * func_name() const override
Definition: item_func.h:1153
enum Functype functype() const override
Definition: item_func.h:1158
Definition: item_func.h:2304
Item_func super
Definition: item_func.h:2305
Item_udf_func(const POS &pos, udf_func *udf_arg, PT_item_list *opt_list)
Definition: item_func.h:2311
const char * func_name() const override
Definition: item_func.h:2318
bool may_have_named_parameters() const override
Named parameters are allowed in a parameter list.
Definition: item_func.h:2341
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:2328
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:5346
bool fix_fields(THD *thd, Item **ref) override
Definition: item_func.cc:4868
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_func.cc:5340
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:2320
~Item_udf_func() override=default
Item_result result_type() const override
Definition: item_func.h:2325
udf_handler udf
Definition: item_func.h:2308
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_func.cc:5331
enum Functype functype() const override
Definition: item_func.h:2319
void compute_cost(CostOfItem *root_cost) const override
Compute the cost of evaluating this Item.
Definition: item_func.h:2336
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:2348
Definition: item_func.h:3491
double val_real() override
Definition: item_func.cc:7420
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_func.cc:7446
void set_value(const char *str, size_t length, const CHARSET_INFO *cs)
Definition: item_func.cc:7412
longlong val_int() override
Definition: item_func.cc:7425
bool val_time(Time_val *) override
Evaluate the item and return result as a time value.
Definition: item_func.h:3510
bool fix_fields(THD *thd, Item **ref) override
Definition: item_func.cc:7381
String * val_str(String *str) override
Definition: item_func.cc:7430
Name_string name
Definition: item_func.h:3492
Item_user_var_as_out_param(const POS &pos, Name_string a)
Definition: item_func.h:3496
enum Type type() const override
Definition: item_func.h:3501
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:7440
bool val_datetime(Datetime_val *, my_time_flags_t) override
Evaluate the item and return result as a datetime value.
Definition: item_func.h:3514
bool val_date(Date_val *, my_time_flags_t) override
Evaluate the item and return result as a date value.
Definition: item_func.h:3506
void set_null_value(const CHARSET_INFO *cs)
Definition: item_func.cc:7406
my_decimal * val_decimal(my_decimal *decimal_buffer) override
Definition: item_func.cc:7435
user_var_entry * entry
Definition: item_func.h:3493
Common class for: Item_func_get_system_var Item_func_get_user_var Item_func_set_user_var.
Definition: item_func.h:3134
Item_var_func(const POS &pos, Item *a)
Definition: item_func.h:3142
Item_var_func()
Definition: item_func.h:3136
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:3150
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:3153
Item_var_func(THD *thd, Item_var_func *item)
Definition: item_func.h:3139
Item_var_func(Item *a)
Definition: item_func.h:3141
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:3144
Item_var_func(const POS &pos)
Definition: item_func.h:3137
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_func.h:3147
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:929
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:3669
void set_nullable(bool nullable)
Definition: item.h:3781
DTCollation collation
Character set and collation properties assigned for this Item.
Definition: item.h:3676
bool get_date_from_int(Date_val *date, my_time_flags_t flags)
Convert val_int() to date.
Definition: item.cc:1653
bool is_nullable() const
Definition: item.h:3780
virtual bool propagate_type(THD *thd, const Type_properties &type)
Propagate data type specifications into parameters and user variables.
Definition: item.h:1314
bool get_time_from_decimal(Time_val *time)
Convert val_decimal() to time.
Definition: item.cc:1777
void set_data_type_float()
Set the data type of the Item to be single precision floating point.
Definition: item.h:1587
static Item_result type_to_result(enum_field_types type)
Definition: item.h:1042
virtual table_map used_tables() const
Definition: item.h:2414
bool get_datetime_from_non_temporal(Datetime_val *dt, my_time_flags_t flags)
Convert a non-temporal type to datetime.
Definition: item.cc:1726
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:3528
void set_data_type_double()
Set the data type of the Item to be double precision floating point.
Definition: item.h:1579
enum_field_types data_type() const
Retrieve the derived data type of the Item.
Definition: item.h:1481
Item_name_string item_name
Name from query.
Definition: item.h:3677
bool fixed
True if item has been resolved.
Definition: item.h:3769
enum_const_item_cache
How to cache constant JSON data.
Definition: item.h:998
@ CACHE_NONE
Don't cache.
Definition: item.h:1000
virtual Item_result result_type() const
Definition: item.h:1451
bool null_value
True if item is null.
Definition: item.h:3806
Type
Definition: item.h:964
@ FIELD_ITEM
A reference to a field (column) in a table.
Definition: item.h:966
@ FUNC_ITEM
A function call reference.
Definition: item.h:967
@ STRING_ITEM
A string literal value.
Definition: item.h:970
bool get_datetime_from_string(Datetime_val *dt, my_time_flags_t flags)
Convert val_str() to datetime.
Definition: item.cc:1605
bool get_datetime_from_int(Datetime_val *dt, my_time_flags_t flags)
Convert val_int() to datetime.
Definition: item.cc:1647
uint8 m_accum_properties
Definition: item.h:3847
void set_accum_properties(const Item *item)
Set accumulated properties for an Item.
Definition: item.h:3523
bool get_datetime_from_real(Datetime_val *dt, my_time_flags_t flags)
Convert val_real() to datetime.
Definition: item.cc:1627
my_decimal * val_decimal_from_real(my_decimal *decimal_value)
Definition: item.cc:371
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:3574
bool get_date_from_real(Date_val *date, my_time_flags_t flags)
Convert val_real() to date.
Definition: item.cc:1621
bool get_time_from_int(Time_val *time)
Convert val_int() to time.
Definition: item.cc:1784
bool unsigned_flag
Definition: item.h:3807
bool get_date_from_string(Date_val *date, my_time_flags_t flags)
Convert val_str() to date.
Definition: item.cc:1613
virtual bool is_null()
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item.h:2631
bool const_for_execution() const
Returns true if item is constant during one query execution.
Definition: item.h:2487
bool get_time_from_non_temporal(Time_val *time)
Convert a non-temporal type to time.
Definition: item.cc:1830
traverse_order
Definition: item.h:995
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:1771
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:3817
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:1799
bool get_datetime_from_decimal(Datetime_val *dt, my_time_flags_t flags)
Convert val_decimal() to datetime.
Definition: item.cc:1640
uint32 max_length
Maximum length of result of evaluating this item, in number of bytes.
Definition: item.h:3694
bool get_date_from_decimal(Date_val *date, my_time_flags_t flags)
Convert val_decimal() to date.
Definition: item.cc:1633
void set_data_type_longlong()
Set the data type of the Item to be longlong.
Definition: item.h:1555
bool update_null_value()
Make sure the null_value member has a correct value.
Definition: item.cc:8021
void set_data_type_decimal(uint8 precision, uint8 scale)
Set the data type of the Item to be decimal.
Definition: item.h:1569
bool get_time_from_string(Time_val *time)
Convert val_str() to time.
Definition: item.cc:1763
bool get_date_from_non_temporal(Date_val *date, my_time_flags_t flags)
Convert a non-temporal type to date.
Definition: item.cc:1745
Definition: sql_optimizer.h:133
Represents a JSON container value of type "object" (ECMA), type J_OBJECT here.
Definition: json_dom.h:374
bool add_alias(std::string_view key, Json_dom *value)
Insert the value into the object.
Definition: json_dom.h:416
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1268
Definition: sql_list.h:494
Storage for name strings.
Definition: item.h:297
A visitor that calls the specified function on every non-aggregated full-text search function (Item_f...
Definition: item_func.h:3899
std::function< bool(Item_func_match *)> m_func
Definition: item_func.h:3906
bool operator()(Item *item)
Definition: item_func.cc:8315
NonAggregatedFullTextSearchVisitor(std::function< bool(Item_func_match *)> func)
Definition: item_func.cc:8311
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:4555
Definition: item.h:663
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:2958
TABLE * table
Definition: table.h:3747
Time_val is a temporal type that represents only time.
Definition: my_temporal.h:57
Type properties, used to collect type information for later assignment to an Item object.
Definition: item.h:626
Table_flags ha_table_flags() const
The cached_table_flags is set at ha_open and ha_external_lock.
Definition: handler.h:5099
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:172
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:3167
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:3184
static const size_t extra_size
Definition: item_func.h:3256
Simple_cstring entry_name
Definition: item_func.h:3281
Item_result m_type
Value type.
Definition: item_func.h:3259
size_t m_length
Value length.
Definition: item_func.h:3258
longlong val_int(bool *null_value) const
Get the value of a variable as an integer.
Definition: item_func.cc:6576
bool unsigned_flag
Definition: item_func.h:3283
THD * m_owner
Definition: item_func.h:3260
size_t length() const
Definition: item_func.h:3355
query_id_t used_query_id() const
Definition: item_func.h:3325
THD * owner_session() const
Definition: item_func.h:3279
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:6419
void set_value(char *value, size_t length)
Definition: item_func.h:3172
String * val_str(bool *null_value, String *str, uint decimals) const
Get the value of a variable as a string.
Definition: item_func.cc:6615
user_var_entry()=default
const char * ptr() const
Definition: item_func.h:3354
void free_value()
Free the external value buffer, if it's allocated.
Definition: item_func.h:3212
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:6466
void init(THD *thd, const Simple_cstring &name, const CHARSET_INFO *cs)
Initialize all members.
Definition: item_func.cc:6454
Item_result type() const
The data type of this variable.
Definition: item_func.h:3357
void destroy()
Free all memory used by a user_var_entry instance previously created by create().
Definition: item_func.h:3344
bool alloced()
Check if m_ptr points to an external buffer previously allocated by realloc().
Definition: item_func.h:3207
void lock()
Definition: item_func.cc:6506
void unlock()
Definition: item_func.cc:6511
void set_null_value(Item_result type)
Set value to NULL.
Definition: item_func.h:3317
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:3220
DTCollation collation
Definition: item_func.h:3282
void set_type(Item_result type)
Set type of to the given value.
Definition: item_func.h:3308
char * m_ptr
Value.
Definition: item_func.h:3257
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:3274
void assert_locked() const
Assert the user variable is locked.
Definition: item_func.cc:6491
void reset_value()
Definition: item_func.h:3168
char * name_ptr()
Position inside a user_var_entry where a null-terminates array of characters representing the variabl...
Definition: item_func.h:3192
double val_real(bool *null_value) const
Get the value of a variable as a double.
Definition: item_func.cc:6547
my_decimal * val_decimal(bool *null_value, my_decimal *result) const
Get the value of a variable as a decimal.
Definition: item_func.cc:6647
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:6436
void set_used_query_id(query_id_t query_id)
Definition: item_func.h:3324
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:4239
bool agg_item_charsets_for_string_result(DTCollation &c, const char *name, Item **items, uint nitems)
Definition: item.h:4232
bool(Item::* Item_analyzer)(uchar **argp)
Definition: item.h:711
void(* Cond_traverser)(const Item *item, void *arg)
Definition: item.h:721
Item *(Item::* Item_transformer)(uchar *arg)
Type for transformers used by Item::transform and Item::compile.
Definition: item.h:720
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:1113
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:1087
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:1684
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:186
void item_func_sleep_free()
Definition: item_func.cc:6208
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:5665
double my_double_round(double value, longlong dec, bool dec_unsigned, bool truncate)
Definition: item_func.cc:3693
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:6198
void mysql_ull_cleanup(THD *thd)
Release all user level locks for this THD.
Definition: item_func.cc:5647
void retrieve_tablespace_statistics(THD *thd, Item **args, bool *null_value)
Retrieve tablespace statistics from SE.
Definition: item_func.cc:10083
bool volatile mqh_used
Definition: mysqld.cc:1333
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:8382
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:1092
void uuid_short_init()
Definition: item_func.cc:9002
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:327
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 int_to_datetime.
Definition: my_time.h:87
#define MAX_BIGINT_WIDTH
Max width for a LONGLONG.
Definition: mysql_com.h:903
thread_local MEM_ROOT ** THR_MALLOC
Definition: mysqld.cc:1593
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:200
@ VGS_CHECK_CONSTRAINT
Definition: field.h:474
@ VGS_GENERATED_COLUMN
Definition: field.h:472
Derivation
For use.
Definition: field.h:176
#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:487
int err_code
the error code found during check(if any)
Definition: item.h:494
const char * banned_function_name
the name of the function which is not allowed
Definition: item.h:501
Value_generator_source source
Definition: item.h:499
Definition: ft_global.h:77
Definition: ft_global.h:72
struct _ft_vft * please
Definition: ft_global.h:73
Definition: item.h:3157
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:414
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:422
Definition: table.h:1456
handler * file
Definition: table.h:1458
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