MySQL 26.10.0
Source Code Documentation
item.h
Go to the documentation of this file.
1#ifndef ITEM_INCLUDED
2#define ITEM_INCLUDED
3
4/* Copyright (c) 2000, 2026, Oracle and/or its affiliates.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2.0,
8 as published by the Free Software Foundation.
9
10 This program is designed to work with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have either included with
16 the program or referenced in the documentation.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License, version 2.0, for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
26
27#include <sys/types.h>
28
29#include <cassert>
30#include <cfloat>
31#include <climits>
32#include <cmath>
33#include <cstdio>
34#include <cstring>
35#include <memory>
36#include <new>
37#include <optional>
38#include <string>
39#include <type_traits>
40#include <vector>
41
42#include "decimal.h"
43#include "field_types.h" // enum_field_types
44#include "lex_string.h"
45#include "memory_debugging.h"
46#include "my_alloc.h"
47#include "my_bitmap.h"
48#include "my_compiler.h"
49#include "my_dbug.h"
50#include "my_double2ulonglong.h"
51#include "my_inttypes.h"
52#include "my_sys.h"
53#include "my_table_map.h"
54#include "my_temporal.h"
55#include "my_time.h"
56#include "mysql/strings/dtoa.h"
60#include "mysql_com.h"
61#include "mysql_time.h"
62#include "mysqld_error.h"
63#include "nulls.h"
64#include "sql-common/my_decimal.h" // my_decimal
65#include "sql/auth/auth_acls.h" // Access_bitmask
66#include "sql/enum_query_type.h"
67#include "sql/field.h" // Derivation
68#include "sql/mem_root_array.h"
69#include "sql/parse_location.h" // POS
70#include "sql/parse_tree_node_base.h" // Parse_tree_node
71#include "sql/sql_array.h" // Bounds_checked_array
72#include "sql/sql_const.h"
73#include "sql/sql_list.h"
74#include "sql/table.h"
75#include "sql/table_trigger_field_support.h" // Table_trigger_field_support
76#include "sql/thr_malloc.h"
77#include "sql/trigger_def.h" // enum_trigger_variable_type
78#include "sql_string.h"
79#include "string_with_len.h"
80#include "template_utils.h"
81
82class Item;
83class Item_cache;
85class Item_field;
86class Item_func;
87class Item_multi_eq;
89class Item_sum;
90class Json_wrapper;
91class Protocol;
92class Query_block;
94class sp_head;
95class sp_rcontext;
96class THD;
97class user_var_entry;
98struct COND_EQUAL;
99struct TYPELIB;
100
102
103void item_init(void); /* Init item functions */
104
105/**
106 Default condition filtering (selectivity) values used by
107 get_filtering_effect() and friends when better estimates
108 (statistics) are not available for a predicate.
109*/
110/**
111 For predicates that are always satisfied. Must be 1.0 or the filter
112 calculation logic will break down.
113*/
114constexpr float COND_FILTER_ALLPASS{1.0f};
115/// Filtering effect for equalities: col1 = col2
116constexpr float COND_FILTER_EQUALITY{0.1f};
117/// Filtering effect for inequalities: col1 > col2
118constexpr float COND_FILTER_INEQUALITY{0.3333f};
119/// Filtering effect for between: col1 BETWEEN a AND b
120constexpr float COND_FILTER_BETWEEN{0.1111f};
121/**
122 Value is out-of-date, will need recalculation.
123 This is used by post-greedy-search logic which changes the access method and
124 thus makes obsolete the filtering value calculated by best_access_path(). For
125 example, test_if_skip_sort_order().
126*/
127constexpr float COND_FILTER_STALE{-1.0f};
128/**
129 A special subcase of the above:
130 - if this is table/index/range scan, and
131 - rows_fetched is how many rows we will examine, and
132 - rows_fetched is less than the number of rows in the table (as determined
133 by test_if_cheaper_ordering() and test_if_skip_sort_order()).
134 Unlike the ordinary case where rows_fetched:
135 - is set by calculate_scan_cost(), and
136 - is how many rows pass the constant condition (so, less than we will
137 examine), and
138 - the actual rows_fetched to show in EXPLAIN is the number of rows in the
139 table (== rows which we will examine), and
140 - the constant condition's effect has to be moved to filter_effect for
141 EXPLAIN.
142*/
143constexpr float COND_FILTER_STALE_NO_CONST{-2.0f};
144
145static inline uint32 char_to_byte_length_safe(uint32 char_length_arg,
146 uint32 mbmaxlen_arg) {
147 const ulonglong tmp = ((ulonglong)char_length_arg) * mbmaxlen_arg;
148 return (tmp > UINT_MAX32) ? (uint32)UINT_MAX32 : (uint32)tmp;
149}
150
152 Item_result result_type,
153 uint8 decimals) {
154 if (is_temporal_type(real_type_to_type(data_type)))
155 return decimals ? DECIMAL_RESULT : INT_RESULT;
156 if (result_type == STRING_RESULT) return REAL_RESULT;
157 return result_type;
158}
159
160/*
161 "Declared Type Collation"
162 A combination of collation and its derivation.
163
164 Flags for collation aggregation modes:
165 MY_COLL_ALLOW_SUPERSET_CONV - allow conversion to a superset
166 MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
167 (i.e. constant).
168 MY_COLL_ALLOW_NUMERIC_CONV - if all items were numbers, convert to
169 @@character_set_connection
170 MY_COLL_ALLOW_NONE - allow return DERIVATION_NONE
171 (e.g. when aggregating for string result)
172 MY_COLL_CMP_CONV - for comparison: Allow SUPERSET and COERCIBLE
173 conversion, disallow NONE.
174*/
175
176#define MY_COLL_ALLOW_SUPERSET_CONV 1
177#define MY_COLL_ALLOW_COERCIBLE_CONV 2
178#define MY_COLL_ALLOW_NONE 4
179#define MY_COLL_ALLOW_NUMERIC_CONV 8
180
181#define MY_COLL_CMP_CONV \
182 (MY_COLL_ALLOW_SUPERSET_CONV | MY_COLL_ALLOW_COERCIBLE_CONV)
183
185 public:
189
193 }
198 }
199 DTCollation(const CHARSET_INFO *collation_arg, Derivation derivation_arg) {
200 collation = collation_arg;
201 derivation = derivation_arg;
202 set_repertoire_from_charset(collation_arg);
203 }
204 void set(const DTCollation &dt) {
205 collation = dt.collation;
208 }
209 void set(const CHARSET_INFO *collation_arg, Derivation derivation_arg) {
210 collation = collation_arg;
211 derivation = derivation_arg;
212 set_repertoire_from_charset(collation_arg);
213 }
214 void set(const CHARSET_INFO *collation_arg, Derivation derivation_arg,
215 uint repertoire_arg) {
216 collation = collation_arg;
217 derivation = derivation_arg;
218 repertoire = repertoire_arg;
219 }
220 void set_numeric() {
224 }
225 void set(const CHARSET_INFO *collation_arg) {
226 collation = collation_arg;
227 set_repertoire_from_charset(collation_arg);
228 }
229 void set(Derivation derivation_arg) { derivation = derivation_arg; }
230 void set_repertoire(uint repertoire_arg) { repertoire = repertoire_arg; }
231 bool aggregate(DTCollation &dt, uint flags = 0);
232 bool set(DTCollation &dt1, DTCollation &dt2, uint flags = 0) {
233 set(dt1);
234 return aggregate(dt2, flags);
235 }
236 const char *derivation_name() const {
237 switch (derivation) {
239 return "NUMERIC";
240 case DERIVATION_NULL:
241 return "NULL";
243 return "COERCIBLE";
245 return "IMPLICIT";
247 return "SYSCONST";
249 return "EXPLICIT";
250 case DERIVATION_NONE:
251 return "NONE";
252 default:
253 return "UNKNOWN";
254 }
255 }
256};
257
258/**
259 Class used as argument to Item::walk() together with mark_field_in_map()
260*/
262 public:
265
266 /**
267 If == NULL, update map of any table.
268 If <> NULL, update map of only this table.
269 */
270 TABLE *const table;
271 /// How to mark the map.
273};
274
275/**
276 Class used as argument to Item::walk() together with used_tables_for_level()
277*/
279 public:
281
282 Query_block *const select; ///< Level for which data is accumulated
283 table_map used_tables; ///< Accumulated used tables data
284};
285
286/*************************************************************************/
287
288/**
289 Storage for name strings.
290 Enpowers Simple_cstring with allocation routines from the sql_strmake family.
291
292 This class must stay as small as possible as we often
293 pass it into functions using call-by-value evaluation.
294
295 Don't add new members or virtual methods into this class!
296*/
298 private:
299 void set_or_copy(const char *str, size_t length, bool is_null_terminated) {
300 if (is_null_terminated)
301 set(str, length);
302 else
303 copy(str, length);
304 }
305
306 public:
308 /*
309 Please do NOT add constructor Name_string(const char *str) !
310 It will involve hidden strlen() call, which can affect
311 performance negatively. Use Name_string(str, len) instead.
312 */
313 Name_string(const char *str, size_t length) : Simple_cstring(str, length) {}
316 Name_string(const char *str, size_t length, bool is_null_terminated)
317 : Simple_cstring() {
318 set_or_copy(str, length, is_null_terminated);
319 }
320 Name_string(const LEX_STRING str, bool is_null_terminated)
321 : Simple_cstring() {
322 set_or_copy(str.str, str.length, is_null_terminated);
323 }
324 /**
325 Allocate space using sql_strmake() or sql_strmake_with_convert().
326 */
327 void copy(const char *str, size_t length, const CHARSET_INFO *cs);
328 /**
329 Variants for copy(), for various argument combinations.
330 */
331 void copy(const char *str, size_t length) {
333 }
334 void copy(const char *str) {
335 copy(str, (str ? strlen(str) : 0), system_charset_info);
336 }
337 void copy(const LEX_STRING lex) { copy(lex.str, lex.length); }
338 void copy(const LEX_STRING *lex) { copy(lex->str, lex->length); }
339 void copy(const Name_string str) { copy(str.ptr(), str.length()); }
340 /**
341 Compare name to another name in C string, case insensitively.
342 */
343 bool eq(const char *str) const {
344 assert(str && ptr());
345 return my_strcasecmp(system_charset_info, ptr(), str) == 0;
346 }
347 bool eq_safe(const char *str) const { return is_set() && str && eq(str); }
348 /**
349 Compare name to another name in Name_string, case insensitively.
350 */
351 bool eq(const Name_string name) const { return eq(name.ptr()); }
352 bool eq_safe(const Name_string name) const {
353 return is_set() && name.is_set() && eq(name);
354 }
355};
356
357#define NAME_STRING(x) Name_string(STRING_WITH_LEN(x))
358
359/**
360 Max length of an Item string for its use in an error message.
361 This should be kept in sync with MYSQL_ERRMSG_SIZE (which should
362 not be exceeded).
363*/
364#define ITEM_TO_QUERY_SUBSTRING_CHAR_LIMIT (300)
365
366extern const Name_string null_name_string;
367
368/**
369 Storage for Item names.
370 Adds "autogenerated" flag and warning functionality to Name_string.
371*/
373 private:
374 bool m_is_autogenerated; /* indicates if name of this Item
375 was autogenerated or set by user */
376 public:
380 /**
381 Set m_is_autogenerated flag to the given value.
382 */
385 }
386 /**
387 Return the auto-generated flag.
388 */
389 bool is_autogenerated() const { return m_is_autogenerated; }
390 using Name_string::copy;
391 /**
392 Copy name together with autogenerated flag.
393 Produce a warning if name was cut.
394 */
395 void copy(const char *str_arg, size_t length_arg, const CHARSET_INFO *cs_arg,
396 bool is_autogenerated_arg);
397};
398
399/**
400 Instances of Name_resolution_context store the information necessary for
401 name resolution of Items and other context analysis of a query made in
402 fix_fields().
403
404 This structure is a part of Query_block, a pointer to this structure is
405 assigned when an item is created (which happens mostly during parsing
406 (sql_yacc.yy)), but the structure itself will be initialized after parsing
407 is complete
408
409 @todo move subquery of INSERT ... SELECT and CREATE ... SELECT to
410 separate Query_block which allow to remove tricks of changing this
411 structure before and after INSERT/CREATE and its SELECT to make correct
412 field name resolution.
413*/
415 /**
416 The name resolution context to search in when an Item cannot be
417 resolved in this context (the context of an outer select)
418 */
420 /// Link to next name res context with the same query block as the base
422
423 /**
424 List of tables used to resolve the items of this context. Usually these
425 are tables from the FROM clause of SELECT statement. The exceptions are
426 INSERT ... SELECT and CREATE ... SELECT statements, where SELECT
427 subquery is not moved to a separate Query_block. For these types of
428 statements we have to change this member dynamically to ensure correct
429 name resolution of different parts of the statement.
430 */
432 /**
433 In most cases the two table references below replace 'table_list' above
434 for the purpose of name resolution. The first and last name resolution
435 table references allow us to search only in a sub-tree of the nested
436 join tree in a FROM clause. This is needed for NATURAL JOIN, JOIN ... USING
437 and JOIN ... ON.
438 */
440 /**
441 Last table to search in the list of leaf table references that begins
442 with first_name_resolution_table.
443 */
445
446 /**
447 Query_block item belong to, in case of merged VIEW it can differ from
448 Query_block where item was created, so we can't use table_list/field_list
449 from there
450 */
452
453 /*
454 Processor of errors caused during Item name resolving, now used only to
455 hide underlying tables in errors about views (i.e. it substitute some
456 errors for views)
457 */
460
461 /**
462 When true, items are resolved in this context against
463 Query_block::item_list, SELECT_lex::group_list and
464 this->table_list. If false, items are resolved only against
465 this->table_list.
466
467 @see Query_block::item_list, Query_block::group_list
468 */
470
471 /**
472 Security context of this name resolution context. It's used for views
473 and is non-zero only if the view is defined with SQL SECURITY DEFINER.
474 */
476
480 }
481};
482
483/**
484 Struct used to pass around arguments to/from
485 check_function_as_value_generator
486*/
490 : err_code(default_error_code), source(val_gen_src) {}
491 /// the order of the column in table
492 int col_index{-1};
493 /// the error code found during check(if any)
495 /*
496 If it is a generated column, default expression or check constraint
497 expression value generator.
498 */
500 /// the name of the function which is not allowed
501 const char *banned_function_name{nullptr};
502
503 /// Return the correct error code, based on whether or not if we are checking
504 /// for disallowed functions in generated column expressions, in default
505 /// value expressions or in check constraint expression.
507 return ((source == VGS_GENERATED_COLUMN)
508 ? ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
510 ? ER_DEFAULT_VAL_GENERATED_FUNCTION_IS_NOT_ALLOWED
511 : ER_CHECK_CONSTRAINT_FUNCTION_IS_NOT_ALLOWED);
512 }
513};
514/*
515 Store and restore the current state of a name resolution context.
516*/
517
519 private:
525
526 public:
527 /* Save the state of a name resolution context. */
528 void save_state(Name_resolution_context *context, Table_ref *table_list) {
529 save_table_list = context->table_list;
532 save_next_local = table_list->next_local;
534 }
535
536 /* Restore a name resolution context from saved state. */
537 void restore_state(Name_resolution_context *context, Table_ref *table_list) {
538 table_list->next_local = save_next_local;
540 context->table_list = save_table_list;
543 }
544
545 void update_next_local(Table_ref *table_list) {
546 save_next_local = table_list;
547 }
548
551 }
552};
553
554/*
555 This enum is used to report information about monotonicity of function
556 represented by Item* tree.
557 Monotonicity is defined only for Item* trees that represent table
558 partitioning expressions (i.e. have no subqueries/user vars/dynamic parameters
559 etc etc). An Item* tree is assumed to have the same monotonicity properties
560 as its corresponding function F:
561
562 [signed] longlong F(field1, field2, ...) {
563 put values of field_i into table record buffer;
564 return item->val_int();
565 }
566
567 NOTE
568 At the moment function monotonicity is not well defined (and so may be
569 incorrect) for Item trees with parameters/return types that are different
570 from INT_RESULT, may be NULL, or are unsigned.
571 It will be possible to address this issue once the related partitioning bugs
572 (BUG#16002, BUG#15447, BUG#13436) are fixed.
573
574 The NOT_NULL enums are used in TO_DAYS, since TO_DAYS('2001-00-00') returns
575 NULL which puts those rows into the NULL partition, but
576 '2000-12-31' < '2001-00-00' < '2001-01-01'. So special handling is needed
577 for this (see Bug#20577).
578*/
579
580typedef enum monotonicity_info {
581 NON_MONOTONIC, /* none of the below holds */
582 MONOTONIC_INCREASING, /* F() is unary and (x < y) => (F(x) <= F(y)) */
583 MONOTONIC_INCREASING_NOT_NULL, /* But only for valid/real x and y */
584 MONOTONIC_STRICT_INCREASING, /* F() is unary and (x < y) => (F(x) < F(y)) */
585 MONOTONIC_STRICT_INCREASING_NOT_NULL /* But only for valid/real x and y */
587
588/**
589 A type for SQL-like 3-valued Booleans: true/false/unknown.
590*/
591class Bool3 {
592 public:
593 /// @returns an instance set to "FALSE"
594 static const Bool3 false3() { return Bool3(v_FALSE); }
595 /// @returns an instance set to "UNKNOWN"
596 static const Bool3 unknown3() { return Bool3(v_UNKNOWN); }
597 /// @returns an instance set to "TRUE"
598 static const Bool3 true3() { return Bool3(v_TRUE); }
599
600 bool is_true() const { return m_val == v_TRUE; }
601 bool is_unknown() const { return m_val == v_UNKNOWN; }
602 bool is_false() const { return m_val == v_FALSE; }
603
604 private:
606 /// This is private; instead, use false3()/etc.
607 Bool3(value v) : m_val(v) {}
608
610 /*
611 No operator to convert Bool3 to bool (or int) - intentionally: how
612 would you map unknown3 to true/false?
613 It is because we want to block such conversions that Bool3 is a class
614 instead of a plain enum.
615 */
616};
617
618/**
619 Type properties, used to collect type information for later assignment
620 to an Item object. The object stores attributes signedness, max length
621 and collation. However, precision and scale (for decimal numbers) and
622 fractional second precision (for time and datetime) are not stored,
623 since any type derived from this object will have default values for these
624 attributes.
625*/
627 public:
628 /// Constructor for any signed numeric type or date type
629 /// Defaults are provided for attributes like signedness and max length
631 : m_type(type_arg),
632 m_unsigned_flag(false),
633 m_max_length(0),
635 assert(type_arg != MYSQL_TYPE_VARCHAR && type_arg != MYSQL_TYPE_JSON);
636 }
637 /// Constructor for any numeric type, with explicit signedness
638 Type_properties(enum_field_types type_arg, bool unsigned_arg)
639 : m_type(type_arg),
640 m_unsigned_flag(unsigned_arg),
641 m_max_length(0),
643 assert(is_numeric_type(type_arg) || type_arg == MYSQL_TYPE_BIT ||
644 type_arg == MYSQL_TYPE_YEAR);
645 }
646 /// Constructor for character type, with explicit character set.
647 /// Default length/max length is provided.
649 : m_type(type_arg),
650 m_unsigned_flag(false),
651 m_max_length(0),
653 /// Constructor for Item
654 Type_properties(Item &item);
656 const bool m_unsigned_flag;
659};
660
661/*************************************************************************/
662
664 public:
666 virtual ~Settable_routine_parameter() = default;
667 /**
668 Set required privileges for accessing the parameter.
669
670 @param privilege The required privileges for this field, with the
671 following alternatives:
672 MODE_IN - SELECT_ACL
673 MODE_OUT - UPDATE_ACL
674 MODE_INOUT - SELECT_ACL | UPDATE_ACL
675 */
677 [[maybe_unused]]) {}
678
679 /*
680 Set parameter value.
681
682 SYNOPSIS
683 set_value()
684 thd thread handle
685 ctx context to which parameter belongs (if it is local
686 variable).
687 it item which represents new value
688
689 RETURN
690 false if parameter value has been set,
691 true if error has occurred.
692 */
693 virtual bool set_value(THD *thd, sp_rcontext *ctx, Item **it) = 0;
694
695 virtual void set_out_param_info(Send_field *info [[maybe_unused]]) {}
696
697 virtual const Send_field *get_out_param_info() const { return nullptr; }
698};
699
700/*
701 Analyzer function
702 SYNOPSIS
703 argp in/out IN: Analysis parameter
704 OUT: Parameter to be passed to the transformer
705
706 RETURN
707 true Invoke the transformer
708 false Don't do it
709
710*/
711typedef bool (Item::*Item_analyzer)(uchar **argp);
712
713/**
714 Type for transformers used by Item::transform and Item::compile
715 @param arg Argument used by the transformer. Really a typeless pointer
716 in spite of the uchar type (historical reasons). The
717 transformer needs to cast this to the desired pointer type
718 @returns The transformed item
719*/
720typedef Item *(Item::*Item_transformer)(uchar *arg);
721typedef void (*Cond_traverser)(const Item *item, void *arg);
722
723/**
724 Utility mixin class to be able to walk() only parts of item trees.
725
726 Used with PREFIX+POSTFIX walk: in the prefix call of the Item
727 processor, we process the item X, may decide that its children should not
728 be processed (just like if they didn't exist): processor calls stop_at(X)
729 for that. Then walk() goes to a child Y; the processor tests is_stopped(Y)
730 which returns true, so processor sees that it must not do any processing
731 and returns immediately. Finally, the postfix call to the processor on X
732 tests is_stopped(X) which returns "true" and understands that the
733 not-to-be-processed children have been skipped so calls restart(). Thus,
734 any sibling of X, any part of the Item tree not under X, can then be
735 processed.
736*/
738 protected:
743
744 /// Stops walking children of this item
745 void stop_at(const Item *i) {
746 assert(stopped_at_item == nullptr);
747 stopped_at_item = i;
748 }
749
750 /**
751 @returns if we are stopped. If item 'i' is where we stopped, restarts the
752 walk for next items.
753 */
754 bool is_stopped(const Item *i) {
755 if (stopped_at_item != nullptr) {
756 /*
757 Walking was disabled for a tree part rooted a one ancestor of 'i' or
758 rooted at 'i'.
759 */
760 if (stopped_at_item == i) {
761 /*
762 Walking was disabled for the tree part rooted at 'i'; we have now just
763 returned back to this root (POSTFIX call), left the tree part:
764 enable the walk again, for other tree parts.
765 */
766 stopped_at_item = nullptr;
767 }
768 // No further processing to do for this item:
769 return true;
770 }
771 return false;
772 }
773
774 private:
775 const Item *stopped_at_item{nullptr};
776};
777
778/// Increment *num if it is less than its maximal value.
779template <typename T>
780void SafeIncrement(T *num) {
781 if (*num < std::numeric_limits<T>::max()) {
782 *num += 1;
783 }
784}
785
786/**
787 This class represents the cost of evaluating an Item. @see SortPredicates
788 to see how this is used.
789*/
790class CostOfItem final {
791 public:
792 /// Set '*this' to represent the cost of 'item'.
793 void Compute(const Item &item) {
794 if (!m_computed) {
795 ComputeInternal(item);
796 }
797 }
798
800 assert(!m_computed);
801 m_is_expensive = true;
802 }
803
804 /// Add the cost of accessing a Field_str.
806 assert(!m_computed);
808 }
809
810 /// Add the cost of accessing any other Field.
812 assert(!m_computed);
814 }
815
816 bool IsExpensive() const {
817 assert(m_computed);
818 return m_is_expensive;
819 }
820
821 /**
822 Get the cost of field access when evaluating the Item associated with this
823 object. The cost unit is arbitrary, but the relative cost of different
824 items reflect the fact that operating on Field_str is more expensive than
825 other Field subclasses.
826 */
827 double FieldCost() const {
828 assert(m_computed);
830 }
831
832 private:
833 /// The cost of accessing a Field_str, relative to other Field types.
834 /// (The value was determined using benchmarks.)
835 static constexpr double kStrFieldCost = 1.8;
836
837 /// The cost of accessing a Field other than Field_str. 1.0 by definition.
838 static constexpr double kOtherFieldCost = 1.0;
839
840 /// True if 'ComputeInternal()' has been called.
841 bool m_computed{false};
842
843 /// True if the associated Item calls user defined functions or stored
844 /// procedures.
845 bool m_is_expensive{false};
846
847 /// The number of Field_str objects accessed by the associated Item.
849
850 /// The number of other Field objects accessed by the associated Item.
852
853 /// Compute the cost of 'root' and its descendants.
854 void ComputeInternal(const Item &root);
855};
856
857/**
858 This class represents a subquery contained in some subclass of
859 Item_subselect, @see FindContainedSubqueries().
860*/
862 /// The strategy for executing the subquery.
863 enum class Strategy : char {
864 /**
865 An independent subquery that is materialized, e.g.:
866 "SELECT * FROM tab WHERE field IN <independent subquery>".
867 where 'independent subquery' does not depend on any fields in 'tab'.
868 (This corresponds to the Item_in_subselect class.)
869 */
871
872 /**
873 A subquery that is reevaluated for each row, e.g.:
874 "SELECT * FROM tab WHERE field IN <dependent subquery>" or
875 "SELECT * FROM tab WHERE field = <dependent subquery>".
876 where 'dependent subquery' depends on at least one field in 'tab'.
877 Alternatively, the subquery may be independent of 'tab', but contain
878 a non-deterministic function such as 'rand()'. Such subqueries are also
879 required to be reevaluated for each row.
880 */
882
883 /**
884 An independent single-row subquery that is evaluated once, e.g.:
885 "SELECT * FROM tab WHERE field = <independent single-row subquery>".
886 (This corresponds to the Item_singlerow_subselect class.)
887 */
889 };
890
891 /// The root path of the subquery.
893
894 /// The strategy for executing the subquery.
896
897 /// The width (in bytes) of the subquery's rows. For variable-sized values we
898 /// use Item.max_length (but cap it at kMaxItemLengthEstimate).
899 /// @see kMaxItemLengthEstimate and
900 /// @see Item_in_subselect::get_contained_subquery().
902
903 /// For a kMaterializable subquery: the root path of the plan without
904 /// injected IN-to-EXISTS conditions, i.e. the plan that is actually
905 /// executed when the subquery is materialized. Used to cost the one-time
906 /// materialization build. Falls back to 'path' if null.
908};
909
910/**
911 Base class that is used to represent any kind of expression in a
912 relational query. The class provides subclasses for simple components, like
913 literal (constant) values, column references and variable references,
914 as well as more complex expressions like comparison predicates,
915 arithmetic and string functions, row objects, function references and
916 subqueries.
917
918 The lifetime of an Item class object is often the same as a relational
919 statement, which may be used for several executions, but in some cases
920 it may also be generated for an optimized statement and thus be valid
921 only for one execution.
922
923 For Item objects with longer lifespan than one execution, we must take
924 special precautions when referencing objects with shorter lifespan.
925 For example, TABLE and Field objects against most tables are valid only for
926 one execution. For such objects, Item classes should rather reference
927 Table_ref and Item_field objects instead of TABLE and Field, because
928 these classes support dynamic rebinding of objects before each execution.
929 See Item::bind_fields() which binds new objects per execution and
930 Item::cleanup() that deletes references to such objects.
931
932 These mechanisms can also be used to handle other objects with shorter
933 lifespan, such as function references and variable references.
934*/
935class Item : public Parse_tree_node {
937
938 friend class udf_handler;
939
940 protected:
941 /**
942 Sets the result value of the function an empty string, using the current
943 character set. No memory is allocated.
944 @retval A pointer to the str_value member.
945 */
948 return &str_value;
949 }
950
951 public:
952 Item(const Item &) = delete;
953 void operator=(Item &) = delete;
954 static void *operator new(size_t size) noexcept {
955 return (*THR_MALLOC)->Alloc(size);
956 }
957 static void *operator new(size_t size, MEM_ROOT *mem_root,
958 const std::nothrow_t &arg
959 [[maybe_unused]] = std::nothrow) noexcept {
960 return mem_root->Alloc(size);
961 }
962
963 static void operator delete(void *ptr [[maybe_unused]],
964 size_t size [[maybe_unused]]) {
965 TRASH(ptr, size);
966 }
967 static void operator delete(void *, MEM_ROOT *,
968 const std::nothrow_t &) noexcept {}
969
970 enum Type {
972 FIELD_ITEM, ///< A reference to a field (column) in a table.
973 FUNC_ITEM, ///< A function call reference.
974 SUM_FUNC_ITEM, ///< A grouped aggregate function, or window function.
975 AGGR_FIELD_ITEM, ///< A special field for certain aggregate operations.
976 STRING_ITEM, ///< A string literal value.
977 INT_ITEM, ///< An integer literal value.
978 DECIMAL_ITEM, ///< A decimal literal value.
979 REAL_ITEM, ///< A floating-point literal value.
980 JSON_ITEM, ///< A JSON literal value.
981 NULL_ITEM, ///< A NULL value.
982 HEX_BIN_ITEM, ///< A hexadecimal or binary literal value.
983 DEFAULT_VALUE_ITEM, ///< A default value for a column.
984 COND_ITEM, ///< An AND or OR condition.
985 REF_ITEM, ///< An indirect reference to another item.
986 INSERT_VALUE_ITEM, ///< A value from a VALUES function (deprecated).
987 SUBQUERY_ITEM, ///< A subquery or predicate referencing a subquery.
988 ROW_ITEM, ///< A row of other items.
989 CACHE_ITEM, ///< An internal item used to cache values.
990 TYPE_HOLDER_ITEM, ///< An internal item used to help aggregate a type.
991 PARAM_ITEM, ///< A dynamic parameter used in a prepared statement.
992 ROUTINE_FIELD_ITEM, ///< A variable inside a routine (proc, func, trigger)
993 TRIGGER_FIELD_ITEM, ///< An OLD or NEW field, used in trigger definitions.
994 XPATH_NODESET_ITEM, ///< Used in XPATH expressions.
995 VALUES_COLUMN_ITEM, ///< A value from a VALUES clause.
996 NAME_CONST_ITEM ///< A NAME_CONST expression
997 };
998
1000
1002
1003 /// How to cache constant JSON data
1005 /// Don't cache
1007 /// Source data is a JSON string, parse and cache result
1009 /// Source data is SQL scalar, convert and cache result
1012
1013 enum Bool_test ///< Modifier for result transformation
1014 {
1025 };
1026
1027 // Return the default data type for a given result type
1029 switch (result) {
1030 case INT_RESULT:
1031 return MYSQL_TYPE_LONGLONG;
1032 case DECIMAL_RESULT:
1033 return MYSQL_TYPE_NEWDECIMAL;
1034 case REAL_RESULT:
1035 return MYSQL_TYPE_DOUBLE;
1036 case STRING_RESULT:
1037 return MYSQL_TYPE_VARCHAR;
1038 case INVALID_RESULT:
1039 return MYSQL_TYPE_INVALID;
1040 case ROW_RESULT:
1041 default:
1042 assert(false);
1043 }
1044 return MYSQL_TYPE_INVALID;
1045 }
1046
1047 // Return the default result type for a given data type
1049 switch (type) {
1050 case MYSQL_TYPE_TINY:
1051 case MYSQL_TYPE_SHORT:
1052 case MYSQL_TYPE_INT24:
1053 case MYSQL_TYPE_LONG:
1055 case MYSQL_TYPE_BOOL:
1056 case MYSQL_TYPE_BIT:
1057 case MYSQL_TYPE_YEAR:
1058 return INT_RESULT;
1060 case MYSQL_TYPE_DECIMAL:
1061 return DECIMAL_RESULT;
1062 case MYSQL_TYPE_FLOAT:
1063 case MYSQL_TYPE_DOUBLE:
1064 return REAL_RESULT;
1065 case MYSQL_TYPE_VARCHAR:
1067 case MYSQL_TYPE_STRING:
1071 case MYSQL_TYPE_BLOB:
1072 case MYSQL_TYPE_VECTOR:
1074 case MYSQL_TYPE_JSON:
1075 case MYSQL_TYPE_ENUM:
1076 case MYSQL_TYPE_SET:
1077 return STRING_RESULT;
1079 case MYSQL_TYPE_DATE:
1080 case MYSQL_TYPE_TIME:
1082 case MYSQL_TYPE_NEWDATE:
1085 case MYSQL_TYPE_TIME2:
1086 return STRING_RESULT;
1087 case MYSQL_TYPE_INVALID:
1088 return INVALID_RESULT;
1089 case MYSQL_TYPE_NULL:
1090 return STRING_RESULT;
1092 break;
1093 }
1094 assert(false);
1095 return INVALID_RESULT;
1096 }
1097
1098 /**
1099 Provide data type for a user or system variable, based on the type of
1100 the item that is assigned to the variable.
1101
1102 @note MYSQL_TYPE_VARCHAR is returned for all string types, but must be
1103 further adjusted based on maximum string length by the caller.
1104
1105 @param src_type Source type that variable's type is derived from
1106 */
1108 switch (src_type) {
1109 case MYSQL_TYPE_BOOL:
1110 case MYSQL_TYPE_TINY:
1111 case MYSQL_TYPE_SHORT:
1112 case MYSQL_TYPE_INT24:
1113 case MYSQL_TYPE_LONG:
1115 case MYSQL_TYPE_BIT:
1116 return MYSQL_TYPE_LONGLONG;
1117 case MYSQL_TYPE_DECIMAL:
1119 return MYSQL_TYPE_NEWDECIMAL;
1120 case MYSQL_TYPE_FLOAT:
1121 case MYSQL_TYPE_DOUBLE:
1122 return MYSQL_TYPE_DOUBLE;
1123 case MYSQL_TYPE_VARCHAR:
1125 case MYSQL_TYPE_STRING:
1126 return MYSQL_TYPE_VARCHAR;
1127 case MYSQL_TYPE_YEAR:
1128 return MYSQL_TYPE_LONGLONG;
1130 case MYSQL_TYPE_DATE:
1131 case MYSQL_TYPE_TIME:
1133 case MYSQL_TYPE_NEWDATE:
1136 case MYSQL_TYPE_TIME2:
1137 case MYSQL_TYPE_JSON:
1138 case MYSQL_TYPE_ENUM:
1139 case MYSQL_TYPE_SET:
1141 case MYSQL_TYPE_NULL:
1143 case MYSQL_TYPE_BLOB:
1144 case MYSQL_TYPE_VECTOR:
1147 return MYSQL_TYPE_VARCHAR;
1148 case MYSQL_TYPE_INVALID:
1150 return MYSQL_TYPE_INVALID;
1151 }
1152 assert(false);
1153 return MYSQL_TYPE_NULL;
1154 }
1155
1156 /// Item constructor for general use.
1157 Item();
1158
1159 /**
1160 Constructor used by Item_field, Item_ref & aggregate functions.
1161 Used for duplicating lists in processing queries with temporary tables.
1162
1163 Also used for Item_cond_and/Item_cond_or for creating top AND/OR structure
1164 of WHERE clause to protect it of optimisation changes in prepared statements
1165 */
1166 Item(THD *thd, const Item *item);
1167
1168 /**
1169 Parse-time context-independent constructor.
1170
1171 This constructor and caller constructors of child classes must not
1172 access/change thd->lex (including thd->lex->current_query_block(),
1173 thd->m_parser_state etc structures).
1174
1175 If we need to finalize the construction of the object, then we move
1176 all context-sensitive code to the itemize() virtual function.
1177
1178 The POS parameter marks this constructor and other context-independent
1179 constructors of child classes for easy recognition/separation from other
1180 (context-dependent) constructors.
1181 */
1182 explicit Item(const POS &);
1183
1184#ifdef EXTRA_DEBUG
1185 ~Item() override { item_name.set(0); }
1186#else
1187 ~Item() override = default;
1188#endif
1189
1190 private:
1191 /*
1192 Hide the contextualize*() functions: call/override the itemize()
1193 in Item class tree instead.
1194 */
1196 assert(0);
1197 return true;
1198 }
1199
1200 protected:
1201 /**
1202 Helper function to skip itemize() for grammar-allocated items
1203
1204 @param [out] res pointer to "this"
1205
1206 @retval true can skip itemize()
1207 @retval false can't skip: the item is allocated directly by the parser
1208 */
1209 bool skip_itemize(Item **res) {
1210 *res = this;
1211 return !is_parser_item;
1212 }
1213
1214 /*
1215 Checks if the function should return binary result based on the items
1216 provided as parameter.
1217 Function should only be used by Item_bit_func*
1218
1219 @param a item to check
1220 @param b item to check, may be nullptr
1221
1222 @returns true if binary result.
1223 */
1224 static bool bit_func_returns_binary(const Item *a, const Item *b);
1225
1226 /**
1227 The core function that does the actual itemization. itemize() is just a
1228 wrapper over this.
1229 */
1230 virtual bool do_itemize(Parse_context *pc, Item **res);
1231
1232 public:
1233 /**
1234 The same as contextualize() but with additional parameter
1235
1236 This function finalize the construction of Item objects (see the Item(POS)
1237 constructor): we can access/change parser contexts from the itemize()
1238 function.
1239
1240 Derived classes should not override this. If needed, they should
1241 override do_itemize().
1242
1243 @param pc current parse context
1244 @param [out] res pointer to "this" or to a newly allocated
1245 replacement object to use in the Item tree instead
1246
1247 @retval false success
1248 @retval true syntax/OOM/etc error
1249 */
1250 // Visual Studio with MSVC_CPPCHECK=ON gives warning C26435:
1251 // Function <fun> should specify exactly one of
1252 // 'virtual', 'override', or 'final'
1255 virtual bool itemize(Parse_context *pc, Item **res) final {
1256 // For condition#2 below ... If position is empty, this item was not
1257 // created in the parser; so don't show it in the parse tree.
1258 if (pc->m_show_parse_tree == nullptr || this->m_pos.is_empty())
1259 return do_itemize(pc, res);
1260
1261 Show_parse_tree *tree = pc->m_show_parse_tree.get();
1262
1263 if (begin_parse_tree(tree)) return true;
1264
1265 if (do_itemize(pc, res)) return true;
1266
1267 if (end_parse_tree(tree)) return true;
1268
1269 return false;
1270 }
1272
1273 void rename(char *new_name);
1274 void init_make_field(Send_field *tmp_field, enum enum_field_types type);
1275 /**
1276 Called for every Item after use (preparation and execution).
1277 Release all allocated resources, such as dynamic memory.
1278 Prepare for new execution by clearing cached values.
1279 Do not remove values allocated during preparation, destructor handles this.
1280 */
1281 virtual void cleanup() { marker = MARKER_NONE; }
1282 /**
1283 Called when an item has been removed, can be used to notify external
1284 objects about the removal, e.g subquery predicates that are part of
1285 the sj_candidates container.
1286 */
1287 virtual void notify_removal() {}
1288 virtual void make_field(Send_field *field);
1289 virtual Field *make_string_field(TABLE *table) const;
1290 virtual bool fix_fields(THD *, Item **);
1291 /**
1292 Fix after tables have been moved from one query_block level to the parent
1293 level, e.g by semijoin conversion.
1294 Basically re-calculate all attributes dependent on the tables.
1295
1296 @param parent_query_block query_block that tables are moved to.
1297 @param removed_query_block query_block that tables are moved away from,
1298 child of parent_query_block.
1299 */
1300 virtual void fix_after_pullout(Query_block *parent_query_block
1301 [[maybe_unused]],
1302 Query_block *removed_query_block
1303 [[maybe_unused]]) {}
1304 /*
1305 should be used in case where we are sure that we do not need
1306 complete fix_fields() procedure.
1307 */
1308 inline void quick_fix_field() { fixed = true; }
1309 virtual void set_can_use_prefix_key() {}
1310
1311 /**
1312 Propagate data type specifications into parameters and user variables.
1313 If item has descendants, propagate type recursively into these.
1314
1315 @param thd thread handler
1316 @param type Data type properties that are propagated
1317
1318 @returns false if success, true if error
1319 */
1320 virtual bool propagate_type(THD *thd [[maybe_unused]],
1321 const Type_properties &type [[maybe_unused]]) {
1322 return false;
1323 }
1324
1325 /**
1326 Wrapper for easier calling of propagate_type(const Type_properties &).
1327 @param thd thread handler
1328 @param def type to make Type_properties object
1329 @param pin if true: also mark the type as pinned
1330 @param inherit if true: also mark the type as inherited
1331
1332 @returns false if success, true if error
1333 */
1335 bool pin = false, bool inherit = false) {
1336 /*
1337 Propagate supplied type if types have not yet been assigned to expression,
1338 or type is pinned, in which case the supplied type overrides the
1339 actual type of parameters. Note we do not support "pinning" of
1340 expressions containing parameters, only standalone parameters,
1341 but this is a very minor problem.
1342 */
1343 if (data_type() != MYSQL_TYPE_INVALID && !(pin && type() == PARAM_ITEM))
1344 return false;
1345 if (propagate_type(thd, (def == MYSQL_TYPE_VARCHAR)
1347 : (def == MYSQL_TYPE_JSON)
1349 : Type_properties(def)))
1350 return true;
1351 if (pin) pin_data_type();
1352 if (inherit) set_data_type_inherited();
1353
1354 return false;
1355 }
1356
1357 /**
1358 For Items with data type JSON, mark that a string argument is treated
1359 as a scalar JSON value. Only relevant for the Item_param class.
1360 */
1361 virtual void mark_json_as_scalar() {}
1362
1363 /**
1364 If this item represents a IN/ALL/ANY/comparison_operator
1365 subquery, return that (along with data on how it will be executed).
1366 (These subqueries correspond to
1367 @see Item_in_subselect and @see Item_singlerow_subselect .) Also,
1368 @see FindContainedSubqueries() for context.
1369 @param outer_query_block the Query_block to which 'this' belongs.
1370 @returns The subquery that 'this' represents, if there is one.
1371 */
1372 virtual std::optional<ContainedSubquery> get_contained_subquery(
1373 const Query_block *outer_query_block [[maybe_unused]]) {
1374 return std::nullopt;
1375 }
1376
1377 protected:
1378 /**
1379 Helper function which does all of the work for
1380 save_in_field(Field*, bool), except some error checking common to
1381 all subclasses, which is performed by save_in_field() itself.
1382
1383 Subclasses that need to specialize the behaviour of
1384 save_in_field(), should override this function instead of
1385 save_in_field().
1386
1387 @param[in,out] field the field to save the item into
1388 @param no_conversions whether or not to allow conversions of the value
1389
1390 @return the status from saving into the field
1391 @retval TYPE_OK item saved without any errors or warnings
1392 @retval != TYPE_OK there were errors or warnings when saving the item
1393 */
1395 bool no_conversions);
1396
1397 public:
1398 /**
1399 Save the item into a field but do not emit any warnings.
1400
1401 @param field field to save the item into
1402 @param no_conversions whether or not to allow conversions of the value
1403
1404 @return the status from saving into the field
1405 @retval TYPE_OK item saved without any issues
1406 @retval != TYPE_OK there were issues saving the item
1407 */
1409 bool no_conversions);
1410 /**
1411 Save a temporal value in packed longlong format into a Field.
1412 Used in optimizer.
1413
1414 Subclasses that need to specialize this function, should override
1415 save_in_field_inner().
1416
1417 @param[in,out] field the field to save the item into
1418 @param no_conversions whether or not to allow conversions of the value
1419
1420 @return the status from saving into the field
1421 @retval TYPE_OK item saved without any errors or warnings
1422 @retval != TYPE_OK there were errors or warnings when saving the item
1423 */
1424 type_conversion_status save_in_field(Field *field, bool no_conversions);
1425
1426 /**
1427 A slightly faster value of save_in_field() that returns no error value
1428 (you will need to check thd->is_error() yourself), and does not support
1429 saving into hidden fields for functional indexes. Used by copy_funcs(),
1430 to avoid the functional call overhead and RAII setup of save_in_field().
1431 */
1432 void save_in_field_no_error_check(Field *field, bool no_conversions) {
1433 assert(!field->is_field_for_functional_index());
1434 save_in_field_inner(field, no_conversions);
1435 }
1436
1437 virtual void save_org_in_field(Field *field) { save_in_field(field, true); }
1438
1439 virtual bool send(Protocol *protocol, String *str);
1440 bool evaluate(THD *thd, String *str);
1441 /**
1442 Compare this item with another item for equality.
1443 If both pointers are the same, the items are equal.
1444 Both items must be of same type.
1445 For literal values, metadata must be the same and the values must be equal.
1446 Strings are compared with the embedded collation.
1447 For column references, table references and column names must be the same.
1448 For functions, the function type, function properties and arguments must
1449 be equal. Otherwise, see specific implementations.
1450 @todo: Current implementation requires that cache objects, ref objects
1451 and rollup wrappers are stripped away. This should be eliminated.
1452 */
1453 virtual bool eq(const Item *) const;
1454
1455 const Item *unwrap_for_eq() const;
1456
1457 virtual Item_result result_type() const { return REAL_RESULT; }
1458 /**
1459 Result type when an item appear in a numeric context.
1460 See Field::numeric_context_result_type() for more comments.
1461 */
1464 }
1465 /**
1466 Similar to result_type() but makes DATE, DATETIME, TIMESTAMP
1467 pretend to be numbers rather than strings.
1468 */
1471 : result_type();
1472 }
1473
1474 /**
1475 Set data type for item as inherited.
1476 Non-empty implementation only for dynamic parameters.
1477 */
1478 virtual void set_data_type_inherited() {}
1479
1480 /**
1481 Pin the data type for the item.
1482 Non-empty implementation only for dynamic parameters.
1483 */
1484 virtual void pin_data_type() {}
1485
1486 /// Retrieve the derived data type of the Item.
1488 return static_cast<enum_field_types>(m_data_type);
1489 }
1490
1491 /**
1492 Retrieve actual data type for an item. Equal to data_type() for
1493 all items, except parameters.
1494 */
1495 virtual enum_field_types actual_data_type() const { return data_type(); }
1496
1497 /**
1498 Get the default data (output) type for the specific item.
1499 Important for some SQL functions that may deliver multiple result types,
1500 and is used to determine data type for function's parameters that cannot
1501 be type-resolved by looking at the context.
1502 An example of such function is '+', which may return INT, DECIMAL,
1503 DOUBLE, depending on arguments.
1504 On the contrary, many other functions have a fixed output type, usually
1505 set with set_data_type_XXX(), which overrides the value of
1506 default_data_type(). For example, COS always returns DOUBLE,
1507 */
1509 // If data type has been set, the information returned here is irrelevant:
1510 assert(data_type() == MYSQL_TYPE_INVALID);
1511 return MYSQL_TYPE_VARCHAR;
1512 }
1513 /**
1514 Set the data type of the current Item. It is however recommended to
1515 use one of the type-specific setters if possible.
1516
1517 @param data_type The data type of this Item.
1518 */
1520 m_data_type = static_cast<uint8>(data_type);
1521 }
1522
1523 inline void set_data_type_null() {
1526 max_length = 0;
1527 set_nullable(true);
1528 }
1529
1530 inline void set_data_type_bool() {
1533 decimals = 0;
1534 max_length = 1;
1535 }
1536
1537 /**
1538 Set the data type of the Item to be a specific integer type
1539
1540 @param type Integer type
1541 @param unsigned_prop Whether the integer is signed or not
1542 @param max_width Maximum width of field in number of digits
1543 */
1544 inline void set_data_type_int(enum_field_types type, bool unsigned_prop,
1545 uint32 max_width) {
1546 assert(type == MYSQL_TYPE_TINY || type == MYSQL_TYPE_SHORT ||
1551 unsigned_flag = unsigned_prop;
1552 decimals = 0;
1553 fix_char_length(max_width);
1554 }
1555
1556 /**
1557 Set the data type of the Item to be longlong.
1558 Maximum display width is set to be the maximum of a 64-bit integer,
1559 but it may be adjusted later. The unsigned property is not affected.
1560 */
1564 decimals = 0;
1565 fix_char_length(21);
1566 }
1567
1568 /**
1569 Set the data type of the Item to be decimal.
1570 The unsigned property must have been set before calling this function.
1571
1572 @param precision Number of digits of precision
1573 @param scale Number of digits after decimal point.
1574 */
1575 inline void set_data_type_decimal(uint8 precision, uint8 scale) {
1578 assert(precision <= DECIMAL_MAX_PRECISION);
1579 decimals = scale;
1581 precision, scale, unsigned_flag));
1582 }
1583
1584 /// Set the data type of the Item to be double precision floating point.
1585 inline void set_data_type_double() {
1590 }
1591
1592 /// Set the data type of the Item to be single precision floating point.
1593 inline void set_data_type_float() {
1598 }
1599
1600 /**
1601 Set the Item to be variable length string. Actual type is determined from
1602 maximum string size. Collation must have been set before calling function.
1603
1604 @param max_l Maximum number of characters in string
1605 */
1606 inline void set_data_type_string(uint32 max_l) {
1613 else
1615 }
1616
1617 /**
1618 Set the Item to be variable length string. Like function above, but with
1619 larger string length precision.
1620
1621 @param max_char_length_arg Maximum number of characters in string
1622 */
1623 inline void set_data_type_string(ulonglong max_char_length_arg) {
1624 ulonglong max_result_length =
1625 max_char_length_arg * collation.collation->mbmaxlen;
1626 if (max_result_length > MAX_BLOB_WIDTH) {
1627 max_result_length = MAX_BLOB_WIDTH;
1628 m_nullable = true;
1629 }
1631 uint32(max_result_length / collation.collation->mbmaxlen));
1632 }
1633
1634 /**
1635 Set the Item to be variable length string. Like function above, but will
1636 also set character set and collation.
1637
1638 @param max_l Maximum number of characters in string
1639 @param cs Pointer to character set and collation struct
1640 */
1641 inline void set_data_type_string(uint32 max_l, const CHARSET_INFO *cs) {
1643 set_data_type_string(max_l);
1644 }
1645
1646 /**
1647 Set the Item to be variable length string. Like function above, but will
1648 also set full collation information.
1649
1650 @param max_l Maximum number of characters in string
1651 @param coll Ref to collation data, including derivation and repertoire
1652 */
1653 inline void set_data_type_string(uint32 max_l, const DTCollation &coll) {
1654 collation.set(coll);
1655 set_data_type_string(max_l);
1656 }
1657
1658 /**
1659 Set the Item to be fixed length string. Collation must have been set
1660 before calling function.
1661
1662 @param max_l Number of characters in string
1663 */
1664 inline void set_data_type_char(uint32 max_l) {
1665 assert(max_l <= MAX_CHAR_WIDTH);
1669 }
1670
1671 /**
1672 Set the Item to be fixed length string. Like function above, but will
1673 also set character set and collation.
1674
1675 @param max_l Maximum number of characters in string
1676 @param cs Pointer to character set and collation struct
1677 */
1678 inline void set_data_type_char(uint32 max_l, const CHARSET_INFO *cs) {
1680 set_data_type_char(max_l);
1681 }
1682
1683 /**
1684 Set the Item to be of BLOB type.
1685
1686 @param type Actual blob data type
1687 @param max_l Maximum number of characters in data type
1688 */
1693 ulonglong max_width = max_l * collation.collation->mbmaxlen;
1694 if (max_width > Field::MAX_LONG_BLOB_WIDTH) {
1695 max_width = Field::MAX_LONG_BLOB_WIDTH;
1696 }
1697 max_length = max_width;
1699 }
1700
1701 /// Set all type properties for Item of DATE type.
1702 inline void set_data_type_date() {
1705 decimals = 0;
1707 }
1708
1709 /**
1710 Set all type properties for Item of TIME type.
1711
1712 @param fsp Fractional seconds precision
1713 */
1714 inline void set_data_type_time(uint8 fsp) {
1715 assert(fsp <= DATETIME_MAX_DECIMALS);
1718 decimals = fsp;
1719 max_length = MAX_TIME_WIDTH + fsp + (fsp > 0 ? 1 : 0);
1720 }
1721
1722 /**
1723 Set all properties for Item of DATETIME type.
1724
1725 @param fsp Fractional seconds precision
1726 */
1728 assert(fsp <= DATETIME_MAX_DECIMALS);
1731 decimals = fsp;
1732 max_length = MAX_DATETIME_WIDTH + fsp + (fsp > 0 ? 1 : 0);
1733 }
1734
1735 /**
1736 Set all properties for Item of TIMESTAMP type.
1737
1738 @param fsp Fractional seconds precision
1739 */
1741 assert(fsp <= DATETIME_MAX_DECIMALS);
1744 decimals = fsp;
1745 max_length = MAX_DATETIME_WIDTH + fsp + (fsp > 0 ? 1 : 0);
1746 }
1747
1748 /**
1749 Set the data type of the Item to be VECTOR.
1750 */
1755 max_length = max_l;
1756 }
1757
1758 /**
1759 Set the data type of the Item to be GEOMETRY.
1760 */
1766 }
1767 /**
1768 Set the data type of the Item to be JSON.
1769 */
1775 }
1776
1777 /**
1778 Set the data type of the Item to be YEAR.
1779 */
1783 decimals = 0;
1784 fix_char_length(4); // YYYY
1785 unsigned_flag = true;
1786 }
1787
1788 /**
1789 Set the data type of the Item to be bit.
1790
1791 @param max_bits Maximum number of bits to store in this field.
1792 */
1793 void set_data_type_bit(uint32 max_bits) {
1796 max_length = max_bits;
1797 unsigned_flag = true;
1798 }
1799
1800 /**
1801 Set data type properties of the item from the properties of another item.
1802
1803 @param item Item to set data type properties from.
1804 */
1805 inline void set_data_type_from_item(const Item *item) {
1806 set_data_type(item->data_type());
1807 collation = item->collation;
1808 max_length = item->max_length;
1809 decimals = item->decimals;
1811 }
1812
1813 /**
1814 Determine correct string field type, based on string length
1815
1816 @param max_bytes Maximum string size, in number of bytes
1817 */
1819 if (max_bytes > Field::MAX_MEDIUM_BLOB_WIDTH)
1820 return MYSQL_TYPE_LONG_BLOB;
1821 else if (max_bytes > Field::MAX_VARCHAR_WIDTH)
1823 else
1824 return MYSQL_TYPE_VARCHAR;
1825 }
1826
1827 /// Get the typelib information for an item of type set or enum
1828 virtual TYPELIB *get_typelib() const { return nullptr; }
1829
1830 virtual Item_result cast_to_int_type() const { return result_type(); }
1831 virtual enum Type type() const = 0;
1832
1833 bool aggregate_type(const char *name, Item **items, uint count);
1834
1835 /*
1836 Return information about function monotonicity. See comment for
1837 enum_monotonicity_info for details. This function can only be called
1838 after fix_fields() call.
1839 */
1841 return NON_MONOTONIC;
1842 }
1843
1844 /*
1845 Convert "func_arg $CMP$ const" half-interval into "FUNC(func_arg) $CMP2$
1846 const2"
1847
1848 SYNOPSIS
1849 val_int_endpoint()
1850 left_endp false <=> The interval is "x < const" or "x <= const"
1851 true <=> The interval is "x > const" or "x >= const"
1852
1853 incl_endp IN false <=> the comparison is '<' or '>'
1854 true <=> the comparison is '<=' or '>='
1855 OUT The same but for the "F(x) $CMP$ F(const)" comparison
1856
1857 DESCRIPTION
1858 This function is defined only for unary monotonic functions. The caller
1859 supplies the source half-interval
1860
1861 x $CMP$ const
1862
1863 The value of const is supplied implicitly as the value of this item's
1864 argument, the form of $CMP$ comparison is specified through the
1865 function's arguments. The call returns the result interval
1866
1867 F(x) $CMP2$ F(const)
1868
1869 passing back F(const) as the return value, and the form of $CMP2$
1870 through the out parameter. NULL values are assumed to be comparable and
1871 be less than any non-NULL values.
1872
1873 RETURN
1874 The output range bound, which equal to the value of val_int()
1875 - If the value of the function is NULL then the bound is the
1876 smallest possible value of LLONG_MIN
1877 */
1878 virtual longlong val_int_endpoint(bool left_endp [[maybe_unused]],
1879 bool *incl_endp [[maybe_unused]]) {
1880 assert(0);
1881 return 0;
1882 }
1883
1884 /* valXXX methods must return NULL or 0 or 0.0 if null_value is set. */
1885 /*
1886 Return double precision floating point representation of item.
1887
1888 SYNOPSIS
1889 val_real()
1890
1891 RETURN
1892 In case of NULL value return 0.0 and set null_value flag to true.
1893 If value is not null null_value flag will be reset to false.
1894 */
1895 virtual double val_real() = 0;
1896 /*
1897 Return integer representation of item.
1898
1899 SYNOPSIS
1900 val_int()
1901
1902 RETURN
1903 In case of NULL value return 0 and set null_value flag to true.
1904 If value is not null null_value flag will be reset to false.
1905 */
1906 virtual longlong val_int() = 0;
1907 /**
1908 Return date value of item in packed longlong format.
1909 */
1910 virtual longlong val_date_temporal();
1911
1912 /**
1913 Produces a key suitable for filesort. Most of the time, val_int() would
1914 suffice, but for temporal values, the packed value (as sent to the handler)
1915 is called for. It is also necessary that the value is in UTC. This function
1916 supplies just that.
1917
1918 @return A sort key value.
1919 */
1921 if (data_type() == MYSQL_TYPE_TIME) {
1922 Time_val time;
1923 if (val_time(&time)) return 0;
1924 return time.for_comparison();
1925 } else if (data_type() == MYSQL_TYPE_DATE) {
1926 Date_val date;
1927 if (val_date(&date, 0)) return 0;
1928 return date.for_comparison();
1929 } else if (is_temporal_with_date()) {
1930 return val_date_temporal_at_utc();
1931 } else {
1932 return val_int();
1933 }
1934 }
1935
1936 /**
1937 Get date or time value in packed longlong format.
1938 Before conversion from MYSQL_TIME to packed format,
1939 the MYSQL_TIME value is rounded to "dec" fractional digits.
1940 */
1942
1943 /*
1944 This is just a shortcut to avoid the cast. You should still use
1945 unsigned_flag to check the sign of the item.
1946 */
1947 inline ulonglong val_uint() { return (ulonglong)val_int(); }
1948 /*
1949 Return string representation of this item object.
1950
1951 SYNOPSIS
1952 val_str()
1953 str an allocated buffer this or any nested Item object can use to
1954 store return value of this method.
1955
1956 NOTE
1957 Buffer passed via argument should only be used if the item itself
1958 doesn't have an own String buffer. In case when the item maintains
1959 it's own string buffer, it's preferable to return it instead to
1960 minimize number of mallocs/memcpys.
1961 The caller of this method can modify returned string, but only in case
1962 when it was allocated on heap, (is_alloced() is true). This allows
1963 the caller to efficiently use a buffer allocated by a child without
1964 having to allocate a buffer of it's own. The buffer, given to
1965 val_str() as argument, belongs to the caller and is later used by the
1966 caller at it's own choosing.
1967 A few implications from the above:
1968 - unless you return a string object which only points to your buffer
1969 but doesn't manages it you should be ready that it will be
1970 modified.
1971 - even for not allocated strings (is_alloced() == false) the caller
1972 can change charset (see Item_func_{typecast/binary}. XXX: is this
1973 a bug?
1974 - still you should try to minimize data copying and return internal
1975 object whenever possible.
1976
1977 RETURN
1978 In case of NULL value or error, return error_str() as this function will
1979 check if the return value may be null, and it will either set null_value
1980 to true and return nullptr or to false and it will return empty string.
1981 If value is not null set null_value flag to false before returning it.
1982 */
1983 virtual String *val_str(String *str) = 0;
1984
1985 /*
1986 Returns string representation of this item in ASCII format.
1987
1988 SYNOPSIS
1989 val_str_ascii()
1990 str - similar to val_str();
1991
1992 NOTE
1993 This method is introduced for performance optimization purposes.
1994
1995 1. val_str() result of some Items in string context
1996 depends on @@character_set_results.
1997 @@character_set_results can be set to a "real multibyte" character
1998 set like UCS2, UTF16, UTF32. (We'll use only UTF32 in the examples
1999 below for convenience.)
2000
2001 So the default string result of such functions
2002 in these circumstances is real multi-byte character set, like UTF32.
2003
2004 For example, all numbers in string context
2005 return result in @@character_set_results:
2006
2007 SELECT CONCAT(20010101); -> UTF32
2008
2009 We do sprintf() first (to get ASCII representation)
2010 and then convert to UTF32;
2011
2012 So these kind "data sources" can use ASCII representation
2013 internally, but return multi-byte data only because
2014 @@character_set_results wants so.
2015 Therefore, conversion from ASCII to UTF32 is applied internally.
2016
2017
2018 2. Some other functions need in fact ASCII input.
2019
2020 For example,
2021 inet_aton(), GeometryFromText(), Convert_TZ(), GET_FORMAT().
2022
2023 Similar, fields of certain type, like DATE, TIME,
2024 when you insert string data into them, expect in fact ASCII input.
2025 If they get non-ASCII input, for example UTF32, they
2026 convert input from UTF32 to ASCII, and then use ASCII
2027 representation to do further processing.
2028
2029
2030 3. Now imagine we pass result of a data source of the first type
2031 to a data destination of the second type.
2032
2033 What happens:
2034 a. data source converts data from ASCII to UTF32, because
2035 @@character_set_results wants so and passes the result to
2036 data destination.
2037 b. data destination gets UTF32 string.
2038 c. data destination converts UTF32 string to ASCII,
2039 because it needs ASCII representation to be able to handle data
2040 correctly.
2041
2042 As a result we get two steps of unnecessary conversion:
2043 From ASCII to UTF32, then from UTF32 to ASCII.
2044
2045 A better way to handle these situations is to pass ASCII
2046 representation directly from the source to the destination.
2047
2048 This is why val_str_ascii() introduced.
2049
2050 RETURN
2051 Similar to val_str()
2052 */
2053 virtual String *val_str_ascii(String *str);
2054
2055 /**
2056 Evaluate item and return result as a decimal value.
2057
2058 @param decimal_buffer buffer which can be used by Item for returning value
2059 (but need not be)
2060
2061 @note
2062 Returned value should not be changed if it is not the same as the one
2063 passed via argument.
2064
2065 @note Example implementation for Item with two arguments:
2066
2067 my_decimal *Item_func_<x>::decimal_op(my_decimal *decimal_value) {
2068 assert(fixed);
2069 my_decimal value1, value2;
2070 null_value = false; // Initialize null_value
2071 // First, process the first argument completely
2072 my_decimal *val1 = args[0]->val_decimal(&value1);
2073 if (val1 == nullptr) { // Handle error or NULL value
2074 null_value = args[0]->null_value; // Propagate NULL value
2075 return nullptr;
2076 }
2077 // Next, process the second argument completely
2078 my_decimal *val2 = args[1]->val_decimal(&value2);
2079 if (val2 == nullptr) { // Handle error or NULL value
2080 null_value = args[1]->null_value; // Propagate NULL value
2081 return nullptr;
2082 }
2083 // Evaluate result into decimal_value, possibly set nullptr or error
2084 if (evaluate(val1, val2) {
2085 return nullptr;
2086 }
2087 return decimal_value; // Return non-NULL result
2088 }
2089
2090 @note Example implementation that converts from other data type
2091
2092 my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value) {
2093 Date_val date;
2094 if (val_date(&date, 0)) { // Evaluate date, possibly with error or NULL
2095 return nullptr; // No NULL value propagation necessary here
2096 }
2097 if (date_to_decimal(date, decimal_value) == nullptr) {
2098 return nullptr; // In case conversion caused an error
2099 }
2100 return decimal_value;
2101 }
2102
2103 @returns pointer to my_decimal value if evaluation was successful
2104 nullptr is returned if evaluation ended in error, or a NULL value
2105 was generated. Unless error is returned, null_value indicates
2106 whether NULL value is returned or not.
2107 */
2108 virtual my_decimal *val_decimal(my_decimal *decimal_buffer) = 0;
2109 /*
2110 Return boolean value of item.
2111
2112 RETURN
2113 false value is false or NULL
2114 true value is true (not equal to 0)
2115 */
2116 virtual bool val_bool();
2117
2118 /**
2119 Get a JSON value from an Item.
2120
2121 All subclasses that can return a JSON value, should override this
2122 function. The function in the base class is not expected to be
2123 called. If it is called, it most likely means that some subclass
2124 is missing an override of val_json().
2125
2126 @param[in,out] result The resulting Json_wrapper.
2127
2128 @return false if successful, true on failure
2129 */
2130 /* purecov: begin deadcode */
2131 virtual bool val_json(Json_wrapper *result [[maybe_unused]]) {
2132 assert(false);
2133 my_error(ER_NOT_SUPPORTED_YET, MYF(0), "item type for JSON");
2134 return error_json();
2135 }
2136 /* purecov: end */
2137
2138 /**
2139 Calculate the filter contribution that is relevant for table
2140 'filter_for_table' for this item.
2141
2142 @param thd Thread handler
2143 @param filter_for_table The table we are calculating filter effect for
2144 @param read_tables Tables earlier in the join sequence.
2145 Predicates for table 'filter_for_table' that
2146 rely on values from these tables can be part of
2147 the filter effect.
2148 @param fields_to_ignore Fields in 'filter_for_table' that should not
2149 be part of the filter calculation. The filtering
2150 effect of these fields is already part of the
2151 calculation somehow (e.g. because there is a
2152 predicate "col = <const>", and the optimizer
2153 has decided to do ref access on 'col').
2154 @param rows_in_table The number of rows in table 'filter_for_table'
2155
2156 @return the filtering effect (between 0 and 1) this
2157 Item contributes with.
2158 */
2159 virtual float get_filtering_effect(THD *thd [[maybe_unused]],
2160 table_map filter_for_table
2161 [[maybe_unused]],
2162 table_map read_tables [[maybe_unused]],
2163 const MY_BITMAP *fields_to_ignore
2164 [[maybe_unused]],
2165 double rows_in_table [[maybe_unused]]) {
2166 // Filtering effect cannot be calculated for a table already read.
2167 assert((read_tables & filter_for_table) == 0);
2168 return COND_FILTER_ALLPASS;
2169 }
2170
2171 /**
2172 Get the value to return from val_json() in case of errors.
2173
2174 @see Item::error_bool
2175
2176 @return The value val_json() should return, which is true.
2177 */
2178 bool error_json() {
2180 return true;
2181 }
2182
2183 /**
2184 Convert a non-temporal type to date
2185 */
2187
2188 /**
2189 Convert a non-temporal type to time
2190 */
2192 /**
2193 Convert a non-temporal type to datetime
2194 */
2196
2197 protected:
2198 /* Helper functions, see item_sum.cc */
2216 double val_real_from_decimal();
2217 double val_real_from_string();
2218
2219 /**
2220 Get the value to return from val_bool() in case of errors.
2221
2222 This function is called from val_bool() when an error has occurred
2223 and we need to return something to abort evaluation of the
2224 item. The expected pattern in val_bool() is
2225
2226 if (@<error condition@>)
2227 {
2228 my_error(...)
2229 return error_bool();
2230 }
2231
2232 @return The value val_bool() should return.
2233 */
2234 bool error_bool() {
2236 return false;
2237 }
2238
2239 /**
2240 Get the value to return from val_int() in case of errors.
2241
2242 @see Item::error_bool
2243
2244 @return The value val_int() should return.
2245 */
2248 return 0;
2249 }
2250
2251 /**
2252 Get the value to return from val_real() in case of errors.
2253
2254 @see Item::error_bool
2255
2256 @return The value val_real() should return.
2257 */
2258 double error_real() {
2260 return 0.0;
2261 }
2262
2263 /**
2264 Get the value to return from val_date() in case of errors.
2265
2266 @see Item::error_bool
2267
2268 @return The true: the function failed.
2269 */
2270 bool error_date() {
2272 return true;
2273 }
2274
2275 /**
2276 Get the value to return from val_time() in case of errors.
2277
2278 @see Item::error_bool
2279
2280 @return The true: the function failed.
2281 */
2282 bool error_time() {
2284 return true;
2285 }
2286
2287 public:
2288 /**
2289 Get the value to return from val_str() in case of error or NULL value.
2290
2291 @see Item::error_bool
2292
2293 @return The value val_str() should return.
2294 */
2298 }
2299
2300 protected:
2301 /**
2302 Gets the value to return from val_str() when returning a NULL value.
2303 @return The value val_str() should return.
2304 */
2306 assert(m_nullable);
2307 null_value = true;
2308 return nullptr;
2309 }
2310
2311 /**
2312 Convert val_str() to date
2313 */
2315 /**
2316 Convert val_real() to date
2317 */
2319 /**
2320 Convert val_decimal() to date
2321 */
2323 /**
2324 Convert val_int() to date
2325 */
2327 /**
2328 Convert val_time() to date
2329 */
2330 bool get_date_from_time(Date_val *date);
2331 /**
2332 Convert val_datetime() to date
2333 */
2335 /**
2336 Convert a numeric type to date
2337 */
2339
2340 /**
2341 Convert val_str() to datetime
2342 */
2344 /**
2345 Convert val_real() to datetime
2346 */
2348 /**
2349 Convert val_decimal() to datetime
2350 */
2352 /**
2353 Convert val_int() to datetime
2354 */
2356 /**
2357 Convert val_time() to datetime
2358 */
2360 /**
2361 Convert val_date() to datetime
2362 */
2364
2365 /**
2366 Convert a numeric type to datetime
2367 */
2369
2370 /**
2371 Convert val_str() to time
2372 */
2373 bool get_time_from_string(Time_val *time);
2374 /**
2375 Convert val_real() to time
2376 */
2377 bool get_time_from_real(Time_val *time);
2378 /**
2379 Convert val_decimal() to time
2380 */
2381 bool get_time_from_decimal(Time_val *time);
2382 /**
2383 Convert val_int() to time
2384 */
2385 bool get_time_from_int(Time_val *time);
2386 /**
2387 Convert date to time
2388 */
2389 bool get_time_from_date(Time_val *time);
2390 /**
2391 Convert datetime to time
2392 */
2393 bool get_time_from_datetime(Time_val *time);
2394
2395 /**
2396 Convert a numeric type to time
2397 */
2398 bool get_time_from_numeric(Time_val *time);
2399
2401
2402 public:
2407
2408 /**
2409 If this Item is being materialized into a temporary table, returns the
2410 field that is being materialized into. (Typically, this is the
2411 “result_field” members for items that have one.)
2412 */
2414 DBUG_TRACE;
2415 return nullptr;
2416 }
2417 /* This is also used to create fields in CREATE ... SELECT: */
2418 virtual Field *tmp_table_field(TABLE *) { return nullptr; }
2419 virtual const char *full_name() const {
2420 return item_name.is_set() ? item_name.ptr() : "???";
2421 }
2422
2423 /* bit map of tables used by item */
2424 virtual table_map used_tables() const { return (table_map)0L; }
2425
2426 /**
2427 Return table map of tables that can't be NULL tables (tables that are
2428 used in a context where if they would contain a NULL row generated
2429 by a LEFT or RIGHT join, the item would not be true).
2430 This expression is used on WHERE item to determinate if a LEFT JOIN can be
2431 converted to a normal join.
2432 Generally this function should return used_tables() if the function
2433 would return null if any of the arguments are null
2434 As this is only used in the beginning of optimization, the value don't
2435 have to be updated in update_used_tables()
2436 */
2437 virtual table_map not_null_tables() const { return used_tables(); }
2438
2439 /**
2440 Returns true if this is a simple constant item like an integer, not
2441 a constant expression. Used in the optimizer to propagate basic constants.
2442 It is assumed that val_xxx() does not modify the item's state for
2443 such items. It is also assumed that val_str() can be called with nullptr
2444 as argument as val_str() will return an internally cached const string.
2445 */
2446 virtual bool basic_const_item() const { return false; }
2447 /**
2448 @returns true when a const item may be evaluated during resolving.
2449 Only const items that are basic const items are evaluated when
2450 resolving CREATE VIEW statements. For other statements, all
2451 const items may be evaluated during resolving.
2452 */
2453 bool may_eval_const_item(const THD *thd) const;
2454 /**
2455 @return cloned item if it is constant
2456 @retval nullptr if this is not const
2457 */
2458 virtual Item *clone_item() const { return nullptr; }
2459 virtual cond_result eq_cmp_result() const { return COND_OK; }
2460 inline uint float_length(uint decimals_par) const {
2461 return decimals != DECIMAL_NOT_SPECIFIED ? (DBL_DIG + 2 + decimals_par)
2462 : DBL_DIG + 8;
2463 }
2464 virtual uint decimal_precision() const;
2465 inline int decimal_int_part() const {
2467 }
2468 /**
2469 TIME precision of the item: 0..6
2470 */
2471 virtual uint time_precision();
2472 /**
2473 DATETIME precision of the item: 0..6
2474 */
2475 virtual uint datetime_precision();
2476 /**
2477 Returns true if item is constant, regardless of query evaluation state.
2478 An expression is constant if it:
2479 - refers no tables.
2480 - refers no subqueries that refers any tables.
2481 - refers no non-deterministic functions.
2482 - refers no statement parameters.
2483 - contains no group expression under rollup
2484 */
2485 bool const_item() const { return (used_tables() == 0); }
2486 /**
2487 Returns true if item is constant during one query execution.
2488 If const_for_execution() is true but const_item() is false, value is
2489 not available before tables have been locked and parameters have been
2490 assigned values. This applies to
2491 - statement parameters
2492 - non-dependent subqueries
2493 - deterministic stored functions that contain SQL code.
2494 For items where the default implementation of used_tables() and
2495 const_item() are effective, const_item() will always return true.
2496 */
2497 bool const_for_execution() const {
2498 return !(used_tables() & ~INNER_TABLE_BIT);
2499 }
2500
2501 /**
2502 Return true if this is a const item that may be evaluated in
2503 the current phase of statement processing.
2504 - No evaluation is performed when analyzing a view, otherwise:
2505 - Items that have the const_item() property can always be evaluated.
2506 - Items that have the const_for_execution() property can be evaluated when
2507 tables are locked (ie during optimization or execution).
2508
2509 This function should be used in the following circumstances:
2510 - during preparation to check whether an item can be permanently transformed
2511 - to check that an item is constant in functions that may be used in both
2512 the preparation and optimization phases.
2513
2514 This function should not be used by code that is called during optimization
2515 and/or execution only. Use const_for_execution() in this case.
2516 */
2517 bool may_evaluate_const(const THD *thd) const;
2518
2519 /**
2520 @returns true if this item is non-deterministic, which means that a
2521 has a component that must be evaluated once per row in
2522 execution of a JOIN query.
2523 */
2525
2526 /**
2527 @returns true if this item is an outer reference, usually this means that
2528 it references a column that contained in a table located in
2529 the FROM clause of an outer query block.
2530 */
2531 bool is_outer_reference() const {
2533 }
2534
2535 /**
2536 This method is used for to:
2537 - to generate a view definition query (SELECT-statement);
2538 - to generate a SQL-query for EXPLAIN EXTENDED;
2539 - to generate a SQL-query to be shown in INFORMATION_SCHEMA;
2540 - to generate a SQL-query that looks like a prepared statement for
2541 query_rewrite
2542 - debug.
2543
2544 For more information about view definition query, INFORMATION_SCHEMA
2545 query and why they should be generated from the Item-tree, @see
2546 mysql_register_view().
2547 */
2548 virtual void print(const THD *, String *str, enum_query_type) const {
2549 str->append(full_name());
2550 }
2551
2552 /**
2553 Generate hash unique to an item depending on its attributes. When overriding
2554 this function, care must be taken to properly handle and fix possible hash
2555 collisions, either due to missing attributes or other reasons.
2556
2557 If a unique hash cannot be generated for the Item (e.g. due to lack of
2558 available information), the NULL hash value should be returned (0).
2559 */
2560 virtual uint64_t hash() { return 0; }
2561
2562 void print_item_w_name(const THD *thd, String *,
2563 enum_query_type query_type) const;
2564 /**
2565 Prints the item when it's part of ORDER BY and GROUP BY.
2566 @param thd Thread handle
2567 @param str String to print to
2568 @param query_type How to format the item
2569 @param used_alias The alias with which this item was referenced, or
2570 nullptr if it was not referenced with an alias.
2571 */
2572 void print_for_order(const THD *thd, String *str, enum_query_type query_type,
2573 const char *used_alias) const;
2574
2575 /**
2576 Updates used tables, not null tables information and accumulates
2577 properties up the item tree, cf. used_tables_cache, not_null_tables_cache
2578 and m_accum_properties.
2579
2580 TODO(sgunders): Consider just removing these caches; it causes a lot of bugs
2581 (cache invalidation is known to be a complex problem), and the performance
2582 benefits are dubious.
2583 */
2584 virtual void update_used_tables() {}
2585
2587 return false;
2588 }
2589 /* Called for items that really have to be split */
2590 bool split_sum_func2(THD *thd, Ref_item_array ref_item_array,
2591 mem_root_deque<Item *> *fields, Item **ref,
2592 bool skip_registered);
2593 /**
2594 Evaluate the item and return result as a date value
2595
2596 @param[out] date Returned date value
2597 @param flags Limit the value returned according to TIME_NO_ZERO_IN_DATE,
2598 TIME_NO_ZERO_DATE, TIME_NO_INVALID_DATES.
2599
2600 @returns false if successful and non-NULL, true otherwise
2601 */
2602 virtual bool val_date(Date_val *date, my_time_flags_t flags) = 0;
2603 /**
2604 Evaluate the item and return result as a time value.
2605
2606 @param[out] time Returned time value.
2607
2608 @returns false if successful and non-NULL, true otherwise
2609 */
2610 virtual bool val_time(Time_val *time) = 0;
2611
2612 /**
2613 Evaluate the item and return result as a datetime value
2614
2615 @param[out] dt Returned datetime value
2616 @param flags Limit the value returned according to TIME_NO_ZERO_IN_DATE,
2617 TIME_NO_ZERO_DATE, TIME_NO_INVALID_DATES.
2618
2619 @returns false if successful and non-NULL, true otherwise
2620 true return means that the result is either a NULL value,
2621 or an error.
2622 */
2624 /**
2625 Get timestamp in "struct timeval" format.
2626 @retval false on success
2627 @retval true on error
2628 */
2629 virtual bool get_timeval(my_timeval *tm, int *warnings);
2630 /**
2631 The method allows to determine nullness of a complex expression
2632 without fully evaluating it, instead of calling val*() then
2633 checking null_value. Used in Item_func_isnull/Item_func_isnotnull
2634 and Item_sum_count/Item_sum_count_distinct.
2635 Any item which can be NULL must implement this method.
2636
2637 @retval false if the expression is not NULL.
2638 @retval true if the expression is NULL, or evaluation caused an error.
2639 The null_value member is set according to the return value.
2640 */
2641 virtual bool is_null() { return false; }
2642
2643 /**
2644 Make sure the null_value member has a correct value.
2645 null_value is set true also when evaluation causes error.
2646
2647 @returns false if success, true if error
2648 */
2649 bool update_null_value();
2650
2651 /**
2652 Apply the IS TRUE truth property, meaning that an UNKNOWN result and a
2653 FALSE result are treated the same.
2654
2655 This property is applied e.g to all conditions in WHERE, HAVING and ON
2656 clauses, and is recursively applied to operands of AND, OR
2657 operators. Some items (currently AND and subquery predicates) may enable
2658 special optimizations when they have this property.
2659 */
2660 virtual void apply_is_true() {}
2661 /*
2662 set field of temporary table for Item which can be switched on temporary
2663 table during query processing (grouping and so on). @see
2664 Item_result_field.
2665 */
2666 virtual void set_result_field(Field *) {}
2667 virtual bool is_result_field() const { return false; }
2668 virtual Field *get_result_field() const { return nullptr; }
2669 virtual bool is_bool_func() const { return false; }
2670 /*
2671 Set value of aggregate function in case of no rows for grouping were found.
2672 Also used for subqueries with outer references in SELECT list.
2673 */
2674 virtual void no_rows_in_result() {}
2675 virtual Item *copy_or_same(THD *) { return this; }
2676 virtual Item *copy_andor_structure(THD *) { return this; }
2677 /**
2678 @returns the "real item" underlying the owner object. Used to strip away
2679 Item_ref objects.
2680 @note remember to implement both real_item() functions in sub classes!
2681 */
2682 virtual Item *real_item() { return this; }
2683 virtual const Item *real_item() const { return this; }
2684 /**
2685 If an Item is materialized in a temporary table, a different Item may have
2686 to be used in the part of the query that runs after the materialization.
2687 For instance, if the Item was an Item_field, the new Item_field needs to
2688 point into the temporary table instead of the original one, but if, on the
2689 other hand, the Item was a literal constant, it can be reused as-is.
2690 This function encapsulates these policies for the different kinds of Items.
2691 See also get_tmp_table_field().
2692
2693 TODO: Document how aggregate functions (Item_sum) are handled.
2694 */
2695 virtual Item *get_tmp_table_item(THD *thd) { return copy_or_same(thd); }
2696
2697 static const CHARSET_INFO *default_charset();
2698 virtual const CHARSET_INFO *compare_collation() const { return nullptr; }
2699
2700 /*
2701 For backward compatibility, to make numeric
2702 data types return "binary" charset in client-side metadata.
2703 */
2707 : &my_charset_bin;
2708 }
2709
2710 /**
2711 Traverses a tree of Items in prefix and/or postfix order.
2712 Optionally walks into subqueries.
2713
2714 @param processor processor function to be invoked per item
2715 returns true to abort traversal, false to continue
2716 @param walk controls how to traverse the item tree
2717 enum_walk::PREFIX: call processor before invoking
2718 children enum_walk::POSTFIX: call processor after invoking children
2719 enum_walk::SUBQUERY go down into subqueries
2720 walk values are bit-coded and may be combined.
2721 Omitting both enum_walk::PREFIX and enum_walk::POSTFIX
2722 is undefined behaviour.
2723 @param arg Optional pointer to a walk-specific object
2724
2725 @retval false walk succeeded
2726 @retval true walk aborted
2727 by agreement, an error may have been reported
2728 */
2729
2730 virtual bool walk(Item_processor processor, enum_walk walk [[maybe_unused]],
2731 uchar *arg) {
2732 return ((walk & enum_walk::PREFIX) && (this->*processor)(arg)) ||
2733 ((walk & enum_walk::POSTFIX) && (this->*processor)(arg));
2734 }
2735
2736 /** @see WalkItem, CompileItem, TransformItem */
2737 template <class T>
2739 return (*reinterpret_cast<std::remove_reference_t<T> *>(arg))(this);
2740 }
2741
2742 /** See CompileItem */
2743 template <class T>
2745 return (*reinterpret_cast<std::remove_reference_t<T> *>(*arg))(this);
2746 }
2747
2748 /**
2749 Perform a generic transformation of the Item tree, by adding zero or
2750 more additional Item objects to it.
2751
2752 @param transformer Transformer function
2753 @param[in,out] arg Pointer to struct used by transformer function
2754
2755 @returns Returned item tree after transformation, NULL if error
2756
2757 Transformation is performed as follows:
2758
2759 @code
2760 transform()
2761 {
2762 transform children if any;
2763 return this->*some_transformer(...);
2764 }
2765 @endcode
2766
2767 Note that unlike Item::compile(), transform() does not support an analyzer
2768 function, ie. all children are unconditionally invoked.
2769
2770 Item::transform() should handle all transformations during preparation.
2771 Notice that all transformations are permanent; they are not rolled back.
2772
2773 Use Item::compile() to perform transformations during optimization.
2774 */
2775 virtual Item *transform(Item_transformer transformer, uchar *arg);
2776
2777 /**
2778 Perform a generic "compilation" of the Item tree, ie transform the Item tree
2779 by adding zero or more Item objects to it.
2780
2781 @param analyzer Analyzer function, see details section
2782 @param[in,out] arg_p Pointer to struct used by analyzer function
2783 @param transformer Transformer function, see details section
2784 @param[in,out] arg_t Pointer to struct used by transformer function
2785
2786 @returns Returned item tree after transformation, NULL if error
2787
2788 The process of this transformation is assumed to be as follows:
2789
2790 @code
2791 compile()
2792 {
2793 if (this->*some_analyzer(...))
2794 {
2795 compile children if any;
2796 return this->*some_transformer(...);
2797 }
2798 else
2799 return this;
2800 }
2801 @endcode
2802
2803 i.e. analysis is performed top-down while transformation is done
2804 bottom-up. If no transformation is applied, the item is returned unchanged.
2805 A transformation error is indicated by returning a NULL pointer. Notice
2806 that the analyzer function should never cause an error.
2807
2808 The function is supposed to be used during the optimization stage of
2809 query execution. All new allocations are recorded using
2810 THD::change_item_tree() so that they can be rolled back after execution.
2811
2812 @todo Pass THD to compile() function, thus no need to use current_thd.
2813 */
2814 virtual Item *compile(Item_analyzer analyzer, uchar **arg_p,
2815 Item_transformer transformer, uchar *arg_t) {
2816 if ((this->*analyzer)(arg_p)) return ((this->*transformer)(arg_t));
2817 return this;
2818 }
2819
2820 virtual void traverse_cond(Cond_traverser traverser, void *arg,
2822 (*traverser)(this, arg);
2823 }
2824
2825 /*
2826 This is used to get the most recent version of any function in
2827 an item tree. The version is the version where a MySQL function
2828 was introduced in. So any function which is added should use
2829 this function and set the int_arg to maximum of the input data
2830 and their own version info.
2831 */
2832 virtual bool intro_version(uchar *) { return false; }
2833
2834 /// cleanup() item if it is resolved ('fixed').
2836 if (fixed) cleanup();
2837 return false;
2838 }
2840 return *(pointer_cast<Item **>(arg)) == this;
2841 }
2842 virtual bool collect_item_field_processor(uchar *) { return false; }
2843 virtual bool collect_item_field_or_ref_processor(uchar *) { return false; }
2844 virtual bool collect_outer_field_processor(uchar *) { return false; }
2845
2847 public:
2850 : m_items(fields_or_refs) {}
2853 const Collect_item_fields_or_refs &) = delete;
2854
2855 friend class Item_sum;
2856 friend class Item_field;
2857 friend class Item_ref;
2858 };
2859
2861 public:
2864 /// Used to compute \c Item_field's \c m_protected_by_any_value. Pushed and
2865 /// popped when walking arguments of \c Item_func_any_value.a
2868 Query_block *transformed_block)
2869 : m_item_fields_or_view_refs(fields_or_vr),
2870 m_transformed_block(transformed_block) {}
2872 delete;
2874 const Collect_item_fields_or_view_refs &) = delete;
2875
2876 friend class Item_sum;
2877 friend class Item_field;
2879 friend class Item_view_ref;
2880 };
2881
2882 /**
2883 Collects fields and view references that have the qualifying table
2884 in the specified query block.
2885 */
2887 return false;
2888 }
2889
2890 /**
2891 Item::walk function. Set bit in table->tmp_set for all fields in
2892 table 'arg' that are referred to by the Item.
2893 */
2894 virtual bool add_field_to_set_processor(uchar *) { return false; }
2895
2896 /// A processor to handle the select lex visitor framework.
2897 virtual bool visitor_processor(uchar *arg);
2898
2899 /**
2900 Item::walk function. Set bit in table->cond_set for all fields of
2901 all tables that are referred to by the Item.
2902 */
2903 virtual bool add_field_to_cond_set_processor(uchar *) { return false; }
2904
2905 /**
2906 Visitor interface for removing all column expressions (Item_field) in
2907 this expression tree from a bitmap. @see walk()
2908
2909 @param arg A MY_BITMAP* cast to unsigned char*, where the bits represent
2910 Field::field_index values.
2911 */
2912 virtual bool remove_column_from_bitmap(uchar *arg [[maybe_unused]]) {
2913 return false;
2914 }
2915 virtual bool find_item_in_field_list_processor(uchar *) { return false; }
2916 virtual bool change_context_processor(uchar *) { return false; }
2917 virtual bool find_item_processor(uchar *arg) { return this == (void *)arg; }
2919 return !basic_const_item();
2920 }
2921 /// Is this an Item_field which references the given Field argument?
2922 virtual bool find_field_processor(uchar *) { return false; }
2923 /// Wrap incompatible arguments in CAST nodes to the expected data types
2924 virtual bool cast_incompatible_args(uchar *) { return false; }
2925 /**
2926 Mark underlying field in read or write map of a table.
2927
2928 @param arg Mark_field object
2929 */
2930 virtual bool mark_field_in_map(uchar *arg [[maybe_unused]]) { return false; }
2931
2932 protected:
2933 /**
2934 Helper function for mark_field_in_map(uchar *arg).
2935
2936 @param mark_field Mark_field object
2937 @param field Field to be marked for read/write
2938 */
2939 static inline bool mark_field_in_map(Mark_field *mark_field, Field *field) {
2940 TABLE *table = mark_field->table;
2941 if (table != nullptr && table != field->table) return false;
2942
2943 table = field->table;
2944 table->mark_column_used(field, mark_field->mark);
2945
2946 return false;
2947 }
2948
2949 public:
2950 /**
2951 Reset execution state for such window function types
2952 as determined by arg
2953
2954 @param arg pointing to a bool which, if true, says to reset state
2955 for framing window function, else for non-framing
2956 */
2957 virtual bool reset_wf_state(uchar *arg [[maybe_unused]]) { return false; }
2958
2959 /**
2960 Return used table information for the specified query block (level).
2961 For a field that is resolved from this query block, return the table number.
2962 For a field that is resolved from a query block outer to the specified one,
2963 return OUTER_REF_TABLE_BIT
2964
2965 @param[in,out] arg pointer to an instance of class Used_tables, which is
2966 constructed with the query block as argument.
2967 The used tables information is accumulated in the field
2968 used_tables in this class.
2969
2970 @note This function is used to update used tables information after
2971 merging a query block (a subquery) with its parent.
2972 */
2973 virtual bool used_tables_for_level(uchar *arg [[maybe_unused]]) {
2974 return false;
2975 }
2976 /**
2977 Check privileges.
2978
2979 @param thd thread handle
2980 */
2981 virtual bool check_column_privileges(uchar *thd [[maybe_unused]]) {
2982 return false;
2983 }
2984 virtual bool inform_item_in_cond_of_tab(uchar *) { return false; }
2985 /**
2986 Bind objects from the current execution context to field objects in
2987 item trees. Typically used to bind Field objects from TABLEs to
2988 Item_field objects.
2989 */
2990 virtual void bind_fields() {}
2991
2992 /**
2993 Context object for (functions that override)
2994 Item::clean_up_after_removal().
2995 */
2997 public:
2999 assert(root != nullptr);
3000 }
3001
3003
3004 private:
3005 /**
3006 Pointer to Cleanup_after_removal_context containing from which
3007 select the walk started, i.e., the Query_block that contained the clause
3008 that was removed.
3009 */
3011
3012 friend class Item;
3013 friend class Item_func_eq;
3014 friend class Item_sum;
3015 friend class Item_subselect;
3016 friend class Item_ref;
3017 };
3018 /**
3019 Clean up after removing the item from the item tree.
3020
3021 param arg pointer to a Cleanup_after_removal_context object
3022 @todo: If class ORDER is refactored so that all indirect
3023 grouping/ordering expressions are represented with Item_ref
3024 objects, all implementations of cleanup_after_removal() except
3025 the one for Item_ref can be removed.
3026 */
3027 virtual bool clean_up_after_removal(uchar *arg);
3028
3029 /// @see Distinct_check::check_query()
3030 virtual bool aggregate_check_distinct(uchar *) { return false; }
3031 /// @see Group_check::check_query()
3032 virtual bool aggregate_check_group(uchar *) { return false; }
3033 /// @see Group_check::analyze_conjunct()
3034 virtual bool is_strong_side_column_not_in_fd(uchar *) { return false; }
3035 /// @see Group_check::is_in_fd_of_underlying()
3036 virtual bool is_column_not_in_fd(uchar *) { return false; }
3037 virtual Bool3 local_column(const Query_block *) const {
3038 return Bool3::false3();
3039 }
3040
3041 /**
3042 Minion class under \c Collect_scalar_subquery_info ("Css"). Information
3043 about one scalar subquery being considered for transformation
3044 */
3045 struct Css_info {
3046 /// set of locations
3048 /// the scalar subquery
3051 /// Where did we find item above? Used when \c m_location == \c L_JOIN_COND,
3052 /// nullptr for other locations.
3054 /// If true, we can forego cardinality checking of the derived table
3056 /// If true, add a COALESCE around replaced subquery: used for implicitly
3057 /// grouped COUNT() in subquery select list when subquery is correlated
3058 bool m_add_coalesce{false};
3059 /// Set iff \c m_add_coalesce is true: we may get a NULL anyway even for
3060 /// COUNT if a HAVING clause is false in the subquery.
3062 /// Index of the having expression copied to select list
3064 };
3065
3066 /**
3067 Context struct used by walk method collect_scalar_subqueries to
3068 accumulate information about scalar subqueries found.
3069
3070 In: m_location of expression walked, m_join_condition_context
3071 Out: m_list
3072 */
3074 enum Location { L_SELECT = 1, L_WHERE = 2, L_HAVING = 4, L_JOIN_COND = 8 };
3075 /// accumulated all scalar subqueries found
3076 std::vector<Css_info> m_list;
3077 /// we are currently looking at this kind of clause, cf. enum Location
3082 friend class Item_sum;
3084 };
3085
3086 virtual bool collect_scalar_subqueries(uchar *) { return false; }
3087 virtual bool collect_grouped_aggregates(uchar *) { return false; }
3088 virtual bool collect_subqueries(uchar *) { return false; }
3089 virtual bool update_depended_from(uchar *) { return false; }
3090 /**
3091 Check if an aggregate is referenced from within the GROUP BY
3092 clause of the query block in which it is aggregated. Such
3093 references will be rejected.
3094 @see Item_ref::fix_fields()
3095 @retval true if this is an aggregate which is referenced from
3096 the GROUP BY clause of the aggregating query block
3097 @retval false otherwise
3098 */
3099 virtual bool has_aggregate_ref_in_group_by(uchar *) { return false; }
3100
3101 bool visit_all_analyzer(uchar **) { return true; }
3102 virtual bool cache_const_expr_analyzer(uchar **cache_item);
3104
3105 virtual bool equality_substitution_analyzer(uchar **) { return false; }
3106
3107 virtual Item *equality_substitution_transformer(uchar *) { return this; }
3108
3109 /**
3110 Check if a partition function is allowed.
3111
3112 @return whether a partition function is not accepted
3113
3114 @details
3115 check_partition_func_processor is used to check if a partition function
3116 uses an allowed function. An allowed function will always ensure that
3117 X=Y guarantees that also part_function(X)=part_function(Y) where X is
3118 a set of partition fields and so is Y. The problems comes mainly from
3119 character sets where two equal strings can be quite unequal. E.g. the
3120 german character for double s is equal to 2 s.
3121
3122 The default is that an item is not allowed
3123 in a partition function. Allowed functions
3124 can never depend on server version, they cannot depend on anything
3125 related to the environment. They can also only depend on a set of
3126 fields in the table itself. They cannot depend on other tables and
3127 cannot contain any queries and cannot contain udf's or similar.
3128 If a new Item class is defined and it inherits from a class that is
3129 allowed in a partition function then it is very important to consider
3130 whether this should be inherited to the new class. If not the function
3131 below should be defined in the new Item class.
3132
3133 The general behaviour is that most integer functions are allowed.
3134 If the partition function contains any multi-byte collations then
3135 the function check_part_func_fields will report an error on the
3136 partition function independent of what functions are used. So the
3137 only character sets allowed are single character collation and
3138 even for those only a limited set of functions are allowed. The
3139 problem with multi-byte collations is that almost every string
3140 function has the ability to change things such that two strings
3141 that are equal will not be equal after manipulated by a string
3142 function. E.g. two strings one contains a double s, there is a
3143 special german character that is equal to two s. Now assume a
3144 string function removes one character at this place, then in
3145 one the double s will be removed and in the other there will
3146 still be one s remaining and the strings are no longer equal
3147 and thus the partition function will not sort equal strings into
3148 the same partitions.
3149
3150 So the check if a partition function is valid is two steps. First
3151 check that the field types are valid, next check that the partition
3152 function is valid. The current set of partition functions valid
3153 assumes that there are no multi-byte collations amongst the partition
3154 fields.
3155 */
3156 virtual bool check_partition_func_processor(uchar *) { return true; }
3157 virtual bool subst_argument_checker(uchar **arg) {
3158 if (*arg) *arg = nullptr;
3159 return true;
3160 }
3161 virtual bool explain_subquery_checker(uchar **) { return true; }
3162 virtual Item *explain_subquery_propagator(uchar *) { return this; }
3163
3164 virtual Item *equal_fields_propagator(uchar *) { return this; }
3165 // Mark the item to not be part of substitution.
3166 virtual bool disable_constant_propagation(uchar *) { return false; }
3167
3169 // Stack of pointers to enclosing functions
3171 };
3172 virtual Item *replace_equal_field(uchar *) { return this; }
3173 virtual bool replace_equal_field_checker(uchar **) { return true; }
3174 /*
3175 Check if an expression value has allowed arguments, like DATE/DATETIME
3176 for date functions. Also used by partitioning code to reject
3177 timezone-dependent expressions in a (sub)partitioning function.
3178 */
3179 virtual bool check_valid_arguments_processor(uchar *) { return false; }
3180
3181 /**
3182 Check if this item is allowed for a virtual column or inside a
3183 default expression. Should be overridden in child classes.
3184
3185 @param[in,out] args Due to the limitation of Item::walk()
3186 it is declared as a pointer to uchar, underneath there's a actually a
3187 structure of type Check_function_as_value_generator_parameters.
3188 It is used mainly in Item_field.
3189
3190 @returns true if function is not accepted
3191 */
3192 virtual bool check_function_as_value_generator(uchar *args);
3193
3194 /**
3195 Check if a generated expression depends on DEFAULT function with
3196 specific column name as argument.
3197
3198 @param[in] args Name of column used as DEFAULT function argument.
3199
3200 @returns false if the function is not DEFAULT(args), otherwise true.
3201 */
3203 [[maybe_unused]]) {
3204 return false;
3205 }
3206 /**
3207 Check if all the columns present in this expression are from the
3208 derived table. Used in determining if a condition can be pushed
3209 down to derived table.
3210 */
3211 virtual bool is_valid_for_pushdown(uchar *arg [[maybe_unused]]) {
3212 // A generic item cannot be pushed down unless it's a constant
3213 // which does not have a subquery.
3214 return !const_item() || has_subquery();
3215 }
3216
3217 /**
3218 Check if all the columns present in this expression are present
3219 in PARTITION clause of window functions of the derived table.
3220 Used in checking if a condition can be pushed down to derived table.
3221 */
3222 virtual bool check_column_in_window_functions(uchar *arg [[maybe_unused]]) {
3223 return false;
3224 }
3225 /**
3226 Check if all the columns present in this expression are present
3227 in GROUP BY clause of the derived table. Used in checking if
3228 a condition can be pushed down to derived table.
3229 */
3230 virtual bool check_column_in_group_by(uchar *arg [[maybe_unused]]) {
3231 return false;
3232 }
3233 /**
3234 Assuming this expression is part of a condition that would be pushed to the
3235 WHERE clause of a materialized derived table, replace, in this expression,
3236 each derived table's column with a clone of the expression lying under it
3237 in the derived table's definition. We replace with a clone, because the
3238 condition can be pushed further down in case of nested derived tables.
3239 */
3240 virtual Item *replace_with_derived_expr(uchar *arg [[maybe_unused]]) {
3241 return this;
3242 }
3243 /**
3244 Assuming this expression is part of a condition that would be pushed to the
3245 HAVING clause of a materialized derived table, replace, in this expression,
3246 each derived table's column with a reference to the expression lying under
3247 it in the derived table's definition. Unlike replace_with_derived_expr, a
3248 clone is not used because HAVING condition will not be pushed further
3249 down in case of nested derived tables.
3250 */
3251 virtual Item *replace_with_derived_expr_ref(uchar *arg [[maybe_unused]]) {
3252 return this;
3253 }
3254 /**
3255 Assuming this expression is part of a condition that would be pushed to a
3256 materialized derived table, replace, in this expression, each view reference
3257 with a clone of the expression in merged derived table's definition.
3258 We replace with a clone, because the referenced item in a view reference
3259 is shared by all the view references to that expression.
3260 */
3261 virtual Item *replace_view_refs_with_clone(uchar *arg [[maybe_unused]]) {
3262 return this;
3263 }
3264 /*
3265 For SP local variable returns pointer to Item representing its
3266 current value and pointer to current Item otherwise.
3267 */
3268 virtual Item *this_item() { return this; }
3269 virtual const Item *this_item() const { return this; }
3270
3271 /*
3272 For SP local variable returns address of pointer to Item representing its
3273 current value and pointer passed via parameter otherwise.
3274 */
3275 virtual Item **this_item_addr(THD *, Item **addr_arg) { return addr_arg; }
3276
3277 // Row emulation
3278 virtual uint cols() const { return 1; }
3279 virtual Item *element_index(uint) { return this; }
3280 virtual Item **addr(uint) { return nullptr; }
3281 virtual bool check_cols(uint c);
3282 // It is not row => null inside is impossible
3283 virtual bool null_inside() { return false; }
3284 // used in row subselects to get value of elements
3285 virtual void bring_value() {}
3286
3287 Field *tmp_table_field_from_field_type(TABLE *table, bool fixed_length) const;
3288 virtual Item_field *field_for_view_update() { return nullptr; }
3289 /**
3290 Informs an item that it is wrapped in a truth test, in case it wants to
3291 transforms itself to implement this test by itself.
3292 @param thd Thread handle
3293 @param test Truth test
3294 */
3295 virtual Item *truth_transformer(THD *thd [[maybe_unused]],
3296 Bool_test test [[maybe_unused]]) {
3297 return nullptr;
3298 }
3299 virtual Item *update_value_transformer(uchar *) { return this; }
3300
3302 Query_block *m_trans_block; ///< Transformed query block
3303 Query_block *m_curr_block; ///< Transformed query block or a contained
3304 ///< subquery. Pushed when diving into
3305 ///< subqueries.
3306 Item_replacement(Query_block *transformed_block, Query_block *current_block)
3307 : m_trans_block(transformed_block), m_curr_block(current_block) {}
3308 };
3310 Field *m_target; ///< The field to be replaced
3311 Item_field *m_item; ///< The replacement field
3312 ///< replacement field iff outer ref
3314 enum class Mode {
3315 CONFLATE, // include both Item_field and Item_default_value
3316 FIELD, // ignore Item_default_value
3317 DEFAULT_VALUE // ignore Item_field
3318 };
3321 Mode default_value = Mode::CONFLATE)
3322 : Item_replacement(select, select),
3323 m_target(target),
3324 m_item(item),
3325 m_default_value(default_value) {}
3326 };
3327
3329 Item_func *m_target; ///< The function call to be replaced
3330 Item_field *m_item; ///< The replacement field
3332 Query_block *select)
3333 : Item_replacement(select, select),
3334 m_target(func_target),
3335 m_item(item) {}
3336 };
3337
3339 Item *m_target; ///< The item identifying the view_ref to be replaced
3340 Field *m_field; ///< The replacement field
3341 Item_field *m_outer_field{nullptr}; ///< replacement field if outer ref
3342 ///< subquery. Pushed when diving into
3343 ///< subqueries.
3345 : Item_replacement(select, select), m_target(target), m_field(field) {}
3346 };
3347
3352 : m_target(target), m_replacement(replacement) {}
3353 };
3354
3355 /**
3356 When walking the item tree seeing an Item_singlerow_subselect matching
3357 a target, replace it with a substitute field used when transforming
3358 scalar subqueries into derived tables. Cf.
3359 Query_block::transform_scalar_subqueries_to_join_with_derived.
3360 */
3361 virtual Item *replace_scalar_subquery(uchar *) { return this; }
3362
3363 /**
3364 Transform processor used by Query_block::transform_grouped_to_derived
3365 to replace fields which used to be at the transformed query block
3366 with corresponding fields in the new derived table containing the grouping
3367 operation of the original transformed query block.
3368 */
3369 virtual Item *replace_item_field(uchar *) { return this; }
3370 virtual Item *replace_func_call(uchar *) { return this; }
3371 virtual Item *replace_item_view_ref(uchar *) { return this; }
3372 virtual Item *replace_aggregate(uchar *) { return this; }
3373 virtual Item *replace_outer_ref(uchar *) { return this; }
3374
3379 : m_target(target), m_owner(owner) {}
3380 };
3381
3382 /**
3383 A walker processor overridden by Item_aggregate_ref, q.v.
3384 */
3385 virtual bool update_aggr_refs(uchar *) { return false; }
3386
3387 /**
3388 Convert constant string in this object into the specified character set.
3389
3390 @param thd thread handler
3391 @param tocs target character set
3392 @param ignore_errors if true, ignore errors in conversion
3393
3394 @returns pointer to new Item containing converted character string
3395 = NULL: If conversion failed
3396 */
3397 Item *convert_charset(THD *thd, const CHARSET_INFO *tocs,
3398 bool ignore_errors = false);
3399
3400 /**
3401 Delete this item.
3402 Note that item must have been cleanup up by calling Item::cleanup().
3403 */
3404 void delete_self() { delete this; }
3405
3406 /** @return whether the item is local to a stored procedure */
3407 virtual bool is_splocal() const { return false; }
3408
3409 /*
3410 Return Settable_routine_parameter interface of the Item. Return 0
3411 if this Item is not Settable_routine_parameter.
3412 */
3414 return nullptr;
3415 }
3416 inline bool is_temporal_with_date() const {
3418 }
3421 }
3422 inline bool is_temporal_with_time() const {
3424 }
3425 inline bool is_temporal() const {
3427 }
3428 /**
3429 Check whether this and the given item has compatible comparison context.
3430 Used by the equality propagation. See Item_field::equal_fields_propagator.
3431
3432 @return
3433 true if the context is the same or if fields could be
3434 compared as DATETIME values by the Arg_comparator.
3435 false otherwise.
3436 */
3437 inline bool has_compatible_context(Item *item) const {
3438 // If no explicit context has been set, assume the same type as the item
3439 const Item_result this_context =
3441 const Item_result other_context = item->cmp_context == INVALID_RESULT
3442 ? item->result_type()
3443 : item->cmp_context;
3444
3445 // Check if both items have the same context
3446 if (this_context == other_context) {
3447 return true;
3448 }
3449 /* DATETIME comparison context. */
3451 return item->is_temporal_with_date() || other_context == STRING_RESULT;
3452 if (item->is_temporal_with_date())
3453 return is_temporal_with_date() || this_context == STRING_RESULT;
3454 return false;
3455 }
3457 return Field::GEOM_GEOMETRY;
3458 }
3459 String *check_well_formed_result(String *str, bool send_error, bool truncate);
3460 bool eq_by_collation(Item *item, const CHARSET_INFO *cs);
3461
3463 m_cost.Compute(*this);
3464 return m_cost;
3465 }
3466
3467 /**
3468 @return maximum number of characters that this Item can store
3469 If Item is of string or blob type, return max string length in bytes
3470 divided by bytes per character, otherwise return max_length.
3471 @todo - check if collation for other types should have mbmaxlen = 1
3472 */
3474 /*
3475 Length of e.g. 5.5e5 in an expression such as GREATEST(5.5e5, '5') is 5
3476 (length of that string) although length of the actual value is 6.
3477 Return MAX_DOUBLE_STR_LENGTH to prevent truncation of data without having
3478 to evaluate the value of the item.
3479 */
3480 const uint32 max_len =
3482 if (result_type() == STRING_RESULT)
3483 return max_len / collation.collation->mbmaxlen;
3484 return max_len;
3485 }
3486
3488 if (cs == &my_charset_bin && result_type() == STRING_RESULT) {
3489 return max_length;
3490 }
3491 return max_char_length();
3492 }
3493
3494 inline void fix_char_length(uint32 max_char_length_arg) {
3495 max_length = char_to_byte_length_safe(max_char_length_arg,
3497 }
3498
3499 /*
3500 Return true if the item points to a column of an outer-joined table.
3501 */
3502 virtual bool is_outer_field() const {
3503 assert(fixed);
3504 return false;
3505 }
3506
3507 /**
3508 Check if an item either is a blob field, or will be represented as a BLOB
3509 field if a field is created based on this item.
3510
3511 @retval true If a field based on this item will be a BLOB field,
3512 @retval false Otherwise.
3513 */
3514 bool is_blob_field() const;
3515
3516 /// @returns number of references to an item.
3517 uint reference_count() const { return m_ref_count; }
3518
3519 /// Increment reference count
3521 assert(!m_abandoned);
3522 ++m_ref_count;
3523 }
3524
3525 /// Decrement reference count
3527 assert(m_ref_count > 0);
3528 if (--m_ref_count == 0) m_abandoned = true;
3529 return m_ref_count;
3530 }
3531
3532 protected:
3533 /// Set accumulated properties for an Item
3534 void set_accum_properties(const Item *item) {
3536 }
3537
3538 /// Add more accumulated properties to an Item
3539 void add_accum_properties(const Item *item) {
3541 }
3542
3543 /// Set the "has subquery" property
3545
3546 /// Set the "has stored program" property
3548
3549 public:
3550 /// @return true if this item or any of its descendants contains a subquery.
3552
3553 /// @return true if this item or any of its descendants refers a stored func.
3554 bool has_stored_program() const {
3556 }
3557
3558 /// @return true if this item or any of its descendants is an aggregated func.
3560
3561 /// Set the "has aggregation" property
3563
3564 /// Reset the "has aggregation" property
3565 void reset_aggregation() { m_accum_properties &= ~PROP_AGGREGATION; }
3566
3567 /// @return true if this item or any of its descendants is a window func.
3569
3570 /// Set the "has window function" property
3572
3573 /**
3574 @return true if this item or any of its descendants within the same query
3575 has a reference to a GROUP BY modifier (such as ROLLUP)
3576 */
3579 }
3580
3581 /**
3582 Set the property: this item (tree) contains a reference to a GROUP BY
3583 modifier (such as ROLLUP)
3584 */
3587 }
3588
3589 /**
3590 @return true if this item or any of underlying items is a GROUPING function
3591 */
3592 bool has_grouping_func() const {
3594 }
3595
3596 /// Set the property: this item is a call to GROUPING
3598
3599 /// Whether this Item was created by the IN->EXISTS subquery transformation
3600 virtual bool created_by_in2exists() const { return false; }
3601
3603 if (has_subquery())
3605 }
3606
3607 /**
3608 Analyzer function for GC substitution. @see substitute_gc()
3609 */
3610 virtual bool gc_subst_analyzer(uchar **) { return false; }
3611 /**
3612 Transformer function for GC substitution. @see substitute_gc()
3613 */
3614 virtual Item *gc_subst_transformer(uchar *) { return this; }
3615
3616 /**
3617 A processor that replaces any Fields with a Create_field_wrapper. This
3618 will allow us to resolve functions during CREATE TABLE, where we only have
3619 Create_field available and not Field. Used for functional index
3620 implementation.
3621 */
3622 virtual bool replace_field_processor(uchar *) { return false; }
3623 /**
3624 Check if this item is of a type that is eligible for GC
3625 substitution. All items that belong to subclasses of Item_func are
3626 eligible for substitution. @see substitute_gc()
3627 Item_fields can also be eligible if they are given as an argument to
3628 a function that takes an array (the field can be substituted with a
3629 generated column that backs a multi-valued index on that field).
3630
3631 @param array true if the item is an argument to a function that takes an
3632 array, or false otherwise
3633 @return true if the expression is eligible for substitution, false otherwise
3634 */
3635 bool can_be_substituted_for_gc(bool array = false) const;
3636
3638 uint nitems);
3639 void aggregate_decimal_properties(Item **items, uint nitems);
3641 uint nitems);
3643 Item **items, uint nitems);
3644 void aggregate_bit_properties(Item **items, uint nitems);
3645
3646 /**
3647 This function applies only to Item_field objects referred to by an Item_ref
3648 object that has been marked as a const_item.
3649
3650 @param arg Keep track of whether an Item_ref refers to an Item_field.
3651 */
3652 virtual bool repoint_const_outer_ref(uchar *arg [[maybe_unused]]) {
3653 return false;
3654 }
3655 virtual bool strip_db_table_name_processor(uchar *) { return false; }
3656
3657 /**
3658 Compute the cost of evaluating this Item.
3659 @param root_cost The cost object to which the cost should be added.
3660 */
3661 virtual void compute_cost(CostOfItem *root_cost [[maybe_unused]]) const {}
3662
3663 bool is_abandoned() const { return m_abandoned; }
3664
3665 private:
3666 virtual bool subq_opt_away_processor(uchar *) { return false; }
3667
3668 public: // Start of data fields
3669 /**
3670 Intrusive list pointer for free list. If not null, points to the next
3671 Item on some Query_arena's free list. For instance, stored procedures
3672 have their own Query_arena's.
3673
3674 @see Query_arena::free_list
3675 */
3676 Item *next_free{nullptr};
3677
3678 protected:
3679 /// str_values's main purpose is to cache the value in save_in_field
3681
3682 public:
3683 /**
3684 Character set and collation properties assigned for this Item.
3685 Used if Item represents a character string expression.
3686 */
3688 Item_name_string item_name; ///< Name from query
3689 Item_name_string orig_name; ///< Original item name (if it was renamed)
3690 /**
3691 Maximum length of result of evaluating this item, in number of bytes.
3692 - For character or blob data types, max char length multiplied by max
3693 character size (collation.mbmaxlen).
3694 - For decimal type, it is the precision in digits plus sign (unless
3695 unsigned) plus decimal point (unless it has zero decimals).
3696 - For other numeric types, the default or specific display length.
3697 - For date/time types, the display length (10 for DATE, 10 + optional FSP
3698 for TIME, 19 + optional fsp for datetime/timestamp).
3699 - For bit, the number of bits.
3700 - For enum, the string length of the widest enum element.
3701 - For set, the sum of the string length of each set element plus separators.
3702 - For geometry, the maximum size of a BLOB (it's underlying storage type).
3703 - For json, the maximum size of a BLOB (it's underlying storage type).
3704 */
3705 uint32 max_length; ///< Maximum length, in bytes
3706 enum item_marker ///< Values for member 'marker'
3707 {
3709 /// When contextualization or itemization adds an implicit comparison '0<>'
3710 /// (see make_condition()), to record that this Item_func_ne was created for
3711 /// this purpose; this value is tested during resolution.
3713 /// When doing constant propagation (e.g. change_cond_ref_to_const(), to
3714 /// remember that we have already processed the item.
3716 /// When creating an internal temporary table: marking group by
3717 /// fields
3719 /// When analyzing functional dependencies for only_full_group_by (says
3720 /// whether a nullable column can be treated at not nullable).
3722 /// When we change DISTINCT to GROUP BY: used for book-keeping of
3723 /// fields.
3725 /// When pushing conditions down to derived table: it says a condition
3726 /// contains only derived table's columns.
3728 /// Used during traversal to avoid deleting an item twice.
3730 /// When pushing index conditions: it says whether a condition uses only
3731 /// indexed columns.
3734 /**
3735 This member has several successive meanings, depending on the phase we're
3736 in (@see item_marker).
3737 The important property is that a phase must have a value (or few values)
3738 which is reserved for this phase. If it wants to set "marked", it assigns
3739 the value; it it wants to test if it is marked, it tests marker !=
3740 value. If the value has been assigned and the phase wants to cancel it can
3741 set marker to MARKER_NONE, which is a magic number which no phase
3742 reserves.
3743 A phase can expect 'marker' to be MARKER_NONE at the start of execution of
3744 a normal statement, at the start of preparation of a PS, and at the start
3745 of execution of a PS.
3746 A phase should not expect marker's value to survive after the phase's
3747 end - as a following phase may change it.
3748 */
3750 Item_result cmp_context; ///< Comparison context
3751 private:
3752 /**
3753 Number of references to this item. It is used for two purposes:
3754 1. When eliminating redundant expressions, the reference count is used
3755 to tell how many Item_ref objects that point to an item. When a
3756 sub-tree of items is eliminated, it is traversed and any item that
3757 is referenced from an Item_ref has its reference count decremented.
3758 Only when the reference count reaches zero is the item actually deleted.
3759 2. Keeping track of unused expressions selected from merged derived tables.
3760 An item that is added to the select list of a query block has its
3761 reference count set to 1. Any references from outer query blocks are
3762 through Item_ref objects, thus they will cause the reference count
3763 to be incremented. At end of resolving, the reference counts of all
3764 items in select list of merged derived tables are decremented, thus
3765 if the reference count becomes zero, the expression is known to
3766 be unused and can be removed.
3767 */
3769 bool m_abandoned{false}; ///< true if item has been fully de-referenced
3770 const bool is_parser_item; ///< true if allocated directly by parser
3771 uint8 m_data_type; ///< Data type assigned to Item
3772
3773 /**
3774 The cost of evaluating this item. This is only needed for predicates,
3775 therefore we use lazy evaluation.
3776 */
3778
3779 public:
3780 bool fixed; ///< True if item has been resolved
3781 /**
3782 Number of decimals in result when evaluating this item
3783 - For integer type, always zero.
3784 - For decimal type, number of decimals.
3785 - For float type, it may be DECIMAL_NOT_SPECIFIED
3786 - For time, datetime and timestamp, number of decimals in fractional second
3787 - For string types, may be decimals of cast source or DECIMAL_NOT_SPECIFIED
3788 */
3790
3791 bool is_nullable() const { return m_nullable; }
3792 void set_nullable(bool nullable) { m_nullable = nullable; }
3793
3794 private:
3795 /**
3796 True if this item may hold the NULL value(if null_value may be set to true).
3797
3798 For items that represent rows, it is true if one of the columns
3799 may be null.
3800
3801 For items that represent scalar or row subqueries, it is true if
3802 one of the returned columns could be null, or if the subquery
3803 could return zero rows.
3804
3805 It is worth noting that this information is correct only until
3806 equality propagation has been run by the optimization phase.
3807 Indeed, consider:
3808 select * from t1, t2,t3 where t1.pk=t2.a and t1.pk+1...
3809 the '+' is not nullable as t1.pk is not nullable;
3810 but if the optimizer chooses plan is t2-t3-t1, then, due to equality
3811 propagation it will replace t1.pk in '+' with t2.a (as t2 is before t1
3812 in plan), making the '+' capable of returning NULL when t2.a is NULL.
3813 */
3815
3816 public:
3817 bool null_value; ///< True if item is null
3819 bool m_is_window_function; ///< True if item represents window func
3820 /**
3821 If the item is in a SELECT list (Query_block::fields) and hidden is true,
3822 the item wasn't actually in the list as given by the user (it was added
3823 by the optimizer, to e.g. make sure it was part of a given
3824 materialization), and should not be returned in the actual result.
3825
3826 If the item is not in a SELECT list, the value is irrelevant.
3827 */
3828 bool hidden{false};
3829 /**
3830 True if item is a top most element in the expression being
3831 evaluated for a check constraint.
3832 */
3834
3835 protected:
3836 /**
3837 Set of properties that are calculated by accumulation from underlying items.
3838 Computed by constructors and fix_fields() and updated by
3839 update_used_tables(). The properties are accumulated up to the root of the
3840 current item tree, except they are not accumulated across subqueries and
3841 functions.
3842 */
3843 static constexpr uint8 PROP_SUBQUERY = 0x01;
3844 static constexpr uint8 PROP_STORED_PROGRAM = 0x02;
3845 static constexpr uint8 PROP_AGGREGATION = 0x04;
3846 static constexpr uint8 PROP_WINDOW_FUNCTION = 0x08;
3847 /**
3848 Set if the item or one or more of the underlying items contains a
3849 GROUP BY modifier (such as ROLLUP).
3850 */
3851 static constexpr uint8 PROP_HAS_GROUPING_SET_DEP = 0x10;
3852 /**
3853 Set if the item or one or more of the underlying items is a GROUPING
3854 function.
3855 */
3856 static constexpr uint8 PROP_GROUPING_FUNC = 0x20;
3857
3859
3860 public:
3861 /**
3862 Apply column masking policy to this item if applicable.
3863
3864 @param thd Thread handle.
3865 @return Item to use after masking (possibly this or a new Item), or
3866 nullptr on error.
3867 */
3868 virtual Item *apply_masking_policy(THD *thd [[maybe_unused]]) { return this; }
3869
3870 /**
3871 Disable application of the masking policy to this item. This is used to
3872 prevent replacing an Item_field with a masking expression when resolving
3873 target columns of INSERT, UPDATE or REPLACE, as these statements would still
3874 need to be able to write to these columns, even though they should be masked
3875 when being read.
3876 */
3877 virtual void disable_masking_policy() {}
3878
3879 /**
3880 Mark this expression as a masking expression for some other expression.
3881 @param masked_item The item that should be masked by this expression.
3882 */
3883 virtual void set_masking_expression_for(const Item_field *masked_item
3884 [[maybe_unused]]) {
3885 // Only expected to be called on the top-level item of the masking policy
3886 // expression as specified in a CREATE MASKING POLICY statement. At the time
3887 // of writing, this has to be an Item_func_case.
3888 assert(false);
3889 }
3890
3891 /**
3892 Check if this expression can be used for partial update of a given
3893 JSON column.
3894
3895 For example, the expression `JSON_REPLACE(col, '$.foo', 'bar')`
3896 can be used to partially update the column `col`.
3897
3898 @param field the JSON column that is being updated
3899 @return true if this expression can be used for partial update,
3900 false otherwise
3901 */
3902 virtual bool supports_partial_update(const Field_json *field
3903 [[maybe_unused]]) const {
3904 return false;
3905 }
3906
3907 /**
3908 Whether the item returns array of its data type
3909 */
3910 virtual bool returns_array() const { return false; }
3911
3912 /**
3913 A helper function to ensure proper usage of CAST(.. AS .. ARRAY)
3914 */
3915 virtual void allow_array_cast() {}
3916};
3917
3918/**
3919 Descriptor of what and how to cache for
3920 Item::cache_const_expr_transformer/analyzer.
3921
3922*/
3923
3925 /// Path from the expression's top to the current item in item tree
3926 /// used to track parent of current item for caching JSON data
3928 /// Item to cache. Used as a binary flag, but kept as Item* for assertion
3929 Item *cache_item{nullptr};
3930 /// How to cache JSON data. @see Item::enum_const_item_cache
3932};
3933
3934/**
3935 A helper class to give in a functor to Item::walk(). Use as e.g.:
3936
3937 bool result = WalkItem(root_item, enum_walk::POSTFIX, [](Item *item) { ... });
3938
3939 TODO: Make Item::walk() just take in a functor in the first place, instead of
3940 a pointer-to-member and an opaque argument.
3941 */
3942template <class T>
3943inline bool WalkItem(Item *item, enum_walk walk, T &&functor) {
3944 return item->walk(&Item::walk_helper_thunk<T>, walk,
3945 reinterpret_cast<uchar *>(&functor));
3946}
3947
3948/**
3949 Overload for const 'item' and functor taking 'const Item*' argument.
3950*/
3951template <class T>
3952inline bool WalkItem(const Item *item, enum_walk walk, T &&functor) {
3953 auto to_const = [&](const Item *descendant) { return functor(descendant); };
3954 return WalkItem(const_cast<Item *>(item), walk, to_const);
3955}
3956
3957/**
3958 Same as WalkItem, but for Item::compile(). Use as e.g.:
3959
3960 Item *item = CompileItem(root_item,
3961 [](Item *item) { return true; }, // Analyzer.
3962 [](Item *item) { return item; }); // Transformer.
3963 */
3964template <class T, class U>
3965inline Item *CompileItem(Item *item, T &&analyzer, U &&transformer) {
3966 uchar *analyzer_ptr = reinterpret_cast<uchar *>(&analyzer);
3967 return item->compile(&Item::analyze_helper_thunk<T>, &analyzer_ptr,
3968 &Item::walk_helper_thunk<U>,
3969 reinterpret_cast<uchar *>(&transformer));
3970}
3971
3972/**
3973 Same as WalkItem, but for Item::transform(). Use as e.g.:
3974
3975 Item *item = TransformItem(root_item, [](Item *item) { return item; });
3976 */
3977template <class T>
3978Item *TransformItem(Item *item, T &&transformer) {
3979 return item->transform(&Item::walk_helper_thunk<T>,
3980 pointer_cast<uchar *>(&transformer));
3981}
3982
3985
3986 public:
3988 explicit Item_basic_constant(const POS &pos) : Item(pos), used_table_map(0) {}
3989
3990 /// @todo add implementation of basic_const_item
3991 /// and remove from subclasses as appropriate.
3992
3994 table_map used_tables() const override { return used_table_map; }
3995 bool check_function_as_value_generator(uchar *) override { return false; }
3996 /* to prevent drop fixed flag (no need parent cleanup call) */
3997 void cleanup() override {
3998 // @todo We should ensure we never change "basic constant" nodes.
3999 // We should then be able to add this assert:
4000 // assert(marker == MARKER_NONE);
4001 // and remove the call to Item::cleanup()
4002 Item::cleanup();
4003 }
4004 bool basic_const_item() const override { return true; }
4005 /**
4006 Note that str_value.ptr() will now point to a string owned by some
4007 other object.
4008 */
4010 str_value.set(str->ptr(), str->length(), str->charset());
4011 }
4012};
4013
4014/*****************************************************************************
4015 The class is a base class for representation of stored routine variables in
4016 the Item-hierarchy. There are the following kinds of SP-vars:
4017 - local variables (Item_splocal);
4018 - CASE expression (Item_case_expr);
4019*****************************************************************************/
4020
4021class Item_sp_variable : public Item {
4022 public:
4024
4025 public:
4026#ifndef NDEBUG
4027 /*
4028 Routine to which this Item_splocal belongs. Used for checking if correct
4029 runtime context is used for variable handling.
4030 */
4031 sp_head *m_sp{nullptr};
4032#endif
4033
4034 public:
4035 Item_sp_variable(const Name_string sp_var_name);
4036
4037 table_map used_tables() const override { return INNER_TABLE_BIT; }
4038 bool fix_fields(THD *thd, Item **) override;
4039
4040 double val_real() override;
4041 longlong val_int() override;
4042 String *val_str(String *sp) override;
4043 my_decimal *val_decimal(my_decimal *decimal_value) override;
4044 bool val_json(Json_wrapper *result) override;
4045 bool val_date(Date_val *date, my_time_flags_t flags) override;
4046 bool val_time(Time_val *time) override;
4047 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
4048 bool is_null() override;
4049
4050 public:
4051 inline void make_field(Send_field *field) override;
4052 bool send(Protocol *protocol, String *str) override {
4053 // Need to override send() in case this_item() is an Item_field with a
4054 // ZEROFILL attribute.
4055 return this_item()->send(protocol, str);
4056 }
4057 bool is_valid_for_pushdown(uchar *arg [[maybe_unused]]) override {
4058 // It is ok to push down a condition like "column > SP_variable"
4059 return false;
4060 }
4061
4062 protected:
4064 Field *field, bool no_conversions) override;
4065};
4066
4067/*****************************************************************************
4068 Item_sp_variable inline implementation.
4069*****************************************************************************/
4070
4072 Item *it = this_item();
4074 it->make_field(field);
4075}
4076
4078 Field *field, bool no_conversions) {
4079 return this_item()->save_in_field(field, no_conversions);
4080}
4081
4082/*****************************************************************************
4083 A reference to local SP variable (incl. reference to SP parameter), used in
4084 runtime.
4085*****************************************************************************/
4086
4087class Item_splocal final : public Item_sp_variable,
4090
4091 public:
4092 /*
4093 If this variable is a parameter in LIMIT clause.
4094 Used only during NAME_CONST substitution, to not append
4095 NAME_CONST to the resulting query and thus not break
4096 the slave.
4097 */
4099 /*
4100 Position of this reference to SP variable in the statement (the
4101 statement itself is in sp_instr_stmt::m_query).
4102 This is valid only for references to SP variables in statements,
4103 excluding DECLARE CURSOR statement. It is used to replace references to SP
4104 variables with NAME_CONST calls when putting statements into the binary
4105 log.
4106 Value of 0 means that this object doesn't corresponding to reference to
4107 SP variable in query text.
4108 */
4110 /*
4111 Byte length of SP variable name in the statement (see pos_in_query).
4112 The value of this field may differ from the name_length value because
4113 name_length contains byte length of UTF8-encoded item name, but
4114 the query string (see sp_instr_stmt::m_query) is currently stored with
4115 a charset from the SET NAMES statement.
4116 */
4118
4119 Item_splocal(const Name_string sp_var_name, uint sp_var_idx,
4120 enum_field_types sp_var_type, uint pos_in_q = 0,
4121 uint len_in_q = 0);
4122
4123 bool is_splocal() const override { return true; }
4124
4125 Item *this_item() override;
4126 const Item *this_item() const override;
4127 Item **this_item_addr(THD *thd, Item **) override;
4128
4129 void print(const THD *thd, String *str,
4130 enum_query_type query_type) const override;
4131
4132 uint64_t hash() override;
4133
4134 public:
4135 uint get_var_idx() const { return m_var_idx; }
4136
4137 Type type() const override { return ROUTINE_FIELD_ITEM; }
4138 Item_result result_type() const override {
4139 return type_to_result(data_type());
4140 }
4141 bool val_json(Json_wrapper *result) override;
4142
4143 private:
4144 bool set_value(THD *thd, sp_rcontext *ctx, Item **it) override;
4145
4146 public:
4148 return this;
4149 }
4150};
4151
4152/*****************************************************************************
4153 A reference to case expression in SP, used in runtime.
4154*****************************************************************************/
4155
4156class Item_case_expr final : public Item_sp_variable {
4157 public:
4158 Item_case_expr(uint case_expr_id);
4159
4160 public:
4161 Item *this_item() override;
4162 const Item *this_item() const override;
4163 Item **this_item_addr(THD *thd, Item **) override;
4164
4165 Type type() const override { return this_item()->type(); }
4166 Item_result result_type() const override {
4167 return this_item()->result_type();
4168 }
4169 /*
4170 NOTE: print() is intended to be used from views and for debug.
4171 Item_case_expr can not occur in views, so here it is only for debug
4172 purposes.
4173 */
4174 void print(const THD *thd, String *str,
4175 enum_query_type query_type) const override;
4176
4177 uint64_t hash() override;
4178
4179 private:
4181};
4182
4183/*
4184 NAME_CONST(given_name, const_value).
4185 This 'function' has all properties of the supplied const_value (which is
4186 assumed to be a literal constant), and the name given_name.
4187
4188 This is used to replace references to SP variables when we write PROCEDURE
4189 statements into the binary log.
4190
4191 TODO
4192 Together with Item_splocal and Item::this_item() we can actually extract
4193 common a base of this class and Item_splocal. Maybe it is possible to
4194 extract a common base with class Item_ref, too.
4195*/
4196
4197class Item_name_const final : public Item {
4198 typedef Item super;
4199
4203
4204 public:
4205 Item_name_const(const POS &pos, Item *name_arg, Item *val);
4206
4207 bool do_itemize(Parse_context *pc, Item **res) override;
4208 bool fix_fields(THD *, Item **) override;
4209
4210 enum Type type() const override { return NAME_CONST_ITEM; }
4211 double val_real() override;
4212 longlong val_int() override;
4213 String *val_str(String *sp) override;
4214 my_decimal *val_decimal(my_decimal *) override;
4215 bool val_date(Date_val *date, my_time_flags_t flags) override;
4216 bool val_time(Time_val *time) override;
4217 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
4218 bool is_null() override;
4219 void print(const THD *thd, String *str,
4220 enum_query_type query_type) const override;
4221
4222 uint64_t hash() override;
4223
4224 Item_result result_type() const override { return value_item->result_type(); }
4225
4227 // Item_name_const always wraps a literal, so there is no need to cache it.
4228 return false;
4229 }
4230
4231 protected:
4233 bool no_conversions) override {
4234 return value_item->save_in_field(field, no_conversions);
4235 }
4236};
4237
4238bool convert_const_strings(DTCollation &coll, Item **args, uint nargs);
4240 Item **items, uint nitems);
4241bool agg_item_charsets(DTCollation &c, const char *name, Item **items,
4242 uint nitems, uint flags);
4244 const char *name, Item **items,
4245 uint nitems) {
4248 return agg_item_charsets(c, name, items, nitems, flags);
4249}
4251 Item **items, uint nitems) {
4253 return agg_item_charsets(c, name, items, nitems, flags);
4254}
4255
4258
4259 public:
4261 explicit Item_num(const POS &pos) : super(pos) { collation.set_numeric(); }
4262
4263 virtual Item_num *neg() = 0;
4264 bool check_partition_func_processor(uchar *) override { return false; }
4265};
4266
4267inline constexpr uint16 NO_FIELD_INDEX((uint16)(-1));
4268
4269class Item_ident : public Item {
4270 typedef Item super;
4271
4272 /** To cache the hash value of this item, populated upon hash() invocation. */
4273 uint64_t m_hash_val{0};
4274
4275 protected:
4276 /**
4277 The fields m_orig_db_name, m_orig_table_name and m_orig_field_name are
4278 maintained so that we can provide information about the origin of a
4279 column that may have been renamed within the query, e.g. as required by
4280 connectors.
4281
4282 Names the original schema of the table that is the source of the field.
4283 If field is from
4284 - a non-aliased base table, the same as db_name.
4285 - an aliased base table, the name of the schema of the base table.
4286 - an expression (including aggregation), a NULL pointer.
4287 - a derived table, the name of the schema of the underlying base table.
4288 - a view, the name of the schema of the underlying base table.
4289 - a temporary table (in optimization stage), the name of the schema of
4290 the source base table.
4291 */
4292 const char *m_orig_db_name;
4293 /**
4294 Names the original table that is the source of the field. If field is from
4295 - a non-aliased base table, the same as table_name.
4296 - an aliased base table, the name of the base table.
4297 - an expression (including aggregation), a NULL pointer.
4298 - a derived table, the name of the underlying base table.
4299 - a view, the name of the underlying base table.
4300 - a temporary table (in optimization stage), the name of the source base tbl
4301 */
4303 /**
4304 Names the field in the source base table. If field is from
4305 - an expression, a NULL pointer.
4306 - a view or base table and is not aliased, the same as field_name.
4307 - a view or base table and is aliased, the column name of the view or
4308 base table.
4309 - a derived table, the column name of the underlying base table.
4310 - a temporary table (in optimization stage), the name of the source column.
4311 */
4313 bool m_alias_of_expr; ///< if this Item's name is alias of SELECT expression
4314
4315 public:
4316 /**
4317 For regularly resolved column references, 'context' points to a name
4318 resolution context object belonging to the query block which simply
4319 contains the reference. To further clarify, in
4320 SELECT (SELECT t.a) FROM t;
4321 t.a is an Item_ident whose 'context' belongs to the subquery
4322 (context->query_block == that of the subquery).
4323 For column references that are part of a generated column expression,
4324 'context' points to a temporary name resolution context object during
4325 resolving, but is set to nullptr after resolving is done. Note that
4326 Item_ident::local_column() depends on that.
4327 */
4329 /**
4330 Schema name of the base table or view the column is part of.
4331 If an expression, a NULL pointer.
4332 If from a derived table, a NULL pointer.
4333 */
4334 const char *db_name;
4335 /**
4336 If column is from a non-aliased base table or view, name of base table or
4337 view.
4338 If column is from an aliased base table or view, the alias name.
4339 If column is from a derived table, the name of the derived table.
4340 If column is from an expression, a NULL pointer.
4341 */
4342 const char *table_name;
4343 /**
4344 If column is aliased, the column alias name.
4345 If column is from a non-aliased base table or view, the name of the
4346 column in that base table or view.
4347 If column is from an expression, a string generated from that expression.
4348
4349 Notice that a column can be aliased in two ways:
4350 1. With an explicit column alias, or @<as clause@>, or
4351 2. With only a column name specified, which differs from the table's
4352 column name due to case insensitivity.
4353 In both cases field_name will differ from m_orig_field_name.
4354 field_name is normally identical to Item::item_name.
4355 */
4356 const char *field_name;
4357 /**
4358 Points to the Table_ref object of the table or view that the column or
4359 reference is resolved against (only valid after resolving).
4360 Notice that for the following types of "tables", no Table_ref object is
4361 assigned and hence m_table_ref is NULL:
4362 - Temporary tables assigned by join optimizer for sorting and aggregation.
4363 - Stored procedure dummy tables.
4364 For fields referencing such tables, table number is always 0, and other
4365 uses of m_table_ref is not needed.
4366 */
4368 /**
4369 For a column or reference that is an outer reference, depended_from points
4370 to the qualifying query block, otherwise it is NULL
4371 (only valid after resolving).
4372 */
4374
4375 Item_ident(Name_resolution_context *context_arg, const char *db_name_arg,
4376 const char *table_name_arg, const char *field_name_arg)
4377 : m_orig_db_name(db_name_arg),
4378 m_orig_table_name(table_name_arg),
4379 m_orig_field_name(field_name_arg),
4380 m_alias_of_expr(false),
4381 context(context_arg),
4382 db_name(db_name_arg),
4383 table_name(table_name_arg),
4384 field_name(field_name_arg) {
4385 item_name.set(field_name_arg);
4386 }
4387
4388 Item_ident(const POS &pos, const char *db_name_arg,
4389 const char *table_name_arg, const char *field_name_arg)
4390 : super(pos),
4391 m_orig_db_name(db_name_arg),
4392 m_orig_table_name(table_name_arg),
4393 m_orig_field_name(field_name_arg),
4394 m_alias_of_expr(false),
4395 db_name(db_name_arg),
4396 table_name(table_name_arg),
4397 field_name(field_name_arg) {
4398 item_name.set(field_name_arg);
4399 }
4400
4401 /// Constructor used by Item_field & Item_*_ref (see Item comment)
4402
4404 : Item(thd, item),
4409 context(item->context),
4410 db_name(item->db_name),
4411 table_name(item->table_name),
4412 field_name(item->field_name),
4413 m_table_ref(item->m_table_ref),
4415
4416 bool do_itemize(Parse_context *pc, Item **res) override;
4417
4418 const char *full_name() const override;
4419 void set_orignal_db_name(const char *name_arg) { m_orig_db_name = name_arg; }
4420 void set_original_table_name(const char *name_arg) {
4421 m_orig_table_name = name_arg;
4422 }
4423 void set_original_field_name(const char *name_arg) {
4424 m_orig_field_name = name_arg;
4425 }
4426 const char *original_db_name() const { return m_orig_db_name; }
4427 const char *original_table_name() const { return m_orig_table_name; }
4428 const char *original_field_name() const { return m_orig_field_name; }
4429 void fix_after_pullout(Query_block *parent_query_block,
4430 Query_block *removed_query_block) override;
4431 bool aggregate_check_distinct(uchar *arg) override;
4432 bool aggregate_check_group(uchar *arg) override;
4433 Bool3 local_column(const Query_block *sl) const override;
4434
4435 void print(const THD *thd, String *str,
4436 enum_query_type query_type) const override {
4437 print(thd, str, query_type, db_name, table_name);
4438 }
4439 uint64_t hash() override;
4440
4441 protected:
4442 /**
4443 Function to print column name for a table
4444
4445 To print a column for a permanent table (picks up database and table from
4446 Item_ident object):
4447
4448 item->print(str, qt)
4449
4450 To print a column for a temporary table:
4451
4452 item->print(str, qt, specific_db, specific_table)
4453
4454 Items of temporary table fields have empty/NULL values of table_name and
4455 db_name. To print column names in a 3D form (`database`.`table`.`column`),
4456 this function prints db_name_arg and table_name_arg parameters instead of
4457 this->db_name and this->table_name respectively.
4458
4459 @param thd Thread handle.
4460 @param [out] str Output string buffer.
4461 @param query_type Bitmap to control printing details.
4462 @param db_name_arg String to output as a column database name.
4463 @param table_name_arg String to output as a column table name.
4464 */
4465 void print(const THD *thd, String *str, enum_query_type query_type,
4466 const char *db_name_arg, const char *table_name_arg) const;
4467
4468 uint64_t hash(const char *db_name_arg, const char *table_name_arg);
4469
4470 public:
4471 ///< Argument object to change_context_processor
4475 };
4476 bool change_context_processor(uchar *arg) override {
4477 context = reinterpret_cast<Change_context *>(arg)->m_context;
4478 return false;
4479 }
4480
4481 /// @returns true if this Item's name is alias of SELECT expression
4482 bool is_alias_of_expr() const { return m_alias_of_expr; }
4483 /// Marks that this Item's name is alias of SELECT expression
4485
4486 /**
4487 Argument structure for walk processor Item::update_depended_from
4488 */
4490 Query_block *old_depended_from; // the transformed query block
4491 Query_block *new_depended_from; // the new derived table for grouping
4492 };
4493
4494 bool update_depended_from(uchar *) override;
4495
4496 /**
4497 @returns true if a part of this Item's full name (name or table name) is
4498 an alias.
4499 */
4500 virtual bool alias_name_used() const { return m_alias_of_expr; }
4502 const char *db_name, const char *table_name,
4504 bool any_privileges);
4505 bool is_strong_side_column_not_in_fd(uchar *arg) override;
4506 bool is_column_not_in_fd(uchar *arg) override;
4507};
4508
4509class Item_ident_for_show final : public Item {
4510 public:
4512 const char *db_name;
4513 const char *table_name;
4514
4515 Item_ident_for_show(Field *par_field, const char *db_arg,
4516 const char *table_name_arg)
4517 : field(par_field), db_name(db_arg), table_name(table_name_arg) {}
4518
4519 enum Type type() const override { return FIELD_ITEM; }
4520 bool fix_fields(THD *thd, Item **ref) override;
4521 double val_real() override { return field->val_real(); }
4522 longlong val_int() override { return field->val_int(); }
4523 String *val_str(String *str) override { return field->val_str(str); }
4525 return field->val_decimal(dec);
4526 }
4527 bool val_date(Date_val *date, my_time_flags_t flags) override {
4528 return field->val_date(date, flags);
4529 }
4530 bool val_time(Time_val *time) override { return field->val_time(time); }
4532 return field->val_datetime(dt, flags);
4533 }
4534 void make_field(Send_field *tmp_field) override;
4536 return field->charset_for_protocol();
4537 }
4538};
4539
4540class Item_field : public Item_ident {
4542
4543 protected:
4544 void set_field(Field *field);
4545 void fix_after_pullout(Query_block *parent_query_block,
4546 Query_block *removed_query_block) override {
4547 super::fix_after_pullout(parent_query_block, removed_query_block);
4548
4549 // Update nullability information, as the table may have taken over
4550 // null_row status from the derived table it was part of.
4552 field->table->is_nullable());
4553 }
4555 bool no_conversions) override;
4556
4557 public:
4558 /// Source field
4559 Field *field{nullptr};
4560
4561 private:
4562 /// Result field
4564
4565 // save_in_field() and save_org_in_field() are often called repeatedly
4566 // with the same destination field (although the destination for the
4567 // two are distinct, thus two distinct caches). We detect this case by
4568 // storing the last destination, and whether it was of a compatible type
4569 // that we can memcpy into (see fields_are_memcpyable()). This saves time
4570 // doing the same type checking over and over again.
4571 //
4572 // The _memcpyable fields are uint32_t(-1) if the fields are not memcpyable,
4573 // and pack_length() (ie., the amount of bytes to copy) if they are.
4574 // See field_conv_with_cache(), where this logic is encapsulated.
4579
4580 /**
4581 If this field is derived from another field, e.g. it is reading a column
4582 from a temporary table which is populated from a base table, this member
4583 points to the field used to populate the temporary table column.
4584 */
4586
4587 /**
4588 State used for transforming scalar subqueries to JOINs with derived tables,
4589 cf. \c transform_grouped_to_derived. Has accessor.
4590 */
4592
4593 /**
4594 Holds a list of items whose values must be equal to the value of
4595 this field, during execution.
4596
4597 Used during optimization to perform multiple equality analysis,
4598 this analysis should be performed during preparation instead, so that
4599 Item_field can be const after preparation.
4600 */
4602
4603 /**
4604 Indicates whether this field should be treated as an outer reference due to
4605 being the result of inlining a local variable within a stored program
4606 (currently applicable only to stored functions).
4607 */
4609
4610 /// apply_masking_policy() is a no-op if this flag is true.
4612
4613 public:
4614 /**
4615 Index for this field in table->field array. Holds NO_FIELD_INDEX
4616 if index value is not known.
4617 */
4620
4622 assert(item_equal != nullptr);
4623 item_equal_all_join_nests = item_equal;
4624 }
4625
4626 /**
4627 Sets m_was_sp_local_variable to true.
4628 */
4630
4631 // A list of fields that are considered "equal" to this field. E.g., a query
4632 // on the form "a JOIN b ON a.i = b.i JOIN c ON b.i = c.i" would consider
4633 // a.i, b.i and c.i equal due to equality propagation. This is the same as
4634 // "item_equal" above, except that "item_equal" will only contain fields from
4635 // the same join nest. This is used by hash join and BKA when they need to
4636 // undo multi-equality propagation done by the optimizer. (The optimizer may
4637 // generate join conditions that references unreachable fields for said
4638 // iterators.) The split is done because NDB expects the list to only
4639 // contain fields from the same join nest.
4641 /// If true, the optimizer's constant propagation will not replace this item
4642 /// with an equal constant.
4644 /*
4645 if any_privileges set to true then here real effective privileges will
4646 be stored
4647 */
4649 /* field need any privileges (for VIEW creation) */
4650 bool any_privileges{false};
4651 /*
4652 if this field is used in a context where covering prefix keys
4653 are supported.
4654 */
4656 Item_field(Name_resolution_context *context_arg, const char *db_arg,
4657 const char *table_name_arg, const char *field_name_arg);
4658 Item_field(const POS &pos, const char *db_arg, const char *table_name_arg,
4659 const char *field_name_arg);
4660 Item_field(THD *thd, Item_field *item);
4661 Item_field(THD *thd, Name_resolution_context *context_arg, Field *field);
4663
4664 bool do_itemize(Parse_context *pc, Item **res) override;
4665
4666 enum Type type() const override { return FIELD_ITEM; }
4667 bool eq(const Item *item) const override;
4668 double val_real() override;
4669 longlong val_int() override;
4670 longlong val_date_temporal() override;
4672 my_decimal *val_decimal(my_decimal *) override;
4673 String *val_str(String *) override;
4674 bool val_json(Json_wrapper *result) override;
4675 bool send(Protocol *protocol, String *str_arg) override;
4676 void reset_field(Field *f);
4677 bool fix_fields(THD *, Item **) override;
4678 void make_field(Send_field *tmp_field) override;
4679 void save_org_in_field(Field *field) override;
4680 table_map used_tables() const override;
4681 Item_result result_type() const override { return field->result_type(); }
4684 }
4685 TYPELIB *get_typelib() const override;
4687 return field->cast_to_int_type();
4688 }
4691 }
4692 longlong val_int_endpoint(bool left_endp, bool *incl_endp) override;
4693 void set_result_field(Field *field_arg) override { result_field = field_arg; }
4695 Field *tmp_table_field(TABLE *) override { return result_field; }
4698 item->base_item_field() != nullptr ? item->base_item_field() : item;
4699 }
4701 return m_base_item_field ? m_base_item_field : this;
4702 }
4703 bool val_date(Date_val *date, my_time_flags_t flags) override;
4704 bool val_time(Time_val *time) override;
4705 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
4706 bool get_timeval(my_timeval *tm, int *warnings) override;
4707 bool is_null() override {
4708 // NOTE: May return true even if maybe_null is not set!
4709 // This can happen if the underlying TABLE did not have a NULL row
4710 // at set_field() time (ie., table->is_null_row() was false),
4711 // but does now.
4712 return field->is_null();
4713 }
4714 Item *get_tmp_table_item(THD *thd) override;
4715 bool collect_item_field_processor(uchar *arg) override;
4716 bool collect_item_field_or_ref_processor(uchar *arg) override;
4718 bool collect_outer_field_processor(uchar *arg) override;
4719 bool add_field_to_set_processor(uchar *arg) override;
4720 bool add_field_to_cond_set_processor(uchar *) override;
4721 bool remove_column_from_bitmap(uchar *arg) override;
4722 bool find_item_in_field_list_processor(uchar *arg) override;
4723 bool find_field_processor(uchar *arg) override {
4724 return pointer_cast<Field *>(arg) == field;
4725 }
4726 bool check_function_as_value_generator(uchar *args) override;
4727 bool mark_field_in_map(uchar *arg) override {
4728 auto mark_field = pointer_cast<Mark_field *>(arg);
4729 bool rc = Item::mark_field_in_map(mark_field, field);
4731 rc |= Item::mark_field_in_map(mark_field, result_field);
4732 return rc;
4733 }
4734 bool used_tables_for_level(uchar *arg) override;
4735 bool check_column_privileges(uchar *arg) override;
4736 bool check_partition_func_processor(uchar *) override { return false; }
4737 void bind_fields() override;
4738 bool is_valid_for_pushdown(uchar *arg) override;
4739 bool check_column_in_window_functions(uchar *arg) override;
4740 bool check_column_in_group_by(uchar *arg) override;
4741 Item *replace_with_derived_expr(uchar *arg) override;
4743 void cleanup() override;
4744 void reset_field();
4745 Item_multi_eq *find_multi_equality(COND_EQUAL *cond_equal) const;
4746 bool subst_argument_checker(uchar **arg) override;
4747 Item *equal_fields_propagator(uchar *arg) override;
4748 Item *replace_item_field(uchar *) override;
4751 return false;
4752 }
4753 Item *replace_equal_field(uchar *) override;
4755 Item_field *field_for_view_update() override { return this; }
4756 bool fix_outer_field(THD *thd, Field **field, Item_ident **ref_field,
4757 bool *complete);
4758 Item *update_value_transformer(uchar *select_arg) override;
4759 void print(const THD *thd, String *str,
4760 enum_query_type query_type) const override;
4761 bool is_outer_field() const override {
4762 assert(fixed);
4764 }
4766 assert(data_type() == MYSQL_TYPE_GEOMETRY);
4767 return field->get_geometry_type();
4768 }
4769 const CHARSET_INFO *charset_for_protocol(void) override {
4770 return field->charset_for_protocol();
4771 }
4772
4773#ifndef NDEBUG
4774 void dbug_print() const {
4775 fprintf(DBUG_FILE, "<field ");
4776 if (field) {
4777 fprintf(DBUG_FILE, "'%s.%s': ", field->table->alias, field->field_name);
4778 field->dbug_print();
4779 } else
4780 fprintf(DBUG_FILE, "NULL");
4781
4782 fprintf(DBUG_FILE, ", result_field: ");
4783 if (result_field) {
4784 fprintf(DBUG_FILE, "'%s.%s': ", result_field->table->alias,
4787 } else
4788 fprintf(DBUG_FILE, "NULL");
4789 fprintf(DBUG_FILE, ">\n");
4790 }
4791#endif
4792
4793 float get_filtering_effect(THD *thd, table_map filter_for_table,
4794 table_map read_tables,
4795 const MY_BITMAP *fields_to_ignore,
4796 double rows_in_table) override;
4797
4798 /**
4799 Returns the probability for the predicate "col OP <val>" to be
4800 true for a row in the case where no index statistics or range
4801 estimates are available for 'col'.
4802
4803 The probability depends on the number of rows in the table: it is by
4804 default 'default_filter', but never lower than 1/max_distinct_values
4805 (e.g. number of rows in the table, or the number of distinct values
4806 possible for the datatype if the field provides that kind of
4807 information).
4808
4809 @param max_distinct_values The maximum number of distinct values,
4810 typically the number of rows in the table
4811 @param default_filter The default filter for the predicate
4812
4813 @return the estimated filtering effect for this predicate
4814 */
4815
4816 float get_cond_filter_default_probability(double max_distinct_values,
4817 float default_filter) const;
4818
4819 /**
4820 @note that field->table->alias_name_used is reliable only if
4821 thd->lex->need_correct_ident() is true.
4822 */
4823 bool alias_name_used() const override {
4824 return m_alias_of_expr ||
4825 // maybe the qualifying table was given an alias ("t1 AS foo"):
4827 }
4828
4829 bool repoint_const_outer_ref(uchar *arg) override;
4830 bool returns_array() const override { return field && field->is_array(); }
4831 Item *apply_masking_policy(THD *thd) override;
4833
4834 void set_can_use_prefix_key() override { can_use_prefix_key = true; }
4835
4836 bool replace_field_processor(uchar *arg) override;
4837 bool strip_db_table_name_processor(uchar *) override;
4838
4839 /**
4840 Checks if the current object represents an asterisk select list item
4841
4842 @returns false if a regular column reference, true if an asterisk
4843 select list item.
4844 */
4845 virtual bool is_asterisk() const { return false; }
4846 /// See \c m_protected_by_any_value
4848
4849 void compute_cost(CostOfItem *root_cost) const override {
4850 field->add_to_cost(root_cost);
4851 }
4852};
4853
4854/**
4855 Represents [schema.][table.]* in a select list
4856
4857 Item_asterisk is used to insert placeholder objects for the special
4858 select list item * (asterisk) into AST.
4859 Those placeholder objects are to be substituted later with e.g. a list of real
4860 table columns by a resolver (@see setup_wild).
4861
4862 @todo The parent class Item_field is redundant. Refactor setup_wild() to
4863 replace Item_field with a simpler one.
4864*/
4867
4868 public:
4869 /**
4870 Constructor
4871
4872 @param pos Location of the * (asterisk) lexeme.
4873 @param opt_schema_name Schema name or nullptr.
4874 @param opt_table_name Table name or nullptr.
4875 */
4876 Item_asterisk(const POS &pos, const char *opt_schema_name,
4877 const char *opt_table_name)
4878 : super(pos, opt_schema_name, opt_table_name, "*") {}
4879
4880 bool do_itemize(Parse_context *pc, Item **res) override;
4881 bool fix_fields(THD *, Item **) override {
4882 assert(false); // should never happen: see setup_wild()
4883 return true;
4884 }
4885 bool is_asterisk() const override { return true; }
4886};
4887
4888// See if the provided item points to a reachable field (one that belongs to a
4889// table within 'reachable_tables'). If not, go through the list of 'equal'
4890// items in the item and see if we have a field that is reachable. If any such
4891// field is found, set "found" to true and create a new Item_field that points
4892// to this reachable field and return it if we are asked to "replace". If the
4893// provided item is already reachable, or if we cannot find a reachable field,
4894// return the provided item unchanged and set "found" to false. This is used
4895// when creating a hash join iterator, where the join condition may point to a
4896// non-reachable field due to multi-equality propagation during optimization.
4897// (Ideally, the optimizer should not set up such condition in the first place.
4898// This is difficult, if not impossible, to accomplish, given that the plan
4899// created by the optimizer does not map 100% to the iterator executor.) Note
4900// that if the field is not reachable, and we cannot find a reachable field, we
4901// provided field is returned unchanged. The effect is that the hash join will
4902// degrade into a nested loop.
4903Item_field *FindEqualField(Item_field *item_field, table_map reachable_tables,
4904 bool replace, bool *found);
4905
4908
4909 void init() {
4911 null_value = true;
4912 fixed = true;
4913 }
4914
4915 protected:
4917 bool no_conversions) override;
4918
4919 public:
4921 init();
4922 item_name = NAME_STRING("NULL");
4923 }
4924 explicit Item_null(const POS &pos) : super(pos) {
4925 init();
4926 item_name = NAME_STRING("NULL");
4927 }
4928
4929 Item_null(const Name_string &name_par) {
4930 init();
4931 item_name = name_par;
4932 }
4933
4934 enum Type type() const override { return NULL_ITEM; }
4935 bool eq(const Item *item) const override;
4936 double val_real() override;
4937 longlong val_int() override;
4938 longlong val_date_temporal() override { return val_int(); }
4939 String *val_str(String *str) override;
4940 my_decimal *val_decimal(my_decimal *) override;
4941 bool val_date(Date_val *, my_time_flags_t) override { return true; }
4942 bool val_time(Time_val *) override { return true; }
4943 bool val_datetime(Datetime_val *, my_time_flags_t) override { return true; }
4944 bool val_json(Json_wrapper *wr) override;
4945 bool send(Protocol *protocol, String *str) override;
4946 Item_result result_type() const override { return STRING_RESULT; }
4947 Item *clone_item() const override { return new Item_null(item_name); }
4948 bool is_null() override { return true; }
4949
4950 void print(const THD *, String *str,
4951 enum_query_type query_type) const override {
4952 str->append(query_type == QT_NORMALIZED_FORMAT ? "?" : "NULL");
4953 }
4954 uint64_t hash() override;
4955
4956 bool check_partition_func_processor(uchar *) override { return false; }
4957};
4958
4959/// Dynamic parameters used as placeholders ('?') inside prepared statements
4960
4961class Item_param final : public Item, private Settable_routine_parameter {
4962 typedef Item super;
4963
4964 protected:
4966 bool no_conversions) override;
4967
4968 public:
4981
4983 m_param_state = state;
4984 }
4985
4987
4988 void mark_json_as_scalar() override { m_json_as_scalar = true; }
4989
4990 /*
4991 A buffer for string and long data values. Historically all allocated
4992 values returned from val_str() were treated as eligible to
4993 modification. I. e. in some cases Item_func_concat can append it's
4994 second argument to return value of the first one. Because of that we
4995 can't return the original buffer holding string data from val_str(),
4996 and have to have one buffer for data and another just pointing to
4997 the data. This is the latter one and it's returned from val_str().
4998 Can not be declared inside the union as it's not a POD type.
4999 */
5005 union {
5007 double real;
5009
5010 private:
5011 /**
5012 True if type of parameter is inherited from parent object (like a typecast).
5013 Reprepare of statement will not change this type.
5014 E.g, we have CAST(? AS DOUBLE), the parameter gets data type
5015 MYSQL_TYPE_DOUBLE and m_type_inherited is set true.
5016 */
5017 bool m_type_inherited{false};
5018 /**
5019 True if type of parameter has been pinned, attempt to use an incompatible
5020 actual type will cause error (no repreparation occurs), and value is
5021 subject to range check. This is used when the parameter is in a context
5022 where its type is imposed. For example, in LIMIT ?, we assign
5023 data_type() == integer, unsigned; and the provided value must be
5024 convertible to unsigned integer: passing a DOUBLE, instead of causing a
5025 repreparation as for an ordinary parameter, will cause an error; passing
5026 integer '-1' will also cause an error.
5027 */
5028 bool m_type_pinned{false};
5029 /**
5030 Parameter objects have a rather complex handling of data type, in order
5031 to consistently handle required type conversion semantics. There are
5032 three data type properties involved:
5033
5034 1. The data_type() property contains the desired type of the parameter
5035 value, as defined by an explicit CAST, the operation the parameter
5036 is part of, and/or the context given by other values and expressions.
5037 After implicit repreparation it may also be assigned from provided
5038 parameter values.
5039
5040 2. The data_type_source() property is the data type of the parameter value,
5041 as given by the supplied user variable or from the protocol buffer.
5042
5043 3. The data_type_actual() property is the data type of the parameter value,
5044 after possible conversion from the source data type.
5045 Conversions may involve
5046 - Character set conversion of string value.
5047 - Conversion from string or number into temporal value, if the
5048 resolved data type is a temporal.
5049 - Conversion from string to number, if the resolved data type is numeric.
5050
5051 In addition, each data type property may have extra attributes to enforce
5052 correct character set, collation and signedness of integers.
5053 */
5054 /**
5055 The "source" data type of the provided parameter.
5056 Used when the parameter comes through protocol buffers.
5057 Notice that signedness of integers is stored in m_unsigned_actual.
5058 */
5060 /**
5061 The actual data type of the parameter value provided by the user.
5062 For example:
5063
5064 PREPARE s FROM "SELECT ?=3e0";
5065
5066 makes Item_param->data_type() be MYSQL_TYPE_DOUBLE ; then:
5067
5068 SET @a='1';
5069 EXECUTE s USING @a;
5070
5071 data_type() is still MYSQL_TYPE_DOUBLE, while data_type_source() is
5072 MYSQL_TYPE_VARCHAR and data_type_actual() is MYSQL_TYPE_VARCHAR.
5073 Compatibility of data_type() and data_type_actual() is later tested
5074 in check_parameter_types().
5075 Only a limited set of field types are possible values:
5076 MYSQL_TYPE_LONGLONG, MYSQL_TYPE_NEWDECIMAL, MYSQL_TYPE_DOUBLE,
5077 MYSQL_TYPE_DATE, MYSQL_TYPE_TIME, MYSQL_TYPE_DATETIME,
5078 MYSQL_TYPE_VARCHAR, MYSQL_TYPE_NULL, MYSQL_TYPE_INVALID
5079 */
5081 /// Used when actual value is integer to indicate whether value is unsigned
5083 /**
5084 The character set and collation of the source parameter value.
5085 Ignored if not a string value.
5086 - If parameter value is sent over the protocol: the client collation
5087 - If parameter value is a user variable: the variable's collation
5088 */
5090 /**
5091 The character set and collation of the value stored in str_value, possibly
5092 after being converted from the m_collation_source collation.
5093 Ignored if not a string value.
5094 - If the derived collation is binary, the connection collation.
5095 - Otherwise, the derived collation (@see Item::collation).
5096 */
5098 /// Result type of parameter. @todo replace with type_to_result(data_type()
5100 /**
5101 m_param_state is used to indicate that no parameter value is available
5102 with NO_VALUE, or a NULL value is available (NULL_VALUE), or the actual
5103 type of the provided parameter value. Usually, this matches m_actual_type,
5104 but in the case of pinned data types, this is matching the resolved data
5105 type of the parameter. m_param_state reflects the type of the value stored
5106 in Item_param::value.
5107 */
5109
5110 /**
5111 If true, when retrieving JSON data, attempt to interpret a string value as
5112 a scalar JSON value, otherwise interpret it as a JSON object.
5113 */
5114 bool m_json_as_scalar{false};
5115
5116 /*
5117 data_type() is used when this item is used in a temporary table.
5118 This is NOT placeholder metadata sent to client, as this value
5119 is assigned after sending metadata (in setup_one_conversion_function).
5120 For example in case of 'SELECT ?' you'll get MYSQL_TYPE_STRING both
5121 in result set and placeholders metadata, no matter what type you will
5122 supply for this placeholder in mysql_stmt_execute.
5123 */
5124
5125 public:
5126 /*
5127 Offset of placeholder inside statement text. Used to create
5128 no-placeholders version of this statement for the binary log.
5129 */
5131
5132 Item_param(const POS &pos, MEM_ROOT *root, uint pos_in_query_arg);
5133
5134 bool do_itemize(Parse_context *pc, Item **item) override;
5135
5136 Item_result result_type() const override { return m_result_type; }
5137 enum Type type() const override { return PARAM_ITEM; }
5138
5139 /// Set the currently resolved data type for this parameter as inherited
5140 void set_data_type_inherited() override { m_type_inherited = true; }
5141
5142 /// @returns true if data type for this parameter is inherited.
5143 bool is_type_inherited() const { return m_type_inherited; }
5144
5145 /// Pin the currently resolved data type for this parameter.
5146 void pin_data_type() override { m_type_pinned = true; }
5147
5148 /// @returns true if data type for this parameter is pinned.
5149 bool is_type_pinned() const { return m_type_pinned; }
5150
5151 /// @returns true if actual data value (integer) is unsigned
5152 bool is_unsigned_actual() const { return m_unsigned_actual; }
5153
5156 m_collation_source = coll;
5157 }
5160 m_collation_actual = coll;
5161 }
5162 /// @returns the source collation of the supplied string parameter
5164
5165 /// @returns the actual collation of the supplied string parameter
5168 return m_collation_actual;
5169 }
5170 bool fix_fields(THD *thd, Item **ref) override;
5171
5172 bool propagate_type(THD *thd, const Type_properties &type) override;
5173
5174 double val_real() override;
5175 longlong val_int() override;
5176 my_decimal *val_decimal(my_decimal *) override;
5177 String *val_str(String *) override;
5178 bool val_json(Json_wrapper *result) override;
5179 bool val_date(Date_val *date, my_time_flags_t flags) override;
5180 bool val_time(Time_val *time) override;
5181 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
5184 m_unsigned_actual = unsigned_val;
5185 }
5186 // For use with non-integer field types only
5189 }
5190 /// For use with all field types, especially integer types
5193 m_unsigned_actual = unsigned_val;
5194 }
5196
5198
5200 return data_type_actual();
5201 }
5202
5203 void set_null();
5204 void set_int(longlong i);
5205 void set_int(ulonglong i);
5206 void set_double(double i);
5207 void set_decimal(const char *str, ulong length);
5208 void set_decimal(const my_decimal *dv);
5209 bool set_str(const char *str, size_t length);
5210 bool set_longdata(const char *str, ulong length);
5212 void set_time(Time_val time);
5213 void set_date(Date_val date);
5214 void set_datetime(Datetime_val dt);
5215 bool set_from_user_var(THD *thd, const user_var_entry *entry);
5217 void reset();
5218
5219 const String *query_val_str(const THD *thd, String *str) const;
5220
5221 bool convert_value();
5222
5223 /*
5224 Parameter is treated as constant during execution, thus it will not be
5225 evaluated during preparation.
5226 */
5227 table_map used_tables() const override { return INNER_TABLE_BIT; }
5228 void print(const THD *thd, String *str,
5229 enum_query_type query_type) const override;
5230 uint64_t hash() override;
5231 bool is_null() override {
5232 assert(m_param_state != NO_VALUE);
5233 return m_param_state == NULL_VALUE;
5234 }
5235
5236 Item *clone_item() const override;
5237 /*
5238 Implement by-value equality evaluation if parameter value
5239 is set and is a basic constant (integer, real or string).
5240 Otherwise return false.
5241 */
5242 bool eq(const Item *item) const override;
5244 bool is_non_const_over_literals(uchar *) override { return true; }
5245 /**
5246 This should be called after any modification done to this Item, to
5247 propagate the said modification to all its clones.
5248 */
5249 void sync_clones();
5250 bool add_clone(Item_param *i) { return m_clones.push_back(i); }
5251
5252 private:
5254 return this;
5255 }
5256
5257 bool set_value(THD *, sp_rcontext *, Item **it) override;
5258
5259 void set_out_param_info(Send_field *info) override;
5260
5261 public:
5262 const Send_field *get_out_param_info() const override;
5263
5264 void make_field(Send_field *field) override;
5265
5268 pointer_cast<Check_function_as_value_generator_parameters *>(args);
5269 func_arg->err_code = func_arg->get_unnamed_function_error_code();
5270 return true;
5271 }
5272 bool is_valid_for_pushdown(uchar *arg [[maybe_unused]]) override {
5273 // It is ok to push down a condition like "column > PS_parameter".
5274 return false;
5275 }
5276
5277 private:
5279 /**
5280 If a query expression's text QT or text of a condition (CT) that is pushed
5281 down to a derived table, containing a parameter, is internally duplicated
5282 and parsed twice (@see reparse_common_table_expression, parse_expression),
5283 the first parsing will create an Item_param I, and the re-parsing, which
5284 parses a forged "(QT)" parse-this-CTE type of statement or parses a
5285 forged condition "(CT)", will create an Item_param J. J should not exist:
5286 - from the point of view of logging: it is not in the original query so it
5287 should not be substituted in the query written to logs (in insert_params()
5288 if with_log is true).
5289 - from the POV of the user:
5290 * user provides one single value for I, not one for I and one for J.
5291 * user expects mysql_stmt_param_count() to return 1, not 2 (count is
5292 sent by the server in send_prep_stmt()).
5293 That is why J is part neither of LEX::param_list, nor of param_array; it
5294 is considered an inferior clone of I; I::m_clones contains J.
5295 The connection between I and J is made once, by comparing their
5296 byte position in the statement, in Item_param::itemize().
5297 J gets its value from I: @see Item_param::sync_clones.
5298 */
5300};
5301
5302class Item_int : public Item_num {
5304
5305 public:
5306 static Item_int *narrow(Item *item);
5307
5310 : value((longlong)i) {
5313 fixed = true;
5314 }
5316 : super(pos), value((longlong)i) {
5319 fixed = true;
5320 }
5324 fixed = true;
5325 }
5327 : value((longlong)i) {
5329 unsigned_flag = true;
5331 fixed = true;
5332 }
5333 Item_int(const Item_int *item_arg) {
5334 set_data_type(item_arg->data_type());
5335 value = item_arg->value;
5336 item_name = item_arg->item_name;
5337 max_length = item_arg->max_length;
5338 fixed = true;
5339 }
5340 Item_int(const Name_string &name_arg, longlong i, uint length) : value(i) {
5343 item_name = name_arg;
5344 fixed = true;
5345 }
5346 Item_int(const POS &pos, const Name_string &name_arg, longlong i, uint length)
5347 : super(pos), value(i) {
5350 item_name = name_arg;
5351 fixed = true;
5352 }
5353 Item_int(const char *str_arg, uint length) {
5355 init(str_arg, length);
5356 }
5357 Item_int(const POS &pos, const char *str_arg, uint length) : super(pos) {
5359 init(str_arg, length);
5360 }
5361
5362 Item_int(const POS &pos, const LEX_STRING &num, int dummy_error = 0)
5363 : Item_int(pos, num, my_strtoll10(num.str, nullptr, &dummy_error),
5364 static_cast<uint>(num.length)) {}
5365
5366 private:
5367 void init(const char *str_arg, uint length);
5370 if (!unsigned_flag && value >= 0) max_length++;
5371 }
5372
5373 protected:
5375 bool no_conversions) override;
5376
5377 public:
5378 enum Type type() const override { return INT_ITEM; }
5379 Item_result result_type() const override { return INT_RESULT; }
5380 longlong val_int() override {
5381 assert(fixed);
5382 return value;
5383 }
5384 double val_real() override {
5385 assert(fixed);
5386 return static_cast<double>(value);
5387 }
5388 my_decimal *val_decimal(my_decimal *) override;
5389 String *val_str(String *) override;
5390 bool val_date(Date_val *date, my_time_flags_t flags) override {
5391 return get_date_from_int(date, flags);
5392 }
5393 bool val_time(Time_val *time) override { return get_time_from_int(time); }
5395 return get_datetime_from_int(dt, flags);
5396 }
5397 Item *clone_item() const override { return new Item_int(this); }
5398 void print(const THD *thd, String *str,
5399 enum_query_type query_type) const override;
5400 uint64_t hash() override;
5401 Item_num *neg() override {
5402 value = -value;
5403 return this;
5404 }
5405 uint decimal_precision() const override {
5406 return static_cast<uint>(max_length - 1);
5407 }
5408 bool eq(const Item *item) const override;
5409 bool check_partition_func_processor(uchar *) override { return false; }
5410 bool check_function_as_value_generator(uchar *) override { return false; }
5411};
5412
5413/**
5414 Item_int with value==0 and length==1
5415*/
5416class Item_int_0 final : public Item_int {
5417 public:
5419 explicit Item_int_0(const POS &pos) : Item_int(pos, NAME_STRING("0"), 0, 1) {}
5420};
5421
5422/*
5423 Item_temporal is used to store numeric representation
5424 of datetime values for queries like:
5425
5426 WHERE datetime_column NOT IN
5427 ('2006-04-25 10:00:00','2006-04-25 10:02:00', ...);
5428
5429 and for SHOW/INFORMATION_SCHEMA purposes (see sql_show.cc)
5430
5431 TS-TODO: Can't we use Item_time_literal, Item_date_literal,
5432 TS-TODO: and Item_datetime_literal for this purpose?
5433*/
5434class Item_temporal final : public Item_int {
5435 protected:
5437 bool no_conversions) override;
5438
5439 public:
5441 assert(is_temporal_type(field_type_arg));
5442 assert(field_type_arg != MYSQL_TYPE_TIME &&
5443 field_type_arg != MYSQL_TYPE_DATE);
5444 set_data_type(field_type_arg);
5445 }
5446 Item_temporal(enum_field_types field_type_arg, const Name_string &name_arg,
5447 longlong i, uint length)
5448 : Item_int(i) {
5449 assert(is_temporal_type(field_type_arg));
5450 assert(field_type_arg != MYSQL_TYPE_TIME &&
5451 field_type_arg != MYSQL_TYPE_DATE);
5452 set_data_type(field_type_arg);
5454 item_name = name_arg;
5455 fixed = true;
5456 }
5457 Item *clone_item() const override {
5458 return new Item_temporal(data_type(), value);
5459 }
5460 longlong val_date_temporal() override { return val_int(); }
5462 assert(false);
5463 return false;
5464 }
5465 bool val_time(Time_val *) override {
5466 assert(false);
5467 return false;
5468 }
5470 assert(false);
5471 return false;
5472 }
5473};
5474
5475class Item_uint : public Item_int {
5476 protected:
5478 bool no_conversions) override;
5479
5480 public:
5481 Item_uint(const char *str_arg, uint length) : Item_int(str_arg, length) {
5482 unsigned_flag = true;
5483 }
5484 Item_uint(const POS &pos, const char *str_arg, uint length)
5485 : Item_int(pos, str_arg, length) {
5486 unsigned_flag = true;
5487 }
5488
5490 Item_uint(const Name_string &name_arg, longlong i, uint length)
5491 : Item_int(name_arg, i, length) {
5492 unsigned_flag = true;
5493 }
5494 double val_real() override {
5495 assert(fixed);
5496 return ulonglong2double(static_cast<ulonglong>(value));
5497 }
5498 String *val_str(String *) override;
5499
5500 Item *clone_item() const override {
5501 return new Item_uint(item_name, value, max_length);
5502 }
5503 void print(const THD *thd, String *str,
5504 enum_query_type query_type) const override;
5505 uint64_t hash() override;
5506 Item_num *neg() override;
5507 uint decimal_precision() const override { return max_length; }
5508};
5509
5510/* decimal (fixed point) constant */
5511class Item_decimal : public Item_num {
5513
5514 protected:
5517 bool no_conversions) override;
5518
5519 public:
5520 Item_decimal(const POS &pos, const char *str_arg, uint length,
5521 const CHARSET_INFO *charset);
5522 Item_decimal(const Name_string &name_arg, const my_decimal *val_arg,
5523 uint decimal_par, uint length);
5524 Item_decimal(my_decimal *value_par);
5525 Item_decimal(longlong val, bool unsig);
5526 Item_decimal(double val);
5527 Item_decimal(const uchar *bin, int precision, int scale);
5528
5529 enum Type type() const override { return DECIMAL_ITEM; }
5530 Item_result result_type() const override { return DECIMAL_RESULT; }
5531 longlong val_int() override;
5532 double val_real() override;
5533 String *val_str(String *) override;
5535 bool val_date(Date_val *date, my_time_flags_t flags) override {
5536 return get_date_from_decimal(date, flags);
5537 }
5538 bool val_time(Time_val *time) override { return get_time_from_decimal(time); }
5540 return get_datetime_from_decimal(dt, flags);
5541 }
5542 Item *clone_item() const override {
5544 }
5545 void print(const THD *thd, String *str,
5546 enum_query_type query_type) const override;
5547 uint64_t hash() override;
5548 Item_num *neg() override {
5551 return this;
5552 }
5553 uint decimal_precision() const override { return decimal_value.precision(); }
5554 bool eq(const Item *item) const override;
5555 void set_decimal_value(const my_decimal *value_par);
5556 bool check_partition_func_processor(uchar *) override { return false; }
5557};
5558
5559class Item_float : public Item_num {
5561
5563
5564 public:
5565 double value;
5566 // Item_real() :value(0) {}
5567 Item_float(const char *str_arg, uint length) { init(str_arg, length); }
5568 Item_float(const POS &pos, const char *str_arg, uint length) : super(pos) {
5569 init(str_arg, length);
5570 }
5571
5572 Item_float(const Name_string name_arg, double val_arg, uint decimal_par,
5573 uint length)
5574 : value(val_arg) {
5575 presentation = name_arg;
5576 item_name = name_arg;
5578 decimals = (uint8)decimal_par;
5580 fixed = true;
5581 }
5582 Item_float(const POS &pos, const Name_string name_arg, double val_arg,
5583 uint decimal_par, uint length)
5584 : super(pos), value(val_arg) {
5585 presentation = name_arg;
5586 item_name = name_arg;
5588 decimals = (uint8)decimal_par;
5590 fixed = true;
5591 }
5592
5593 Item_float(double value_par, uint decimal_par) : value(value_par) {
5595 decimals = (uint8)decimal_par;
5596 max_length = float_length(decimal_par);
5597 fixed = true;
5598 }
5599
5600 private:
5601 void init(const char *str_arg, uint length);
5602
5603 protected:
5605 bool no_conversions) override;
5606
5607 public:
5608 enum Type type() const override { return REAL_ITEM; }
5609 double val_real() override {
5610 assert(fixed);
5611 return value;
5612 }
5613 longlong val_int() override {
5614 assert(fixed);
5615 if (value <= LLONG_MIN) {
5616 return LLONG_MIN;
5617 } else if (value > LLONG_MAX_DOUBLE) {
5618 return LLONG_MAX;
5619 }
5620 return (longlong)rint(value);
5621 }
5622 String *val_str(String *) override;
5623 my_decimal *val_decimal(my_decimal *) override;
5624 bool val_date(Date_val *date, my_time_flags_t flags) override {
5625 return get_date_from_real(date, flags);
5626 }
5627 bool val_time(Time_val *time) override { return get_time_from_real(time); }
5629 return get_datetime_from_real(dt, flags);
5630 }
5631 Item *clone_item() const override {
5633 }
5634 Item_num *neg() override {
5635 value = -value;
5636 return this;
5637 }
5638 void print(const THD *thd, String *str,
5639 enum_query_type query_type) const override;
5640 uint64_t hash() override;
5641 bool eq(const Item *item) const override;
5642};
5643
5644class Item_func_pi : public Item_float {
5646
5647 public:
5648 Item_func_pi(const POS &pos)
5649 : Item_float(pos, null_name_string, M_PI, 6, 8),
5650 func_name(NAME_STRING("pi()")) {}
5651
5652 void print(const THD *, String *str, enum_query_type) const override {
5653 str->append(func_name);
5654 }
5655};
5656
5659
5660 protected:
5661 explicit Item_string(const POS &pos) : super(pos), m_cs_specified(false) {
5663 }
5664
5665 void init(const char *str, size_t length, const CHARSET_INFO *cs,
5666 Derivation dv, uint repertoire) {
5669 collation.set(cs, dv, repertoire);
5670 /*
5671 We have to have a different max_length than 'length' here to
5672 ensure that we get the right length if we do use the item
5673 to create a new table. In this case max_length must be the maximum
5674 number of chars for a string of this type because we in Create_field::
5675 divide the max_length with mbmaxlen).
5676 */
5677 max_length = static_cast<uint32>(str_value.numchars() * cs->mbmaxlen);
5680 // it is constant => can be used without fix_fields (and frequently used)
5681 fixed = true;
5682 /*
5683 Check if the string has any character that can't be
5684 interpreted using the relevant charset.
5685 */
5686 check_well_formed_result(&str_value, false, false);
5687 }
5689 bool no_conversions) override;
5690
5691 public:
5692 /* Create from a string, set name from the string itself. */
5693 Item_string(const char *str, size_t length, const CHARSET_INFO *cs,
5695 uint repertoire = MY_REPERTOIRE_UNICODE30)
5696 : m_cs_specified(false) {
5697 init(str, length, cs, dv, repertoire);
5698 }
5699 Item_string(const POS &pos, const char *str, size_t length,
5701 uint repertoire = MY_REPERTOIRE_UNICODE30)
5702 : super(pos), m_cs_specified(false) {
5703 init(str, length, cs, dv, repertoire);
5704 }
5705
5706 /* Just create an item and do not fill string representation */
5708 : m_cs_specified(false) {
5709 collation.set(cs, dv);
5711 max_length = 0;
5713 fixed = true;
5714 }
5715
5716 /* Create from the given name and string. */
5717 Item_string(const Name_string name_par, const char *str, size_t length,
5719 uint repertoire = MY_REPERTOIRE_UNICODE30)
5720 : m_cs_specified(false) {
5722 collation.set(cs, dv, repertoire);
5724 max_length = static_cast<uint32>(str_value.numchars() * cs->mbmaxlen);
5725 item_name = name_par;
5727 // it is constant => can be used without fix_fields (and frequently used)
5728 fixed = true;
5729 }
5730 Item_string(const POS &pos, const Name_string name_par, const char *str,
5731 size_t length, const CHARSET_INFO *cs,
5733 uint repertoire = MY_REPERTOIRE_UNICODE30)
5734 : super(pos), m_cs_specified(false) {
5736 collation.set(cs, dv, repertoire);
5738 max_length = static_cast<uint32>(str_value.numchars() * cs->mbmaxlen);
5739 item_name = name_par;
5741 // it is constant => can be used without fix_fields (and frequently used)
5742 fixed = true;
5743 }
5744
5745 /* Create from the given name and string. */
5746 Item_string(const POS &pos, const Name_string name_par,
5747 const LEX_CSTRING &literal, const CHARSET_INFO *cs,
5749 uint repertoire = MY_REPERTOIRE_UNICODE30)
5750 : super(pos), m_cs_specified(false) {
5751 str_value.set_or_copy_aligned(literal.str ? literal.str : "",
5752 literal.str ? literal.length : 0, cs);
5753 collation.set(cs, dv, repertoire);
5755 max_length = static_cast<uint32>(str_value.numchars() * cs->mbmaxlen);
5756 item_name = name_par;
5758 // it is constant => can be used without fix_fields (and frequently used)
5759 fixed = true;
5760 }
5761
5762 /*
5763 This is used in stored procedures to avoid memory leaks and
5764 does a deep copy of its argument.
5765 */
5766 void set_str_with_copy(const char *str_arg, uint length_arg) {
5767 str_value.copy(str_arg, length_arg, collation.collation);
5768 max_length = static_cast<uint32>(str_value.numchars() *
5770 }
5771 bool set_str_with_copy(const char *str_arg, uint length_arg,
5772 const CHARSET_INFO *from_cs);
5773 /// Update collation of string value to be according to item's collation
5775
5779 }
5780 enum Type type() const override { return STRING_ITEM; }
5781 double val_real() override;
5782 longlong val_int() override;
5783 String *val_str(String *) override {
5784 assert(fixed);
5785 return &str_value;
5786 }
5787 my_decimal *val_decimal(my_decimal *) override;
5788 bool val_date(Date_val *date, my_time_flags_t flags) override {
5789 return get_date_from_string(date, flags);
5790 }
5791 bool val_time(Time_val *time) override { return get_time_from_string(time); }
5793 return get_datetime_from_string(dt, flags);
5794 }
5795 Item_result result_type() const override { return STRING_RESULT; }
5796 bool eq(const Item *item) const override;
5797 bool eq_binary(const Item_string *item) const {
5798 return !stringcmp(&str_value, &item->str_value);
5799 }
5800 Item *clone_item() const override {
5801 return new Item_string(static_cast<Name_string>(item_name), str_value.ptr(),
5803 }
5804 inline void append(char *str, size_t length) {
5806 max_length = static_cast<uint32>(str_value.numchars() *
5808 }
5809 void print(const THD *thd, String *str,
5810 enum_query_type query_type) const override;
5811 uint64_t hash() override;
5812 bool check_partition_func_processor(uchar *) override { return false; }
5813
5814 /**
5815 Return true if character-set-introducer was explicitly specified in the
5816 original query for this item (text literal).
5817
5818 This operation is to be called from Item_string::print(). The idea is
5819 that when a query is generated (re-constructed) from the Item-tree,
5820 character-set-introducers should appear only for those literals, where
5821 they were explicitly specified by the user. Otherwise, that may lead to
5822 loss collation information (character set introducers implies default
5823 collation for the literal).
5824
5825 Basically, that makes sense only for views and hopefully will be gone
5826 one day when we start using original query as a view definition.
5827
5828 @return This operation returns the value of m_cs_specified attribute.
5829 @retval true if character set introducer was explicitly specified in
5830 the original query.
5831 @retval false otherwise.
5832 */
5833 inline bool is_cs_specified() const { return m_cs_specified; }
5834
5835 /**
5836 Set the value of m_cs_specified attribute.
5837
5838 m_cs_specified attribute shows whether character-set-introducer was
5839 explicitly specified in the original query for this text literal or
5840 not. The attribute makes sense (is used) only for views.
5841
5842 This operation is to be called from the parser during parsing an input
5843 query.
5844 */
5845 inline void set_cs_specified(bool cs_specified) {
5846 m_cs_specified = cs_specified;
5847 }
5848
5850
5851 private:
5853};
5854
5856 const char *cptr, const char *end,
5857 int unsigned_target);
5858double double_from_string_with_check(const CHARSET_INFO *cs, const char *cptr,
5859 const char *end);
5860
5863
5864 public:
5865 Item_static_string_func(const Name_string &name_par, const char *str,
5866 size_t length, const CHARSET_INFO *cs,
5869 func_name(name_par) {}
5870 Item_static_string_func(const POS &pos, const Name_string &name_par,
5871 const char *str, size_t length,
5872 const CHARSET_INFO *cs,
5874 : Item_string(pos, null_name_string, str, length, cs, dv),
5875 func_name(name_par) {}
5876
5877 void print(const THD *, String *str, enum_query_type) const override {
5878 str->append(func_name);
5879 }
5880 uint64_t hash() override;
5881 bool check_partition_func_processor(uchar *) override { return true; }
5884 pointer_cast<Check_function_as_value_generator_parameters *>(args);
5885 func_arg->banned_function_name = func_name.ptr();
5886 return true;
5887 }
5888};
5889
5890/* for show tables */
5892 public:
5894 const CHARSET_INFO *cs = nullptr)
5895 : Item_string(name, NullS, 0, cs) {
5896 max_length = static_cast<uint32>(length);
5897 }
5898};
5899
5901 public:
5902 Item_blob(const char *name, size_t length)
5904 &my_charset_bin) {
5906 }
5907 enum Type type() const override { return STRING_ITEM; }
5910 pointer_cast<Check_function_as_value_generator_parameters *>(args);
5911 func_arg->err_code = func_arg->get_unnamed_function_error_code();
5912 return true;
5913 }
5914};
5915
5916/**
5917 Item_empty_string -- is a utility class to put an item into List<Item>
5918 which is then used in protocol.send_result_set_metadata() when sending SHOW
5919 output to the client.
5920*/
5921
5923 public:
5924 Item_empty_string(const char *header, size_t length,
5925 const CHARSET_INFO *cs = nullptr)
5927 Name_string(header, strlen(header)), 0,
5930 }
5931 void make_field(Send_field *field) override;
5932};
5933
5935 public:
5936 Item_return_int(const char *name_arg, uint length,
5937 enum_field_types field_type_arg, longlong value_arg = 0)
5938 : Item_int(Name_string(name_arg, name_arg ? strlen(name_arg) : 0),
5939 value_arg, length) {
5940 set_data_type(field_type_arg);
5941 unsigned_flag = true;
5942 }
5943};
5944
5947
5948 protected:
5950 bool no_conversions) override;
5951
5952 public:
5954 explicit Item_hex_string(const POS &pos) : super(pos) {
5956 }
5957
5958 Item_hex_string(const POS &pos, const LEX_STRING &literal);
5959
5960 enum Type type() const override { return HEX_BIN_ITEM; }
5961 double val_real() override {
5962 assert(fixed);
5963 return (double)(ulonglong)Item_hex_string::val_int();
5964 }
5965 longlong val_int() override;
5966 Item *clone_item() const override;
5967
5968 String *val_str(String *) override {
5969 assert(fixed);
5970 return &str_value;
5971 }
5972 my_decimal *val_decimal(my_decimal *) override;
5973 bool val_date(Date_val *date, my_time_flags_t flags) override {
5974 return get_date_from_string(date, flags);
5975 }
5976 bool val_time(Time_val *time) override { return get_time_from_string(time); }
5978 return get_datetime_from_string(dt, flags);
5979 }
5980 Item_result result_type() const override { return STRING_RESULT; }
5982 return INT_RESULT;
5983 }
5984 Item_result cast_to_int_type() const override { return INT_RESULT; }
5985 void print(const THD *thd, String *str,
5986 enum_query_type query_type) const override;
5987 uint64_t hash() override;
5988 bool eq(const Item *item) const override;
5989 bool check_partition_func_processor(uchar *) override { return false; }
5990 static LEX_CSTRING make_hex_str(const char *str, size_t str_length);
5991 uint decimal_precision() const override;
5992
5993 private:
5994 void hex_string_init(const char *str, uint str_length);
5995};
5996
5997class Item_bin_string final : public Item_hex_string {
5999
6000 public:
6001 Item_bin_string(const char *str, size_t str_length) {
6002 bin_string_init(str, str_length);
6003 }
6004 Item_bin_string(const POS &pos, const LEX_STRING &literal) : super(pos) {
6005 bin_string_init(literal.str, literal.length);
6006 }
6007
6008 static LEX_CSTRING make_bin_str(const char *str, size_t str_length);
6009
6010 private:
6011 void bin_string_init(const char *str, size_t str_length);
6012};
6013
6014/**
6015 Item with result field.
6016
6017 It adds to an Item a "result_field" Field member. This is for an item which
6018 may have a result (e.g. Item_func), and may store this result into a field;
6019 usually this field is a column of an internal temporary table. So the
6020 function may be evaluated by save_in_field(), storing result into
6021 result_field in tmp table. Then this result can be copied from tmp table to
6022 a following tmp table (e.g. GROUP BY table then ORDER BY table), or to a row
6023 buffer and back, as we want to avoid multiple evaluations of the Item, first
6024 because of performance, second because that evaluation may have side
6025 effects, e.g. SLEEP, GET_LOCK, RAND, window functions doing
6026 accumulations...
6027 Item_field and Item_ref also have a "result_field" for a similar goal.
6028 Literals don't need such "result_field" as their value is readily
6029 available.
6030*/
6031class Item_result_field : public Item {
6032 protected:
6033 Field *result_field{nullptr}; /* Save result here */
6034 public:
6036 explicit Item_result_field(const POS &pos) : Item(pos) {}
6037
6038 // Constructor used for Item_sum/Item_cond_and/or (see Item comment)
6040 : Item(thd, item), result_field(item->result_field) {}
6042 Field *tmp_table_field(TABLE *) override { return result_field; }
6043 table_map used_tables() const override { return 1; }
6044
6045 /**
6046 Resolve type-related information for this item, such as result field type,
6047 maximum size, precision, signedness, character set and collation.
6048 Also check compatibility of argument types and return error when applicable.
6049 Also adjust nullability when applicable.
6050
6051 @param thd thread handler
6052 @returns false if success, true if error
6053 */
6054 virtual bool resolve_type(THD *thd) = 0;
6055
6056 void set_result_field(Field *field) override { result_field = field; }
6057 bool is_result_field() const override { return true; }
6058 Field *get_result_field() const override { return result_field; }
6059
6060 void cleanup() override;
6061 bool check_function_as_value_generator(uchar *) override { return false; }
6062 bool mark_field_in_map(uchar *arg) override {
6063 bool rc = Item::mark_field_in_map(arg);
6064 if (result_field) // most likely result_field will be read too
6065 rc |= Item::mark_field_in_map(pointer_cast<Mark_field *>(arg),
6066 result_field);
6067 return rc;
6068 }
6069
6071 if (realval < LLONG_MIN || realval > LLONG_MAX_DOUBLE) {
6073 return error_int();
6074 }
6075 return llrint(realval);
6076 }
6077
6078 void raise_numeric_overflow(const char *type_name);
6079
6081 raise_numeric_overflow("DOUBLE");
6082 return 0.0;
6083 }
6084
6086 raise_numeric_overflow(unsigned_flag ? "BIGINT UNSIGNED" : "BIGINT");
6087 return 0;
6088 }
6089
6091 raise_numeric_overflow(unsigned_flag ? "DECIMAL UNSIGNED" : "DECIMAL");
6092 return E_DEC_OVERFLOW;
6093 }
6094};
6095
6096class Item_ref : public Item_ident {
6097 protected:
6098 void set_properties();
6100 bool no_conversions) override;
6101
6102 public:
6104 // If true, depended_from information of this ref was pushed down to
6105 // underlying field.
6107
6108 private:
6109 Field *result_field{nullptr}; /* Save result here */
6110
6111 protected:
6112 /// Indirect pointer to the referenced item.
6113 Item **m_ref_item{nullptr};
6114
6115 public:
6116 Item_ref(const POS &pos, const char *db_name_arg, const char *table_name_arg,
6117 const char *field_name_arg)
6118 : Item_ident(pos, db_name_arg, table_name_arg, field_name_arg) {}
6119
6120 /*
6121 This constructor is used in two scenarios:
6122 A) *item = NULL
6123 No initialization is performed, fix_fields() call will be necessary.
6124
6125 B) *item points to an Item this Item_ref will refer to. This is
6126 used for GROUP BY. fix_fields() will not be called in this case,
6127 so we call set_properties to make this item "fixed". set_properties
6128 performs a subset of action Item_ref::fix_fields does, and this subset
6129 is enough for Item_ref's used in GROUP BY.
6130
6131 TODO we probably fix a superset of problems like in BUG#6658. Check this
6132 with Bar, and if we have a more broader set of problems like this.
6133 */
6134 Item_ref(Name_resolution_context *context_arg, Item **item,
6135 const char *db_name_arg, const char *table_name_arg,
6136 const char *field_name_arg, bool alias_of_expr_arg = false);
6137 Item_ref(Name_resolution_context *context_arg, Item **item,
6138 const char *field_name_arg);
6139
6140 /* Constructor need to process subselect with temporary tables (see Item) */
6141 Item_ref(THD *thd, Item_ref *item)
6142 : Item_ident(thd, item),
6144 m_ref_item(item->m_ref_item) {}
6145
6146 /// @returns the item referenced by this object
6147 Item *ref_item() const { return *m_ref_item; }
6148
6149 /// @returns the pointer to the item referenced by this object
6150 Item **ref_pointer() const { return m_ref_item; }
6151
6153
6154 enum Type type() const override { return REF_ITEM; }
6155 bool eq(const Item *item) const override {
6156 const Item *it = item->real_item();
6157 // May search for a referenced item that is not yet resolved:
6158 if (m_ref_item == nullptr) return false;
6159 return ref_item()->eq(it);
6160 }
6161 double val_real() override;
6162 longlong val_int() override;
6163 longlong val_date_temporal() override;
6164 my_decimal *val_decimal(my_decimal *) override;
6165 bool val_bool() override;
6166 String *val_str(String *tmp) override;
6167 bool val_json(Json_wrapper *result) override;
6168 bool is_null() override;
6169 bool val_date(Date_val *date, my_time_flags_t flags) override;
6170 bool val_time(Time_val *time) override;
6171 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
6172 bool send(Protocol *prot, String *tmp) override;
6173 void make_field(Send_field *field) override;
6174 bool fix_fields(THD *, Item **) override;
6175 void fix_after_pullout(Query_block *parent_query_block,
6176 Query_block *removed_query_block) override;
6177
6178 Item_result result_type() const override { return ref_item()->result_type(); }
6179
6180 TYPELIB *get_typelib() const override { return ref_item()->get_typelib(); }
6181
6183 return result_field != nullptr ? result_field
6185 }
6186 Item *get_tmp_table_item(THD *thd) override;
6187 table_map used_tables() const override {
6188 if (depended_from != nullptr) return OUTER_REF_TABLE_BIT;
6189 const table_map map = ref_item()->used_tables();
6190 if (map != 0) return map;
6191 // rollup constant: ensure it is non-constant by returning RAND_TABLE_BIT
6193 return 0;
6194 }
6195 void update_used_tables() override {
6196 if (depended_from == nullptr) ref_item()->update_used_tables();
6197 /*
6198 Reset all flags except GROUP BY modifier, since we do not mark the rollup
6199 expression itself.
6200 */
6203 }
6204
6205 table_map not_null_tables() const override {
6206 /*
6207 It can happen that our 'depended_from' member is set but the
6208 'depended_from' member of the referenced item is not (example: if a
6209 field in a subquery belongs to an outer merged view), so we first test
6210 ours:
6211 */
6212 return depended_from != nullptr ? OUTER_REF_TABLE_BIT
6214 }
6215 void set_result_field(Field *field) override { result_field = field; }
6216 bool is_result_field() const override { return true; }
6217 Field *get_result_field() const override { return result_field; }
6218 Item *real_item() override {
6219 // May look into unresolved Item_ref objects
6220 if (m_ref_item == nullptr) return this;
6221 return ref_item()->real_item();
6222 }
6223 const Item *real_item() const override {
6224 // May look into unresolved Item_ref objects
6225 if (m_ref_item == nullptr) return this;
6226 return ref_item()->real_item();
6227 }
6228
6229 bool walk(Item_processor processor, enum_walk walk, uchar *arg) override {
6230 // Unresolved items may have m_ref_item = nullptr
6231 return ((walk & enum_walk::PREFIX) && (this->*processor)(arg)) ||
6232 (m_ref_item != nullptr ? ref_item()->walk(processor, walk, arg)
6233 : false) ||
6234 ((walk & enum_walk::POSTFIX) && (this->*processor)(arg));
6235 }
6236 Item *transform(Item_transformer, uchar *arg) override;
6237 Item *compile(Item_analyzer analyzer, uchar **arg_p,
6238 Item_transformer transformer, uchar *arg_t) override;
6239 void traverse_cond(Cond_traverser traverser, void *arg,
6240 traverse_order order) override {
6241 assert(ref_item() != nullptr);
6242 if (order == PREFIX) (*traverser)(this, arg);
6243 ref_item()->traverse_cond(traverser, arg, order);
6244 if (order == POSTFIX) (*traverser)(this, arg);
6245 }
6247 /*
6248 Always return false: we don't need to go deeper into referenced
6249 expression tree since we have to mark aliased subqueries at
6250 their original places (select list, derived tables), not by
6251 references from other expression (order by etc).
6252 */
6253 return false;
6254 }
6255 bool clean_up_after_removal(uchar *arg) override;
6256 void print(const THD *thd, String *str,
6257 enum_query_type query_type) const override;
6258 uint64_t hash() override;
6259 void cleanup() override;
6261 return ref_item()->field_for_view_update();
6262 }
6263 virtual Ref_Type ref_type() const { return REF; }
6264
6265 // Row emulation: forwarding of ROW-related calls to ref
6266 uint cols() const override {
6267 assert(m_ref_item != nullptr);
6268 return result_type() == ROW_RESULT ? ref_item()->cols() : 1;
6269 }
6270 Item *element_index(uint i) override {
6271 assert(m_ref_item != nullptr);
6272 return result_type() == ROW_RESULT ? ref_item()->element_index(i) : this;
6273 }
6274 Item **addr(uint i) override {
6275 assert(m_ref_item != nullptr);
6276 return result_type() == ROW_RESULT ? ref_item()->addr(i) : nullptr;
6277 }
6278 bool check_cols(uint c) override {
6279 assert(m_ref_item != nullptr);
6280 return result_type() == ROW_RESULT ? ref_item()->check_cols(c)
6281 : Item::check_cols(c);
6282 }
6283 bool null_inside() override {
6284 assert(m_ref_item != nullptr);
6285 return result_type() == ROW_RESULT ? ref_item()->null_inside() : false;
6286 }
6287 void bring_value() override {
6288 assert(m_ref_item != nullptr);
6290 }
6291
6292 bool basic_const_item() const override { return false; }
6293
6294 bool is_outer_field() const override {
6295 assert(fixed);
6296 assert(ref_item());
6297 return ref_item()->is_outer_field();
6298 }
6299
6300 bool created_by_in2exists() const override {
6301 return ref_item()->created_by_in2exists();
6302 }
6303
6304 bool repoint_const_outer_ref(uchar *arg) override;
6305 bool is_non_const_over_literals(uchar *) override { return true; }
6308 pointer_cast<Check_function_as_value_generator_parameters *>(args);
6309 func_arg->err_code = func_arg->get_unnamed_function_error_code();
6310 return true;
6311 }
6313 return ref_item()->cast_to_int_type();
6314 }
6315 bool is_valid_for_pushdown(uchar *arg) override {
6316 return ref_item()->is_valid_for_pushdown(arg);
6317 }
6320 }
6321 bool check_column_in_group_by(uchar *arg) override {
6322 return ref_item()->check_column_in_group_by(arg);
6323 }
6324 bool collect_item_field_or_ref_processor(uchar *arg) override;
6325};
6326
6327/**
6328 Class for fields from derived tables and views.
6329 The same as Item_ref, but call fix_fields() of reference if
6330 not called yet.
6331*/
6332class Item_view_ref final : public Item_ref {
6334
6335 public:
6337 const char *db_name_arg, const char *alias_name_arg,
6338 const char *table_name_arg, const char *field_name_arg,
6339 Table_ref *tr)
6340 : Item_ref(context_arg, item, db_name_arg, alias_name_arg,
6341 field_name_arg),
6343 if (tr->is_view()) {
6344 m_orig_db_name = db_name_arg;
6345 m_orig_table_name = table_name_arg;
6346 } else {
6347 assert(db_name_arg == nullptr);
6348 m_orig_table_name = table_name_arg;
6349 }
6350 m_table_ref = tr;
6352 set_nullable(true);
6354 }
6355 }
6356
6357 /*
6358 We share one underlying Item_field, so we have to disable
6359 build_equal_items_for_cond().
6360 TODO: Implement multiple equality optimization for views.
6361 */
6362 bool subst_argument_checker(uchar **) override { return false; }
6363
6364 bool fix_fields(THD *, Item **) override;
6365
6366 table_map used_tables() const override;
6367
6368 bool eq(const Item *item) const override;
6369 Ref_Type ref_type() const override { return VIEW_REF; }
6370
6371 bool check_column_privileges(uchar *arg) override;
6372 bool mark_field_in_map(uchar *arg) override {
6373 /*
6374 If this referenced column is marked as used, flag underlying
6375 selected item from a derived table/view as used.
6376 */
6377 auto mark_field = (Mark_field *)arg;
6378 return get_result_field()
6380 : false;
6381 }
6382 longlong val_int() override;
6383 double val_real() override;
6385 String *val_str(String *str) override;
6386 bool val_date(Date_val *date, my_time_flags_t flags) override;
6387 bool val_time(Time_val *time) override;
6388 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
6389 bool val_bool() override;
6390 bool val_json(Json_wrapper *wr) override;
6391 bool is_null() override;
6392 bool send(Protocol *prot, String *tmp) override;
6394 Item *replace_item_view_ref(uchar *arg) override;
6395 Item *replace_view_refs_with_clone(uchar *arg) override;
6397
6398 protected:
6400 bool no_conversions) override;
6401
6402 private:
6403 /// @return true if item is from a null-extended row from an outer join
6404 bool has_null_row() const {
6406 }
6407
6408 /**
6409 If this column belongs to a view that is an inner table of an outer join,
6410 then this field points to the first leaf table of the view, otherwise NULL.
6411 */
6413};
6414
6415/*
6416 Class for outer fields.
6417 An object of this class is created when the select where the outer field was
6418 resolved is a grouping one. After it has been fixed the ref field will point
6419 to an Item_ref object which will be used to access the field.
6420 The ref field may also point to an Item_field instance.
6421 See also comments of the Item_field::fix_outer_field() function.
6422*/
6423
6424class Item_outer_ref final : public Item_ref {
6426
6427 private:
6428 /**
6429 Qualifying query of this outer ref (i.e. query block which owns FROM of
6430 table which this Item references).
6431 */
6433
6434 public:
6436 /* The aggregate function under which this outer ref is used, if any. */
6438 /*
6439 true <=> that the outer_ref is already present in the select list
6440 of the outer select.
6441 */
6445 : Item_ref(context_arg, nullptr, ident_arg->db_name,
6446 ident_arg->table_name, ident_arg->field_name, false),
6448 outer_ref(ident_arg),
6450 found_in_select_list(false) {
6454 // keep any select list alias:
6455 item_name = ident_arg->item_name;
6456 fixed = false;
6457 }
6459 const char *db_name_arg, const char *table_name_arg,
6460 const char *field_name_arg, bool alias_of_expr_arg,
6462 : Item_ref(context_arg, item, db_name_arg, table_name_arg, field_name_arg,
6463 alias_of_expr_arg),
6467 found_in_select_list(true) {}
6468 bool fix_fields(THD *, Item **) override;
6469 void fix_after_pullout(Query_block *parent_query_block,
6470 Query_block *removed_query_block) override;
6471 table_map used_tables() const override {
6472 return ref_item()->used_tables() == 0 ? 0 : OUTER_REF_TABLE_BIT;
6473 }
6474 table_map not_null_tables() const override { return 0; }
6475
6476 Ref_Type ref_type() const override { return OUTER_REF; }
6477 Item *replace_outer_ref(uchar *) override;
6478};
6479
6480/*
6481 An object of this class is like Item_ref, and
6482 sets owner->was_null=true if it has returned a NULL value from any
6483 val_XXX() function. This allows to inject an Item_ref_null_helper
6484 object into subquery and then check if the subquery has produced a row
6485 with NULL value.
6486*/
6487
6488class Item_ref_null_helper final : public Item_ref {
6490
6491 protected:
6493
6494 public:
6496 Item_in_subselect *master, Item **item)
6497 : super(context_arg, item, "", "", ""), owner(master) {}
6498 Item_ref_null_helper(const Item_ref_null_helper &ref_null_helper, Item **item)
6499 : Item_ref_null_helper(ref_null_helper.context, ref_null_helper.owner,
6500 item) {}
6501 double val_real() override;
6502 longlong val_int() override;
6503 longlong val_date_temporal() override;
6504 String *val_str(String *s) override;
6505 my_decimal *val_decimal(my_decimal *) override;
6506 bool val_bool() override;
6507 bool val_time(Time_val *time) override;
6508 bool val_date(Date_val *date, my_time_flags_t flags) override;
6509 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
6510 void print(const THD *thd, String *str,
6511 enum_query_type query_type) const override;
6512 Ref_Type ref_type() const override { return NULL_HELPER_REF; }
6513 /*
6514 we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
6515 */
6516 table_map used_tables() const override {
6519 }
6520};
6521
6522/*
6523 The following class is used to optimize comparing of bigint columns.
6524 We need to save the original item ('ref') to be able to call
6525 ref->save_in_field(). This is used to create index search keys.
6526
6527 An instance of Item_int_with_ref may have signed or unsigned integer value.
6528
6529*/
6530
6532 protected:
6535 bool no_conversions) override {
6536 return ref->save_in_field(field, no_conversions);
6537 }
6538
6539 public:
6541 bool unsigned_arg)
6542 : Item_int(i), ref(ref_arg) {
6543 set_data_type(field_type);
6544 unsigned_flag = unsigned_arg;
6545 }
6546 Item *clone_item() const override;
6547 uint64_t hash() override;
6548 Item *real_item() override { return ref; }
6549 const Item *real_item() const override { return ref; }
6550};
6551
6552/*
6553 Similar to Item_int_with_ref, but to optimize comparing of temporal columns.
6554*/
6556 public:
6557 Item_temporal_with_ref(enum_field_types field_type_arg, uint8 decimals_arg,
6558 longlong i, Item *ref_arg, bool unsigned_arg)
6559 : Item_int_with_ref(field_type_arg, i, ref_arg, unsigned_arg) {
6560 decimals = decimals_arg;
6561 }
6562 void print(const THD *thd, String *str,
6563 enum_query_type query_type) const override;
6564
6566 assert(false);
6567 return true;
6568 }
6569 bool val_time(Time_val *time) override {
6570 bool rc = ref->val_time(time);
6572 return rc;
6573 }
6574};
6575
6576/*
6577 Item_datetime_with_ref is used to optimize queries like:
6578 SELECT ... FROM t1 WHERE date_or_datetime_column = 20110101101010;
6579 The numeric constant is replaced to Item_datetime_with_ref
6580 by convert_constant_item().
6581*/
6583 public:
6584 /**
6585 Constructor for Item_datetime_with_ref.
6586 @param field_type_arg Data type: MYSQL_TYPE_DATE or MYSQL_TYPE_DATETIME
6587 @param decimals_arg Number of fractional digits.
6588 @param i Temporal value in packed format.
6589 @param ref_arg Pointer to the original numeric Item.
6590 */
6591 Item_datetime_with_ref(enum_field_types field_type_arg, uint8 decimals_arg,
6592 longlong i, Item *ref_arg)
6593 : Item_temporal_with_ref(field_type_arg, decimals_arg, i, ref_arg, true) {
6594 }
6595 Item *clone_item() const override;
6596 longlong val_date_temporal() override { return val_int(); }
6597};
6598
6599/**
6600 This is used for segregating rows in groups (e.g. GROUP BY, windows), to
6601 detect boundaries of groups.
6602 It caches a value, which is representative of the group, and can compare it
6603 to another row, and update its value when entering a new group.
6604*/
6606 protected:
6607 Item *item; ///< The item whose value to cache.
6608 explicit Cached_item(Item *i) : item(i) {}
6609
6610 public:
6611 bool null_value{true};
6612 virtual ~Cached_item() = default;
6613 /**
6614 Compare the value associated with the item with the stored value.
6615 If they are different, update the stored value with item's value and
6616 return true.
6617
6618 @returns true if item's value and stored value are different.
6619 Notice that first call is to establish an initial value and
6620 return value should be ignored.
6621 */
6622 virtual bool cmp() = 0;
6623 Item *get_item() const { return item; }
6624 Item **get_item_ptr() { return &item; }
6625};
6626
6628 // Make sure value.ptr() is never nullptr, as not all collation functions
6629 // are prepared for that (even with empty strings).
6632
6633 public:
6634 explicit Cached_item_str(Item *arg) : Cached_item(arg) {}
6635 bool cmp() override;
6636};
6637
6638/// Cached_item subclass for JSON values.
6640 Json_wrapper *m_value; ///< The cached JSON value.
6641 public:
6642 explicit Cached_item_json(Item *item);
6643 ~Cached_item_json() override;
6644 bool cmp() override;
6645};
6646
6648 double value{0.0};
6649
6650 public:
6651 explicit Cached_item_real(Item *item_par) : Cached_item(item_par) {}
6652 bool cmp() override;
6653};
6654
6657
6658 public:
6659 explicit Cached_item_int(Item *item_par) : Cached_item(item_par) {}
6660 bool cmp() override;
6661};
6662
6664 public:
6665 explicit Cached_item_time(Item *item_par) : Cached_item(item_par) {}
6666 bool cmp() override;
6667
6668 private:
6670};
6671
6673 public:
6674 explicit Cached_item_date(Item *item_par) : Cached_item(item_par) {}
6675 bool cmp() override;
6676
6677 private:
6679};
6680
6683
6684 public:
6685 explicit Cached_item_temporal(Item *item_par) : Cached_item(item_par) {}
6686 bool cmp() override;
6687};
6688
6691
6692 public:
6693 explicit Cached_item_decimal(Item *item_par) : Cached_item(item_par) {}
6694 bool cmp() override;
6695};
6696
6697class Item_default_value final : public Item_field {
6699
6700 protected:
6702 bool no_conversions) override;
6703
6704 public:
6705 Item_default_value(const POS &pos, Item *a = nullptr)
6706 : super(pos, nullptr, nullptr, nullptr), arg(a) {}
6707 bool do_itemize(Parse_context *pc, Item **res) override;
6708 enum Type type() const override { return DEFAULT_VALUE_ITEM; }
6709 bool eq(const Item *item) const override;
6710 bool fix_fields(THD *, Item **) override;
6711 void bind_fields() override;
6712 void cleanup() override;
6713 void print(const THD *thd, String *str,
6714 enum_query_type query_type) const override;
6715 uint64_t hash() override;
6716 table_map used_tables() const override { return 0; }
6717 Item *get_tmp_table_item(THD *thd) override { return copy_or_same(thd); }
6719 Item *replace_item_field(uchar *) override;
6720
6721 /*
6722 No additional privilege check for default values, as the walk() function
6723 checks privileges for the underlying column through the argument.
6724 */
6725 bool check_column_privileges(uchar *) override { return false; }
6726
6727 bool walk(Item_processor processor, enum_walk walk, uchar *args) override {
6728 return ((walk & enum_walk::PREFIX) && (this->*processor)(args)) ||
6729 (arg && arg->walk(processor, walk, args)) ||
6730 ((walk & enum_walk::POSTFIX) && (this->*processor)(args));
6731 }
6732
6735 reinterpret_cast<char *>(args));
6736 }
6737
6738 Item *transform(Item_transformer transformer, uchar *args) override;
6739 Item *argument() const { return arg; }
6740
6741 private:
6742 /// The argument for this function
6744 /// Pointer to row buffer that was used to calculate field value offset
6746};
6747
6748/*
6749 Item_insert_value -- an implementation of VALUES() function.
6750 You can use the VALUES(col_name) function in the UPDATE clause
6751 to refer to column values from the INSERT portion of the INSERT
6752 ... UPDATE statement. In other words, VALUES(col_name) in the
6753 UPDATE clause refers to the value of col_name that would be
6754 inserted, had no duplicate-key conflict occurred.
6755 In all other places this function returns NULL.
6756*/
6757
6758class Item_insert_value final : public Item_field {
6759 protected:
6761 bool no_conversions) override {
6762 return Item_field::save_in_field_inner(field_arg, no_conversions);
6763 }
6764
6765 public:
6766 /**
6767 Constructs an Item_insert_value that represents a call to the deprecated
6768 VALUES function.
6769 */
6772 arg(a),
6773 m_is_values_function(true) {}
6774
6775 /**
6776 Constructs an Item_insert_value that represents a derived table that wraps a
6777 table value constructor.
6778 */
6780 : Item_field(context_arg, nullptr, nullptr, nullptr),
6781 arg(a),
6782 m_is_values_function(false) {}
6783
6784 bool do_itemize(Parse_context *pc, Item **res) override {
6785 if (skip_itemize(res)) return false;
6786 return Item_field::do_itemize(pc, res) || arg->itemize(pc, &arg);
6787 }
6788
6789 enum Type type() const override { return INSERT_VALUE_ITEM; }
6790 bool eq(const Item *item) const override;
6791 bool fix_fields(THD *, Item **) override;
6792 void bind_fields() override;
6793 void cleanup() override;
6794 void print(const THD *thd, String *str,
6795 enum_query_type query_type) const override;
6796 uint64_t hash() override;
6797 /*
6798 We use RAND_TABLE_BIT to prevent Item_insert_value from
6799 being treated as a constant and precalculated before execution
6800 */
6801 table_map used_tables() const override { return RAND_TABLE_BIT; }
6802
6803 bool walk(Item_processor processor, enum_walk walk, uchar *args) override {
6804 return ((walk & enum_walk::PREFIX) && (this->*processor)(args)) ||
6805 arg->walk(processor, walk, args) ||
6806 ((walk & enum_walk::POSTFIX) && (this->*processor)(args));
6807 }
6810 pointer_cast<Check_function_as_value_generator_parameters *>(args);
6811 func_arg->banned_function_name = "values";
6812 return true;
6813 }
6814
6815 private:
6816 /// The argument for this function
6818 /// Pointer to row buffer that was used to calculate field value offset
6820 /**
6821 This flag is true if the item represents a call to the deprecated VALUES
6822 function. It is false if the item represents a derived table that wraps a
6823 table value constructor.
6824 */
6826};
6827
6828/**
6829 Represents NEW/OLD version of field of row which is
6830 changed/read in trigger.
6831
6832 Note: For this item main part of actual binding to Field object happens
6833 not during fix_fields() call (like for Item_field) but right after
6834 parsing of trigger definition, when table is opened, with special
6835 setup_field() call. On fix_fields() stage we simply choose one of
6836 two Field instances representing either OLD or NEW version of this
6837 field.
6838*/
6839class Item_trigger_field final : public Item_field,
6841 public:
6842 /* Is this item represents row from NEW or OLD row ? */
6844 /* Next in list of all Item_trigger_field's in trigger */
6846 /*
6847 Next list of Item_trigger_field's in "sp_head::
6848 m_list_of_trig_fields_item_lists".
6849 */
6851 /* Index of the field in the TABLE::field array */
6853 /* Pointer to an instance of Table_trigger_field_support interface */
6855
6857 enum_trigger_variable_type trigger_var_type_arg,
6858 const char *field_name_arg, Access_bitmask priv,
6859 const bool ro)
6860 : Item_field(context_arg, nullptr, nullptr, field_name_arg),
6861 trigger_var_type(trigger_var_type_arg),
6863 field_idx((uint)-1),
6864 want_privilege(priv),
6866 read_only(ro) {}
6868 enum_trigger_variable_type trigger_var_type_arg,
6869 const char *field_name_arg, Access_bitmask priv,
6870 const bool ro)
6871 : Item_field(pos, nullptr, nullptr, field_name_arg),
6872 trigger_var_type(trigger_var_type_arg),
6873 field_idx((uint)-1),
6874 want_privilege(priv),
6876 read_only(ro) {}
6877 void setup_field(Table_trigger_field_support *table_triggers,
6878 GRANT_INFO *table_grant_info);
6879 enum Type type() const override { return TRIGGER_FIELD_ITEM; }
6880 bool eq(const Item *item) const override;
6881 bool fix_fields(THD *, Item **) override;
6882 void bind_fields() override;
6883 bool check_column_privileges(uchar *arg) override;
6884 void print(const THD *thd, String *str,
6885 enum_query_type query_type) const override;
6886 table_map used_tables() const override { return INNER_TABLE_BIT; }
6887 Field *get_tmp_table_field() override { return nullptr; }
6888 Item *copy_or_same(THD *) override { return this; }
6889 Item *get_tmp_table_item(THD *thd) override { return copy_or_same(thd); }
6890 void cleanup() override;
6891 void set_required_privilege(Access_bitmask privilege) override {
6892 want_privilege = privilege;
6893 }
6894
6897 pointer_cast<Check_function_as_value_generator_parameters *>(args);
6898 func_arg->err_code = func_arg->get_unnamed_function_error_code();
6899 return true;
6900 }
6901
6902 bool is_valid_for_pushdown(uchar *args [[maybe_unused]]) override {
6903 return true;
6904 }
6905
6906 private:
6907 bool set_value(THD *thd, sp_rcontext *ctx, Item **it) override;
6908
6909 public:
6911 return (read_only ? nullptr : this);
6912 }
6913
6914 bool set_value(THD *thd, Item **it) {
6915 const bool ret = set_value(thd, nullptr, it);
6916 if (!ret)
6918 field_idx);
6919 return ret;
6920 }
6921
6922 private:
6923 /*
6924 'want_privilege' holds privileges required to perform operation on
6925 this trigger field (SELECT_ACL if we are going to read it and
6926 UPDATE_ACL if we are going to update it). It is initialized at
6927 parse time but can be updated later if this trigger field is used
6928 as OUT or INOUT parameter of stored routine (in this case
6929 set_required_privilege() is called to appropriately update
6930 want_privilege).
6931 */
6934 /*
6935 Trigger field is read-only unless it belongs to the NEW row in a
6936 BEFORE INSERT of BEFORE UPDATE trigger.
6937 */
6939};
6940
6942 protected:
6943 Item *example{nullptr};
6945 /**
6946 Field that this object will get value from. This is used by
6947 index-based subquery engines to detect and remove the equality injected
6948 by IN->EXISTS transformation.
6949 */
6951 /*
6952 true <=> cache holds value of the last stored item (i.e actual value).
6953 store() stores item to be cached and sets this flag to false.
6954 On the first call of val_xxx function if this flag is set to false the
6955 cache_value() will be called to actually cache value of saved item.
6956 cache_value() will set this flag to true.
6957 */
6958 bool value_cached{false};
6959
6960 friend bool has_rollup_result(Item *item);
6962 THD *thd, Query_block *select, Item *item_arg);
6963
6964 public:
6966 fixed = true;
6967 set_nullable(true);
6968 null_value = true;
6969 }
6971 set_data_type(field_type_arg);
6972 fixed = true;
6973 set_nullable(true);
6974 null_value = true;
6975 }
6976
6977 void fix_after_pullout(Query_block *parent_query_block,
6978 Query_block *removed_query_block) override {
6979 if (example == nullptr) return;
6980 example->fix_after_pullout(parent_query_block, removed_query_block);
6982 }
6983
6984 virtual bool allocate(uint) { return false; }
6985 virtual bool setup(Item *item) {
6986 example = item;
6987 max_length = item->max_length;
6988 decimals = item->decimals;
6989 collation.set(item->collation);
6992 if (item->type() == FIELD_ITEM) {
6993 cached_field = down_cast<Item_field *>(item);
6994 if (cached_field->m_table_ref != nullptr)
6996 } else {
6997 used_table_map = item->used_tables();
6998 }
6999 return false;
7000 }
7001 enum Type type() const override { return CACHE_ITEM; }
7002 static Item_cache *get_cache(const Item *item);
7003 static Item_cache *get_cache(const Item *item, const Item_result type);
7004 table_map used_tables() const override { return used_table_map; }
7005 void print(const THD *thd, String *str,
7006 enum_query_type query_type) const override;
7007 uint64_t hash() override;
7008 bool eq_def(const Field *field) {
7009 return cached_field != nullptr && cached_field->field->eq_def(field);
7010 }
7011 bool eq(const Item *item) const override { return this == item; }
7012 /**
7013 Check if saved item has a non-NULL value.
7014 Will cache value of saved item if not already done.
7015 @return true if cached value is non-NULL.
7016 */
7017 bool has_value();
7018
7019 /**
7020 If this item caches a field value, return pointer to underlying field.
7021
7022 @return Pointer to field, or NULL if this is not a cache for a field value.
7023 */
7025
7026 /**
7027 Assigns to the cache the expression to be cached. Does not evaluate it.
7028 @param item the expression to be cached
7029 */
7030 virtual void store(Item *item);
7031
7032 /**
7033 Force an item to be null. Used for empty subqueries to avoid attempts to
7034 evaluate expressions which could have uninitialized columns due to
7035 bypassing the subquery exec.
7036 */
7037 void store_null() {
7038 assert(is_nullable());
7039 value_cached = true;
7040 null_value = true;
7041 }
7042
7043 virtual bool cache_value() = 0;
7044 bool store_and_cache(Item *item) {
7045 store(item);
7046 return cache_value();
7047 }
7048 void cleanup() override;
7049 bool basic_const_item() const override {
7050 return (example != nullptr && example->basic_const_item());
7051 }
7052 bool walk(Item_processor processor, enum_walk walk, uchar *arg) override;
7053 virtual void clear() {
7054 null_value = true;
7055 value_cached = false;
7056 }
7057 bool is_null() override {
7058 return value_cached ? null_value : example->is_null();
7059 }
7060 bool is_non_const_over_literals(uchar *) override { return true; }
7063 pointer_cast<Check_function_as_value_generator_parameters *>(args);
7064 func_arg->banned_function_name = "cached item";
7065 // This should not happen as SELECT statements are not allowed.
7066 assert(false);
7067 return true;
7068 }
7069 Item_result result_type() const override {
7070 if (!example) return INT_RESULT;
7072 }
7073 Item *get_example() const { return example; }
7075};
7076
7078 public:
7081 : Item_cache(field_type_arg), value(0) {}
7082
7083 /**
7084 Unlike store(), this stores an explicitly provided value, not the one of
7085 'item'; however, NULLness is still taken from 'item'.
7086 */
7087 void store_value(Item *item, longlong val_arg);
7088 double val_real() override;
7089 longlong val_int() override;
7090 longlong val_date_temporal() override { return val_int(); }
7091 String *val_str(String *str) override;
7092 my_decimal *val_decimal(my_decimal *) override;
7093 bool val_date(Date_val *date, my_time_flags_t flags) override {
7094 return get_date_from_int(date, flags);
7095 }
7096 bool val_time(Time_val *time) override { return get_time_from_int(time); }
7098 return get_datetime_from_int(dt, flags);
7099 }
7100 Item_result result_type() const override { return INT_RESULT; }
7101 bool cache_value() override;
7102
7103 protected:
7105};
7106
7107/**
7108 Cache class for BIT type expressions. The BIT data type behaves like unsigned
7109 integer numbers in all situations, except when formatted as a string, where
7110 it is directly interpreted as a byte string, possibly right-extended with
7111 zero-bits.
7112*/
7113class Item_cache_bit final : public Item_cache_int {
7114 public:
7116 : Item_cache_int(field_type_arg) {
7117 assert(field_type_arg == MYSQL_TYPE_BIT);
7118 }
7119
7120 /**
7121 Transform the result Item_cache_int::value in bit format. The process is
7122 similar to Field_bit_as_char::store().
7123 */
7124 String *val_str(String *str) override;
7125 uint string_length() { return ((max_length + 7) / 8); }
7126};
7127
7128class Item_cache_real final : public Item_cache {
7129 public:
7131
7132 double val_real() override;
7133 longlong val_int() override;
7134 String *val_str(String *str) override;
7135 my_decimal *val_decimal(my_decimal *) override;
7136 bool val_date(Date_val *date, my_time_flags_t flags) override {
7137 return get_date_from_real(date, flags);
7138 }
7139 bool val_time(Time_val *time) override { return get_time_from_real(time); }
7141 return get_datetime_from_real(dt, flags);
7142 }
7143 Item_result result_type() const override { return REAL_RESULT; }
7144 bool cache_value() override;
7145 void store_value(Item *expr, double value);
7146
7147 private:
7148 double value{0};
7149};
7150
7151class Item_cache_decimal final : public Item_cache {
7152 public:
7154
7155 double val_real() override;
7156 longlong val_int() override;
7157 String *val_str(String *str) override;
7158 my_decimal *val_decimal(my_decimal *) override;
7159 bool val_date(Date_val *date, my_time_flags_t flags) override {
7160 return get_date_from_decimal(date, flags);
7161 }
7162 bool val_time(Time_val *time) override { return get_time_from_decimal(time); }
7164 return get_datetime_from_decimal(dt, flags);
7165 }
7166 Item_result result_type() const override { return DECIMAL_RESULT; }
7167 bool cache_value() override;
7168 void store_value(Item *expr, my_decimal *d);
7169
7170 private:
7172};
7173
7174class Item_cache_str final : public Item_cache {
7178
7179 protected:
7181 bool no_conversions) override;
7182
7183 public:
7185 : Item_cache(item->data_type()),
7186 value(nullptr),
7187 is_varbinary(item->type() == FIELD_ITEM &&
7189 !((const Item_field *)item)->field->has_charset()) {
7190 collation.set(item->collation);
7191 }
7192 double val_real() override;
7193 longlong val_int() override;
7194 String *val_str(String *) override;
7195 my_decimal *val_decimal(my_decimal *) override;
7196 bool val_date(Date_val *date, my_time_flags_t flags) override {
7197 return get_date_from_string(date, flags);
7198 }
7199 bool val_time(Time_val *time) override { return get_time_from_string(time); }
7201 return get_datetime_from_string(dt, flags);
7202 }
7203 Item_result result_type() const override { return STRING_RESULT; }
7204 const CHARSET_INFO *charset() const { return value->charset(); }
7205 bool cache_value() override;
7206 void store_value(Item *expr, String &s);
7207};
7208
7209class Item_cache_row final : public Item_cache {
7210 public:
7212
7213 /**
7214 'allocate' is only used in Item_cache_row::setup()
7215 */
7216 bool allocate(uint num) override;
7217 /*
7218 'setup' is needed only by row => it not called by simple row subselect
7219 (only by IN subselect (in subselect optimizer))
7220 */
7221 bool setup(Item *item) override;
7222 void store(Item *item) override;
7223 void illegal_method_call(const char *) const MY_ATTRIBUTE((cold));
7224 void make_field(Send_field *) override { illegal_method_call("make_field"); }
7225 double val_real() override {
7226 illegal_method_call("val_real");
7227 return 0;
7228 }
7229 longlong val_int() override {
7230 illegal_method_call("val_int");
7231 return 0;
7232 }
7233 String *val_str(String *) override {
7234 illegal_method_call("val_str");
7235 return nullptr;
7236 }
7238 illegal_method_call("val_decimal");
7239 return nullptr;
7240 }
7242 illegal_method_call("val_date");
7243 return true;
7244 }
7245 bool val_time(Time_val *) override {
7246 illegal_method_call("val_time");
7247 return true;
7248 }
7250 illegal_method_call("val_datetime");
7251 return true;
7252 }
7253 Item_result result_type() const override { return ROW_RESULT; }
7254
7255 uint cols() const override { return item_count; }
7256 Item *element_index(uint i) override { return values[i]; }
7257 Item **addr(uint i) override { return (Item **)(values + i); }
7258 bool check_cols(uint c) override;
7259 bool null_inside() override;
7260 void bring_value() override;
7261 void cleanup() override { Item_cache::cleanup(); }
7262 bool cache_value() override;
7263
7264 private:
7265 Item_cache **values{nullptr};
7266 uint item_count{2};
7267};
7268
7270 public:
7273 }
7274
7275 void store(Item *item) override;
7276 double val_real() override;
7277 longlong val_int() override;
7278 longlong val_date_temporal() override;
7279 String *val_str(String *str) override;
7280 my_decimal *val_decimal(my_decimal *) override;
7281 bool val_date(Date_val *date, my_time_flags_t flags) override;
7282 bool val_time(Time_val *time) override;
7283 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
7284 Item_result result_type() const override { return STRING_RESULT; }
7285 bool cache_value() override;
7286 /**
7287 Cache a single non-NULL time value. Requires that "example" is not set.
7288
7289 @param time Time value to cache
7290 */
7291 void store_value(Time_val time);
7292
7293 private:
7295};
7296
7298 public:
7301 }
7302
7303 void store(Item *item) override;
7304 double val_real() override;
7305 longlong val_int() override;
7306 longlong val_date_temporal() override;
7307 String *val_str(String *str) override;
7308 my_decimal *val_decimal(my_decimal *) override;
7309 bool val_date(Date_val *date, my_time_flags_t flags) override;
7310 bool val_time(Time_val *time) override;
7311 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
7312 Item_result result_type() const override { return STRING_RESULT; }
7313 bool cache_value() override;
7314 /**
7315 Cache a single non-NULL date value. Requires that "example" is not set.
7316
7317 @param date Date value to cache
7318 */
7319 void store_value(Date_val date);
7320
7321 private:
7323};
7324
7326 public:
7328 : Item_cache(field_type_arg), int_value(0), str_value_cached(false) {
7329 assert(field_type_arg != MYSQL_TYPE_TIME &&
7330 field_type_arg != MYSQL_TYPE_DATE);
7332 }
7333
7334 void store_value(Item *item, longlong val_arg);
7335 void store(Item *item) override;
7336 double val_real() override;
7337 longlong val_int() override;
7338 longlong val_date_temporal() override;
7339 String *val_str(String *str) override;
7340 my_decimal *val_decimal(my_decimal *) override;
7341 bool val_date(Date_val *date, my_time_flags_t flags) override;
7342 bool val_time(Time_val *time) override;
7343 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
7344 Item_result result_type() const override { return STRING_RESULT; }
7345 /*
7346 In order to avoid INT <-> STRING conversion of a DATETIME value
7347 two cache_value functions are introduced. One (cache_value) caches STRING
7348 value, another (cache_value_int) - INT value. Thus this cache item
7349 completely relies on the ability of the underlying item to do the
7350 correct conversion.
7351 */
7352 bool cache_value_int();
7353 bool cache_value() override;
7354 void clear() override {
7356 str_value_cached = false;
7357 }
7358
7359 private:
7360 /// Used for DATETIME values
7362 /// Used when required in a string context
7364 /// If true, cached_string contains a valid value
7365 bool str_value_cached{false};
7366};
7367
7368/// An item cache for values of type JSON.
7370 /// Cached value
7372 /// Whether the cached value is array and it is sorted
7374
7375 public:
7377 ~Item_cache_json() override;
7378 bool cache_value() override;
7379 void store_value(Item *expr, Json_wrapper *wr);
7380 bool val_json(Json_wrapper *wr) override;
7381 longlong val_int() override;
7382 String *val_str(String *str) override;
7383 Item_result result_type() const override { return STRING_RESULT; }
7384
7385 double val_real() override;
7386 my_decimal *val_decimal(my_decimal *val) override;
7387 bool val_date(Date_val *date, my_time_flags_t flags) override;
7388 bool val_time(Time_val *time) override;
7389 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
7390 /// Sort cached data. Only arrays are affected.
7391 void sort();
7392 /// Returns true when cached value is array and it's sorted
7393 bool is_sorted() { return m_is_sorted; }
7394};
7395
7396/**
7397 Interface for storing an aggregation of type and type specification of
7398 multiple Item objects.
7399
7400 This is useful for cases where a field is an amalgamation of multiple types,
7401 such as in UNION where type conversions must be done to a common denominator.
7402*/
7404 protected:
7405 /// Typelib information, only used for data type ENUM and SET.
7407 /// Geometry type, only used for data type GEOMETRY.
7409
7410 void set_typelib(Item *item);
7411
7412 public:
7414
7415 double val_real() override = 0;
7416 longlong val_int() override = 0;
7418 String *val_str(String *) override = 0;
7419 bool val_date(Date_val *, my_time_flags_t) override = 0;
7420 bool val_time(Time_val *time) override = 0;
7422 Item_result result_type() const override;
7423 bool unify_types(Item *item);
7424 bool unify_types(const char *op_string, Item **items, size_t count);
7425 Field *make_field_by_type(TABLE *table, bool strict);
7426 static uint32 display_length(Item *item);
7428 return geometry_type;
7429 }
7430 void make_field(Send_field *field) override {
7431 Item::make_field(field);
7432 // Item_type_holder is used for unions and effectively sends Fields
7433 field->field = true;
7434 }
7437 pointer_cast<Check_function_as_value_generator_parameters *>(args);
7438 func_arg->err_code = func_arg->get_unnamed_function_error_code();
7439 return true;
7440 }
7441};
7442
7443/**
7444 Item_type_holder stores an aggregation of name, type and type specification of
7445 UNIONS and derived tables.
7446*/
7449
7450 public:
7451 /// @todo Consider giving Item_type_holder objects default names from the item
7452 /// they are initialized by. This would ensure that
7453 /// Query_expression::get_unit_column_types() always contains named items.
7454 Item_type_holder(THD *thd, Item *item) : super(thd, item) {}
7455
7456 enum Type type() const override { return TYPE_HOLDER_ITEM; }
7457
7458 /**
7459 Class is used in type aggregation only - this is needed to ensure
7460 that it is not attempted to be evaluated as a const value.
7461 */
7462 table_map used_tables() const override { return RAND_TABLE_BIT; }
7463
7464 double val_real() override;
7465 longlong val_int() override;
7466 my_decimal *val_decimal(my_decimal *) override;
7467 String *val_str(String *) override;
7468 bool val_date(Date_val *date, my_time_flags_t flags) override;
7469 bool val_time(Time_val *time) override;
7470 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
7471};
7472
7473/**
7474 Reference item that encapsulates both the type and the contained items of a
7475 single column of a VALUES ROW query expression.
7476
7477 During execution, the item that will be output for the current iteration is
7478 contained in m_value_ref. The type of the column and the referenced item may
7479 differ in cases where a column of a VALUES clause contains different types
7480 across different rows, and must therefore do type conversions to their common
7481 denominator (e.g. a column containing both 10 and "10", of which the types
7482 will be aggregated into VARCHAR).
7483
7484 See the class comment for TableValueConstructorIterator for info on how
7485 Item_values_column is used as an indirection to iterate over the rows of a
7486 table value constructor (i.e. VALUES ROW expressions).
7487*/
7490
7491 private:
7493 /*
7494 Even if a table value constructor contains only constant values, we
7495 still need to identify individual rows within it. Set RAND_TABLE_BIT
7496 to ensure that all rows are scanned, and that the whole VALUES clause
7497 is never substituted with a const value or row.
7498 */
7500
7502 bool no_conversions) override;
7503
7504 public:
7506
7507 bool eq(const Item *item) const override;
7508 double val_real() override;
7509 longlong val_int() override;
7510 my_decimal *val_decimal(my_decimal *) override;
7511 bool val_bool() override;
7512 String *val_str(String *tmp) override;
7513 bool val_json(Json_wrapper *result) override;
7514 bool is_null() override;
7515 bool val_date(Date_val *date, my_time_flags_t flags) override;
7516 bool val_time(Time_val *time) override;
7517 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
7518 enum Type type() const override { return VALUES_COLUMN_ITEM; }
7519 void set_value(Item *new_value) { m_value_ref = new_value; }
7521 void add_used_tables(Item *value);
7522};
7523
7524/// A class that represents a constant JSON value.
7525class Item_json final : public Item_basic_constant {
7527
7528 public:
7530 const Item_name_string &name);
7531 ~Item_json() override;
7532 enum Type type() const override { return JSON_ITEM; }
7533 void print(const THD *, String *str, enum_query_type) const override;
7534 uint64_t hash() override;
7535 bool val_json(Json_wrapper *result) override;
7536 Item_result result_type() const override { return STRING_RESULT; }
7537 double val_real() override;
7538 longlong val_int() override;
7539 String *val_str(String *str) override;
7541 bool val_date(Date_val *date, my_time_flags_t flags) override;
7542 bool val_time(Time_val *time) override;
7543 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
7544 Item *clone_item() const override;
7545};
7546
7547extern Cached_item *new_Cached_item(THD *thd, Item *item);
7549extern bool resolve_const_item(THD *thd, Item **ref, Item *cmp_item);
7550extern int stored_field_cmp_to_item(THD *thd, Field *field, Item *item);
7551extern bool is_null_on_empty_table(THD *thd, Item_field *i);
7552
7553extern const String my_null_string;
7554void convert_and_print(const String *from_str, String *to_str,
7555 const CHARSET_INFO *to_cs);
7556
7557std::string ItemToString(const Item *item, enum_query_type q_type);
7558std::string ItemToString(const Item *item);
7559
7560std::string ItemToQuerySubstrNoCharLimit(const Item *item);
7561std::string ItemToQuerySubstr(
7562 const Item *item, const LEX *lex = nullptr,
7564
7565inline size_t CountVisibleFields(const mem_root_deque<Item *> &fields) {
7566 return std::count_if(fields.begin(), fields.end(),
7567 [](Item *item) { return !item->hidden; });
7568}
7569
7570inline size_t CountHiddenFields(const mem_root_deque<Item *> &fields) {
7571 return std::count_if(fields.begin(), fields.end(),
7572 [](Item *item) { return item->hidden; });
7573}
7574
7576 size_t index) {
7577 for (Item *item : fields) {
7578 if (item->hidden) continue;
7579 if (index-- == 0) return item;
7580 }
7581 assert(false);
7582 return nullptr;
7583}
7584
7585/**
7586 Returns true iff the two items are equal, as in a->eq(b),
7587 after unwrapping refs and Item_cache objects.
7588 */
7589bool ItemsAreEqual(const Item *a, const Item *b);
7590
7591/**
7592 Returns true iff all items in the two arrays (which must be of the same size)
7593 are equal, as in a->eq(b), after unwrapping refs and Item_cache objects.
7594 */
7595bool AllItemsAreEqual(const Item *const *a, const Item *const *b,
7596 int num_items);
7597
7598#endif /* ITEM_INCLUDED */
uint32_t Access_bitmask
Definition: auth_acls.h:34
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
A type for SQL-like 3-valued Booleans: true/false/unknown.
Definition: item.h:591
value
Definition: item.h:605
@ v_UNKNOWN
Definition: item.h:605
@ v_FALSE
Definition: item.h:605
@ v_TRUE
Definition: item.h:605
Bool3(value v)
This is private; instead, use false3()/etc.
Definition: item.h:607
static const Bool3 true3()
Definition: item.h:598
static const Bool3 unknown3()
Definition: item.h:596
static const Bool3 false3()
Definition: item.h:594
bool is_true() const
Definition: item.h:600
value m_val
Definition: item.h:609
bool is_unknown() const
Definition: item.h:601
bool is_false() const
Definition: item.h:602
Definition: item.h:6672
Cached_item_date(Item *item_par)
Definition: item.h:6674
bool cmp() override
Compare the value associated with the item with the stored value.
Definition: item_buff.cc:198
Date_val m_date
Definition: item.h:6678
Definition: item.h:6689
bool cmp() override
Compare the value associated with the item with the stored value.
Definition: item_buff.cc:242
Cached_item_decimal(Item *item_par)
Definition: item.h:6693
my_decimal value
Definition: item.h:6690
Definition: item.h:6655
longlong value
Definition: item.h:6656
bool cmp() override
Compare the value associated with the item with the stored value.
Definition: item_buff.cc:164
Cached_item_int(Item *item_par)
Definition: item.h:6659
Cached_item subclass for JSON values.
Definition: item.h:6639
Json_wrapper * m_value
The cached JSON value.
Definition: item.h:6640
~Cached_item_json() override
Definition: item_buff.cc:110
Cached_item_json(Item *item)
Definition: item_buff.cc:107
bool cmp() override
Compare the new JSON value in member 'item' with the previous value.
Definition: item_buff.cc:120
Definition: item.h:6647
Cached_item_real(Item *item_par)
Definition: item.h:6651
bool cmp() override
Compare the value associated with the item with the stored value.
Definition: item_buff.cc:148
double value
Definition: item.h:6648
Definition: item.h:6627
String tmp_value
Definition: item.h:6631
Cached_item_str(Item *arg)
Definition: item.h:6634
bool cmp() override
Compare the value associated with the item with the stored value.
Definition: item_buff.cc:84
String value
Definition: item.h:6630
Definition: item.h:6681
Cached_item_temporal(Item *item_par)
Definition: item.h:6685
bool cmp() override
Compare the value associated with the item with the stored value.
Definition: item_buff.cc:215
longlong value
Definition: item.h:6682
Definition: item.h:6663
Cached_item_time(Item *item_par)
Definition: item.h:6665
bool cmp() override
Compare the value associated with the item with the stored value.
Definition: item_buff.cc:181
Time_val m_time
Definition: item.h:6669
This is used for segregating rows in groups (e.g.
Definition: item.h:6605
Item ** get_item_ptr()
Definition: item.h:6624
Item * item
The item whose value to cache.
Definition: item.h:6607
virtual ~Cached_item()=default
Item * get_item() const
Definition: item.h:6623
virtual bool cmp()=0
Compare the value associated with the item with the stored value.
Cached_item(Item *i)
Definition: item.h:6608
bool null_value
Definition: item.h:6611
This class represents the cost of evaluating an Item.
Definition: item.h:790
bool m_is_expensive
True if the associated Item calls user defined functions or stored procedures.
Definition: item.h:845
double FieldCost() const
Get the cost of field access when evaluating the Item associated with this object.
Definition: item.h:827
uint8 m_other_fields
The number of other Field objects accessed by the associated Item.
Definition: item.h:851
void Compute(const Item &item)
Set '*this' to represent the cost of 'item'.
Definition: item.h:793
static constexpr double kStrFieldCost
The cost of accessing a Field_str, relative to other Field types.
Definition: item.h:835
uint8 m_str_fields
The number of Field_str objects accessed by the associated Item.
Definition: item.h:848
bool IsExpensive() const
Definition: item.h:816
void AddFieldCost()
Add the cost of accessing any other Field.
Definition: item.h:811
bool m_computed
True if 'ComputeInternal()' has been called.
Definition: item.h:841
void ComputeInternal(const Item &root)
Compute the cost of 'root' and its descendants.
Definition: item.cc:139
static constexpr double kOtherFieldCost
The cost of accessing a Field other than Field_str. 1.0 by definition.
Definition: item.h:838
void AddStrFieldCost()
Add the cost of accessing a Field_str.
Definition: item.h:805
void MarkExpensive()
Definition: item.h:799
Definition: item.h:184
void set(Derivation derivation_arg)
Definition: item.h:229
DTCollation(const CHARSET_INFO *collation_arg, Derivation derivation_arg)
Definition: item.h:199
void set_repertoire_from_charset(const CHARSET_INFO *cs)
Definition: item.h:190
bool aggregate(DTCollation &dt, uint flags=0)
Aggregate two collations together taking into account their coercibility (aka derivation).
Definition: item.cc:2756
void set(const DTCollation &dt)
Definition: item.h:204
DTCollation()
Definition: item.h:194
void set(const CHARSET_INFO *collation_arg, Derivation derivation_arg, uint repertoire_arg)
Definition: item.h:214
bool set(DTCollation &dt1, DTCollation &dt2, uint flags=0)
Definition: item.h:232
void set_numeric()
Definition: item.h:220
void set_repertoire(uint repertoire_arg)
Definition: item.h:230
const CHARSET_INFO * collation
Definition: item.h:186
Derivation derivation
Definition: item.h:187
const char * derivation_name() const
Definition: item.h:236
void set(const CHARSET_INFO *collation_arg, Derivation derivation_arg)
Definition: item.h:209
uint repertoire
Definition: item.h:188
void set(const CHARSET_INFO *collation_arg)
Definition: item.h:225
Date_val is a temporal type that represents dates within the range 0000-01-01 and 9999-12-31.
Definition: my_temporal.h:421
int32_t for_comparison() const
Definition: my_temporal.h:461
Definition: my_temporal.h:341
A field that stores a JSON value.
Definition: field.h:3922
Definition: field.h:573
const CHARSET_INFO * charset_for_protocol() const
Definition: field.h:1633
virtual Item_result cast_to_int_type() const
Definition: field.h:1050
static constexpr size_t MAX_LONG_BLOB_WIDTH
Definition: field.h:741
virtual bool is_array() const
Whether the field is a typed array.
Definition: field.h:1840
static constexpr size_t MAX_VARCHAR_WIDTH
Definition: field.h:735
const char * field_name
Definition: field.h:690
virtual void add_to_cost(CostOfItem *cost) const
Update '*cost' with the fact that this Field is accessed.
Definition: field.cc:1403
virtual uint32 max_display_length() const =0
TABLE * table
Pointer to TABLE object that owns this field.
Definition: field.h:685
bool is_null(ptrdiff_t row_offset=0) const
Check whether the full table's row is NULL or the Field has value NULL.
Definition: field.h:1230
virtual my_decimal * val_decimal(my_decimal *) const =0
bool is_tmp_nullable() const
Definition: field.h:936
virtual double val_real() const =0
virtual bool val_date(Date_val *date, my_time_flags_t flags) const
Retrieve field value and return the result as a date.
Definition: field.cc:2304
virtual longlong val_int() const =0
virtual Item_result numeric_context_result_type() const
Returns Item_result type of a field when it appears in numeric context such as: SELECT time_column + ...
Definition: field.h:1046
virtual bool eq_def(const Field *field) const
Definition: field.cc:8529
geometry_type
Definition: field.h:722
@ GEOM_GEOMETRY
Definition: field.h:723
virtual bool val_time(Time_val *time) const
Retrieve field value and return the result as a time.
Definition: field.cc:2320
virtual Item_result result_type() const =0
bool is_nullable() const
Definition: field.h:1305
virtual bool val_datetime(Datetime_val *dt, my_time_flags_t flags) const
Retrieve field value and return the result as a datetime/timestamp.
Definition: field.cc:2312
virtual geometry_type get_geometry_type() const
Definition: field.h:1716
static Item_result result_merge_type(enum_field_types)
Detect Item_result by given field type of UNION merge result.
Definition: field.cc:1522
String * val_str(String *str) const
Definition: field.h:1015
bool is_field_for_functional_index() const
Definition: field.h:896
static constexpr size_t MAX_MEDIUM_BLOB_WIDTH
Definition: field.h:740
void dbug_print() const
Definition: field.h:1723
Context object for (functions that override) Item::clean_up_after_removal().
Definition: item.h:2996
Query_block *const m_root
Pointer to Cleanup_after_removal_context containing from which select the walk started,...
Definition: item.h:3010
Cleanup_after_removal_context(Query_block *root)
Definition: item.h:2998
Query_block * get_root()
Definition: item.h:3002
Definition: item.h:2846
List< Item > * m_items
Definition: item.h:2848
Collect_item_fields_or_refs(List< Item > *fields_or_refs)
Definition: item.h:2849
Collect_item_fields_or_refs(const Collect_item_fields_or_refs &)=delete
Collect_item_fields_or_refs & operator=(const Collect_item_fields_or_refs &)=delete
Collect_item_fields_or_view_refs(const Collect_item_fields_or_view_refs &)=delete
Query_block * m_transformed_block
Definition: item.h:2863
List< Item > * m_item_fields_or_view_refs
Definition: item.h:2862
Collect_item_fields_or_view_refs(List< Item > *fields_or_vr, Query_block *transformed_block)
Definition: item.h:2867
uint m_any_value_level
Used to compute Item_field's m_protected_by_any_value.
Definition: item.h:2866
Collect_item_fields_or_view_refs & operator=(const Collect_item_fields_or_view_refs &)=delete
Interface for storing an aggregation of type and type specification of multiple Item objects.
Definition: item.h:7403
longlong val_int() override=0
Item_result result_type() const override
Return expression type of Item_aggregate_type.
Definition: item.cc:11254
bool val_date(Date_val *, my_time_flags_t) override=0
Evaluate the item and return result as a date value.
my_decimal * val_decimal(my_decimal *) override=0
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override=0
Evaluate the item and return result as a datetime value.
void set_typelib(Item *item)
Set typelib information for an aggregated enum/set field.
Definition: item.cc:11527
Item_aggregate_type(THD *, Item *)
Definition: item.cc:11235
String * val_str(String *) override=0
bool check_function_as_value_generator(uchar *args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item.h:7435
static uint32 display_length(Item *item)
Calculate length for merging result for given Item type.
Definition: item.cc:11409
bool val_time(Time_val *time) override=0
Evaluate the item and return result as a time value.
void make_field(Send_field *field) override
Definition: item.h:7430
Field * make_field_by_type(TABLE *table, bool strict)
Make temporary table field according collected information about type of UNION result.
Definition: item.cc:11472
double val_real() override=0
Field::geometry_type get_geometry_type() const override
Definition: item.h:7427
TYPELIB * m_typelib
Typelib information, only used for data type ENUM and SET.
Definition: item.h:7406
bool unify_types(Item *item)
Unify type from given item with the type in the current item.
Definition: item.cc:11368
Field::geometry_type geometry_type
Geometry type, only used for data type GEOMETRY.
Definition: item.h:7408
Represents [schema.
Definition: item.h:4865
bool is_asterisk() const override
Checks if the current object represents an asterisk select list item.
Definition: item.h:4885
Item_asterisk(const POS &pos, const char *opt_schema_name, const char *opt_table_name)
Constructor.
Definition: item.h:4876
Item_field super
Definition: item.h:4866
bool fix_fields(THD *, Item **) override
Resolve the name of a column reference.
Definition: item.h:4881
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item.cc:11965
Definition: item.h:3983
Item_basic_constant(const POS &pos)
Definition: item.h:3988
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item.h:3997
void set_str_value(String *str)
Note that str_value.ptr() will now point to a string owned by some other object.
Definition: item.h:4009
bool basic_const_item() const override
Returns true if this is a simple constant item like an integer, not a constant expression.
Definition: item.h:4004
void set_used_tables(table_map map)
Definition: item.h:3993
table_map used_table_map
Definition: item.h:3984
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.h:3995
Item_basic_constant()
Definition: item.h:3987
table_map used_tables() const override
Definition: item.h:3994
Definition: item.h:5997
Item_bin_string(const char *str, size_t str_length)
Definition: item.h:6001
void bin_string_init(const char *str, size_t str_length)
Definition: item.cc:7869
static LEX_CSTRING make_bin_str(const char *str, size_t str_length)
Definition: item.cc:7839
Item_hex_string super
Definition: item.h:5998
Item_bin_string(const POS &pos, const LEX_STRING &literal)
Definition: item.h:6004
Definition: item.h:5900
Item_blob(const char *name, size_t length)
Definition: item.h:5902
enum Type type() const override
Definition: item.h:5907
bool check_function_as_value_generator(uchar *args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item.h:5908
Cache class for BIT type expressions.
Definition: item.h:7113
Item_cache_bit(enum_field_types field_type_arg)
Definition: item.h:7115
uint string_length()
Definition: item.h:7125
String * val_str(String *str) override
Transform the result Item_cache_int::value in bit format.
Definition: item.cc:10480
Definition: item.h:7297
void store(Item *item) override
Assigns to the cache the expression to be cached.
Definition: item.cc:10607
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item.cc:10656
bool cache_value() override
Definition: item.cc:10577
double val_real() override
Definition: item.cc:10652
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.cc:10616
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:10609
String * val_str(String *str) override
Definition: item.cc:10593
Date_val m_date
Definition: item.h:7322
Item_cache_date()
Definition: item.h:7299
Item_result result_type() const override
Definition: item.h:7312
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.cc:10640
longlong val_int() override
Definition: item.cc:10650
void store_value(Date_val date)
Cache a single non-NULL date value.
Definition: item.cc:10586
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.cc:10628
Definition: item.h:7325
longlong val_int() override
Definition: item.cc:10833
longlong int_value
Used for DATETIME values.
Definition: item.h:7361
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item.cc:10824
bool cache_value() override
Definition: item.cc:10681
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:10740
void store_value(Item *item, longlong val_arg)
Definition: item.cc:10698
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.cc:10797
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.cc:10759
String * val_str(String *str) override
Definition: item.cc:10711
bool str_value_cached
If true, cached_string contains a valid value.
Definition: item.h:7365
Item_result result_type() const override
Definition: item.h:7344
void clear() override
Definition: item.h:7354
String cached_string
Used when required in a string context.
Definition: item.h:7363
void store(Item *item) override
Assigns to the cache the expression to be cached.
Definition: item.cc:10706
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.cc:10767
bool cache_value_int()
Definition: item.cc:10665
Item_cache_datetime(enum_field_types field_type_arg)
Definition: item.h:7327
double val_real() override
Definition: item.cc:10822
Definition: item.h:7151
double val_real() override
Definition: item.cc:11032
my_decimal decimal_value
Definition: item.h:7171
bool cache_value() override
Definition: item.cc:11008
longlong val_int() override
Definition: item.cc:11040
Item_cache_decimal()
Definition: item.h:7153
String * val_str(String *str) override
Definition: item.cc:11048
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.h:7159
void store_value(Item *expr, my_decimal *d)
Definition: item.cc:11025
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:11057
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.h:7163
Item_result result_type() const override
Definition: item.h:7166
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.h:7162
Definition: item.h:7077
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.h:7096
double val_real() override
Definition: item.cc:10467
longlong val_int() override
Definition: item.cc:10474
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.h:7093
longlong value
Definition: item.h:7104
Item_cache_int(enum_field_types field_type_arg)
Definition: item.h:7080
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item.h:7090
Item_result result_type() const override
Definition: item.h:7100
Item_cache_int()
Definition: item.h:7079
bool cache_value() override
Definition: item.cc:10436
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:10460
void store_value(Item *item, longlong val_arg)
Unlike store(), this stores an explicitly provided value, not the one of 'item'; however,...
Definition: item.cc:10445
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.h:7097
String * val_str(String *str) override
Definition: item.cc:10453
An item cache for values of type JSON.
Definition: item.h:7369
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.cc:10916
Item_result result_type() const override
Definition: item.h:7383
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.cc:10940
my_decimal * val_decimal(my_decimal *val) override
Definition: item.cc:10906
bool m_is_sorted
Whether the cached value is array and it is sorted.
Definition: item.h:7373
Json_wrapper * m_value
Cached value.
Definition: item.h:7371
bool cache_value() override
Read the JSON value and cache it.
Definition: item.cc:10848
Item_cache_json()
Definition: item.cc:10835
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.cc:10928
~Item_cache_json() override
Definition: item.cc:10840
bool val_json(Json_wrapper *wr) override
Copy the cached JSON value into a wrapper.
Definition: item.cc:10881
bool is_sorted()
Returns true when cached value is array and it's sorted.
Definition: item.h:7393
void store_value(Item *expr, Json_wrapper *wr)
Definition: item.cc:10865
double val_real() override
Definition: item.cc:10896
String * val_str(String *str) override
Definition: item.cc:10886
void sort()
Sort cached data. Only arrays are affected.
Definition: item.cc:10960
longlong val_int() override
Definition: item.cc:10951
Definition: item.h:7128
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.h:7136
Item_cache_real()
Definition: item.h:7130
void store_value(Item *expr, double value)
Definition: item.cc:10976
double value
Definition: item.h:7148
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.h:7139
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.h:7140
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:11001
bool cache_value() override
Definition: item.cc:10968
Item_result result_type() const override
Definition: item.h:7143
double val_real() override
Definition: item.cc:10982
String * val_str(String *str) override
Definition: item.cc:10994
longlong val_int() override
Definition: item.cc:10988
Definition: item.h:7209
Item * element_index(uint i) override
Definition: item.h:7256
longlong val_int() override
Definition: item.h:7229
bool val_datetime(Datetime_val *, my_time_flags_t) override
Evaluate the item and return result as a datetime value.
Definition: item.h:7249
double val_real() override
Definition: item.h:7225
bool null_inside() override
Definition: item.cc:11217
Item_result result_type() const override
Definition: item.h:7253
Item ** addr(uint i) override
Definition: item.h:7257
bool allocate(uint num) override
'allocate' is only used in Item_cache_row::setup()
Definition: item.cc:11147
Item_cache_row()
Definition: item.h:7211
void bring_value() override
Definition: item.cc:11228
my_decimal * val_decimal(my_decimal *) override
Definition: item.h:7237
void make_field(Send_field *) override
Definition: item.h:7224
void illegal_method_call(const char *) const
Definition: item.cc:11201
uint item_count
Definition: item.h:7266
bool check_cols(uint c) override
Definition: item.cc:11209
bool val_date(Date_val *, my_time_flags_t) override
Evaluate the item and return result as a date value.
Definition: item.h:7241
bool cache_value() override
Definition: item.cc:11178
uint cols() const override
Definition: item.h:7255
bool setup(Item *item) override
Definition: item.cc:11154
void store(Item *item) override
Assigns to the cache the expression to be cached.
Definition: item.cc:11167
bool val_time(Time_val *) override
Evaluate the item and return result as a time value.
Definition: item.h:7245
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item.h:7261
Item_cache ** values
Definition: item.h:7265
String * val_str(String *) override
Definition: item.h:7233
Definition: item.h:7174
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.cc:11133
bool cache_value() override
Definition: item.cc:11063
Item_result result_type() const override
Definition: item.h:7203
void store_value(Item *expr, String &s)
Definition: item.cc:11085
String value_buff
Definition: item.h:7176
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:11123
const CHARSET_INFO * charset() const
Definition: item.h:7204
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.h:7196
double val_real() override
Definition: item.cc:11095
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.h:7200
String * val_str(String *) override
Definition: item.cc:11117
longlong val_int() override
Definition: item.cc:11106
char buffer[STRING_BUFFER_USUAL_SIZE]
Definition: item.h:7175
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.h:7199
String * value
Definition: item.h:7176
bool is_varbinary
Definition: item.h:7177
Item_cache_str(const Item *item)
Definition: item.h:7184
Definition: item.h:7269
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.cc:10556
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.cc:10535
Item_cache_time()
Definition: item.h:7271
void store(Item *item) override
Assigns to the cache the expression to be cached.
Definition: item.cc:10525
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.cc:10545
bool cache_value() override
Definition: item.cc:10496
Item_result result_type() const override
Definition: item.h:7284
Time_val time_value
Definition: item.h:7294
void store_value(Time_val time)
Cache a single non-NULL time value.
Definition: item.cc:10505
String * val_str(String *str) override
Definition: item.cc:10512
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item.cc:10569
longlong val_int() override
Definition: item.cc:10565
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:10527
double val_real() override
Definition: item.cc:10567
Definition: item.h:6941
bool walk(Item_processor processor, enum_walk walk, uchar *arg) override
Traverses a tree of Items in prefix and/or postfix order.
Definition: item.cc:10407
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item.cc:10425
Field * field()
If this item caches a field value, return pointer to underlying field.
Definition: item.h:7024
Item * get_example() const
Definition: item.h:7073
bool eq_def(const Field *field)
Definition: item.h:7008
Item_field * cached_field
Field that this object will get value from.
Definition: item.h:6950
virtual bool allocate(uint)
Definition: item.h:6984
Item ** get_example_ptr()
Definition: item.h:7074
bool is_non_const_over_literals(uchar *) override
Definition: item.h:7060
bool has_value()
Check if saved item has a non-NULL value.
Definition: item.cc:10413
Item_result result_type() const override
Definition: item.h:7069
friend bool has_rollup_result(Item *item)
Checks if an item has a ROLLUP NULL which needs to be written to temp table.
Definition: sql_executor.cc:371
bool basic_const_item() const override
Returns true if this is a simple constant item like an integer, not a constant expression.
Definition: item.h:7049
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:10400
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item.h:7011
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.h:6977
virtual bool cache_value()=0
void store_null()
Force an item to be null.
Definition: item.h:7037
Item_cache(enum_field_types field_type_arg)
Definition: item.h:6970
table_map used_table_map
Definition: item.h:6944
enum Type type() const override
Definition: item.h:7001
Item_cache()
Definition: item.h:6965
virtual void store(Item *item)
Assigns to the cache the expression to be cached.
Definition: item.cc:10376
virtual bool setup(Item *item)
Definition: item.h:6985
bool value_cached
Definition: item.h:6958
table_map used_tables() const override
Definition: item.h:7004
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item.h:7057
virtual void clear()
Definition: item.h:7053
bool check_function_as_value_generator(uchar *args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item.h:7061
Item * example
Definition: item.h:6943
friend bool replace_contents_of_rollup_wrappers_with_tmp_fields(THD *thd, Query_block *select, Item *item_arg)
For each rollup wrapper below the given item, replace its argument with a temporary field,...
Definition: sql_executor.cc:4596
static Item_cache * get_cache(const Item *item)
Definition: item.cc:10327
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:10390
bool store_and_cache(Item *item)
Definition: item.h:7044
Definition: item.h:4156
uint m_case_expr_id
Definition: item.h:4180
Type type() const override
Definition: item.h:4165
Item * this_item() override
Definition: item.cc:2117
Item_case_expr(uint case_expr_id)
Definition: item.cc:2113
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:2142
Item ** this_item_addr(THD *thd, Item **) override
Definition: item.cc:2129
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:2135
Item_result result_type() const override
Definition: item.h:4166
Definition: item.h:6582
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item.h:6596
Item_datetime_with_ref(enum_field_types field_type_arg, uint8 decimals_arg, longlong i, Item *ref_arg)
Constructor for Item_datetime_with_ref.
Definition: item.h:6591
Item * clone_item() const override
Definition: item.cc:7509
Definition: item.h:5511
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:3806
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.h:5539
uint decimal_precision() const override
Definition: item.h:5553
String * val_str(String *) override
Definition: item.cc:3776
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:3782
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item.cc:3808
Item_result result_type() const override
Definition: item.h:5530
longlong val_int() override
Definition: item.cc:3764
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.h:5535
enum Type type() const override
Definition: item.h:5529
my_decimal * val_decimal(my_decimal *) override
Definition: item.h:5534
my_decimal decimal_value
Definition: item.h:5515
double val_real() override
Definition: item.cc:3770
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item.h:5556
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.cc:7478
Item_num super
Definition: item.h:5512
Item_decimal(const POS &pos, const char *str_arg, uint length, const CHARSET_INFO *charset)
Definition: item.cc:3705
Item * clone_item() const override
Definition: item.h:5542
Item_num * neg() override
Definition: item.h:5548
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.h:5538
void set_decimal_value(const my_decimal *value_par)
Definition: item.cc:3823
Definition: item.h:6697
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:9741
Item * transform(Item_transformer transformer, uchar *args) override
Perform a generic transformation of the Item tree, by adding zero or more additional Item objects to ...
Definition: item.cc:9790
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.cc:9746
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:9730
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item.cc:9635
Item_default_value(const POS &pos, Item *a=nullptr)
Definition: item.h:6705
void bind_fields() override
Bind objects from the current execution context to field objects in item trees.
Definition: item.cc:9716
bool walk(Item_processor processor, enum_walk walk, uchar *args) override
Traverses a tree of Items in prefix and/or postfix order.
Definition: item.h:6727
Item_field super
Definition: item.h:6698
bool check_column_privileges(uchar *) override
Check privileges of base table column.
Definition: item.h:6725
table_map used_tables() const override
Definition: item.h:6716
bool check_gcol_depend_default_processor(uchar *args) override
Check if a generated expression depends on DEFAULT function with specific column name as argument.
Definition: item.h:6733
Item * arg
The argument for this function.
Definition: item.h:6743
bool collect_item_field_or_view_ref_processor(uchar *arg) override
Collects fields and view references that have the qualifying table in the specified query block.
Definition: item.cc:6753
Item * argument() const
Definition: item.h:6739
uchar * m_rowbuffer_saved
Pointer to row buffer that was used to calculate field value offset.
Definition: item.h:6745
bool fix_fields(THD *, Item **) override
Resolve the name of a column reference.
Definition: item.cc:9656
enum Type type() const override
Definition: item.h:6708
Item * replace_item_field(uchar *) override
If this default value is the target of replacement, replace it with the info object's item or,...
Definition: item.cc:6777
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.h:6717
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item.cc:9651
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item.cc:9706
Item_empty_string – is a utility class to put an item into List<Item> which is then used in protocol....
Definition: item.h:5922
void make_field(Send_field *field) override
Definition: item.cc:6882
Item_empty_string(const char *header, size_t length, const CHARSET_INFO *cs=nullptr)
Definition: item.h:5924
Definition: item.h:4540
Item * replace_equal_field(uchar *) override
Replace an Item_field for an equal Item_field that evaluated earlier (if any).
Definition: item.cc:6823
bool protected_by_any_value() const
See m_protected_by_any_value.
Definition: item.h:4847
bool check_column_privileges(uchar *arg) override
Check privileges of base table column.
Definition: item.cc:1414
bool collect_outer_field_processor(uchar *arg) override
Definition: item.cc:1014
bool collect_item_field_or_ref_processor(uchar *arg) override
When collecting information about columns when transforming correlated scalar subqueries using derive...
Definition: item.cc:1046
bool check_column_in_window_functions(uchar *arg) override
Check if this column is found in PARTITION clause of all the window functions.
Definition: item.cc:1227
bool find_field_processor(uchar *arg) override
Is this an Item_field which references the given Field argument?
Definition: item.h:4723
bool alias_name_used() const override
Definition: item.h:4823
bool any_privileges
Definition: item.h:4650
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item.h:4736
void set_item_equal_all_join_nests(Item_multi_eq *item_equal)
Definition: item.h:4621
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.cc:3464
enum Type type() const override
Definition: item.h:4666
Item * apply_masking_policy(THD *thd) override
Apply column masking policy to this item if applicable.
Definition: item.cc:11992
bool add_field_to_cond_set_processor(uchar *) override
Item::walk function.
Definition: item.cc:1093
Item_result numeric_context_result_type() const override
Result type when an item appear in a numeric context.
Definition: item.h:4682
Item_multi_eq * multi_equality() const
Definition: item.h:4619
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.cc:3454
void set_field(Field *field)
Definition: item.cc:3230
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.cc:3447
Item_result cast_to_int_type() const override
Definition: item.h:4686
void set_item_was_sp_local_variable()
Sets m_was_sp_local_variable to true.
Definition: item.h:4629
const Item_field * base_item_field() const
Definition: item.h:4700
bool collect_item_field_processor(uchar *arg) override
Store the pointer to this item field into a list if not already there.
Definition: item.cc:1002
Item_multi_eq * find_multi_equality(COND_EQUAL *cond_equal) const
Find a field among specified multiple equalities.
Definition: item.cc:6582
Item * replace_with_derived_expr_ref(uchar *arg) override
Assuming this expression is part of a condition that would be pushed to the HAVING clause of a materi...
Definition: item.cc:1291
uint16 field_index
Index for this field in table->field array.
Definition: item.h:4618
const CHARSET_INFO * charset_for_protocol(void) override
Definition: item.h:4769
bool subst_argument_checker(uchar **arg) override
Check whether a field can be substituted by an equal item.
Definition: item.cc:6626
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:8567
Field * result_field
Result field.
Definition: item.h:4563
void disable_masking_policy() override
Disable application of the masking policy to this item.
Definition: item.h:4832
Item_multi_eq * item_equal_all_join_nests
Definition: item.h:4640
Item_result result_type() const override
Definition: item.h:4681
uint32 max_disp_length()
Definition: item.h:4754
void dbug_print() const
Definition: item.h:4774
double val_real() override
Definition: item.cc:3417
bool find_item_in_field_list_processor(uchar *arg) override
Check if an Item_field references some field from a list of fields.
Definition: item.cc:1122
void save_org_in_field(Field *field) override
Set a field's value from a item.
Definition: item.cc:7183
void make_field(Send_field *tmp_field) override
Definition: item.cc:7129
void set_base_item_field(const Item_field *item)
Definition: item.h:4696
bool get_timeval(my_timeval *tm, int *warnings) override
Get timestamp in "struct timeval" format.
Definition: item.cc:3474
enum_monotonicity_info get_monotonicity_info() const override
Definition: item.h:4689
float get_cond_filter_default_probability(double max_distinct_values, float default_filter) const
Returns the probability for the predicate "col OP <val>" to be true for a row in the case where no in...
Definition: item.cc:8609
Item_field * field_for_view_update() override
Definition: item.h:4755
const Item_field * m_base_item_field
If this field is derived from another field, e.g.
Definition: item.h:4585
void set_result_field(Field *field_arg) override
Definition: item.h:4693
bool send(Protocol *protocol, String *str_arg) override
This is only called from items that is not of type item_field.
Definition: item.cc:8532
table_map used_tables() const override
Definition: item.cc:3518
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item.h:4707
void reset_field()
Reset all aspect of a field object, so that it can be re-resolved.
Definition: item.cc:6554
Field * field
Source field.
Definition: item.h:4559
void compute_cost(CostOfItem *root_cost) const override
Compute the cost of evaluating this Item.
Definition: item.h:4849
Item_multi_eq * m_multi_equality
Holds a list of items whose values must be equal to the value of this field, during execution.
Definition: item.h:4601
Item * update_value_transformer(uchar *select_arg) override
Add the field to the select list and substitute it for the reference to the field.
Definition: item.cc:8553
bool check_column_in_group_by(uchar *arg) override
Check if this column is found in GROUP BY.
Definition: item.cc:1261
uint32_t last_org_destination_field_memcpyable
Definition: item.h:4577
bool returns_array() const override
Whether the item returns array of its data type.
Definition: item.h:4830
Item * replace_item_field(uchar *) override
If this field is the target is the target of replacement, replace it with the info object's item or,...
Definition: item.cc:6727
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item.cc:3429
void bind_fields() override
Bind objects from the current execution context to field objects in item trees.
Definition: item.cc:6488
void set_can_use_prefix_key() override
Definition: item.h:4834
uint32_t last_destination_field_memcpyable
Definition: item.h:4578
Item * equal_fields_propagator(uchar *arg) override
If field matches a multiple equality, set a pointer to that object in the field.
Definition: item.cc:6683
bool fix_outer_field(THD *thd, Field **field, Item_ident **ref_field, bool *complete)
Resolve the name of a column that may be an outer reference.
Definition: item.cc:5857
String * val_str(String *) override
Definition: item.cc:3402
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.cc:3609
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:3441
Field::geometry_type get_geometry_type() const override
Definition: item.h:4765
Access_bitmask have_privileges
Definition: item.h:4648
bool add_field_to_set_processor(uchar *arg) override
Item::walk function.
Definition: item.cc:1084
Item * replace_with_derived_expr(uchar *arg) override
Assuming this expression is part of a condition that would be pushed to the WHERE clause of a materia...
Definition: item.cc:1274
bool strip_db_table_name_processor(uchar *) override
Generated fields don't need db/table names.
Definition: item.cc:11870
bool remove_column_from_bitmap(uchar *arg) override
Visitor interface for removing all column expressions (Item_field) in this expression tree from a bit...
Definition: item.cc:1100
bool is_outer_field() const override
Definition: item.h:4761
bool repoint_const_outer_ref(uchar *arg) override
If this object is the real_item of an Item_ref, repoint the result_field to field.
Definition: item.cc:11859
bool no_constant_propagation
If true, the optimizer's constant propagation will not replace this item with an equal constant.
Definition: item.h:4643
bool val_json(Json_wrapper *result) override
Get a JSON value from an Item.
Definition: item.cc:3409
bool collect_item_field_or_view_ref_processor(uchar *arg) override
Collects fields and view references that have the qualifying table in the specified query block.
Definition: item.cc:1062
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item.cc:3126
bool is_valid_for_pushdown(uchar *arg) override
Check if all the columns present in this expression are from the derived table.
Definition: item.cc:1133
Item_ident super
Definition: item.h:4541
virtual bool is_asterisk() const
Checks if the current object represents an asterisk select list item.
Definition: item.h:4845
Field * tmp_table_field(TABLE *) override
Definition: item.h:4695
bool can_use_prefix_key
Definition: item.h:4655
bool m_protected_by_any_value
State used for transforming scalar subqueries to JOINs with derived tables, cf.
Definition: item.h:4591
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.h:4545
Item_field(Name_resolution_context *context_arg, const char *db_arg, const char *table_name_arg, const char *field_name_arg)
Constructor used for internal information queries.
Definition: item.cc:3102
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.cc:7198
longlong val_date_temporal_at_utc() override
Definition: item.cc:3435
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item.cc:6517
bool m_masking_policy_disabled
apply_masking_policy() is a no-op if this flag is true.
Definition: item.h:4611
longlong val_int() override
Definition: item.cc:3423
bool m_was_sp_local_variable
Indicates whether this field should be treated as an outer reference due to being the result of inlin...
Definition: item.h:4608
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 condition filtering effect for "WHERE field", which implicitly means "WHERE field <> 0".
Definition: item.cc:8597
Field * last_org_destination_field
Definition: item.h:4575
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item.cc:3480
bool used_tables_for_level(uchar *arg) override
Return used table information for the specified query block (level).
Definition: item.cc:3524
TYPELIB * get_typelib() const override
Get the typelib information for an item of type set or enum.
Definition: item.cc:3398
bool mark_field_in_map(uchar *arg) override
Mark underlying field in read or write map of a table.
Definition: item.h:4727
bool check_function_as_value_generator(uchar *args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item.cc:1325
bool disable_constant_propagation(uchar *) override
Definition: item.h:4749
bool replace_field_processor(uchar *arg) override
A processor that replaces any Fields with a Create_field_wrapper.
Definition: sql_table.cc:7858
Field * last_destination_field
Definition: item.h:4576
Field * get_tmp_table_field() override
If this Item is being materialized into a temporary table, returns the field that is being materializ...
Definition: item.h:4694
longlong val_int_endpoint(bool left_endp, bool *incl_endp) override
Definition: item.cc:3620
bool fix_fields(THD *, Item **) override
Resolve the name of a column reference.
Definition: item.cc:6268
Definition: item.h:5559
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.h:5627
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.h:5624
Item_num super
Definition: item.h:5560
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:7627
longlong val_int() override
Definition: item.h:5613
Name_string presentation
Definition: item.h:5562
Item_float(double value_par, uint decimal_par)
Definition: item.h:5593
Item_float(const POS &pos, const Name_string name_arg, double val_arg, uint decimal_par, uint length)
Definition: item.h:5582
Item * clone_item() const override
Definition: item.h:5631
void init(const char *str_arg, uint length)
This function is only called during parsing:
Definition: item.cc:7586
Item_float(const char *str_arg, uint length)
Definition: item.h:5567
double val_real() override
Definition: item.h:5609
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.cc:7603
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:7611
Item_num * neg() override
Definition: item.h:5634
String * val_str(String *) override
Definition: item.cc:3831
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:3837
double value
Definition: item.h:5565
Item_float(const Name_string name_arg, double val_arg, uint decimal_par, uint length)
Definition: item.h:5572
Item_float(const POS &pos, const char *str_arg, uint length)
Definition: item.h:5568
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item.cc:7635
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.h:5628
enum Type type() const override
Definition: item.h:5608
Implements the comparison operator equals (=)
Definition: item_cmpfunc.h:1111
Definition: item.h:5644
void print(const THD *, String *str, enum_query_type) const override
This method is used for to:
Definition: item.h:5652
const Name_string func_name
Definition: item.h:5645
Item_func_pi(const POS &pos)
Definition: item.h:5648
Definition: item_func.h:101
Definition: item.h:5945
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.h:5976
uint decimal_precision() const override
Definition: item.cc:7687
Item_result result_type() const override
Definition: item.h:5980
Item_result cast_to_int_type() const override
Definition: item.h:5984
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:7762
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:7822
void hex_string_init(const char *str, uint str_length)
Definition: item.cc:7713
Item_result numeric_context_result_type() const override
Result type when an item appear in a numeric context.
Definition: item.h:5981
enum Type type() const override
Definition: item.h:5960
Item_hex_string()
Definition: item.cc:7653
longlong val_int() override
Definition: item.cc:7723
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.h:5977
Item_basic_constant super
Definition: item.h:5946
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.h:5973
Item * clone_item() const override
Definition: item.cc:7660
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item.cc:7824
static LEX_CSTRING make_hex_str(const char *str, size_t str_length)
Definition: item.cc:7671
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.cc:7769
double val_real() override
Definition: item.h:5961
String * val_str(String *) override
Definition: item.h:5968
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:7800
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item.h:5989
Item_hex_string(const POS &pos)
Definition: item.h:5954
Definition: item.h:4509
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.h:4527
my_decimal * val_decimal(my_decimal *dec) override
Definition: item.h:4524
const CHARSET_INFO * charset_for_protocol() override
Definition: item.h:4535
Item_ident_for_show(Field *par_field, const char *db_arg, const char *table_name_arg)
Definition: item.h:4515
const char * table_name
Definition: item.h:4513
enum Type type() const override
Definition: item.h:4519
longlong val_int() override
Definition: item.h:4522
double val_real() override
Definition: item.h:4521
Field * field
Definition: item.h:4511
String * val_str(String *str) override
Definition: item.h:4523
bool fix_fields(THD *thd, Item **ref) override
Definition: item.cc:3052
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.h:4530
void make_field(Send_field *tmp_field) override
Definition: item.cc:3039
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.h:4531
const char * db_name
Definition: item.h:4512
Definition: item.h:4269
bool m_alias_of_expr
if this Item's name is alias of SELECT expression
Definition: item.h:4313
uint64_t m_hash_val
To cache the hash value of this item, populated upon hash() invocation.
Definition: item.h:4273
virtual bool alias_name_used() const
Definition: item.h:4500
const char * original_db_name() const
Definition: item.h:4426
void set_alias_of_expr()
Marks that this Item's name is alias of SELECT expression.
Definition: item.h:4484
bool is_strong_side_column_not_in_fd(uchar *arg) override
Definition: item.cc:11834
Item_ident(Name_resolution_context *context_arg, const char *db_name_arg, const char *table_name_arg, const char *field_name_arg)
Definition: item.h:4375
bool is_alias_of_expr() const
Definition: item.h:4482
Item_ident(THD *thd, Item_ident *item)
Constructor used by Item_field & Item_*_ref (see Item comment)
Definition: item.h:4403
Query_block * depended_from
For a column or reference that is an outer reference, depended_from points to the qualifying query bl...
Definition: item.h:4373
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.cc:3543
const char * m_orig_field_name
Names the field in the source base table.
Definition: item.h:4312
void set_original_field_name(const char *name_arg)
Definition: item.h:4423
const char * m_orig_table_name
Names the original table that is the source of the field.
Definition: item.h:4302
const char * original_table_name() const
Definition: item.h:4427
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.h:4435
Item_ident(const POS &pos, const char *db_name_arg, const char *table_name_arg, const char *field_name_arg)
Definition: item.h:4388
bool update_depended_from(uchar *) override
Definition: item.cc:977
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item.cc:957
Table_ref * m_table_ref
Points to the Table_ref object of the table or view that the column or reference is resolved against ...
Definition: item.h:4367
const char * table_name
If column is from a non-aliased base table or view, name of base table or view.
Definition: item.h:4342
Name_resolution_context * context
For regularly resolved column references, 'context' points to a name resolution context object belong...
Definition: item.h:4328
friend bool insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, const char *table_name, mem_root_deque< Item * >::iterator *it, bool any_privileges)
const char * db_name
Schema name of the base table or view the column is part of.
Definition: item.h:4334
const char * full_name() const override
Definition: item.cc:3286
bool aggregate_check_group(uchar *arg) override
Definition: item.cc:11829
bool is_column_not_in_fd(uchar *arg) override
Definition: item.cc:11842
const char * field_name
If column is aliased, the column alias name.
Definition: item.h:4356
uint64_t hash(const char *db_name_arg, const char *table_name_arg)
void set_orignal_db_name(const char *name_arg)
Definition: item.h:4419
const char * original_field_name() const
Definition: item.h:4428
bool change_context_processor(uchar *arg) override
Definition: item.h:4476
void set_original_table_name(const char *name_arg)
Definition: item.h:4420
Item super
Definition: item.h:4270
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:3371
const char * m_orig_db_name
The fields m_orig_db_name, m_orig_table_name and m_orig_field_name are maintained so that we can prov...
Definition: item.h:4292
bool aggregate_check_distinct(uchar *arg) override
Definition: item.cc:11781
Bool3 local_column(const Query_block *sl) const override
Tells if this is a column of a table whose qualifying query block is 'sl'.
Definition: item.cc:11748
Representation of IN subquery predicates of the form "left_expr IN (SELECT ...)".
Definition: item_subselect.h:608
Definition: item.h:6758
Item_insert_value(Name_resolution_context *context_arg, Item *a)
Constructs an Item_insert_value that represents a derived table that wraps a table value constructor.
Definition: item.h:6779
bool check_function_as_value_generator(uchar *args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item.h:6808
bool fix_fields(THD *, Item **) override
Resolve the name of a column reference.
Definition: item.cc:9808
Item_insert_value(const POS &pos, Item *a)
Constructs an Item_insert_value that represents a call to the deprecated VALUES function.
Definition: item.h:6770
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item.h:6784
uchar * m_rowbuffer_saved
Pointer to row buffer that was used to calculate field value offset.
Definition: item.h:6819
const bool m_is_values_function
This flag is true if the item represents a call to the deprecated VALUES function.
Definition: item.h:6825
type_conversion_status save_in_field_inner(Field *field_arg, bool no_conversions) override
Helper function which does all of the work for save_in_field(Field*, bool), except some error checkin...
Definition: item.h:6760
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item.cc:9803
Item * arg
The argument for this function.
Definition: item.h:6817
bool walk(Item_processor processor, enum_walk walk, uchar *args) override
Traverses a tree of Items in prefix and/or postfix order.
Definition: item.h:6803
table_map used_tables() const override
Definition: item.h:6801
enum Type type() const override
Definition: item.h:6789
void bind_fields() override
Bind objects from the current execution context to field objects in item trees.
Definition: item.cc:9891
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:9919
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:9926
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item.cc:9913
Item_int with value==0 and length==1.
Definition: item.h:5416
Item_int_0()
Definition: item.h:5418
Item_int_0(const POS &pos)
Definition: item.h:5419
Definition: item.h:6531
Item * clone_item() const override
Definition: item.cc:7498
type_conversion_status save_in_field_inner(Field *field, bool no_conversions) override
Store this item's int-value in a field.
Definition: item.h:6534
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:7530
const Item * real_item() const override
Definition: item.h:6549
Item_int_with_ref(enum_field_types field_type, longlong i, Item *ref_arg, bool unsigned_arg)
Definition: item.h:6540
Item * ref
Definition: item.h:6533
Item * real_item() override
Definition: item.h:6548
Definition: item.h:5302
Item_result result_type() const override
Definition: item.h:5379
Item_int(const POS &pos, const LEX_STRING &num, int dummy_error=0)
Definition: item.h:5362
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:3663
Item_int(longlong i, uint length=MY_INT64_NUM_DECIMAL_DIGITS)
Definition: item.h:5321
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:3651
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.h:5394
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.h:5410
double val_real() override
Definition: item.h:5384
Item_int(const POS &pos, const char *str_arg, uint length)
Definition: item.h:5357
Item * clone_item() const override
Definition: item.h:5397
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item.h:5409
Item_int(const POS &pos, const Name_string &name_arg, longlong i, uint length)
Definition: item.h:5346
longlong value
Definition: item.h:5308
Item_int(int32 i, uint length=MY_INT32_NUM_DECIMAL_DIGITS)
Definition: item.h:5309
type_conversion_status save_in_field_inner(Field *field, bool no_conversions) override
Store this item's int-value in a field.
Definition: item.cc:7459
void init(const char *str_arg, uint length)
Init an item from a string we KNOW points to a valid longlong.
Definition: item.cc:3642
uint decimal_precision() const override
Definition: item.h:5405
Item_int(const POS &pos, int32 i, uint length=MY_INT32_NUM_DECIMAL_DIGITS)
Definition: item.h:5315
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.h:5390
Item_int(const Item_int *item_arg)
Definition: item.h:5333
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:3685
Item_int(const char *str_arg, uint length)
Definition: item.h:5353
void set_max_size(uint length)
Definition: item.h:5368
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.h:5393
static Item_int * narrow(Item *item)
Definition: item.cc:3625
String * val_str(String *) override
Definition: item.cc:3656
Item_num super
Definition: item.h:5303
enum Type type() const override
Definition: item.h:5378
Item_int(ulonglong i, uint length=MY_INT64_NUM_DECIMAL_DIGITS)
Definition: item.h:5326
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item.cc:7485
Item_int(const Name_string &name_arg, longlong i, uint length)
Definition: item.h:5340
Item_num * neg() override
Definition: item.h:5401
longlong val_int() override
Definition: item.h:5380
A class that represents a constant JSON value.
Definition: item.h:7525
unique_ptr_destroy_only< Json_wrapper > m_value
Definition: item.h:7526
longlong val_int() override
Definition: item.cc:7923
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.cc:7938
Item_result result_type() const override
Definition: item.h:7536
~Item_json() override
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:7900
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.cc:7952
void print(const THD *, String *str, enum_query_type) const override
This method is used for to:
Definition: item.cc:7894
Item * clone_item() const override
Definition: item.cc:7957
Item_json(unique_ptr_destroy_only< Json_wrapper > value, const Item_name_string &name)
Definition: item.cc:7885
my_decimal * val_decimal(my_decimal *buf) override
Definition: item.cc:7934
bool val_json(Json_wrapper *result) override
Get a JSON value from an Item.
Definition: item.cc:7907
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.cc:7945
double val_real() override
Definition: item.cc:7919
String * val_str(String *str) override
Definition: item.cc:7927
enum Type type() const override
Definition: item.h:7532
The class Item_multi_eq is used to represent conjunctions of equality predicates of the form field1 =...
Definition: item_cmpfunc.h:2715
Definition: item.h:4197
Item * value_item
Definition: item.h:4200
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.cc:2184
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.cc:2179
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.h:4232
Item * name_item
Definition: item.h:4201
Item_result result_type() const override
Definition: item.h:4224
bool fix_fields(THD *, Item **) override
Definition: item.cc:2248
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item.cc:2194
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:2283
bool valid_args
Definition: item.h:4202
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:2172
bool cache_const_expr_analyzer(uchar **) override
Check if an item is a constant one and can be cached.
Definition: item.h:4226
longlong val_int() override
Definition: item.cc:2158
double val_real() override
Definition: item.cc:2151
Item_name_const(const POS &pos, Item *name_arg, Item *val)
Definition: item.cc:2196
Item super
Definition: item.h:4198
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:2274
enum Type type() const override
Definition: item.h:4210
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.cc:2189
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item.cc:2201
String * val_str(String *sp) override
Definition: item.cc:2165
Storage for Item names.
Definition: item.h:372
void set_autogenerated(bool is_autogenerated)
Set m_is_autogenerated flag to the given value.
Definition: item.h:383
bool is_autogenerated() const
Return the auto-generated flag.
Definition: item.h:389
void copy(const char *str_arg, size_t length_arg, const CHARSET_INFO *cs_arg, bool is_autogenerated_arg)
Copy name together with autogenerated flag.
Definition: item.cc:1500
Item_name_string()
Definition: item.h:377
Item_name_string(const Name_string name)
Definition: item.h:378
bool m_is_autogenerated
Definition: item.h:374
Definition: item.h:4906
type_conversion_status save_in_field_inner(Field *field, bool no_conversions) override
Store null in field.
Definition: item.cc:7240
Item_null()
Definition: item.h:4920
bool send(Protocol *protocol, String *str) override
Pack data in buffer for sending.
Definition: item.cc:7881
void print(const THD *, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.h:4950
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item.cc:4005
Item_basic_constant super
Definition: item.h:4907
bool val_time(Time_val *) override
Evaluate the item and return result as a time value.
Definition: item.h:4942
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:4007
Item_result result_type() const override
Definition: item.h:4946
Item_null(const POS &pos)
Definition: item.h:4924
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item.h:4956
Item * clone_item() const override
Definition: item.h:4947
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item.h:4938
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item.h:4948
double val_real() override
Definition: item.cc:4009
longlong val_int() override
Definition: item.cc:4015
bool val_datetime(Datetime_val *, my_time_flags_t) override
Evaluate the item and return result as a datetime value.
Definition: item.h:4943
Item_null(const Name_string &name_par)
Definition: item.h:4929
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item.cc:4031
String * val_str(String *str) override
Definition: item.cc:4022
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:4029
enum Type type() const override
Definition: item.h:4934
bool val_date(Date_val *, my_time_flags_t) override
Evaluate the item and return result as a date value.
Definition: item.h:4941
void init()
Definition: item.h:4909
Definition: item.h:4256
virtual Item_num * neg()=0
Item_basic_constant super
Definition: item.h:4257
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item.h:4264
Item_num()
Definition: item.h:4260
Item_num(const POS &pos)
Definition: item.h:4261
Definition: item.h:6424
bool fix_fields(THD *, Item **) override
Prepare referenced outer field then call usual Item_ref::fix_fields.
Definition: item.cc:9358
Item * replace_outer_ref(uchar *) override
Definition: item.cc:9432
Query_block * qualifying
Qualifying query of this outer ref (i.e.
Definition: item.h:6432
bool found_in_select_list
Definition: item.h:6442
Ref_Type ref_type() const override
Definition: item.h:6476
Item * outer_ref
Definition: item.h:6435
Item_outer_ref(Name_resolution_context *context_arg, Item_ident *ident_arg, Query_block *qualifying)
Definition: item.h:6443
Item_ref super
Definition: item.h:6425
Item_outer_ref(Name_resolution_context *context_arg, Item **item, const char *db_name_arg, const char *table_name_arg, const char *field_name_arg, bool alias_of_expr_arg, Query_block *qualifying)
Definition: item.h:6458
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.h:6474
table_map used_tables() const override
Definition: item.h:6471
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.cc:9421
Item_sum * in_sum_func
Definition: item.h:6437
Dynamic parameters used as placeholders ('?') inside prepared statements.
Definition: item.h:4961
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.cc:4640
void set_data_type_actual(enum_field_types data_type, bool unsigned_val)
For use with all field types, especially integer types.
Definition: item.h:5191
union Item_param::@61 value
enum_field_types data_type_source() const
Definition: item.h:5195
void reset()
Resets parameter after execution.
Definition: item.cc:4575
void set_null()
Definition: item.cc:4272
bool set_value(THD *, sp_rcontext *, Item **it) override
This operation is intended to store some item value in Item_param to be used later.
Definition: item.cc:5378
Time_val m_time
Definition: item.h:5003
void set_time(Datetime_val *dt, enum_mysql_timestamp_type type)
Set parameter value from MYSQL_TIME value.
Definition: item.cc:4382
const String * query_val_str(const THD *thd, String *str) const
Return Param item values in string format, for generating the dynamic query used in update/binary log...
Definition: item.cc:4911
bool m_json_as_scalar
If true, when retrieving JSON data, attempt to interpret a string value as a scalar JSON value,...
Definition: item.h:5114
bool is_type_inherited() const
Definition: item.h:5143
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:4775
double real
Definition: item.h:5007
void set_param_state(enum enum_item_param_state state)
Definition: item.h:4982
bool is_type_pinned() const
Definition: item.h:5149
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:5278
Mem_root_array< Item_param * > m_clones
If a query expression's text QT or text of a condition (CT) that is pushed down to a derived table,...
Definition: item.h:5299
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.cc:4588
String * val_str(String *) override
Definition: item.cc:4806
void sync_clones()
This should be called after any modification done to this Item, to propagate the said modification to...
Definition: item.cc:4241
void set_collation_actual(const CHARSET_INFO *coll)
Definition: item.h:5158
bool val_json(Json_wrapper *result) override
Get a JSON value from an Item.
Definition: item.cc:4848
void set_out_param_info(Send_field *info) override
Setter of Item_param::m_out_param_info.
Definition: item.cc:5441
Date_val m_date
Definition: item.h:5002
bool set_from_user_var(THD *thd, const user_var_entry *entry)
Set parameter value from user variable value.
Definition: item.cc:4483
Item_result m_result_type
Result type of parameter.
Definition: item.h:5099
uint pos_in_query
Definition: item.h:5130
bool is_unsigned_actual() const
Definition: item.h:5152
void set_data_type_source(enum_field_types data_type, bool unsigned_val)
Definition: item.h:5182
bool add_clone(Item_param *i)
Definition: item.h:5250
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item.h:5231
longlong integer
Definition: item.h:5006
void pin_data_type() override
Pin the currently resolved data type for this parameter.
Definition: item.h:5146
const CHARSET_INFO * m_collation_source
The character set and collation of the source parameter value.
Definition: item.h:5089
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.cc:4675
bool is_non_const_over_literals(uchar *) override
Definition: item.h:5244
String str_value_ptr
Definition: item.h:5000
const Send_field * get_out_param_info() const override
Getter of Item_param::m_out_param_info.
Definition: item.cc:5460
enum_field_types data_type_actual() const
Definition: item.h:5197
my_decimal decimal_value
Definition: item.h:5001
Settable_routine_parameter * get_settable_routine_parameter() override
Definition: item.h:5253
Item_result result_type() const override
Definition: item.h:5136
enum_field_types m_data_type_actual
The actual data type of the parameter value provided by the user.
Definition: item.h:5080
void set_decimal(const char *str, ulong length)
Set decimal parameter value from string.
Definition: item.cc:4316
void make_field(Send_field *field) override
Fill meta-data information for the corresponding column in a result set.
Definition: item.cc:5472
bool is_valid_for_pushdown(uchar *arg) override
Check if all the columns present in this expression are from the derived table.
Definition: item.h:5272
enum_item_param_state
Definition: item.h:4969
@ STRING_VALUE
Definition: item.h:4974
@ DECIMAL_VALUE
Definition: item.h:4979
@ NO_VALUE
Definition: item.h:4970
@ REAL_VALUE
Definition: item.h:4973
@ TIME_VALUE
Definition: item.h:4975
@ LONG_DATA_VALUE
Definition: item.h:4978
@ INT_VALUE
Definition: item.h:4972
@ DATETIME_VALUE
Definition: item.h:4977
@ NULL_VALUE
Definition: item.h:4971
@ DATE_VALUE
Definition: item.h:4976
Datetime_val m_datetime
Definition: item.h:5004
enum_field_types m_data_type_source
Parameter objects have a rather complex handling of data type, in order to consistently handle requir...
Definition: item.h:5059
enum Type type() const override
Definition: item.h:5137
enum_item_param_state m_param_state
m_param_state is used to indicate that no parameter value is available with NO_VALUE,...
Definition: item.h:5108
bool check_function_as_value_generator(uchar *args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item.h:5266
void set_int(longlong i)
Definition: item.cc:4281
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:5265
bool convert_value()
Convert value according to the following rules:
Definition: item.cc:4994
void set_data_type_inherited() override
Set the currently resolved data type for this parameter as inherited.
Definition: item.h:5140
const CHARSET_INFO * collation_actual() const
Definition: item.h:5166
bool fix_fields(THD *thd, Item **ref) override
Definition: item.cc:4109
void set_date(Date_val date)
Set parameter value from date value.
Definition: item.cc:4351
Send_field * m_out_param_info
Definition: item.h:5278
void set_datetime(Datetime_val dt)
Set parameter value from datetime value.
Definition: item.cc:4365
bool do_itemize(Parse_context *pc, Item **item) override
The core function that does the actual itemization.
Definition: item.cc:4045
void set_collation_source(const CHARSET_INFO *coll)
Definition: item.h:5154
const CHARSET_INFO * collation_source() const
Definition: item.h:5163
longlong val_int() override
Definition: item.cc:4738
bool set_str(const char *str, size_t length)
Definition: item.cc:4414
bool m_unsigned_actual
Used when actual value is integer to indicate whether value is unsigned.
Definition: item.h:5082
bool m_type_inherited
True if type of parameter is inherited from parent object (like a typecast).
Definition: item.h:5017
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item.cc:5261
double val_real() override
Definition: item.cc:4697
enum_field_types actual_data_type() const override
Retrieve actual data type for an item.
Definition: item.h:5199
enum enum_item_param_state param_state() const
Definition: item.h:4986
Item * clone_item() const override
Definition: item.cc:5237
const CHARSET_INFO * m_collation_actual
The character set and collation of the value stored in str_value, possibly after being converted from...
Definition: item.h:5097
void set_param_type_and_swap_value(Item_param *from)
Preserve the original parameter types and values when re-preparing a prepared statement.
Definition: item.cc:5348
bool m_type_pinned
True if type of parameter has been pinned, attempt to use an incompatible actual type will cause erro...
Definition: item.h:5028
bool propagate_type(THD *thd, const Type_properties &type) override
Propagate data type specifications into parameters and user variables.
Definition: item.cc:4163
void set_double(double i)
Definition: item.cc:4297
void mark_json_as_scalar() override
For Items with data type JSON, mark that a string argument is treated as a scalar JSON value.
Definition: item.h:4988
bool set_longdata(const char *str, ulong length)
Definition: item.cc:4442
void copy_param_actual_type(Item_param *from)
Definition: item.cc:4859
Item_param(const POS &pos, MEM_ROOT *root, uint pos_in_query_arg)
Definition: item.cc:4038
table_map used_tables() const override
Definition: item.h:5227
void set_data_type_actual(enum_field_types data_type)
Definition: item.h:5187
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.cc:4618
Item super
Definition: item.h:4962
Definition: item.h:5891
Item_partition_func_safe_string(const Name_string name, size_t length, const CHARSET_INFO *cs=nullptr)
Definition: item.h:5893
Definition: item.h:6488
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.cc:5544
Item_ref_null_helper(const Item_ref_null_helper &ref_null_helper, Item **item)
Definition: item.h:6498
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.cc:5556
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:5526
bool val_bool() override
Definition: item.cc:5532
String * val_str(String *s) override
Definition: item.cc:5538
Item_in_subselect * owner
Definition: item.h:6492
Item_ref_null_helper(Name_resolution_context *context_arg, Item_in_subselect *master, Item **item)
Definition: item.h:6495
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item.cc:5520
longlong val_int() override
Definition: item.cc:5514
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:9230
Item_ref super
Definition: item.h:6489
double val_real() override
Definition: item.cc:5508
Ref_Type ref_type() const override
Definition: item.h:6512
table_map used_tables() const override
Definition: item.h:6516
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.cc:5550
Definition: item.h:6096
Item * compile(Item_analyzer analyzer, uchar **arg_p, Item_transformer transformer, uchar *arg_t) override
Compile an Item_ref object with a processor and a transformer callback function.
Definition: item.cc:9051
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item.h:6195
bool created_by_in2exists() const override
Whether this Item was created by the IN->EXISTS subquery transformation.
Definition: item.h:6300
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item.cc:9141
bool collect_item_field_or_ref_processor(uchar *arg) override
Definition: item.cc:9241
bool is_result_field() const override
Definition: item.h:6216
void set_properties()
Definition: item.cc:8985
table_map used_tables() const override
Definition: item.h:6187
Item_field * field_for_view_update() override
Definition: item.h:6260
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.cc:9148
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item.h:6155
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.cc:9175
Item_ref(THD *thd, Item_ref *item)
Definition: item.h:6141
Item ** addr(uint i) override
Definition: item.h:6274
void traverse_cond(Cond_traverser traverser, void *arg, traverse_order order) override
Definition: item.h:6239
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.cc:9199
bool clean_up_after_removal(uchar *arg) override
Clean up after removing the item from the item tree.
Definition: item.cc:8660
bool fix_fields(THD *, Item **) override
Resolve the name of a reference to a column reference.
Definition: item.cc:8743
bool check_function_as_value_generator(uchar *args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item.h:6306
bool is_valid_for_pushdown(uchar *arg) override
Check if all the columns present in this expression are from the derived table.
Definition: item.h:6315
Item_result result_type() const override
Definition: item.h:6178
void make_field(Send_field *field) override
Definition: item.cc:9183
void bring_value() override
Definition: item.h:6287
uint cols() const override
Definition: item.h:6266
Item ** ref_pointer() const
Definition: item.h:6150
bool val_json(Json_wrapper *result) override
Get a JSON value from an Item.
Definition: item.cc:9134
bool val_bool() override
Definition: item.cc:9120
bool is_outer_field() const override
Definition: item.h:6294
bool null_inside() override
Definition: item.h:6283
void set_result_field(Field *field) override
Definition: item.h:6215
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:9068
Item * real_item() override
Definition: item.h:6218
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item.cc:9112
Field * get_tmp_table_field() override
If this Item is being materialized into a temporary table, returns the field that is being materializ...
Definition: item.h:6182
Item_result cast_to_int_type() const override
Definition: item.h:6312
Ref_Type
Definition: item.h:6103
@ NULL_HELPER_REF
Definition: item.h:6103
@ VIEW_REF
Definition: item.h:6103
@ REF
Definition: item.h:6103
@ AGGREGATE_REF
Definition: item.h:6103
@ OUTER_REF
Definition: item.h:6103
String * val_str(String *tmp) override
Definition: item.cc:9127
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:9083
Field * result_field
Definition: item.h:6109
bool explain_subquery_checker(uchar **) override
Definition: item.h:6246
void link_referenced_item()
Definition: item.h:6152
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.h:6318
bool is_non_const_over_literals(uchar *) override
Definition: item.h:6305
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item.cc:9005
const Item * real_item() const override
Definition: item.h:6223
Item_ref(const POS &pos, const char *db_name_arg, const char *table_name_arg, const char *field_name_arg)
Definition: item.h:6116
Field * get_result_field() const override
Definition: item.h:6217
TYPELIB * get_typelib() const override
Get the typelib information for an item of type set or enum.
Definition: item.h:6180
bool walk(Item_processor processor, enum_walk walk, uchar *arg) override
Traverses a tree of Items in prefix and/or postfix order.
Definition: item.h:6229
enum Type type() const override
Definition: item.h:6154
bool send(Protocol *prot, String *tmp) override
This is only called from items that is not of type item_field.
Definition: item.cc:9094
bool pusheddown_depended_from
Definition: item.h:6106
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.h:6321
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.cc:9438
virtual Ref_Type ref_type() const
Definition: item.h:6263
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.cc:9155
bool basic_const_item() const override
Returns true if this is a simple constant item like an integer, not a constant expression.
Definition: item.h:6292
Item * transform(Item_transformer, uchar *arg) override
Transform an Item_ref object with a transformer callback function.
Definition: item.cc:9021
bool repoint_const_outer_ref(uchar *arg) override
The aim here is to find a real_item() which is of type Item_field.
Definition: item.cc:11850
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.h:6205
Item * element_index(uint i) override
Definition: item.h:6270
bool check_cols(uint c) override
Definition: item.h:6278
Item ** m_ref_item
Indirect pointer to the referenced item.
Definition: item.h:6113
longlong val_int() override
Definition: item.cc:9105
Item * ref_item() const
Definition: item.h:6147
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:9169
double val_real() override
Definition: item.cc:9098
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.cc:9162
Item with result field.
Definition: item.h:6031
Item_result_field(const POS &pos)
Definition: item.h:6036
Field * tmp_table_field(TABLE *) override
Definition: item.h:6042
Field * result_field
Definition: item.h:6033
int raise_decimal_overflow()
Definition: item.h:6090
longlong raise_integer_overflow()
Definition: item.h:6085
Field * get_tmp_table_field() override
If this Item is being materialized into a temporary table, returns the field that is being materializ...
Definition: item.h:6041
Item_result_field(THD *thd, const Item_result_field *item)
Definition: item.h:6039
virtual bool resolve_type(THD *thd)=0
Resolve type-related information for this item, such as result field type, maximum size,...
longlong llrint_with_overflow_check(double realval)
Definition: item.h:6070
bool mark_field_in_map(uchar *arg) override
Mark underlying field in read or write map of a table.
Definition: item.h:6062
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.h:6061
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item.cc:11689
void raise_numeric_overflow(const char *type_name)
Definition: item.cc:11695
Item_result_field()=default
double raise_float_overflow()
Definition: item.h:6080
bool is_result_field() const override
Definition: item.h:6057
table_map used_tables() const override
Definition: item.h:6043
void set_result_field(Field *field) override
Definition: item.h:6056
Field * get_result_field() const override
Definition: item.h:6058
Definition: item.h:5934
Item_return_int(const char *name_arg, uint length, enum_field_types field_type_arg, longlong value_arg=0)
Definition: item.h:5936
Class that represents scalar subquery and row subquery.
Definition: item_subselect.h:283
Definition: item.h:4021
bool is_valid_for_pushdown(uchar *arg) override
Check if all the columns present in this expression are from the derived table.
Definition: item.h:4057
Item_sp_variable(const Name_string sp_var_name)
Definition: item.cc:1935
Name_string m_name
Definition: item.h:4023
bool val_json(Json_wrapper *result) override
Get a JSON value from an Item.
Definition: item.cc:2018
String * val_str(String *sp) override
Definition: item.cc:1977
bool fix_fields(THD *thd, Item **) override
Definition: item.cc:1938
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.cc:2026
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item.cc:2010
void make_field(Send_field *field) override
Definition: item.h:4071
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.cc:2032
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.h:4077
double val_real() override
Definition: item.cc:1961
longlong val_int() override
Definition: item.cc:1969
table_map used_tables() const override
Definition: item.h:4037
bool send(Protocol *protocol, String *str) override
This is only called from items that is not of type item_field.
Definition: item.h:4052
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.cc:2038
sp_head * m_sp
Definition: item.h:4031
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item.cc:2044
Definition: item.h:4088
bool limit_clause_param
Definition: item.h:4098
Item_result result_type() const override
Definition: item.h:4138
bool set_value(THD *thd, sp_rcontext *ctx, Item **it) override
Definition: item.cc:2105
uint len_in_query
Definition: item.h:4117
bool is_splocal() const override
Definition: item.h:4123
uint get_var_idx() const
Definition: item.h:4135
bool val_json(Json_wrapper *result) override
Get a JSON value from an Item.
Definition: item.cc:2081
uint m_var_idx
Definition: item.h:4089
Settable_routine_parameter * get_settable_routine_parameter() override
Definition: item.h:4147
uint pos_in_query
Definition: item.h:4109
Item * this_item() override
Definition: item.cc:2063
Item_splocal(const Name_string sp_var_name, uint sp_var_idx, enum_field_types sp_var_type, uint pos_in_q=0, uint len_in_q=0)
Definition: item.cc:2050
Type type() const override
Definition: item.h:4137
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:2100
Item ** this_item_addr(THD *thd, Item **) override
Definition: item.cc:2075
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:2088
Definition: item.h:5861
void print(const THD *, String *str, enum_query_type) const override
Definition: item.h:5877
Item_static_string_func(const Name_string &name_par, const char *str, size_t length, const CHARSET_INFO *cs, Derivation dv=DERIVATION_COERCIBLE)
Definition: item.h:5865
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item.h:5881
bool check_function_as_value_generator(uchar *args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item.h:5882
const Name_string func_name
Definition: item.h:5862
Item_static_string_func(const POS &pos, const Name_string &name_par, const char *str, size_t length, const CHARSET_INFO *cs, Derivation dv=DERIVATION_COERCIBLE)
Definition: item.h:5870
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:4000
Definition: item.h:5657
Item_string(const POS &pos, const char *str, size_t length, const CHARSET_INFO *cs, Derivation dv=DERIVATION_COERCIBLE, uint repertoire=MY_REPERTOIRE_UNICODE30)
Definition: item.h:5699
String * val_str(String *) override
Definition: item.h:5783
Item_string(const char *str, size_t length, const CHARSET_INFO *cs, Derivation dv=DERIVATION_COERCIBLE, uint repertoire=MY_REPERTOIRE_UNICODE30)
Definition: item.h:5693
void set_cs_specified(bool cs_specified)
Set the value of m_cs_specified attribute.
Definition: item.h:5845
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item.cc:1595
bool is_cs_specified() const
Return true if character-set-introducer was explicitly specified in the original query for this item ...
Definition: item.h:5833
Item_string(const CHARSET_INFO *cs, Derivation dv=DERIVATION_COERCIBLE)
Definition: item.h:5707
Item_string(const POS &pos)
Definition: item.h:5661
void append(char *str, size_t length)
Definition: item.h:5804
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.h:5792
void init(const char *str, size_t length, const CHARSET_INFO *cs, Derivation dv, uint repertoire)
Definition: item.h:5665
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item.h:5812
Item_string(const POS &pos, const Name_string name_par, const LEX_CSTRING &literal, const CHARSET_INFO *cs, Derivation dv=DERIVATION_COERCIBLE, uint repertoire=MY_REPERTOIRE_UNICODE30)
Definition: item.h:5746
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.h:5788
void mark_result_as_const()
Definition: item.h:5849
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.cc:7409
Item_result result_type() const override
Definition: item.h:5795
Item * clone_item() const override
Definition: item.h:5800
bool m_cs_specified
Definition: item.h:5852
void print(const THD *thd, String *str, enum_query_type query_type) const override
Definition: item.cc:3866
void set_value_collation()
Update collation of string value to be according to item's collation.
Definition: item.h:5774
Item_string(const Name_string name_par, const char *str, size_t length, const CHARSET_INFO *cs, Derivation dv=DERIVATION_COERCIBLE, uint repertoire=MY_REPERTOIRE_UNICODE30)
Definition: item.h:5717
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:3922
Item_basic_constant super
Definition: item.h:5658
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.h:5791
void set_str_with_copy(const char *str_arg, uint length_arg)
Definition: item.h:5766
double val_real() override
Definition: item.cc:3940
Item_string(const POS &pos, const Name_string name_par, const char *str, size_t length, const CHARSET_INFO *cs, Derivation dv=DERIVATION_COERCIBLE, uint repertoire=MY_REPERTOIRE_UNICODE30)
Definition: item.h:5730
void set_repertoire_from_value()
Definition: item.h:5776
longlong val_int() override
Definition: item.cc:3989
bool eq_binary(const Item_string *item) const
Definition: item.h:5797
enum Type type() const override
Definition: item.h:5780
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:3996
Base class that is common to all subqueries and subquery predicates.
Definition: item_subselect.h:80
Class Item_sum is the base class used for special expressions that SQL calls 'set functions'.
Definition: item_sum.h:399
Definition: item.h:6555
bool val_date(Date_val *, my_time_flags_t) override
Evaluate the item and return result as a date value.
Definition: item.h:6565
Item_temporal_with_ref(enum_field_types field_type_arg, uint8 decimals_arg, longlong i, Item *ref_arg, bool unsigned_arg)
Definition: item.h:6557
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:7519
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.h:6569
Definition: item.h:5434
type_conversion_status save_in_field_inner(Field *field, bool no_conversions) override
Store this item's int-value in a field.
Definition: item.cc:7465
Item_temporal(enum_field_types field_type_arg, const Name_string &name_arg, longlong i, uint length)
Definition: item.h:5446
bool val_date(Date_val *, my_time_flags_t) override
Evaluate the item and return result as a date value.
Definition: item.h:5461
Item * clone_item() const override
Definition: item.h:5457
Item_temporal(enum_field_types field_type_arg, longlong i)
Definition: item.h:5440
bool val_datetime(Datetime_val *, my_time_flags_t) override
Evaluate the item and return result as a datetime value.
Definition: item.h:5469
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item.h:5460
bool val_time(Time_val *) override
Evaluate the item and return result as a time value.
Definition: item.h:5465
Utility mixin class to be able to walk() only parts of item trees.
Definition: item.h:737
bool is_stopped(const Item *i)
Definition: item.h:754
const Item * stopped_at_item
Definition: item.h:775
void stop_at(const Item *i)
Stops walking children of this item.
Definition: item.h:745
Item_tree_walker(const Item_tree_walker &)=delete
Item_tree_walker()
Definition: item.h:739
Item_tree_walker & operator=(const Item_tree_walker &)=delete
~Item_tree_walker()
Definition: item.h:740
Represents NEW/OLD version of field of row which is changed/read in trigger.
Definition: item.h:6840
SQL_I_List< Item_trigger_field > * next_trig_field_list
Definition: item.h:6850
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:10069
void setup_field(Table_trigger_field_support *table_triggers, GRANT_INFO *table_grant_info)
Find index of Field object which will be appropriate for item representing field of row being changed...
Definition: item.cc:9953
uint field_idx
Definition: item.h:6852
GRANT_INFO * table_grants
Definition: item.h:6933
bool check_column_privileges(uchar *arg) override
Check privileges of base table column.
Definition: item.cc:10058
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.h:6889
Item_trigger_field(const POS &pos, enum_trigger_variable_type trigger_var_type_arg, const char *field_name_arg, Access_bitmask priv, const bool ro)
Definition: item.h:6867
bool set_value(THD *thd, sp_rcontext *ctx, Item **it) override
Definition: item.cc:9974
Item_trigger_field(Name_resolution_context *context_arg, enum_trigger_variable_type trigger_var_type_arg, const char *field_name_arg, Access_bitmask priv, const bool ro)
Definition: item.h:6856
bool set_value(THD *thd, Item **it)
Definition: item.h:6914
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item.cc:9965
Settable_routine_parameter * get_settable_routine_parameter() override
Definition: item.h:6910
Item_trigger_field * next_trg_field
Definition: item.h:6845
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item.cc:10076
Access_bitmask want_privilege
Definition: item.h:6932
enum Type type() const override
Definition: item.h:6879
Item * copy_or_same(THD *) override
Definition: item.h:6888
Table_trigger_field_support * triggers
Definition: item.h:6854
Field * get_tmp_table_field() override
If this Item is being materialized into a temporary table, returns the field that is being materializ...
Definition: item.h:6887
enum_trigger_variable_type trigger_var_type
Definition: item.h:6843
table_map used_tables() const override
Definition: item.h:6886
bool fix_fields(THD *, Item **) override
Resolve the name of a column reference.
Definition: item.cc:10001
bool read_only
Definition: item.h:6938
void bind_fields() override
Bind objects from the current execution context to field objects in item trees.
Definition: item.cc:10037
bool check_function_as_value_generator(uchar *args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item.h:6895
bool is_valid_for_pushdown(uchar *args) override
Check if all the columns present in this expression are from the derived table.
Definition: item.h:6902
void set_required_privilege(Access_bitmask privilege) override
Set required privileges for accessing the parameter.
Definition: item.h:6891
Item_type_holder stores an aggregation of name, type and type specification of UNIONS and derived tab...
Definition: item.h:7447
Item_aggregate_type super
Definition: item.h:7448
enum Type type() const override
Definition: item.h:7456
table_map used_tables() const override
Class is used in type aggregation only - this is needed to ensure that it is not attempted to be eval...
Definition: item.h:7462
Item_type_holder(THD *thd, Item *item)
Definition: item.h:7454
String * val_str(String *) override
Definition: item.cc:11556
longlong val_int() override
Definition: item.cc:11546
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.cc:11566
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.cc:11561
double val_real() override
Definition: item.cc:11541
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:11551
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.cc:11571
Definition: item.h:5475
uint decimal_precision() const override
Definition: item.h:5507
Item * clone_item() const override
Definition: item.h:5500
Item_num * neg() override
Definition: item.cc:7537
Item_uint(const Name_string &name_arg, longlong i, uint length)
Definition: item.h:5490
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item.cc:3694
Item_uint(const POS &pos, const char *str_arg, uint length)
Definition: item.h:5484
type_conversion_status save_in_field_inner(Field *field, bool no_conversions) override
Store this item's int-value in a field.
Definition: item.cc:7415
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item.cc:3703
double val_real() override
Definition: item.h:5494
String * val_str(String *) override
Definition: item.cc:3687
Item_uint(const char *str_arg, uint length)
Definition: item.h:5481
Item_uint(ulonglong i)
Definition: item.h:5489
Reference item that encapsulates both the type and the contained items of a single column of a VALUES...
Definition: item.h:7488
Item_values_column(THD *thd, Item *ref)
Definition: item.cc:11584
void set_value(Item *new_value)
Definition: item.h:7519
Item * m_value_ref
Definition: item.h:7492
table_map used_tables() const override
Definition: item.h:7520
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.cc:11663
Item_aggregate_type super
Definition: item.h:7489
longlong val_int() override
Definition: item.cc:11599
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.cc:11576
my_decimal * val_decimal(my_decimal *) override
Definition: item.cc:11606
bool is_null() override
Item_values_column is dualistic in nature: It represents both a set of values, and,...
Definition: item.cc:11648
bool eq(const Item *item) const override
Compare this item with another item for equality.
Definition: item.cc:11588
bool val_json(Json_wrapper *result) override
Get a JSON value from an Item.
Definition: item.cc:11622
enum Type type() const override
Definition: item.h:7518
String * val_str(String *tmp) override
Definition: item.cc:11631
void add_used_tables(Item *value)
Definition: item.cc:11685
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.cc:11677
double val_real() override
Definition: item.cc:11592
bool val_bool() override
Definition: item.cc:11614
table_map m_aggregated_used_tables
Definition: item.h:7499
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.cc:11670
Class for fields from derived tables and views.
Definition: item.h:6332
Ref_Type ref_type() const override
Definition: item.h:6369
Table_ref * first_inner_table
If this column belongs to a view that is an inner table of an outer join, then this field points to t...
Definition: item.h:6412
bool mark_field_in_map(uchar *arg) override
Mark underlying field in read or write map of a table.
Definition: item.h:6372
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item.cc:9537
Item_view_ref(Name_resolution_context *context_arg, Item **item, const char *db_name_arg, const char *alias_name_arg, const char *table_name_arg, const char *field_name_arg, Table_ref *tr)
Definition: item.h:6336
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item.cc:9497
bool collect_item_field_or_view_ref_processor(uchar *arg) override
Collects fields and view references that have the qualifying table in the specified query block.
Definition: item.cc:9556
bool has_null_row() const
Definition: item.h:6404
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.cc:9548
double val_real() override
Definition: item.cc:9473
bool send(Protocol *prot, String *tmp) override
This is only called from items that is not of type item_field.
Definition: item.cc:9543
bool fix_fields(THD *, Item **) override
Prepare referenced field then call usual Item_ref::fix_fields .
Definition: item.cc:9261
bool val_bool() override
Definition: item.cc:9521
Item * replace_item_view_ref(uchar *arg) override
Definition: item.cc:9578
longlong val_int() override
Definition: item.cc:9465
Item_ref super
Definition: item.h:6333
bool subst_argument_checker(uchar **) override
Definition: item.h:6362
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item.cc:9505
Table_ref * get_first_inner_table() const
Definition: item.h:6396
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item.cc:9529
table_map used_tables() const override
Return the set of tables this view column logically depends on.
Definition: item.cc:9309
String * val_str(String *str) override
Definition: item.cc:9489
bool check_column_privileges(uchar *arg) override
Check privileges of view column.
Definition: item.cc:1436
Item * replace_view_refs_with_clone(uchar *arg) override
Assuming this expression is part of a condition that would be pushed to a materialized derived table,...
Definition: item.cc:9612
my_decimal * val_decimal(my_decimal *dec) override
Definition: item.cc:9481
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item.cc:9513
bool eq(const Item *item) const override
Compare two view column references for equality.
Definition: item.cc:9454
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:935
void increment_ref_count()
Increment reference count.
Definition: item.h:3520
virtual double val_real()=0
uint32 max_char_length() const
Definition: item.h:3473
String * make_empty_result()
Sets the result value of the function an empty string, using the current character set.
Definition: item.h:946
virtual const CHARSET_INFO * compare_collation() const
Definition: item.h:2698
virtual 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)
Calculate the filter contribution that is relevant for table 'filter_for_table' for this item.
Definition: item.h:2159
virtual Field::geometry_type get_geometry_type() const
Definition: item.h:3456
String str_value
str_values's main purpose is to cache the value in save_in_field
Definition: item.h:3680
bool skip_itemize(Item **res)
Helper function to skip itemize() for grammar-allocated items.
Definition: item.h:1209
void set_nullable(bool nullable)
Definition: item.h:3792
bool get_datetime_from_numeric(Datetime_val *dt, my_time_flags_t flags)
Convert a numeric type to datetime.
Definition: item.cc:1717
virtual bool change_context_processor(uchar *)
Definition: item.h:2916
void set_data_type_date()
Set all type properties for Item of DATE type.
Definition: item.h:1702
void set_data_type_blob(enum_field_types type, uint32 max_l)
Set the Item to be of BLOB type.
Definition: item.h:1689
virtual bool check_column_in_group_by(uchar *arg)
Check if all the columns present in this expression are present in GROUP BY clause of the derived tab...
Definition: item.h:3230
DTCollation collation
Character set and collation properties assigned for this Item.
Definition: item.h:3687
ulonglong val_uint()
Definition: item.h:1947
bool has_subquery() const
Definition: item.h:3551
virtual bool subst_argument_checker(uchar **arg)
Definition: item.h:3157
CostOfItem cost() const
Definition: item.h:3462
bool contains_item(uchar *arg)
Definition: item.h:2839
my_decimal * val_decimal_from_datetime(my_decimal *decimal_value)
Definition: item.cc:429
void set_data_type_bool()
Definition: item.h:1530
longlong val_int_from_decimal()
Definition: item.cc:500
bool has_stored_program() const
Definition: item.h:3554
String * val_string_from_int(String *str)
Definition: item.cc:315
int error_int()
Get the value to return from val_int() in case of errors.
Definition: item.h:2246
bool get_time_from_datetime(Time_val *time)
Convert datetime to time.
Definition: item.cc:1810
virtual bool subq_opt_away_processor(uchar *)
Definition: item.h:3666
bool get_date_from_int(Date_val *date, my_time_flags_t flags)
Convert val_int() to date.
Definition: item.cc:1653
void set_data_type(enum_field_types data_type)
Set the data type of the current Item.
Definition: item.h:1519
bool error_date()
Get the value to return from val_date() in case of errors.
Definition: item.h:2270
virtual bool collect_item_field_or_view_ref_processor(uchar *)
Collects fields and view references that have the qualifying table in the specified query block.
Definition: item.h:2886
bool has_aggregation() const
Definition: item.h:3559
virtual bool find_field_processor(uchar *)
Is this an Item_field which references the given Field argument?
Definition: item.h:2922
longlong val_int_from_datetime()
Definition: item.cc:527
void set_data_type_string(ulonglong max_char_length_arg)
Set the Item to be variable length string.
Definition: item.h:1623
my_decimal * val_decimal_from_string(my_decimal *decimal_value)
Definition: item.cc:390
void aggregate_float_properties(enum_field_types type, Item **items, uint nitems)
Set max_length and decimals of function if function is floating point and result length/precision dep...
Definition: item.cc:8287
bool is_nullable() const
Definition: item.h:3791
void set_data_type_geometry()
Set the data type of the Item to be GEOMETRY.
Definition: item.h:1761
double error_real()
Get the value to return from val_real() in case of errors.
Definition: item.h:2258
virtual bool do_itemize(Parse_context *pc, Item **res)
The core function that does the actual itemization.
Definition: item.cc:807
void save_in_field_no_error_check(Field *field, bool no_conversions)
A slightly faster value of save_in_field() that returns no error value (you will need to check thd->i...
Definition: item.h:1432
virtual enum_field_types actual_data_type() const
Retrieve actual data type for an item.
Definition: item.h:1495
static const CHARSET_INFO * default_charset()
Definition: item.cc:1880
virtual bool split_sum_func(THD *, Ref_item_array, mem_root_deque< Item * > *)
Definition: item.h:2586
void init_make_field(Send_field *tmp_field, enum enum_field_types type)
Definition: item.cc:6857
virtual bool propagate_type(THD *thd, const Type_properties &type)
Propagate data type specifications into parameters and user variables.
Definition: item.h:1320
virtual Item * replace_func_call(uchar *)
Definition: item.h:3370
String * val_string_from_date(String *str)
Definition: item.cc:346
bool is_non_deterministic() const
Definition: item.h:2524
void set_subquery()
Set the "has subquery" property.
Definition: item.h:3544
void fix_char_length(uint32 max_char_length_arg)
Definition: item.h:3494
void operator=(Item &)=delete
virtual bool is_bool_func() const
Definition: item.h:2669
void mark_subqueries_optimized_away()
Definition: item.h:3602
String * null_return_str()
Gets the value to return from val_str() when returning a NULL value.
Definition: item.h:2305
double val_real_from_decimal()
Definition: item.cc:480
virtual bool disable_constant_propagation(uchar *)
Definition: item.h:3166
Item()
Item constructor for general use.
Definition: item.cc:163
bool has_grouping_set_dep() const
Definition: item.h:3577
uint8 m_data_type
Data type assigned to Item.
Definition: item.h:3771
bool get_time_from_decimal(Time_val *time)
Convert val_decimal() to time.
Definition: item.cc:1789
void set_data_type_float()
Set the data type of the Item to be single precision floating point.
Definition: item.h:1593
void reset_aggregation()
Reset the "has aggregation" property.
Definition: item.h:3565
virtual Item * this_item()
Definition: item.h:3268
void print_for_order(const THD *thd, String *str, enum_query_type query_type, const char *used_alias) const
Prints the item when it's part of ORDER BY and GROUP BY.
Definition: item.cc:914
bool is_temporal_with_date() const
Definition: item.h:3416
virtual bool strip_db_table_name_processor(uchar *)
Definition: item.h:3655
static Item_result type_to_result(enum_field_types type)
Definition: item.h:1048
virtual table_map used_tables() const
Definition: item.h:2424
String * val_string_from_datetime(String *str)
Definition: item.cc:333
virtual bool equality_substitution_analyzer(uchar **)
Definition: item.h:3105
virtual bool find_item_in_field_list_processor(uchar *)
Definition: item.h:2915
virtual longlong val_date_temporal_at_utc()
Definition: item.h:2400
bool get_datetime_from_non_temporal(Datetime_val *dt, my_time_flags_t flags)
Convert a non-temporal type to datetime.
Definition: item.cc:1738
virtual bool val_date(Date_val *date, my_time_flags_t flags)=0
Evaluate the item and return result as a date value.
virtual bool created_by_in2exists() const
Whether this Item was created by the IN->EXISTS subquery transformation.
Definition: item.h:3600
static enum_field_types string_field_type(uint32 max_bytes)
Determine correct string field type, based on string length.
Definition: item.h:1818
bool error_json()
Get the value to return from val_json() in case of errors.
Definition: item.h:2178
virtual void cleanup()
Called for every Item after use (preparation and execution).
Definition: item.h:1281
virtual Item * real_item()
Definition: item.h:2682
virtual Item * equality_substitution_transformer(uchar *)
Definition: item.h:3107
void set_stored_program()
Set the "has stored program" property.
Definition: item.h:3547
virtual bool eq(const Item *) const
Compare this item with another item for equality.
Definition: item.cc:1526
virtual bool supports_partial_update(const Field_json *field) const
Check if this expression can be used for partial update of a given JSON column.
Definition: item.h:3902
virtual enum_field_types default_data_type() const
Get the default data (output) type for the specific item.
Definition: item.h:1508
void set_data_type_string(uint32 max_l, const CHARSET_INFO *cs)
Set the Item to be variable length string.
Definition: item.h:1641
virtual bool explain_subquery_checker(uchar **)
Definition: item.h:3161
bool get_datetime_from_time(Datetime_val *dt)
Convert val_time() to datetime.
Definition: item.cc:1681
uint m_ref_count
Number of references to this item.
Definition: item.h:3768
virtual Field * make_string_field(TABLE *table) const
Create a field to hold a string value from an item.
Definition: item.cc:6979
virtual bool replace_equal_field_checker(uchar **)
Definition: item.h:3173
virtual my_decimal * val_decimal(my_decimal *decimal_buffer)=0
void add_accum_properties(const Item *item)
Add more accumulated properties to an Item.
Definition: item.h:3539
virtual bool check_valid_arguments_processor(uchar *)
Definition: item.h:3179
longlong val_int_from_date()
Definition: item.cc:520
virtual Settable_routine_parameter * get_settable_routine_parameter()
Definition: item.h:3413
virtual Item * equal_fields_propagator(uchar *)
Definition: item.h:3164
bool error_bool()
Get the value to return from val_bool() in case of errors.
Definition: item.h:2234
virtual type_conversion_status save_in_field_inner(Field *field, bool no_conversions)
Helper function which does all of the work for save_in_field(Field*, bool), except some error checkin...
Definition: item.cc:7277
virtual bool remove_column_from_bitmap(uchar *arg)
Visitor interface for removing all column expressions (Item_field) in this expression tree from a bit...
Definition: item.h:2912
virtual bool update_depended_from(uchar *)
Definition: item.h:3089
void set_data_type_double()
Set the data type of the Item to be double precision floating point.
Definition: item.h:1585
my_decimal * val_decimal_from_int(my_decimal *decimal_value)
Definition: item.cc:381
void set_data_type_year()
Set the data type of the Item to be YEAR.
Definition: item.h:1780
virtual uint decimal_precision() const
Definition: item.cc:827
Item_result cmp_context
Comparison context.
Definition: item.h:3750
virtual void allow_array_cast()
A helper function to ensure proper usage of CAST(.
Definition: item.h:3915
virtual Item * truth_transformer(THD *thd, Bool_test test)
Informs an item that it is wrapped in a truth test, in case it wants to transforms itself to implemen...
Definition: item.h:3295
bool get_time_from_date(Time_val *time)
Convert date to time.
Definition: item.cc:1802
Item(const Item &)=delete
type_conversion_status save_datetime_in_field(Field *field)
Definition: item.cc:569
virtual Item * replace_equal_field(uchar *)
Definition: item.h:3172
virtual Item * element_index(uint)
Definition: item.h:3279
virtual bool check_function_as_value_generator(uchar *args)
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item.cc:964
virtual void traverse_cond(Cond_traverser traverser, void *arg, traverse_order)
Definition: item.h:2820
bool get_time_from_numeric(Time_val *time)
Convert a numeric type to time.
Definition: item.cc:1819
uint float_length(uint decimals_par) const
Definition: item.h:2460
Field * tmp_table_field_from_field_type(TABLE *table, bool fixed_length) const
Create a field based on field_type of argument.
Definition: item.cc:7014
virtual Item * copy_andor_structure(THD *)
Definition: item.h:2676
virtual bool val_json(Json_wrapper *result)
Get a JSON value from an Item.
Definition: item.h:2131
virtual longlong val_int()=0
virtual Item_field * field_for_view_update()
Definition: item.h:3288
static constexpr uint8 PROP_GROUPING_FUNC
Set if the item or one or more of the underlying items is a GROUPING function.
Definition: item.h:3856
virtual void print(const THD *, String *str, enum_query_type) const
This method is used for to:
Definition: item.h:2548
enum_field_types data_type() const
Retrieve the derived data type of the Item.
Definition: item.h:1487
virtual bool collect_outer_field_processor(uchar *)
Definition: item.h:2844
static constexpr uint8 PROP_SUBQUERY
Set of properties that are calculated by accumulation from underlying items.
Definition: item.h:3843
Item_name_string item_name
Name from query.
Definition: item.h:3688
void set_data_type_int(enum_field_types type, bool unsigned_prop, uint32 max_width)
Set the data type of the Item to be a specific integer type.
Definition: item.h:1544
const Item * unwrap_for_eq() const
Unwrap an Item argument so that Item::eq() can see the "real" item, and not just the wrapper.
Definition: item.cc:1542
bool eq_by_collation(Item *item, const CHARSET_INFO *cs)
Compare two items using a given collation.
Definition: item.cc:6952
void print_item_w_name(const THD *thd, String *, enum_query_type query_type) const
Definition: item.cc:884
virtual String * val_str_ascii(String *str)
Definition: item.cc:275
virtual Item * get_tmp_table_item(THD *thd)
If an Item is materialized in a temporary table, a different Item may have to be used in the part of ...
Definition: item.h:2695
~Item() override=default
virtual bool fix_fields(THD *, Item **)
Definition: item.cc:5499
virtual bool check_column_privileges(uchar *thd)
Check privileges.
Definition: item.h:2981
bool fixed
True if item has been resolved.
Definition: item.h:3780
static bool bit_func_returns_binary(const Item *a, const Item *b)
Definition: item_func.cc:3442
enum_const_item_cache
How to cache constant JSON data.
Definition: item.h:1004
@ CACHE_NONE
Don't cache.
Definition: item.h:1006
@ CACHE_JSON_VALUE
Source data is a JSON string, parse and cache result.
Definition: item.h:1008
@ CACHE_JSON_ATOM
Source data is SQL scalar, convert and cache result.
Definition: item.h:1010
virtual Item_result result_type() const
Definition: item.h:1457
bool const_item() const
Returns true if item is constant, regardless of query evaluation state.
Definition: item.h:2485
longlong val_int_from_time()
Definition: item.cc:511
bool null_value
True if item is null.
Definition: item.h:3817
virtual Item * apply_masking_policy(THD *thd)
Apply column masking policy to this item if applicable.
Definition: item.h:3868
Type
Definition: item.h:970
@ SUBQUERY_ITEM
A subquery or predicate referencing a subquery.
Definition: item.h:987
@ ROW_ITEM
A row of other items.
Definition: item.h:988
@ INVALID_ITEM
Definition: item.h:971
@ JSON_ITEM
A JSON literal value.
Definition: item.h:980
@ INSERT_VALUE_ITEM
A value from a VALUES function (deprecated).
Definition: item.h:986
@ CACHE_ITEM
An internal item used to cache values.
Definition: item.h:989
@ REAL_ITEM
A floating-point literal value.
Definition: item.h:979
@ TRIGGER_FIELD_ITEM
An OLD or NEW field, used in trigger definitions.
Definition: item.h:993
@ SUM_FUNC_ITEM
A grouped aggregate function, or window function.
Definition: item.h:974
@ TYPE_HOLDER_ITEM
An internal item used to help aggregate a type.
Definition: item.h:990
@ NAME_CONST_ITEM
A NAME_CONST expression.
Definition: item.h:996
@ REF_ITEM
An indirect reference to another item.
Definition: item.h:985
@ FIELD_ITEM
A reference to a field (column) in a table.
Definition: item.h:972
@ INT_ITEM
An integer literal value.
Definition: item.h:977
@ FUNC_ITEM
A function call reference.
Definition: item.h:973
@ COND_ITEM
An AND or OR condition.
Definition: item.h:984
@ XPATH_NODESET_ITEM
Used in XPATH expressions.
Definition: item.h:994
@ PARAM_ITEM
A dynamic parameter used in a prepared statement.
Definition: item.h:991
@ ROUTINE_FIELD_ITEM
A variable inside a routine (proc, func, trigger)
Definition: item.h:992
@ DECIMAL_ITEM
A decimal literal value.
Definition: item.h:978
@ VALUES_COLUMN_ITEM
A value from a VALUES clause.
Definition: item.h:995
@ HEX_BIN_ITEM
A hexadecimal or binary literal value.
Definition: item.h:982
@ NULL_ITEM
A NULL value.
Definition: item.h:981
@ AGGR_FIELD_ITEM
A special field for certain aggregate operations.
Definition: item.h:975
@ DEFAULT_VALUE_ITEM
A default value for a column.
Definition: item.h:983
@ STRING_ITEM
A string literal value.
Definition: item.h:976
void set_data_type_bit(uint32 max_bits)
Set the data type of the Item to be bit.
Definition: item.h:1793
virtual bool collect_scalar_subqueries(uchar *)
Definition: item.h:3086
virtual Field * tmp_table_field(TABLE *)
Definition: item.h:2418
virtual uint64_t hash()
Generate hash unique to an item depending on its attributes.
Definition: item.h:2560
virtual bool check_cols(uint c)
Definition: item.cc:1462
virtual bool itemize(Parse_context *pc, Item **res) final
The same as contextualize() but with additional parameter.
Definition: item.h:1255
const bool is_parser_item
true if allocated directly by parser
Definition: item.h:3770
bool is_temporal_with_time() const
Definition: item.h:3422
bool get_datetime_from_string(Datetime_val *dt, my_time_flags_t flags)
Convert val_str() to datetime.
Definition: item.cc:1605
virtual bool visitor_processor(uchar *arg)
A processor to handle the select lex visitor framework.
Definition: item.cc:933
Parse_tree_node super
Definition: item.h:936
virtual Item * replace_item_view_ref(uchar *)
Definition: item.h:3371
bool cleanup_processor(uchar *)
cleanup() item if it is resolved ('fixed').
Definition: item.h:2835
void set_data_type_datetime(uint8 fsp)
Set all properties for Item of DATETIME type.
Definition: item.h:1727
virtual void set_masking_expression_for(const Item_field *masked_item)
Mark this expression as a masking expression for some other expression.
Definition: item.h:3883
virtual Item * replace_with_derived_expr_ref(uchar *arg)
Assuming this expression is part of a condition that would be pushed to the HAVING clause of a materi...
Definition: item.h:3251
virtual const CHARSET_INFO * charset_for_protocol()
Definition: item.h:2704
void set_aggregation()
Set the "has aggregation" property.
Definition: item.h:3562
virtual uint time_precision()
TIME precision of the item: 0..6.
Definition: item.cc:852
void delete_self()
Delete this item.
Definition: item.h:3404
bool m_in_check_constraint_exec_ctx
True if item is a top most element in the expression being evaluated for a check constraint.
Definition: item.h:3833
virtual uint datetime_precision()
DATETIME precision of the item: 0..6.
Definition: item.cc:867
virtual bool send(Protocol *protocol, String *str)
This is only called from items that is not of type item_field.
Definition: item.cc:7969
bool has_compatible_context(Item *item) const
Check whether this and the given item has compatible comparison context.
Definition: item.h:3437
virtual Item * replace_view_refs_with_clone(uchar *arg)
Assuming this expression is part of a condition that would be pushed to a materialized derived table,...
Definition: item.h:3261
virtual void pin_data_type()
Pin the data type for the item.
Definition: item.h:1484
virtual bool cache_const_expr_analyzer(uchar **cache_item)
Check if an item is a constant one and can be cached.
Definition: item.cc:8157
bool get_datetime_from_int(Datetime_val *dt, my_time_flags_t flags)
Convert val_int() to datetime.
Definition: item.cc:1647
virtual void apply_is_true()
Apply the IS TRUE truth property, meaning that an UNKNOWN result and a FALSE result are treated the s...
Definition: item.h:2660
Item * next_free
Intrusive list pointer for free list.
Definition: item.h:3676
virtual bool collect_item_field_or_ref_processor(uchar *)
Definition: item.h:2843
virtual bool val_bool()
Definition: item.cc:247
String * error_str()
Get the value to return from val_str() in case of error or NULL value.
Definition: item.h:2295
static enum_field_types type_for_variable(enum_field_types src_type)
Provide data type for a user or system variable, based on the type of the item that is assigned to th...
Definition: item.h:1107
uint8 m_accum_properties
Definition: item.h:3858
type_conversion_status save_str_value_in_field(Field *field, String *result)
Definition: item.cc:598
virtual bool check_column_in_window_functions(uchar *arg)
Check if all the columns present in this expression are present in PARTITION clause of window functio...
Definition: item.h:3222
void set_data_type_vector(uint32 max_l)
Set the data type of the Item to be VECTOR.
Definition: item.h:1751
virtual Item * update_value_transformer(uchar *)
Definition: item.h:3299
virtual Item * replace_outer_ref(uchar *)
Definition: item.h:3373
virtual bool reset_wf_state(uchar *arg)
Reset execution state for such window function types as determined by arg.
Definition: item.h:2957
void set_accum_properties(const Item *item)
Set accumulated properties for an Item.
Definition: item.h:3534
virtual bool repoint_const_outer_ref(uchar *arg)
This function applies only to Item_field objects referred to by an Item_ref object that has been mark...
Definition: item.h:3652
virtual bool cast_incompatible_args(uchar *)
Wrap incompatible arguments in CAST nodes to the expected data types.
Definition: item.h:2924
bool get_datetime_from_real(Datetime_val *dt, my_time_flags_t flags)
Convert val_real() to datetime.
Definition: item.cc:1627
virtual longlong val_date_temporal()
Return date value of item in packed longlong format.
Definition: item.cc:437
bool visit_all_analyzer(uchar **)
Definition: item.h:3101
virtual table_map not_null_tables() const
Return table map of tables that can't be NULL tables (tables that are used in a context where if they...
Definition: item.h:2437
virtual Item_result numeric_context_result_type() const
Result type when an item appear in a numeric context.
Definition: item.h:1462
my_decimal * val_decimal_from_date(my_decimal *decimal_value)
Definition: item.cc:410
longlong val_temporal_with_round(enum_field_types type, uint8 dec)
Get date or time value in packed longlong format.
Definition: item.cc:449
virtual void compute_cost(CostOfItem *root_cost) const
Compute the cost of evaluating this Item.
Definition: item.h:3661
bool can_be_substituted_for_gc(bool array=false) const
Check if this item is of a type that is eligible for GC substitution.
Definition: item.cc:8237
virtual Item * compile(Item_analyzer analyzer, uchar **arg_p, Item_transformer transformer, uchar *arg_t)
Perform a generic "compilation" of the Item tree, ie transform the Item tree by adding zero or more I...
Definition: item.h:2814
type_conversion_status save_in_field_no_warnings(Field *field, bool no_conversions)
Save the item into a field but do not emit any warnings.
Definition: item.cc:1892
bool error_time()
Get the value to return from val_time() in case of errors.
Definition: item.h:2282
virtual TYPELIB * get_typelib() const
Get the typelib information for an item of type set or enum.
Definition: item.h:1828
bool has_wf() const
Definition: item.h:3568
my_decimal * val_decimal_from_real(my_decimal *decimal_value)
Definition: item.cc:371
virtual bool collect_subqueries(uchar *)
Definition: item.h:3088
void aggregate_bit_properties(Item **items, uint nitems)
Set data type and properties of a BIT column.
Definition: item.cc:8455
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:3585
virtual void fix_after_pullout(Query_block *parent_query_block, Query_block *removed_query_block)
Fix after tables have been moved from one query_block level to the parent level, e....
Definition: item.h:1300
void set_data_type_char(uint32 max_l)
Set the Item to be fixed length string.
Definition: item.h:1664
bool get_date_from_real(Date_val *date, my_time_flags_t flags)
Convert val_real() to date.
Definition: item.cc:1621
virtual bool null_inside()
Definition: item.h:3283
bool get_time_from_int(Time_val *time)
Convert val_int() to time.
Definition: item.cc:1796
void set_data_type_json()
Set the data type of the Item to be JSON.
Definition: item.h:1770
bool unsigned_flag
Definition: item.h:3818
virtual bool aggregate_check_group(uchar *)
Definition: item.h:3032
bool propagate_type(THD *thd, enum_field_types def=MYSQL_TYPE_VARCHAR, bool pin=false, bool inherit=false)
Wrapper for easier calling of propagate_type(const Type_properties &).
Definition: item.h:1334
bool is_blob_field() const
Check if an item either is a blob field, or will be represented as a BLOB field if a field is created...
Definition: item.cc:1920
bool is_outer_reference() const
Definition: item.h:2531
bool get_date_from_string(Date_val *date, my_time_flags_t flags)
Convert val_str() to date.
Definition: item.cc:1613
virtual bool is_null()
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item.h:2641
bool const_for_execution() const
Returns true if item is constant during one query execution.
Definition: item.h:2497
void aggregate_temporal_properties(enum_field_types type, Item **items, uint nitems)
Set data type and fractional seconds precision for temporal functions.
Definition: item.cc:8341
longlong val_int_from_string()
Definition: item.cc:541
item_marker
< Values for member 'marker'
Definition: item.h:3707
@ MARKER_FUNC_DEP_NOT_NULL
When analyzing functional dependencies for only_full_group_by (says whether a nullable column can be ...
Definition: item.h:3721
@ MARKER_GROUP_BY_BIT
When creating an internal temporary table: marking group by fields.
Definition: item.h:3718
@ MARKER_TRAVERSAL
Used during traversal to avoid deleting an item twice.
Definition: item.h:3729
@ MARKER_DISTINCT_GROUP
When we change DISTINCT to GROUP BY: used for book-keeping of fields.
Definition: item.h:3724
@ MARKER_IMPLICIT_NE_ZERO
When contextualization or itemization adds an implicit comparison '0<>' (see make_condition()),...
Definition: item.h:3712
@ MARKER_NONE
Definition: item.h:3708
@ MARKER_COND_DERIVED_TABLE
When pushing conditions down to derived table: it says a condition contains only derived table's colu...
Definition: item.h:3727
@ MARKER_CONST_PROPAG
When doing constant propagation (e.g.
Definition: item.h:3715
@ MARKER_ICP_COND_USES_INDEX_ONLY
When pushing index conditions: it says whether a condition uses only indexed columns.
Definition: item.h:3732
virtual bool is_valid_for_pushdown(uchar *arg)
Check if all the columns present in this expression are from the derived table.
Definition: item.h:3211
virtual Item * copy_or_same(THD *)
Definition: item.h:2675
Item_name_string orig_name
Original item name (if it was renamed)
Definition: item.h:3689
virtual bool collect_grouped_aggregates(uchar *)
Definition: item.h:3087
virtual bool clean_up_after_removal(uchar *arg)
Clean up after removing the item from the item tree.
Definition: item.cc:8224
virtual cond_result eq_cmp_result() const
Definition: item.h:2459
bool get_time_from_non_temporal(Time_val *time)
Convert a non-temporal type to time.
Definition: item.cc:1842
uint32 max_char_length(const CHARSET_INFO *cs) const
Definition: item.h:3487
virtual Item * explain_subquery_propagator(uchar *)
Definition: item.h:3162
virtual void update_used_tables()
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item.h:2584
virtual bool aggregate_check_distinct(uchar *)
Definition: item.h:3030
bool evaluate(THD *thd, String *str)
Evaluate scalar item, possibly using the supplied buffer.
Definition: item.cc:8077
void set_wf()
Set the "has window function" property.
Definition: item.h:3571
virtual bool returns_array() const
Whether the item returns array of its data type.
Definition: item.h:3910
virtual void make_field(Send_field *field)
Definition: item.cc:6878
virtual Field * get_tmp_table_field()
If this Item is being materialized into a temporary table, returns the field that is being materializ...
Definition: item.h:2413
virtual bool is_outer_field() const
Definition: item.h:3502
void set_grouping_func()
Set the property: this item is a call to GROUPING.
Definition: item.h:3597
virtual void set_result_field(Field *)
Definition: item.h:2666
bool is_abandoned() const
Definition: item.h:3663
cond_result
Definition: item.h:999
@ COND_UNDEF
Definition: item.h:999
@ COND_TRUE
Definition: item.h:999
@ COND_FALSE
Definition: item.h:999
@ COND_OK
Definition: item.h:999
virtual bool walk(Item_processor processor, enum_walk walk, uchar *arg)
Traverses a tree of Items in prefix and/or postfix order.
Definition: item.h:2730
type_conversion_status save_time_in_field(Field *field)
Definition: item.cc:551
item_marker marker
This member has several successive meanings, depending on the phase we're in (.
Definition: item.h:3749
Item_result temporal_with_date_as_number_result_type() const
Similar to result_type() but makes DATE, DATETIME, TIMESTAMP pretend to be numbers rather than string...
Definition: item.h:1469
traverse_order
Definition: item.h:1001
@ POSTFIX
Definition: item.h:1001
@ PREFIX
Definition: item.h:1001
virtual bool is_strong_side_column_not_in_fd(uchar *)
Definition: item.h:3034
virtual bool intro_version(uchar *)
Definition: item.h:2832
bool m_abandoned
true if item has been fully de-referenced
Definition: item.h:3769
virtual bool inform_item_in_cond_of_tab(uchar *)
Definition: item.h:2984
bool get_datetime_from_date(Datetime_val *dt, my_time_flags_t flags)
Convert val_date() to datetime.
Definition: item.cc:1691
static constexpr uint8 PROP_STORED_PROGRAM
Definition: item.h:3844
virtual const Item * real_item() const
Definition: item.h:2683
bool is_temporal() const
Definition: item.h:3425
bool is_temporal_with_date_and_time() const
Definition: item.h:3419
virtual const char * full_name() const
Definition: item.h:2419
auto walk_helper_thunk(uchar *arg)
Definition: item.h:2738
void set_data_type_null()
Definition: item.h:1523
uint8 decimals
Number of decimals in result when evaluating this item.
Definition: item.h:3789
virtual bool val_datetime(Datetime_val *dt, my_time_flags_t flags)=0
Evaluate the item and return result as a datetime value.
virtual Item ** addr(uint)
Definition: item.h:3280
virtual Item * clone_item() const
Definition: item.h:2458
void set_data_type_string(uint32 max_l)
Set the Item to be variable length string.
Definition: item.h:1606
virtual void set_can_use_prefix_key()
Definition: item.h:1309
void set_data_type_timestamp(uint8 fsp)
Set all properties for Item of TIMESTAMP type.
Definition: item.h:1740
bool do_contextualize(Parse_context *) override
Definition: item.h:1195
void set_data_type_string(uint32 max_l, const DTCollation &coll)
Set the Item to be variable length string.
Definition: item.h:1653
virtual std::optional< ContainedSubquery > get_contained_subquery(const Query_block *outer_query_block)
If this item represents a IN/ALL/ANY/comparison_operator subquery, return that (along with data on ho...
Definition: item.h:1372
uint decrement_ref_count()
Decrement reference count.
Definition: item.h:3526
Item * convert_charset(THD *thd, const CHARSET_INFO *tocs, bool ignore_errors=false)
Convert constant string in this object into the specified character set.
Definition: item.cc:1560
virtual bool find_item_processor(uchar *arg)
Definition: item.h:2917
virtual void no_rows_in_result()
Definition: item.h:2674
virtual bool add_field_to_set_processor(uchar *)
Item::walk function.
Definition: item.h:2894
virtual bool add_field_to_cond_set_processor(uchar *)
Item::walk function.
Definition: item.h:2903
virtual Item * replace_with_derived_expr(uchar *arg)
Assuming this expression is part of a condition that would be pushed to the WHERE clause of a materia...
Definition: item.h:3240
uint reference_count() const
Definition: item.h:3517
bool get_time_from_real(Time_val *time)
Convert val_real() to time.
Definition: item.cc:1783
static enum_field_types result_to_type(Item_result result)
Definition: item.h:1028
virtual Item * replace_scalar_subquery(uchar *)
When walking the item tree seeing an Item_singlerow_subselect matching a target, replace it with a su...
Definition: item.h:3361
type_conversion_status save_in_field(Field *field, bool no_conversions)
Save a temporal value in packed longlong format into a Field.
Definition: item.cc:7245
virtual bool check_gcol_depend_default_processor(uchar *args)
Check if a generated expression depends on DEFAULT function with specific column name as argument.
Definition: item.h:3202
virtual bool is_splocal() const
Definition: item.h:3407
virtual bool val_time(Time_val *time)=0
Evaluate the item and return result as a time value.
Bool_test
< Modifier for result transformation
Definition: item.h:1014
@ BOOL_NOT_FALSE
Definition: item.h:1019
@ BOOL_IS_UNKNOWN
Definition: item.h:1017
@ BOOL_NOT_TRUE
Definition: item.h:1018
@ BOOL_IS_TRUE
Definition: item.h:1015
@ BOOL_ALWAYS_FALSE
Definition: item.h:1024
@ BOOL_NOT_UNKNOWN
Definition: item.h:1020
@ BOOL_ALWAYS_TRUE
Definition: item.h:1023
@ BOOL_IS_FALSE
Definition: item.h:1016
@ BOOL_IDENTITY
Definition: item.h:1021
@ BOOL_NEGATED
Definition: item.h:1022
String * check_well_formed_result(String *str, bool send_error, bool truncate)
Verifies that the input string is well-formed according to its character set.
Definition: item.cc:6901
virtual bool replace_field_processor(uchar *)
A processor that replaces any Fields with a Create_field_wrapper.
Definition: item.h:3622
virtual bool update_aggr_refs(uchar *)
A walker processor overridden by Item_aggregate_ref, q.v.
Definition: item.h:3385
virtual void disable_masking_policy()
Disable application of the masking policy to this item.
Definition: item.h:3877
bool get_date_from_time(Date_val *date)
Convert val_time() to date.
Definition: item.cc:1659
virtual void notify_removal()
Called when an item has been removed, can be used to notify external objects about the removal,...
Definition: item.h:1287
bool may_evaluate_const(const THD *thd) const
Return true if this is a const item that may be evaluated in the current phase of statement processin...
Definition: item.cc:1454
bool aggregate_type(const char *name, Item **items, uint count)
Aggregates data types from array of items into current item.
Definition: item.cc:639
virtual Item * replace_aggregate(uchar *)
Definition: item.h:3372
virtual String * val_str(String *str)=0
bool m_nullable
True if this item may hold the NULL value(if null_value may be set to true).
Definition: item.h:3814
virtual Item * replace_item_field(uchar *)
Transform processor used by Query_block::transform_grouped_to_derived to replace fields which used to...
Definition: item.h:3369
virtual bool mark_field_in_map(uchar *arg)
Mark underlying field in read or write map of a table.
Definition: item.h:2930
virtual bool basic_const_item() const
Returns true if this is a simple constant item like an integer, not a constant expression.
Definition: item.h:2446
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:3828
virtual bool get_timeval(my_timeval *tm, int *warnings)
Get timestamp in "struct timeval" format.
Definition: item.cc:1865
bool m_is_window_function
True if item represents window func.
Definition: item.h:3819
bool may_eval_const_item(const THD *thd) const
Definition: item.cc:238
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:1805
bool get_datetime_from_decimal(Datetime_val *dt, my_time_flags_t flags)
Convert val_decimal() to datetime.
Definition: item.cc:1640
static bool mark_field_in_map(Mark_field *mark_field, Field *field)
Helper function for mark_field_in_map(uchar *arg).
Definition: item.h:2939
bool get_date_from_datetime(Date_val *date, my_time_flags_t flags)
Convert val_datetime() to date.
Definition: item.cc:1669
Item * cache_const_expr_transformer(uchar *item)
Cache item if needed.
Definition: item.cc:8472
String * val_string_from_time(String *str)
Definition: item.cc:360
virtual Item ** this_item_addr(THD *, Item **addr_arg)
Definition: item.h:3275
virtual bool is_result_field() const
Definition: item.h:2667
virtual const Item * this_item() const
Definition: item.h:3269
void aggregate_decimal_properties(Item **items, uint nitems)
Set data type, precision and scale of item of type decimal from list of items.
Definition: item.cc:8321
virtual Item * transform(Item_transformer transformer, uchar *arg)
Perform a generic transformation of the Item tree, by adding zero or more additional Item objects to ...
Definition: item.cc:953
virtual enum_monotonicity_info get_monotonicity_info() const
Definition: item.h:1840
virtual bool collect_item_field_processor(uchar *)
Definition: item.h:2842
virtual bool has_aggregate_ref_in_group_by(uchar *)
Check if an aggregate is referenced from within the GROUP BY clause of the query block in which it is...
Definition: item.h:3099
uint32 max_length
Maximum length of result of evaluating this item, in number of bytes.
Definition: item.h:3705
bool get_date_from_numeric(Date_val *date, my_time_flags_t flags)
Convert a numeric type to date.
Definition: item.cc:1701
bool get_date_from_decimal(Date_val *date, my_time_flags_t flags)
Convert val_decimal() to date.
Definition: item.cc:1633
void set_data_type_longlong()
Set the data type of the Item to be longlong.
Definition: item.h:1561
static constexpr uint8 PROP_WINDOW_FUNCTION
Definition: item.h:3846
auto analyze_helper_thunk(uchar **arg)
See CompileItem.
Definition: item.h:2744
double val_real_from_string()
Definition: item.cc:491
bool update_null_value()
Make sure the null_value member has a correct value.
Definition: item.cc:8058
virtual bool gc_subst_analyzer(uchar **)
Analyzer function for GC substitution.
Definition: item.h:3610
void rename(char *new_name)
rename item (used for views, cleanup() return original name).
Definition: item.cc:944
bool aggregate_string_properties(enum_field_types type, const char *name, Item **items, uint nitems)
Aggregate string properties (character set, collation and maximum length) for string function.
Definition: item.cc:8397
virtual bool is_column_not_in_fd(uchar *)
Definition: item.h:3036
virtual longlong val_int_endpoint(bool left_endp, bool *incl_endp)
Definition: item.h:1878
virtual enum Type type() const =0
virtual uint cols() const
Definition: item.h:3278
virtual Item * gc_subst_transformer(uchar *)
Transformer function for GC substitution.
Definition: item.h:3614
virtual Bool3 local_column(const Query_block *) const
Definition: item.h:3037
virtual void bring_value()
Definition: item.h:3285
void set_data_type_time(uint8 fsp)
Set all type properties for Item of TIME type.
Definition: item.h:1714
void set_data_type_decimal(uint8 precision, uint8 scale)
Set the data type of the Item to be decimal.
Definition: item.h:1575
CostOfItem m_cost
The cost of evaluating this item.
Definition: item.h:3777
void quick_fix_field()
Definition: item.h:1308
virtual bool used_tables_for_level(uchar *arg)
Return used table information for the specified query block (level).
Definition: item.h:2973
my_decimal * val_decimal_from_time(my_decimal *decimal_value)
Definition: item.cc:421
virtual Item_result cast_to_int_type() const
Definition: item.h:1830
type_conversion_status save_date_in_field(Field *field)
Definition: item.cc:560
bool split_sum_func2(THD *thd, Ref_item_array ref_item_array, mem_root_deque< Item * > *fields, Item **ref, bool skip_registered)
Definition: item.cc:2472
bool get_time_from_string(Time_val *time)
Convert val_str() to time.
Definition: item.cc:1775
String * val_string_from_real(String *str)
Definition: item.cc:292
virtual bool is_non_const_over_literals(uchar *)
Definition: item.h:2918
virtual void mark_json_as_scalar()
For Items with data type JSON, mark that a string argument is treated as a scalar JSON value.
Definition: item.h:1361
void set_data_type_char(uint32 max_l, const CHARSET_INFO *cs)
Set the Item to be fixed length string.
Definition: item.h:1678
bool has_grouping_func() const
Definition: item.h:3592
virtual void save_org_in_field(Field *field)
Definition: item.h:1437
static constexpr uint8 PROP_AGGREGATION
Definition: item.h:3845
virtual Field * get_result_field() const
Definition: item.h:2668
longlong int_sort_key()
Produces a key suitable for filesort.
Definition: item.h:1920
int decimal_int_part() const
Definition: item.h:2465
virtual void set_data_type_inherited()
Set data type for item as inherited.
Definition: item.h:1478
String * val_string_from_decimal(String *str)
Definition: item.cc:322
virtual bool check_partition_func_processor(uchar *)
Check if a partition function is allowed.
Definition: item.h:3156
static constexpr uint8 PROP_HAS_GROUPING_SET_DEP
Set if the item or one or more of the underlying items contains a GROUP BY modifier (such as ROLLUP).
Definition: item.h:3851
virtual void bind_fields()
Bind objects from the current execution context to field objects in item trees.
Definition: item.h:2990
bool get_date_from_non_temporal(Date_val *date, my_time_flags_t flags)
Convert a non-temporal type to date.
Definition: item.cc:1757
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1268
Definition: sql_list.h:494
Class used as argument to Item::walk() together with mark_field_in_map()
Definition: item.h:261
Mark_field(TABLE *table, enum_mark_columns mark)
Definition: item.h:263
Mark_field(enum_mark_columns mark)
Definition: item.h:264
TABLE *const table
If == NULL, update map of any table.
Definition: item.h:270
const enum_mark_columns mark
How to mark the map.
Definition: item.h:272
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:432
Definition: item.h:518
Table_ref * save_next_local
Definition: item.h:524
void save_state(Name_resolution_context *context, Table_ref *table_list)
Definition: item.h:528
Table_ref * save_next_name_resolution_table
Definition: item.h:522
void update_next_local(Table_ref *table_list)
Definition: item.h:545
Table_ref * get_first_name_resolution_table()
Definition: item.h:549
Table_ref * save_table_list
Definition: item.h:520
bool save_resolve_in_select_list
Definition: item.h:523
Table_ref * save_first_name_resolution_table
Definition: item.h:521
void restore_state(Name_resolution_context *context, Table_ref *table_list)
Definition: item.h:537
Storage for name strings.
Definition: item.h:297
void copy(const char *str)
Definition: item.h:334
Name_string(const char *str, size_t length)
Definition: item.h:313
void copy(const LEX_STRING lex)
Definition: item.h:337
void set_or_copy(const char *str, size_t length, bool is_null_terminated)
Definition: item.h:299
bool eq_safe(const Name_string name) const
Definition: item.h:352
Name_string(const LEX_STRING str, bool is_null_terminated)
Definition: item.h:320
bool eq_safe(const char *str) const
Definition: item.h:347
Name_string(const LEX_STRING str)
Definition: item.h:314
Name_string()
Definition: item.h:307
bool eq(const char *str) const
Compare name to another name in C string, case insensitively.
Definition: item.h:343
void copy(const char *str, size_t length)
Variants for copy(), for various argument combinations.
Definition: item.h:331
Name_string(const LEX_CSTRING str)
Definition: item.h:315
Name_string(const char *str, size_t length, bool is_null_terminated)
Definition: item.h:316
void copy(const char *str, size_t length, const CHARSET_INFO *cs)
Allocate space using sql_strmake() or sql_strmake_with_convert().
Definition: item.cc:1472
bool eq(const Name_string name) const
Compare name to another name in Name_string, case insensitively.
Definition: item.h:351
void copy(const Name_string str)
Definition: item.h:339
void copy(const LEX_STRING *lex)
Definition: item.h:338
Base class for parse tree nodes (excluding the Parse_tree_root hierarchy)
Definition: parse_tree_node_base.h:231
bool end_parse_tree(Show_parse_tree *tree)
Definition: parse_tree_node_base.h:400
bool begin_parse_tree(Show_parse_tree *tree)
Definition: parse_tree_node_base.h:385
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:1198
Simple intrusive linked list.
Definition: sql_list.h:48
A set of THD members describing the current authenticated user.
Definition: sql_security_ctx.h:54
Definition: field.h:4569
bool field
Definition: field.h:4582
Definition: item.h:663
virtual void set_out_param_info(Send_field *info)
Definition: item.h:695
virtual ~Settable_routine_parameter()=default
Settable_routine_parameter()=default
virtual void set_required_privilege(Access_bitmask privilege)
Set required privileges for accessing the parameter.
Definition: item.h:676
virtual bool set_value(THD *thd, sp_rcontext *ctx, Item **it)=0
virtual const Send_field * get_out_param_info() const
Definition: item.h:697
Holds the json parse tree being generated by the SHOW PARSE_TREE command.
Definition: parse_tree_node_base.h:140
A wrapper class for null-terminated constant strings.
Definition: sql_string.h:74
const char * ptr() const
Return string buffer.
Definition: sql_string.h:105
bool is_set() const
Check if m_ptr is set.
Definition: sql_string.h:109
size_t length() const
Return name length.
Definition: sql_string.h:113
void set(const char *str_arg, size_t length_arg)
Initialize from a C string whose length is already known.
Definition: sql_string.h:83
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:169
bool append(const String &s)
Definition: sql_string.cc:419
const CHARSET_INFO * charset() const
Definition: sql_string.h:242
void set_charset(const CHARSET_INFO *charset_arg)
Definition: sql_string.h:241
const char * ptr() const
Definition: sql_string.h:251
bool set_or_copy_aligned(const char *s, size_t arg_length, const CHARSET_INFO *cs)
Definition: sql_string.cc:332
void mark_as_const()
Definition: sql_string.h:249
size_t length() const
Definition: sql_string.h:243
size_t numchars() const
Definition: sql_string.cc:538
bool copy()
Definition: sql_string.cc:198
void set(String &str, size_t offset, size_t arg_length)
Definition: sql_string.h:304
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: table.h:2958
Table_ref * outer_join_nest() const
Returns the outer join nest that this Table_ref belongs to, if any.
Definition: table.h:3564
table_map map() const
Return table map derived from table number.
Definition: table.h:4153
bool is_view() const
Return true if this represents a named view.
Definition: table.h:3220
bool is_inner_table_of_outer_join() const
Return true if this table is an inner table of some outer join.
Definition: table.h:3579
bool outer_join
True if right argument of LEFT JOIN; false in other cases (i.e.
Definition: table.h:3974
Table_ref * next_local
Definition: table.h:3664
Table_ref * any_outer_leaf_table()
Return any leaf table that is not an inner table of an outer join.
Definition: table.h:3405
TABLE * table
Definition: table.h:3747
Table_ref * next_name_resolution_table
Definition: table.h:3744
This is an interface to be used from Item_trigger_field to access information about table trigger fie...
Definition: table_trigger_field_support.h:44
virtual TABLE * get_subject_table()=0
Time_val is a temporal type that represents only time.
Definition: my_temporal.h:57
int64_t for_comparison() const
Definition: my_temporal.h:118
Type properties, used to collect type information for later assignment to an Item object.
Definition: item.h:626
const uint32 m_max_length
Definition: item.h:657
const bool m_unsigned_flag
Definition: item.h:656
const DTCollation m_collation
Definition: item.h:658
Type_properties(enum_field_types type_arg)
Constructor for any signed numeric type or date type Defaults are provided for attributes like signed...
Definition: item.h:630
Type_properties(enum_field_types type_arg, const CHARSET_INFO *charset)
Constructor for character type, with explicit character set.
Definition: item.h:648
Type_properties(enum_field_types type_arg, bool unsigned_arg)
Constructor for any numeric type, with explicit signedness.
Definition: item.h:638
const enum_field_types m_type
Definition: item.h:655
Class used as argument to Item::walk() together with used_tables_for_level()
Definition: item.h:278
Used_tables(Query_block *select)
Definition: item.h:280
table_map used_tables
Accumulated used tables data.
Definition: item.h:283
Query_block *const select
Level for which data is accumulated.
Definition: item.h:282
Definition: item_cmpfunc.h:1924
Definition: mem_root_deque.h:366
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:172
iterator begin()
Definition: mem_root_deque.h:517
iterator end()
Definition: mem_root_deque.h:518
my_decimal class limits 'decimal_t' type to what we need in MySQL.
Definition: my_decimal.h:97
uint precision() const
Definition: my_decimal.h:135
bool sign() const
Definition: my_decimal.h:133
sp_head represents one instance of a stored program.
Definition: sp_head.h:389
Definition: sp_rcontext.h:77
Definition: sql_udf.h:83
Definition: item_func.h:3167
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
#define L
Definition: ctype-tis620.cc:74
#define U
Definition: ctype-tis620.cc:73
#define E_DEC_OVERFLOW
Definition: decimal.h:149
static constexpr int DECIMAL_NOT_SPECIFIED
Definition: dtoa.h:54
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:31
@ QT_NORMALIZED_FORMAT
Change all Item_basic_constant to ? (used by query rewrite to compute digest.) Un-resolved hints will...
Definition: enum_query_type.h:69
bool is_temporal_type_with_time(enum_field_types type)
Tests if field type is temporal and has time part, i.e.
Definition: field_common_properties.h:161
bool is_temporal_type(enum_field_types type)
Tests if field type is temporal, i.e.
Definition: field_common_properties.h:139
bool is_string_type(enum_field_types type)
Tests if field type is a string type.
Definition: field_common_properties.h:89
bool is_numeric_type(enum_field_types type)
Tests if field type is a numeric type.
Definition: field_common_properties.h:65
bool is_temporal_type_with_date(enum_field_types type)
Tests if field type is temporal and has date part, i.e.
Definition: field_common_properties.h:180
bool is_temporal_type_with_date_and_time(enum_field_types type)
Tests if field type is temporal and has date and time parts, i.e.
Definition: field_common_properties.h:201
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:56
@ MYSQL_TYPE_BOOL
Currently just a placeholder.
Definition: field_types.h:80
@ MYSQL_TYPE_TIME2
Internal to MySQL.
Definition: field_types.h:76
@ MYSQL_TYPE_VARCHAR
Definition: field_types.h:72
@ MYSQL_TYPE_LONGLONG
Definition: field_types.h:65
@ MYSQL_TYPE_LONG_BLOB
Definition: field_types.h:87
@ MYSQL_TYPE_VAR_STRING
Definition: field_types.h:89
@ MYSQL_TYPE_BLOB
Definition: field_types.h:88
@ MYSQL_TYPE_TINY
Definition: field_types.h:58
@ MYSQL_TYPE_TIME
Definition: field_types.h:68
@ MYSQL_TYPE_SET
Definition: field_types.h:84
@ MYSQL_TYPE_NEWDATE
Internal to MySQL.
Definition: field_types.h:71
@ MYSQL_TYPE_VECTOR
Definition: field_types.h:78
@ MYSQL_TYPE_JSON
Definition: field_types.h:81
@ MYSQL_TYPE_STRING
Definition: field_types.h:90
@ MYSQL_TYPE_NULL
Definition: field_types.h:63
@ MYSQL_TYPE_ENUM
Definition: field_types.h:83
@ MYSQL_TYPE_TINY_BLOB
Definition: field_types.h:85
@ MYSQL_TYPE_LONG
Definition: field_types.h:60
@ MYSQL_TYPE_BIT
Definition: field_types.h:73
@ MYSQL_TYPE_INVALID
Definition: field_types.h:79
@ MYSQL_TYPE_GEOMETRY
Definition: field_types.h:91
@ MYSQL_TYPE_NEWDECIMAL
Definition: field_types.h:82
@ MYSQL_TYPE_DECIMAL
Definition: field_types.h:57
@ MYSQL_TYPE_TYPED_ARRAY
Used for replication only.
Definition: field_types.h:77
@ MYSQL_TYPE_DOUBLE
Definition: field_types.h:62
@ MYSQL_TYPE_MEDIUM_BLOB
Definition: field_types.h:86
@ MYSQL_TYPE_DATETIME2
Internal to MySQL.
Definition: field_types.h:75
@ MYSQL_TYPE_SHORT
Definition: field_types.h:59
@ MYSQL_TYPE_DATE
Definition: field_types.h:67
@ MYSQL_TYPE_FLOAT
Definition: field_types.h:61
@ MYSQL_TYPE_TIMESTAMP
Definition: field_types.h:64
@ MYSQL_TYPE_INT24
Definition: field_types.h:66
@ MYSQL_TYPE_DATETIME
Definition: field_types.h:69
@ MYSQL_TYPE_TIMESTAMP2
Definition: field_types.h:74
@ MYSQL_TYPE_YEAR
Definition: field_types.h:70
static const std::string dec("DECRYPTION")
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
enum_mysql_timestamp_type
Definition: mysql_time.h:45
#define MY_COLL_ALLOW_SUPERSET_CONV
Definition: item.h:176
const Name_string null_name_string
monotonicity_info
Definition: item.h:580
@ NON_MONOTONIC
Definition: item.h:581
@ MONOTONIC_STRICT_INCREASING
Definition: item.h:584
@ MONOTONIC_INCREASING_NOT_NULL
Definition: item.h:583
@ MONOTONIC_INCREASING
Definition: item.h:582
@ MONOTONIC_STRICT_INCREASING_NOT_NULL
Definition: item.h:585
Item * GetNthVisibleField(const mem_root_deque< Item * > &fields, size_t index)
Definition: item.h:7575
constexpr float COND_FILTER_STALE_NO_CONST
A special subcase of the above:
Definition: item.h:143
constexpr uint16 NO_FIELD_INDEX((uint16)(-1))
std::string ItemToString(const Item *item, enum_query_type q_type)
Definition: item.cc:11876
bool agg_item_charsets(DTCollation &c, const char *name, Item **items, uint nitems, uint flags)
Definition: item.cc:3033
longlong longlong_from_string_with_check(const CHARSET_INFO *cs, const char *cptr, const char *end, int unsigned_target)
Converts a string to a longlong integer, with warnings.
Definition: item.cc:3956
Bounds_checked_array< Item * > Ref_item_array
Definition: item.h:99
Item * TransformItem(Item *item, T &&transformer)
Same as WalkItem, but for Item::transform().
Definition: item.h:3978
#define MY_COLL_ALLOW_NONE
Definition: item.h:178
#define ITEM_TO_QUERY_SUBSTRING_CHAR_LIMIT
Max length of an Item string for its use in an error message.
Definition: item.h:364
Item_result numeric_context_result_type(enum_field_types data_type, Item_result result_type, uint8 decimals)
Definition: item.h:151
bool WalkItem(Item *item, enum_walk walk, T &&functor)
A helper class to give in a functor to Item::walk().
Definition: item.h:3943
Cached_item * new_Cached_item(THD *thd, Item *item)
Create right type of Cached_item for an item.
Definition: item_buff.cc:55
bool agg_item_charsets_for_comparison(DTCollation &c, const char *name, Item **items, uint nitems)
Definition: item.h:4250
Item * CompileItem(Item *item, T &&analyzer, U &&transformer)
Same as WalkItem, but for Item::compile().
Definition: item.h:3965
bool ItemsAreEqual(const Item *a, const Item *b)
Returns true iff the two items are equal, as in a->eq(b), after unwrapping refs and Item_cache object...
Definition: item.cc:11978
bool agg_item_charsets_for_string_result(DTCollation &c, const char *name, Item **items, uint nitems)
Definition: item.h:4243
size_t CountHiddenFields(const mem_root_deque< Item * > &fields)
Definition: item.h:7570
constexpr float COND_FILTER_EQUALITY
Filtering effect for equalities: col1 = col2.
Definition: item.h:116
static uint32 char_to_byte_length_safe(uint32 char_length_arg, uint32 mbmaxlen_arg)
Definition: item.h:145
void convert_and_print(const String *from_str, String *to_str, const CHARSET_INFO *to_cs)
Helper method: Convert string to the given charset, then print.
Definition: item.cc:11711
bool(Item::* Item_analyzer)(uchar **argp)
Definition: item.h:711
Item_field * FindEqualField(Item_field *item_field, table_map reachable_tables, bool replace, bool *found)
Definition: item.cc:11929
enum monotonicity_info enum_monotonicity_info
void item_init(void)
Init all special items.
Definition: item.cc:158
size_t CountVisibleFields(const mem_root_deque< Item * > &fields)
Definition: item.h:7565
constexpr float COND_FILTER_STALE
Value is out-of-date, will need recalculation.
Definition: item.h:127
bool convert_const_strings(DTCollation &coll, Item **args, uint nargs)
Convert constant strings according to a specific character set/collation.
Definition: item.cc:2947
bool agg_item_collations_for_comparison(DTCollation &c, const char *name, Item **items, uint nitems)
Aggregate collations for items used in a comparison operations.
Definition: item.cc:2927
Item_result item_cmp_type(Item_result a, Item_result b)
Definition: item.cc:10086
void(* Cond_traverser)(const Item *item, void *arg)
Definition: item.h:721
Item *(Item::* Item_transformer)(uchar *arg)
Type for transformers used by Item::transform and Item::compile.
Definition: item.h:720
std::string ItemToQuerySubstrNoCharLimit(const Item *item)
#define NAME_STRING(x)
Definition: item.h:357
bool is_null_on_empty_table(THD *thd, Item_field *i)
Check if the column reference that is currently being resolved, will be set to NULL if its qualifying...
Definition: item.cc:6153
constexpr float COND_FILTER_BETWEEN
Filtering effect for between: col1 BETWEEN a AND b.
Definition: item.h:120
constexpr float COND_FILTER_ALLPASS
Default condition filtering (selectivity) values used by get_filtering_effect() and friends when bett...
Definition: item.h:114
const String my_null_string
void SafeIncrement(T *num)
Increment *num if it is less than its maximal value.
Definition: item.h:780
bool AllItemsAreEqual(const Item *const *a, const Item *const *b, int num_items)
Returns true iff all items in the two arrays (which must be of the same size) are equal,...
Definition: item.cc:11982
double double_from_string_with_check(const CHARSET_INFO *cs, const char *cptr, const char *end)
Definition: item.cc:3924
#define MY_COLL_ALLOW_NUMERIC_CONV
Definition: item.h:179
constexpr float COND_FILTER_INEQUALITY
Filtering effect for inequalities: col1 > col2.
Definition: item.h:118
int stored_field_cmp_to_item(THD *thd, Field *field, Item *item)
Compare the value stored in field with the expression from the query.
Definition: item.cc:10247
#define MY_COLL_ALLOW_COERCIBLE_CONV
Definition: item.h:177
bool resolve_const_item(THD *thd, Item **ref, Item *cmp_item)
Substitute a const item with a simpler const item, if possible.
Definition: item.cc:10111
std::string ItemToQuerySubstr(const Item *item, const LEX *lex=nullptr, uint32 char_limit=ITEM_TO_QUERY_SUBSTRING_CHAR_LIMIT)
Definition: item.cc:11918
#define T
Definition: jit_executor_value.cc:373
constexpr int default_error_code
Definition: logger_stream.h:42
A better implementation of the UNIX ctype(3) library.
static constexpr uint32_t MY_CS_PUREASCII
Definition: m_ctype.h:140
int my_strcasecmp(const CHARSET_INFO *cs, const char *s1, const char *s2)
Definition: m_ctype.h:651
static constexpr uint32_t MY_REPERTOIRE_UNICODE30
Definition: m_ctype.h:156
MYSQL_STRINGS_EXPORT CHARSET_INFO my_charset_bin
Definition: ctype-bin.cc:499
MYSQL_STRINGS_EXPORT CHARSET_INFO my_charset_utf8mb4_bin
Definition: ctype-utf8.cc:7813
MYSQL_STRINGS_EXPORT unsigned my_string_repertoire(const CHARSET_INFO *cs, const char *str, size_t len)
Definition: ctype.cc:799
static constexpr uint32_t MY_REPERTOIRE_ASCII
Definition: m_ctype.h:152
MYSQL_STRINGS_EXPORT CHARSET_INFO my_charset_utf8mb3_general_ci
Definition: ctype-utf8.cc:5785
MYSQL_PLUGIN_IMPORT CHARSET_INFO * system_charset_info
Definition: mysqld.cc:1582
Various macros useful for communicating with memory debuggers, such as Valgrind.
void TRASH(void *ptr, size_t length)
Put bad content in memory to be sure it will segfault if dereferenced.
Definition: memory_debugging.h:71
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:480
static void bitmap_set_bit(MY_BITMAP *map, uint bit)
Definition: my_bitmap.h:80
Header for compiler-dependent features.
#define MY_COMPILER_MSVC_DIAGNOSTIC_IGNORE(X)
Definition: my_compiler.h:247
#define MY_COMPILER_DIAGNOSTIC_PUSH()
save the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:277
#define MY_COMPILER_DIAGNOSTIC_POP()
restore the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:278
#define DBUG_FILE
Definition: my_dbug.h:194
#define DBUG_TRACE
Definition: my_dbug.h:146
It is interface module to fixed precision decimals library.
int my_decimal_int_part(uint precision, uint decimals)
Definition: my_decimal.h:85
void my_decimal_neg(decimal_t *arg)
Definition: my_decimal.h:338
static constexpr int DECIMAL_MAX_PRECISION
maximum guaranteed precision of number in decimal digits (number of our digits * number of decimal di...
Definition: my_decimal.h:71
uint32 my_decimal_precision_to_length_no_truncation(uint precision, uint8 scale, bool unsigned_flag)
Definition: my_decimal.h:193
Utility functions for converting between ulonglong and double.
static constexpr double LLONG_MAX_DOUBLE
Definition: my_double2ulonglong.h:57
#define ulonglong2double(A)
Definition: my_double2ulonglong.h:46
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
int8_t int8
Definition: my_inttypes.h:62
#define MY_INT32_NUM_DECIMAL_DIGITS
Definition: my_inttypes.h:100
#define MYF(v)
Definition: my_inttypes.h:97
int32_t int32
Definition: my_inttypes.h:66
uint16_t uint16
Definition: my_inttypes.h:65
#define MY_INT64_NUM_DECIMAL_DIGITS
Definition: my_inttypes.h:103
uint32_t uint32
Definition: my_inttypes.h:67
#define UINT_MAX32
Definition: my_inttypes.h:79
MYSQL_STRINGS_EXPORT long long my_strtoll10(const char *nptr, const char **endptr, int *error)
Definition: my_strtoll10.cc:87
Common header for many mysys elements.
uint64_t table_map
Definition: my_table_map.h:30
Server classes for temporal handling (DATE, TIME, DATETIME)
Interface for low level time utilities.
constexpr const int DATETIME_MAX_DECIMALS
Definition: my_time.h:146
unsigned int my_time_flags_t
Flags to str_to_datetime and int_to_datetime.
Definition: my_time.h:87
static int count
Definition: myisam_ftdump.cc:45
Common definition between mysql server & client.
#define MAX_BLOB_WIDTH
Default width for blob in bytes.
Definition: mysql_com.h:913
#define MAX_CHAR_WIDTH
Max width for a CHAR column, in number of characters.
Definition: mysql_com.h:911
static bool ignore_errors
Definition: mysqlcheck.cc:62
static bool replace
Definition: mysqlimport.cc:70
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1077
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Definition: buf0block_hint.cc:30
const std::string charset("charset")
Definition: applier_version.h:27
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
bool index(const std::string &value, const String &search_for, uint32_t *idx)
Definition: contains.h:76
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
ValueType max(X &&first)
Definition: gtid.h:103
std::string_view type_name()
Return the name of the given type (not demangled).
Definition: object_lifetime_tracker.h:57
size_t size(const char *const c)
Definition: base64.h:46
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
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:600
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2742
#define NullS
Definition of the null string (a null pointer of type char *), used in some of our string handling co...
Definition: nulls.h:33
type_conversion_status
Status when storing a value in a field or converting from one datatype to another.
Definition: field.h:200
#define MY_REPERTOIRE_NUMERIC
Definition: field.h:256
enum_field_types real_type_to_type(enum_field_types real_type)
Convert temporal real types as returned by field->real_type() to field type as returned by field->typ...
Definition: field.h:391
Value_generator_source
Enum to indicate source for which value generator is used.
Definition: field.h:471
@ VGS_DEFAULT_EXPRESSION
Definition: field.h:473
@ VGS_GENERATED_COLUMN
Definition: field.h:472
#define my_charset_numeric
Definition: field.h:255
Derivation
For use.
Definition: field.h:176
@ DERIVATION_COERCIBLE
Definition: field.h:180
@ DERIVATION_SYSCONST
Definition: field.h:181
@ DERIVATION_EXPLICIT
Definition: field.h:184
@ DERIVATION_NONE
Definition: field.h:177
@ DERIVATION_NUMERIC
Definition: field.h:179
@ DERIVATION_NULL
Definition: field.h:178
@ DERIVATION_IMPLICIT
Definition: field.h:182
File containing constants that can be used throughout the server.
constexpr const table_map RAND_TABLE_BIT
Definition: sql_const.h:113
constexpr const int MAX_TIME_WIDTH
-838:59:59
Definition: sql_const.h:70
constexpr const int MAX_DATE_WIDTH
YYYY-MM-DD.
Definition: sql_const.h:68
constexpr const size_t STRING_BUFFER_USUAL_SIZE
Definition: sql_const.h:126
constexpr const table_map OUTER_REF_TABLE_BIT
Definition: sql_const.h:112
constexpr const int MAX_DOUBLE_STR_LENGTH
-[digits].E+###
Definition: sql_const.h:158
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
constexpr const int MAX_DATETIME_WIDTH
YYYY-MM-DD HH:MM:SS.
Definition: sql_const.h:76
enum_mark_columns
Definition: sql_const.h:232
int stringcmp(const String *s, const String *t)
Definition: sql_string.cc:712
Our own string classes, used pervasively throughout the executor.
case opt name
Definition: sslopt-case.h:29
Access paths are a query planning structure that correspond 1:1 to iterators, in that an access path ...
Definition: access_path.h:243
Definition: m_ctype.h:421
unsigned mbmaxlen
Definition: m_ctype.h:445
Definition: item_cmpfunc.h:2869
Struct used to pass around arguments to/from check_function_as_value_generator.
Definition: item.h:487
int err_code
the error code found during check(if any)
Definition: item.h:494
int col_index
the order of the column in table
Definition: item.h:492
const char * banned_function_name
the name of the function which is not allowed
Definition: item.h:501
Value_generator_source source
Definition: item.h:499
int get_unnamed_function_error_code() const
Return the correct error code, based on whether or not if we are checking for disallowed functions in...
Definition: item.h:506
Check_function_as_value_generator_parameters(int default_error_code, Value_generator_source val_gen_src)
Definition: item.h:488
This class represents a subquery contained in some subclass of Item_subselect,.
Definition: item.h:861
Strategy strategy
The strategy for executing the subquery.
Definition: item.h:895
Strategy
The strategy for executing the subquery.
Definition: item.h:863
@ kMaterializable
An independent subquery that is materialized, e.g.
@ kIndependentSingleRow
An independent single-row subquery that is evaluated once, e.g.
@ kNonMaterializable
A subquery that is reevaluated for each row, e.g.
AccessPath * path_no_in2exists
For a kMaterializable subquery: the root path of the plan without injected IN-to-EXISTS conditions,...
Definition: item.h:907
AccessPath * path
The root path of the subquery.
Definition: item.h:892
int row_width
The width (in bytes) of the subquery's rows.
Definition: item.h:901
The current state of the privilege checking process for the current user, SQL statement and SQL objec...
Definition: table.h:384
Definition: item.h:3375
Aggregate_ref_update(Item_sum *target, Query_block *owner)
Definition: item.h:3378
Query_block * m_owner
Definition: item.h:3377
Item_sum * m_target
Definition: item.h:3376
Definition: item.h:3348
Aggregate_replacement(Item_sum *target, Item_field *replacement)
Definition: item.h:3351
Item_field * m_replacement
Definition: item.h:3350
Item_sum * m_target
Definition: item.h:3349
Context struct used by walk method collect_scalar_subqueries to accumulate information about scalar s...
Definition: item.h:3073
Item * m_join_condition_context
Definition: item.h:3079
Location
Definition: item.h:3074
@ L_JOIN_COND
Definition: item.h:3074
@ L_HAVING
Definition: item.h:3074
@ L_SELECT
Definition: item.h:3074
@ L_WHERE
Definition: item.h:3074
bool m_collect_unconditionally
Definition: item.h:3080
int8 m_location
we are currently looking at this kind of clause, cf. enum Location
Definition: item.h:3078
std::vector< Css_info > m_list
accumulated all scalar subqueries found
Definition: item.h:3076
Minion class under Collect_scalar_subquery_info ("Css").
Definition: item.h:3045
int8 m_locations
set of locations
Definition: item.h:3047
Item * m_join_condition
Where did we find item above? Used when m_location == L_JOIN_COND, nullptr for other locations.
Definition: item.h:3053
bool m_add_coalesce
If true, add a COALESCE around replaced subquery: used for implicitly grouped COUNT() in subquery sel...
Definition: item.h:3058
table_map m_correlation_map
Definition: item.h:3050
uint m_having_idx
Index of the having expression copied to select list.
Definition: item.h:3063
Item_singlerow_subselect * item
the scalar subquery
Definition: item.h:3049
bool m_add_having_compensation
Set iff m_add_coalesce is true: we may get a NULL anyway even for COUNT if a HAVING clause is false i...
Definition: item.h:3061
bool m_implicitly_grouped_and_no_union
If true, we can forego cardinality checking of the derived table.
Definition: item.h:3055
Definition: item.h:3309
Mode m_default_value
Definition: item.h:3319
Item_field * m_outer_field
Definition: item.h:3313
Field * m_target
The field to be replaced.
Definition: item.h:3310
Item_field_replacement(Field *target, Item_field *item, Query_block *select, Mode default_value=Mode::CONFLATE)
Definition: item.h:3320
Mode
Definition: item.h:3314
Item_field * m_item
The replacement field replacement field iff outer ref.
Definition: item.h:3311
Definition: item.h:3328
Item_func * m_target
The function call to be replaced.
Definition: item.h:3329
Item_func_call_replacement(Item_func *func_target, Item_field *item, Query_block *select)
Definition: item.h:3331
Item_field * m_item
The replacement field.
Definition: item.h:3330
Definition: item.h:3301
Item_replacement(Query_block *transformed_block, Query_block *current_block)
Definition: item.h:3306
Query_block * m_curr_block
Transformed query block or a contained.
Definition: item.h:3303
Query_block * m_trans_block
Transformed query block.
Definition: item.h:3302
Definition: item.h:3338
Item * m_target
The item identifying the view_ref to be replaced.
Definition: item.h:3339
Field * m_field
The replacement field.
Definition: item.h:3340
Item_view_ref_replacement(Item *target, Field *field, Query_block *select)
Definition: item.h:3344
Item_field * m_outer_field
replacement field if outer ref
Definition: item.h:3341
Definition: item.h:3168
List< Item_func > stack
Definition: item.h:3170
< Argument object to change_context_processor
Definition: item.h:4472
Name_resolution_context * m_context
Definition: item.h:4473
Change_context(Name_resolution_context *context)
Definition: item.h:4474
Argument structure for walk processor Item::update_depended_from.
Definition: item.h:4489
Query_block * old_depended_from
Definition: item.h:4490
Query_block * new_depended_from
Definition: item.h:4491
The LEX object currently serves three different purposes:
Definition: sql_lex.h:4021
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
void * Alloc(size_t length)
Allocate memory.
Definition: my_alloc.h:145
Definition: mysql_lex_string.h:40
const char * str
Definition: mysql_lex_string.h:41
size_t length
Definition: mysql_lex_string.h:42
Definition: mysql_lex_string.h:35
char * str
Definition: mysql_lex_string.h:36
size_t length
Definition: mysql_lex_string.h:37
Definition: my_bitmap.h:43
Bison "location" class.
Definition: parse_location.h:43
Instances of Name_resolution_context store the information necessary for name resolution of Items and...
Definition: item.h:414
Name_resolution_context * next_context
Link to next name res context with the same query block as the base.
Definition: item.h:421
Table_ref * view_error_handler_arg
Definition: item.h:459
Name_resolution_context * outer_context
The name resolution context to search in when an Item cannot be resolved in this context (the context...
Definition: item.h:419
Security_context * security_ctx
Security context of this name resolution context.
Definition: item.h:475
Table_ref * first_name_resolution_table
In most cases the two table references below replace 'table_list' above for the purpose of name resol...
Definition: item.h:439
Table_ref * last_name_resolution_table
Last table to search in the list of leaf table references that begins with first_name_resolution_tabl...
Definition: item.h:444
Query_block * query_block
Query_block item belong to, in case of merged VIEW it can differ from Query_block where item was crea...
Definition: item.h:451
bool resolve_in_select_list
When true, items are resolved in this context against Query_block::item_list, SELECT_lex::group_list ...
Definition: item.h:469
bool view_error_handler
Definition: item.h:458
Table_ref * table_list
List of tables used to resolve the items of this context.
Definition: item.h:431
void resolve_in_table_list_only(Table_ref *tables)
Definition: item.h:477
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:422
Definition: table.h:1456
const char * alias
alias or table name
Definition: table.h:1708
bool has_null_row() const
Definition: table.h:2228
MY_BITMAP * fields_set_during_insert
A pointer to the bitmap of table fields (columns), which are explicitly set in the INSERT INTO statem...
Definition: table.h:1791
bool alias_name_used
Definition: table.h:1917
bool is_nullable() const
Return whether table is nullable.
Definition: table.h:2130
Definition: typelib.h:35
Definition: completion_hash.h:35
Descriptor of what and how to cache for Item::cache_const_expr_transformer/analyzer.
Definition: item.h:3924
Item * cache_item
Item to cache. Used as a binary flag, but kept as Item* for assertion.
Definition: item.h:3929
List< Item > stack
Path from the expression's top to the current item in item tree used to track parent of current item ...
Definition: item.h:3927
Item::enum_const_item_cache cache_arg
How to cache JSON data.
Definition: item.h:3931
Replacement of system's struct timeval to ensure we can carry 64 bit values even on a platform which ...
Definition: my_time_t.h:45
Definition: result.h:30
This file defines all base public constants related to triggers in MySQL.
enum_trigger_variable_type
Enum constants to designate NEW and OLD trigger pseudo-variables.
Definition: trigger_def.h:73
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
@ INVALID_RESULT
Definition: udf_registration_types.h:40
@ ROW_RESULT
long long
Definition: udf_registration_types.h:44
Definition: dtoa.cc:595