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