MySQL 8.0.33
Source Code Documentation
item_cmpfunc.h
Go to the documentation of this file.
1#ifndef ITEM_CMPFUNC_INCLUDED
2#define ITEM_CMPFUNC_INCLUDED
3
4/* Copyright (c) 2000, 2023, 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 also distributed 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 included with MySQL.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License, version 2.0, for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25
26/* compare and test functions */
27
28#include <assert.h>
29#include <sys/types.h>
30
31#include <cstring>
32#include <memory>
33
34#include "field_types.h"
35#include "my_alloc.h"
36#include "my_compiler.h"
37
38#include "my_inttypes.h"
39#include "my_table_map.h"
40#include "my_time.h"
42#include "mysql_time.h"
43#include "sql/enum_query_type.h"
44#include "sql/item.h"
45#include "sql/item_func.h" // Item_int_func
46#include "sql/item_row.h" // Item_row
47#include "sql/mem_root_array.h" // Mem_root_array
48#include "sql/my_decimal.h"
49#include "sql/parse_location.h" // POS
50#include "sql/sql_const.h"
51#include "sql/sql_list.h"
52#include "sql/table.h"
53#include "sql_string.h"
54#include "template_utils.h" // down_cast
55
56class Arg_comparator;
57class Field;
58class Item_eq_base;
60class Item_subselect;
61class Item_sum_hybrid;
63class Json_wrapper;
64class PT_item_list;
65class Query_block;
66class THD;
67struct CHARSET_INFO;
68struct MY_BITMAP;
69struct Parse_context;
70
72
73typedef int (Arg_comparator::*arg_cmp_func)();
74
75/// A class that represents a join condition in a hash join. The class holds an
76/// equality condition, as well as a pre-calculated bitmap of the used tables
77/// (Item::used_tables()) for each side of the condition.
78///
79/// The class also contains one Item for each side of the condition. In most
80/// cases, the Item is only a pointer to the left/right Item of the join
81/// condition. But for certain data types (DECIMAL, DOUBLE(M, N), FLOAT(M, N)),
82/// the Item might be a typecast. Either way, the caller should use these Items
83/// when i.e. reading the values from the join condition, so that the values are
84/// read in the right data type context. See the comments for
85/// Item_eq_base::create_cast_if_needed for more details around this.
87 public:
89
91
94 bool left_uses_any_table(table_map tables) const {
95 return (m_left_used_tables & tables) != 0;
96 }
97
98 bool right_uses_any_table(table_map tables) const {
99 return (m_right_used_tables & tables) != 0;
100 }
101
103
105
106 /// Returns true if this join condition evaluates to TRUE if both
107 /// operands are NULL.
108 bool null_equals_null() const { return m_null_equals_null; }
109
110 private:
114
115 // Item::used_tables() is heavily used during the join to determine which side
116 // of the condition we are to read the value from, so caching the result of
117 // used_tables() gives a nice speedup.
120
121 // The maximum number of characters among the two arguments. This is
122 // especially relevant when we have a PAD SPACE collation and the SQL mode
123 // PAD_CHAR_TO_FULL_LENGTH enabled, since we will have to pad the shortest
124 // argument to the same length as the longest argument.
125 const size_t m_max_character_length{0};
126
127 // Normally, we store the full sort key for the condition as key in the hash
128 // table. However, if the string is very long, or we have a PAD SPACE
129 // collation, this could result in huge sort keys. If we detect that this
130 // could happen in the worst case, we store just a hash in the key instead (so
131 // we hash the hash). If so, we have to do a recheck afterwards, in order to
132 // guard against hash collisions.
134
135 // True if NULL is considered equal to NULL, and not as UNKNOWN.
137};
138
140 Item **left{nullptr};
141 Item **right{nullptr};
144 Arg_comparator *comparators{nullptr}; // used only for compare_row()
146 double precision{0.0};
147 /* Fields used in DATE/DATETIME comparison. */
148 Item *left_cache{nullptr}; // Cached values of "left" and "right" items
149 Item *right_cache{nullptr};
150 bool set_null{true}; // true <=> set owner->null_value
151 // when one of arguments is NULL.
152
154 static bool get_date_from_const(Item *date_arg, Item *str_arg,
155 ulonglong *const_value);
156 /**
157 Only used by compare_json() in the case where a JSON value is
158 compared to an SQL value. This member points to pre-allocated
159 memory that can be used instead of the heap when converting the
160 SQL value to a JSON value.
161 */
163
164 public:
166 /* Allow owner function to use string buffers. */
168
169 Arg_comparator() = default;
170
172
174 bool set_cmp_func(Item_result_field *owner_arg, Item **left, Item **right,
176
177 bool set_cmp_func(Item_result_field *owner_arg, Item **left, Item **right,
178 bool set_null_arg);
179
180 bool set_cmp_func(Item_result_field *owner_arg, Item **left, Item **right,
181 bool set_null_arg, Item_result type);
182 /**
183 Comparison function are expected to operate on arguments having the
184 same data types. Since MySQL has very loosened up rules, it accepts
185 all kind of arguments which the standard SQL does not allow, and then it
186 converts the arguments internally to ones usable in the comparison.
187 This function transforms these internal conversions to explicit CASTs
188 so that the internally executed query becomes compatible with the standard
189 At the moment nodes are injected only for comparisons between:
190
191 1) temporal types and numeric data types: in which case the
192 comparison is normally done as DOUBLE, so the arguments which are not
193 floating point, will get converted to DOUBLE, and also for
194
195 2) comparisons between temporal types: in which case the
196 comparison happens as DATETIME if the arguments have different data
197 types, so in this case the temporal arguments that are not DATETIME
198 will get wrapped in a CAST to DATETIME.
199
200 WL#12108; This function will limit itself to comparison between regular
201 functions, aggregation functions and fields, all of which are constant
202 for execution (so this excludes stored procedures, stored functions, GC,
203 user defined functions, as well as literals).
204 For const arguments, see type conversions done in fold_condition.
205
206 @return false if successful, true otherwise
207 */
208 bool inject_cast_nodes();
209
210 inline int compare() { return (this->*func)(); }
211
212 int compare_string(); // compare args[0] & args[1]
213 int compare_binary_string(); // compare args[0] & args[1]
214 int compare_real(); // compare args[0] & args[1]
215 int compare_decimal(); // compare args[0] & args[1]
216 int compare_int_signed(); // compare args[0] & args[1]
221 int compare_row(); // compare args[0] & args[1]
222 int compare_real_fixed();
223 int compare_datetime(); // compare args[0] & args[1] as DATETIMEs
224 int compare_json();
225 bool compare_null_values();
226
227 static bool can_compare_as_dates(const Item *a, const Item *b);
228
229 void set_datetime_cmp_func(Item_result_field *owner_arg, Item **a1,
230 Item **b1);
232 void cleanup();
233 /*
234 Set correct cmp_context if items would be compared as INTs.
235 */
238 if ((*left)->is_temporal()) (*left)->cmp_context = INT_RESULT;
239 if ((*right)->is_temporal()) (*right)->cmp_context = INT_RESULT;
240 }
241
243
245
247
248 /// @returns true if the class has decided that values should be extracted
249 /// from the Items using function pointers set up by this class.
251 return get_value_a_func != nullptr;
252 }
253
254 // Read the value from one of the Items (decided by "left_argument"), using
255 // the function pointers that this class has set up. This can happen for DATE,
256 // TIME, DATETIME and YEAR values, and the returned value is a temporal value
257 // in packed format.
258 longlong extract_value_from_argument(THD *thd, Item *item, bool left_argument,
259 bool *is_null) const;
260
261 Item **get_left_ptr() const { return left; }
262 Item *get_right() const { return *right; }
263
264 private:
265 /// A function pointer that is used for retrieving the value from argument
266 /// "left". This function is only used when we are comparing in a datetime
267 /// context, and it retrieves the value as a DATE, TIME, DATETIME or YEAR,
268 /// depending on the comparison context.
269 ///
270 /// @param thd thread handle. Used to retrieve the SQL mode among other things
271 /// @param item_arg the item to retrieve the value from
272 /// @param cache_arg a pointer to an Item where we can cache the value
273 /// from "item_arg". Can be nullptr
274 /// @param warn_item if raising an conversion warning, the warning gets the
275 /// data type and item name from this item
276 /// @param is_null whether or not "item_arg" returned SQL NULL
277 ///
278 /// @returns a DATE/TIME/YEAR/DATETIME value, in packed format
279 longlong (*get_value_a_func)(THD *thd, Item ***item_arg, Item **cache_arg,
280 const Item *warn_item, bool *is_null){nullptr};
281
282 // This function does the same as "get_value_a_func", except that it returns
283 // the value from the argument "right" (the right side of the comparison).
284 longlong (*get_value_b_func)(THD *thd, Item ***item_arg, Item **cache_arg,
285 const Item *warn_item, bool *is_null){nullptr};
286
287 // The data type that is used when comparing the two Items. I.e., if the type
288 // is INT_RESULT, we call val_int() on both sides and compare those.
290};
291
293 protected:
295 explicit Item_bool_func(const POS &pos) : Item_int_func(pos) {
297 }
298
300 Item_bool_func(const POS &pos, Item *a) : Item_int_func(pos, a) {
302 }
303
304 Item_bool_func(Item *a, Item *b, Item *c) : Item_int_func(a, b, c) {
306 }
309 }
310 Item_bool_func(const POS &pos, Item *a, Item *b) : Item_int_func(pos, a, b) {
312 }
313 Item_bool_func(const POS &pos, Item *a, Item *b, Item *c)
314 : Item_int_func(pos, a, b, c) {
316 }
317
319 : Item_int_func(thd, item),
322 }
323
324 public:
325 bool is_bool_func() const override { return true; }
326 bool resolve_type(THD *thd) override {
327 max_length = 1;
328 return Item_int_func::resolve_type(thd);
329 }
330 uint decimal_precision() const override { return 1; }
331 bool created_by_in2exists() const override { return m_created_by_in2exists; }
333
334 static const char *bool_transform_names[10];
335 /**
336 Array that transforms a boolean test according to another.
337 First dimension is existing value, second dimension is test to apply
338 */
339 static const Bool_test bool_transform[10][8];
340
341 private:
342 /**
343 True <=> this item was added by IN->EXISTS subquery transformation, and
344 should thus be deleted if we switch to materialization.
345 */
347};
348
349/**
350 A predicate that is "always true" or "always false". To be used as a
351 standalone condition or as part of conditions, together with other condition
352 and predicate objects.
353 Mostly used when generating conditions internally.
354*/
356 public:
358 max_length = 1;
361 fixed = true;
362 }
363 explicit Item_func_bool_const(const POS &pos) : Item_bool_func(pos) {
364 max_length = 1;
367 fixed = true;
368 }
369 bool fix_fields(THD *, Item **) override { return false; }
370 bool basic_const_item() const override { return true; }
371 void cleanup() override { result_field = nullptr; }
372};
373
374/// A predicate that is "always true".
375
377 public:
379 explicit Item_func_true(const POS &pos) : Item_func_bool_const(pos) {}
380 const char *func_name() const override { return "true"; }
381 bool val_bool() override { return true; }
382 longlong val_int() override { return 1; }
383 void print(const THD *, String *str, enum_query_type) const override {
384 str->append("true");
385 }
386 enum Functype functype() const override { return TRUE_FUNC; }
387};
388
389/// A predicate that is "always false".
390
392 public:
394 explicit Item_func_false(const POS &pos) : Item_func_bool_const(pos) {}
395 const char *func_name() const override { return "false"; }
396 bool val_bool() override { return false; }
397 longlong val_int() override { return 0; }
398 void print(const THD *, String *str, enum_query_type) const override {
399 str->append("false");
400 }
401 enum Functype functype() const override { return FALSE_FUNC; }
402};
403
404/**
405 Item class, to represent <code>X IS [NOT] (TRUE | FALSE)</code>
406 boolean predicates.
407*/
408class Item_func_truth final : public Item_bool_func {
410
411 public:
412 longlong val_int() override;
413 bool resolve_type(THD *) override;
414 void print(const THD *thd, String *str,
415 enum_query_type query_type) const override;
416 Item *truth_transformer(THD *, Bool_test test) override {
418 return this;
419 }
420 const char *func_name() const override {
422 }
423 enum Functype functype() const override { return ISTRUTH_FUNC; }
424
426 : super(pos, a), truth_test(truth_test) {
427 null_on_null = false;
428 switch (truth_test) {
429 case BOOL_IS_TRUE:
430 case BOOL_IS_FALSE:
431 case BOOL_NOT_TRUE:
432 case BOOL_NOT_FALSE:
433 break;
434 default:
435 assert(false);
436 }
437 }
440 null_on_null = false;
441 switch (truth_test) {
442 case BOOL_IS_TRUE:
443 case BOOL_IS_FALSE:
444 case BOOL_NOT_TRUE:
445 case BOOL_NOT_FALSE:
446 break;
447 default:
448 assert(false);
449 }
450 }
451 void apply_is_true() override {
452 /*
453 This item cannot produce NULL result. But, if the upper item confuses
454 NULL and FALSE, we can do as if NULL input caused a NULL result when it
455 actually causes a FALSE result.
456 */
457 switch (truth_test) {
458 case BOOL_IS_TRUE:
459 case BOOL_IS_FALSE:
460 null_on_null = true;
461 default:
462 break;
463 }
464 }
465
466 protected:
467 Bool_test truth_test; ///< The value we're testing for.
468};
469
470static const int UNKNOWN = -1;
471
472/*
473 Item_in_optimizer(Item_in_subselect(...))
474
475 Item_in_optimizer is used to wrap an instance of Item_in_subselect. This
476 class does the following:
477 - Evaluate the left expression and store it in Item_cache_* object (to
478 avoid re-evaluating it many times during subquery execution)
479 - Shortcut the evaluation of "NULL IN (...)" to NULL in the cases where we
480 don't care if the result is NULL or FALSE.
481
482 args[0] keeps a reference to the Item_in_subselect object.
483
484 NOTE
485 It is not quite clear why the above listed functionality should be
486 placed into a separate class called 'Item_in_optimizer'.
487*/
488
489class Item_in_optimizer final : public Item_bool_func {
490 private:
491 Item_cache *cache{nullptr};
492 /**
493 Stores the value of "NULL IN (SELECT ...)" for uncorrelated subqueries:
494 UNKNOWN - "NULL in (SELECT ...)" has not yet been evaluated
495 FALSE - result is FALSE
496 TRUE - result is NULL
497 */
499
500 public:
502 : Item_bool_func(pointer_cast<Item *>(item)) {
503 set_subquery();
504 }
505 bool fix_fields(THD *, Item **) override;
506 bool fix_left(THD *thd, Item **ref);
507 void fix_after_pullout(Query_block *parent_query_block,
508 Query_block *removed_query_block) override;
509 void split_sum_func(THD *thd, Ref_item_array ref_item_array,
510 mem_root_deque<Item *> *fields) override;
511 void print(const THD *thd, String *str,
512 enum_query_type query_type) const override;
513 bool is_null() override;
514 longlong val_int() override;
515 void cleanup() override;
516 const char *func_name() const override { return "<in_optimizer>"; }
517 Item_cache **get_cache() { return &cache; }
518 void update_used_tables() override;
519};
520
521/// Abstract factory interface for creating comparison predicates.
523 public:
524 virtual ~Comp_creator() = default;
525 virtual Item_bool_func *create(Item *a, Item *b) const = 0;
526
527 /// This interface is only used by Item_allany_subselect.
528 virtual const char *symbol(bool invert) const = 0;
529 virtual bool eqne_op() const = 0;
530 virtual bool l_op() const = 0;
531};
532
533/// Abstract base class for the comparison operators =, <> and <=>.
535 public:
536 Item_bool_func *create(Item *a, Item *b) const override;
537 bool eqne_op() const override { return true; }
538 bool l_op() const override { return false; }
539
540 protected:
541 /**
542 Creates only an item tree node, without attempting to rewrite row
543 constructors.
544 @see create()
545 */
547
548 /// Combines a list of conditions <code>exp op exp</code>.
550};
551
553 public:
554 const char *symbol(bool invert) const override { return invert ? "<>" : "="; }
555
556 protected:
557 Item_bool_func *create_scalar_predicate(Item *a, Item *b) const override;
558 Item_bool_func *combine(List<Item> list) const override;
559};
560
562 public:
563 const char *symbol(bool invert [[maybe_unused]]) const override {
564 // This will never be called with true.
565 assert(!invert);
566 return "<=>";
567 }
568
569 protected:
570 Item_bool_func *create_scalar_predicate(Item *a, Item *b) const override;
571 Item_bool_func *combine(List<Item> list) const override;
572};
573
575 public:
576 const char *symbol(bool invert) const override { return invert ? "=" : "<>"; }
577
578 protected:
579 Item_bool_func *create_scalar_predicate(Item *a, Item *b) const override;
580 Item_bool_func *combine(List<Item> list) const override;
581};
582
583class Gt_creator : public Comp_creator {
584 public:
585 Item_bool_func *create(Item *a, Item *b) const override;
586 const char *symbol(bool invert) const override { return invert ? "<=" : ">"; }
587 bool eqne_op() const override { return false; }
588 bool l_op() const override { return false; }
589};
590
591class Lt_creator : public Comp_creator {
592 public:
593 Item_bool_func *create(Item *a, Item *b) const override;
594 const char *symbol(bool invert) const override { return invert ? ">=" : "<"; }
595 bool eqne_op() const override { return false; }
596 bool l_op() const override { return true; }
597};
598
599class Ge_creator : public Comp_creator {
600 public:
601 Item_bool_func *create(Item *a, Item *b) const override;
602 const char *symbol(bool invert) const override { return invert ? "<" : ">="; }
603 bool eqne_op() const override { return false; }
604 bool l_op() const override { return false; }
605};
606
607class Le_creator : public Comp_creator {
608 public:
609 Item_bool_func *create(Item *a, Item *b) const override;
610 const char *symbol(bool invert) const override { return invert ? ">" : "<="; }
611 bool eqne_op() const override { return false; }
612 bool l_op() const override { return true; }
613};
614
615/// Base class for functions that usually take two arguments, which are possibly
616/// strings, and perform some kind of comparison on the two arguments and return
617/// a boolean. The functions may take more than two arguments (for example, LIKE
618/// takes an optional third argument in the ESCAPE clause), but all of the
619/// functions perform a comparison between the first two arguments, and extra
620/// arguments are modifiers that affect how the comparison is performed.
622 private:
623 bool convert_constant_arg(THD *thd, Item *field, Item **item,
624 bool *converted);
625
626 protected:
628 bool abort_on_null{false};
629
631 : Item_bool_func(a, b), cmp(args, args + 1) {}
632
634 : Item_bool_func(a, b, c), cmp(args, args + 1) {}
635
636 Item_bool_func2(const POS &pos, Item *a, Item *b)
637 : Item_bool_func(pos, a, b), cmp(args, args + 1) {}
638
639 Item_bool_func2(const POS &pos, Item *a, Item *b, Item *c)
640 : Item_bool_func(pos, a, b, c), cmp(args, args + 1) {}
641
642 public:
643 bool resolve_type(THD *) override;
644 /// Sets up a comparator of the correct type based on the type of the
645 /// function's arguments. Also sets up caches to hold constant values
646 /// converted to the type expected by the comparator. See
647 /// Arg_comparator::set_cmp_func().
648 virtual bool set_cmp_func() {
649 return cmp.set_cmp_func(this, args, args + 1, is_nullable());
650 }
651 optimize_type select_optimize(const THD *) override { return OPTIMIZE_OP; }
652 /// @returns an operator REV_OP so that "B REV_OP A" is equivalent to
653 /// "A this_operator B".
654 virtual enum Functype rev_functype() const { return UNKNOWN_FUNC; }
655 bool have_rev_func() const override { return rev_functype() != UNKNOWN_FUNC; }
656
657 void print(const THD *thd, String *str,
658 enum_query_type query_type) const override {
659 Item_func::print_op(thd, str, query_type);
660 }
661
662 bool is_null() override { return args[0]->is_null() || args[1]->is_null(); }
663 const CHARSET_INFO *compare_collation() const override {
665 }
667 void apply_is_true() override { abort_on_null = true; }
668 /// Treat UNKNOWN result like FALSE because callers see no difference
669 bool ignore_unknown() const { return abort_on_null; }
670 void cleanup() override {
672 cmp.cleanup();
673 }
674 const Arg_comparator *get_comparator() const { return &cmp; }
676 friend class Arg_comparator;
677};
678
679/**
680 Item_func_comparison is a class for comparison functions that take two
681 arguments and return a boolean result.
682 It is a common class for the regular comparison operators (=, <>, <, <=,
683 >, >=) as well as the special <=> equality operator.
684*/
686 public:
688 allowed_arg_cols = 0; // Fetch this value from first argument
689 }
690 Item_func_comparison(const POS &pos, Item *a, Item *b)
691 : Item_bool_func2(pos, a, b) {
692 allowed_arg_cols = 0; // Fetch this value from first argument
693 }
694
695 Item *truth_transformer(THD *, Bool_test) override;
696 virtual Item *negated_item();
697 bool subst_argument_checker(uchar **) override { return true; }
698 bool is_null() override;
699
700 bool cast_incompatible_args(uchar *) override;
701};
702
703/**
704 XOR inherits from Item_bool_func2 because it is not optimized yet.
705 Later, when XOR is optimized, it needs to inherit from
706 Item_cond instead. See WL#5800.
707*/
708class Item_func_xor final : public Item_bool_func2 {
710
711 public:
712 Item_func_xor(Item *i1, Item *i2) : Item_bool_func2(i1, i2) {}
713 Item_func_xor(const POS &pos, Item *i1, Item *i2)
714 : Item_bool_func2(pos, i1, i2) {}
715
716 enum Functype functype() const override { return XOR_FUNC; }
717 const char *func_name() const override { return "xor"; }
718 bool itemize(Parse_context *pc, Item **res) override;
719 longlong val_int() override;
720 void apply_is_true() override {}
721 Item *truth_transformer(THD *, Bool_test) override;
722
723 float get_filtering_effect(THD *thd, table_map filter_for_table,
724 table_map read_tables,
725 const MY_BITMAP *fields_to_ignore,
726 double rows_in_table) override;
727};
728
730 public:
732 Item_func_not(const POS &pos, Item *a) : Item_bool_func(pos, a) {}
733
734 longlong val_int() override;
735 enum Functype functype() const override { return NOT_FUNC; }
736 const char *func_name() const override { return "not"; }
737 Item *truth_transformer(THD *, Bool_test) override;
738 void print(const THD *thd, String *str,
739 enum_query_type query_type) const override;
740
741 float get_filtering_effect(THD *thd, table_map filter_for_table,
742 table_map read_tables,
743 const MY_BITMAP *fields_to_ignore,
744 double rows_in_table) override;
745};
746
747/**
748 Wrapper class when MATCH function is used in WHERE clause.
749 The MATCH clause can be used as a function returning a floating point value
750 in the SELECT list or in the WHERE clause. However, it may also be used as
751 a boolean function in the WHERE clause, where it has different semantics than
752 when used together with a comparison operator. With a comparison operator,
753 the match operation is performed with ranking. To preserve this behavior,
754 the Item_func_match object is wrapped inside an object of class
755 Item_func_match_predicate, which effectively transforms the function into
756 a predicate. The overridden functions implemented in this class generally
757 forward all evaluation to the underlying object.
758*/
760 public:
762
763 longlong val_int() override;
764 enum Functype functype() const override { return MATCH_FUNC; }
765 const char *func_name() const override { return "match"; }
766 void print(const THD *thd, String *str,
767 enum_query_type query_type) const override {
768 args[0]->print(thd, str, query_type);
769 }
770
771 float get_filtering_effect(THD *thd, table_map filter_for_table,
772 table_map read_tables,
773 const MY_BITMAP *fields_to_ignore,
774 double rows_in_table) override {
775 return args[0]->get_filtering_effect(thd, filter_for_table, read_tables,
776 fields_to_ignore, rows_in_table);
777 }
778};
780class JOIN;
781
782/*
783 trigcond<param>(arg) ::= param? arg : true
784
785 The class Item_func_trig_cond is used for guarded predicates
786 which are employed only for internal purposes.
787 A guarded predicate is an object consisting of an a regular or
788 a guarded predicate P and a pointer to a boolean guard variable g.
789 A guarded predicate P/g is evaluated to true if the value of the
790 guard g is false, otherwise it is evaluated to the same value that
791 the predicate P: val(P/g)= g ? val(P):true.
792 Guarded predicates allow us to include predicates into a conjunction
793 conditionally. Currently they are utilized for pushed down predicates
794 in queries with outer join operations.
795
796 In the future, probably, it makes sense to extend this class to
797 the objects consisting of three elements: a predicate P, a pointer
798 to a variable g and a firing value s with following evaluation
799 rule: val(P/g,s)= g==s? val(P) : true. It will allow us to build only
800 one item for the objects of the form P/g1/g2...
801
802 Objects of this class are built only for query execution after
803 the execution plan has been already selected. That's why this
804 class needs only val_int out of generic methods.
805
806 Current uses of Item_func_trig_cond objects:
807 - To wrap selection conditions when executing outer joins
808 - To wrap condition that is pushed down into subquery
809*/
810
812 public:
814 /**
815 This trigger type deactivates join conditions when a row has been
816 NULL-complemented. For example, in t1 LEFT JOIN t2, the join condition
817 can be tested on t2's row only if that row is not NULL-complemented.
818 */
820
821 /**
822 This trigger type deactivates predicated from WHERE condition when no
823 row satisfying the join condition has been found. For Example, in t1
824 LEFT JOIN t2, the where condition pushed to t2 can be tested only after
825 at least one t2 row has been produced, which may be a NULL-complemented
826 row.
827 */
829
830 /**
831 In IN->EXISTS subquery transformation, new predicates are added:
832 WHERE inner_field=outer_field OR inner_field IS NULL,
833 as well as
834 HAVING inner_field IS NOT NULL,
835 are disabled if outer_field is a NULL value
836 */
838 };
839
840 private:
841 /** Pointer to trigger variable */
842 bool *trig_var;
843 /// Optional: JOIN of table which is the source of trig_var
844 const JOIN *m_join;
845 /// Optional: if join!=NULL: index of table
847 /** Type of trig_var; for printing */
849
850 public:
851 /**
852 @param a the item for @<condition@>
853 @param f pointer to trigger variable
854 @param join if a table's property is the source of 'f', JOIN
855 which owns this table; NULL otherwise.
856 @param idx if join!=NULL: index of this table in the
857 JOIN_TAB/QEP_TAB array. NO_PLAN_IDX otherwise.
858 @param trig_type_arg type of 'f'
859 */
861 enum_trig_type trig_type_arg)
862 : Item_bool_func(a),
863 trig_var(f),
864 m_join(join),
865 m_idx(idx),
866 trig_type(trig_type_arg) {}
867 longlong val_int() override;
868 enum Functype functype() const override { return TRIG_COND_FUNC; }
869 /// '@<if@>', to distinguish from the if() SQL function
870 const char *func_name() const override { return "<if>"; }
871 /// Get range of inner tables spanned by associated outer join operation
872 void get_table_range(Table_ref **first_table, Table_ref **last_table) const;
873 /// Get table_map of inner tables spanned by associated outer join operation
875 bool fix_fields(THD *thd, Item **ref) override {
876 if (Item_bool_func::fix_fields(thd, ref)) return true;
878 return false;
879 }
882 assert(m_join != nullptr);
883 // Make this function dependent on the inner tables
885 } else if (trig_type == OUTER_FIELD_IS_NOT_NULL) {
887 }
888 }
889 void update_used_tables() override {
892 }
893 void fix_after_pullout(Query_block *parent_query_block,
894 Query_block *removed_query_block) override {
895 Item_bool_func::fix_after_pullout(parent_query_block, removed_query_block);
897 }
898 const JOIN *get_join() const { return m_join; }
899 enum enum_trig_type get_trig_type() const { return trig_type; }
900 bool *get_trig_var() { return trig_var; }
902 void print(const THD *thd, String *str,
903 enum_query_type query_type) const override;
904 plan_idx idx() const { return m_idx; }
905
906 bool contains_only_equi_join_condition() const override;
907};
908
910 /* allow to check presence of values in max/min optimization */
915
916 public:
917 bool show;
918
920 : Item_func_not(a),
924 abort_on_null(false),
925 show(false) {}
926 void apply_is_true() override { abort_on_null = true; }
927 /// Treat UNKNOWN result like FALSE because callers see no difference
928 bool ignore_unknown() const { return abort_on_null; }
929 longlong val_int() override;
930 enum Functype functype() const override { return NOT_ALL_FUNC; }
931 const char *func_name() const override { return "<not>"; }
932 void print(const THD *thd, String *str,
933 enum_query_type query_type) const override;
936 void set_subselect(Item_subselect *item) { subselect = item; }
937 table_map not_null_tables() const override {
938 /*
939 See handling of not_null_tables_cache in
940 Item_in_optimizer::fix_fields().
941
942 This item is the result of a transformation from an ALL clause
943 such as
944 left-expr < ALL(subquery)
945 into
946 <not>(left-expr >= ANY(subquery)
947
948 An inequality usually rejects NULLs from both operands, so the
949 not_null_tables() of the inequality is the union of the
950 null-rejecting tables of both operands. However, since this is a
951 transformed ALL clause that should return true if the subquery
952 is empty (even if left-expr is NULL), it is not null rejecting
953 for left-expr. The not null tables mask for left-expr should be
954 removed, leaving only the null-rejecting tables of the
955 subquery. Item_subselect::not_null_tables() always returns 0 (no
956 null-rejecting tables). Therefore, always return 0.
957 */
958 return 0;
959 }
961 Item *truth_transformer(THD *, Bool_test) override;
962};
963
965 public:
967 longlong val_int() override;
968 const char *func_name() const override { return "<nop>"; }
970 Item *truth_transformer(THD *, Bool_test) override;
971};
972
973/**
974 Base class for the equality comparison operators = and <=>.
975
976 Both of these operators can be used to construct a key for a hash join, as
977 both represent an equality, only differing in how NULL values are handled. The
978 common code for constructing hash join keys is located in this class.
979*/
981 protected:
983 Item_eq_base(const POS &pos, Item *a, Item *b)
984 : Item_func_comparison(pos, a, b) {}
985
986 public:
987 bool contains_only_equi_join_condition() const final;
988
989 /// Read the value from the join condition, and append it to the output vector
990 /// "join_key_buffer". The function will determine which side of the condition
991 /// to read the value from by using the bitmap "tables".
992 ///
993 /// @param thd the thread handler
994 /// @param tables a bitmap that marks the tables that are involved in the join
995 /// @param join_condition an instance containing the join condition together
996 /// with some pre-calculated values
997 /// @param[out] join_key_buffer a buffer where the value from the join
998 /// condition will be appended
999 /// @param is_multi_column_key true if the hash join key has multiple columns
1000 /// (that is, the hash join condition is a conjunction)
1001 ///
1002 /// @returns true if this is an ordinary equality (=) predicate and the value
1003 /// evaluated to NULL, or false otherwise.
1005 const HashJoinCondition &join_condition,
1006 bool is_multi_column_key,
1007 String *join_key_buffer) const;
1008
1009 /// Wrap the argument in a typecast, if needed.
1010 ///
1011 /// When computing a hash of the join value during a hash join, we want to
1012 /// create a hash value that is memcmp-able. This is quite straightforward
1013 /// for most data types, but it can be tricky for some types. For the
1014 /// straightforward cases, this function just returns the argument it was
1015 /// given in. For the complex cases, the function returns the given argument,
1016 /// wrapped in a typecast node. Which typecast node it is wrapped in is
1017 /// determined by the comparison context of this equality condition. The
1018 /// comparison context is given by the member "cmp"; a comparator class that
1019 /// is set up during query resolving.
1020 ///
1021 /// @param mem_root the MEM_ROOT where the typecast node is allocated
1022 /// @param argument the argument that we might wrap in a typecast. This is
1023 /// either the left or the right side of the Item_eq_base
1024 ///
1025 /// @returns either the argument it was given, or the argument wrapped in a
1026 /// typecast
1027 Item *create_cast_if_needed(MEM_ROOT *mem_root, Item *argument) const;
1028
1029 /// If this equality originally came from a multi-equality, this documents
1030 /// which one it came from (otherwise nullptr). It is used during planning:
1031 /// For selectivity estimates and for not pushing down the same multi-equality
1032 /// to the same join more than once (see IsBadJoinForCondition()).
1033 ///
1034 /// This is used only in the hypergraph optimizer; the pre-hypergraph
1035 /// optimizer uses COND_EQUAL to find this instead.
1036 ///
1037 /// It is always nullptr in Item_func_equal objects, as such objects are never
1038 /// created from multiple equalities.
1040};
1041
1042/**
1043 Implements the comparison operator equals (=)
1044*/
1045class Item_func_eq final : public Item_eq_base {
1046 public:
1048 Item_func_eq(const POS &pos, Item *a, Item *b) : Item_eq_base(pos, a, b) {}
1049 longlong val_int() override;
1050 enum Functype functype() const override { return EQ_FUNC; }
1051 enum Functype rev_functype() const override { return EQ_FUNC; }
1052 cond_result eq_cmp_result() const override { return COND_TRUE; }
1053 const char *func_name() const override { return "="; }
1054 Item *negated_item() override;
1055 bool equality_substitution_analyzer(uchar **) override { return true; }
1057 bool gc_subst_analyzer(uchar **) override { return true; }
1058
1059 float get_filtering_effect(THD *thd, table_map filter_for_table,
1060 table_map read_tables,
1061 const MY_BITMAP *fields_to_ignore,
1062 double rows_in_table) override;
1063
1064 /// See if this is a condition where any of the arguments refers to a field
1065 /// that is outside the bits marked by 'left_side_tables' and
1066 /// 'right_side_tables'.
1067 ///
1068 /// This is a situation that can happen during equality propagation in the
1069 /// optimization phase. Consider the following query:
1070 ///
1071 /// SELECT * FROM t1 LEFT JOIN
1072 /// (t2 LEFT JOIN t3 ON t3.i = t2.i) ON t2.i = t1.i;
1073 ///
1074 /// The optimizer will see that t1.i = t2.i = t3.i. Furthermore, it will
1075 /// replace one side of this condition with a field from a table that is as
1076 /// early in the join order as possible. However, this will break queries
1077 /// executed in the iterator executor. The above query will end up with
1078 /// something like this after optimization:
1079 ///
1080 /// Left hash join <--- t1.i = t2.i
1081 /// | |
1082 /// t1 Left hash join <--- t1.i = t3.i
1083 /// | |
1084 /// t2 t3
1085 ///
1086 /// Note that 't2.i = t3.i' has been rewritten to 't1.i = t3.i'. When
1087 /// evaluating the join between t2 and t3, t1 is outside our reach!
1088 /// To overcome this, we must reverse the changes done by the equality
1089 /// propagation. It is possible to do so because during equality propagation,
1090 /// we save a list of all of the fields that were considered equal.
1091 /// If we are asked to replace ("replace" set to true), arguments of this
1092 /// function are replaced with an equal field. If we are not replacing, we
1093 /// set "found" to "true" if an equal field is found, "false" otherwise.
1095 table_map right_side_tables,
1096 bool replace, bool *found);
1097};
1098
1099/**
1100 The <=> operator evaluates the same as
1101
1102 a IS NULL || b IS NULL ? a IS NULL == b IS NULL : a = b
1103
1104 a <=> b is equivalent to the standard operation a IS NOT DISTINCT FROM b.
1105
1106 Notice that the result is TRUE or FALSE, and never UNKNOWN.
1107*/
1108class Item_func_equal final : public Item_eq_base {
1109 public:
1111 null_on_null = false;
1112 }
1113 Item_func_equal(const POS &pos, Item *a, Item *b) : Item_eq_base(pos, a, b) {
1114 null_on_null = false;
1115 }
1116 // Needs null value propagated to parent, even though operator is not nullable
1117 bool set_cmp_func() override {
1118 return cmp.set_cmp_func(this, args, args + 1, true);
1119 }
1120 longlong val_int() override;
1121 bool resolve_type(THD *thd) override;
1122 enum Functype functype() const override { return EQUAL_FUNC; }
1123 enum Functype rev_functype() const override { return EQUAL_FUNC; }
1124 cond_result eq_cmp_result() const override { return COND_TRUE; }
1125 const char *func_name() const override { return "<=>"; }
1126 Item *truth_transformer(THD *, Bool_test) override { return nullptr; }
1127 bool is_null() override { return false; }
1128
1129 float get_filtering_effect(THD *thd, table_map filter_for_table,
1130 table_map read_tables,
1131 const MY_BITMAP *fields_to_ignore,
1132 double rows_in_table) override;
1133};
1134
1135/**
1136 Implements the comparison operator greater than or equals (>=)
1137*/
1139 public:
1141 longlong val_int() override;
1142 enum Functype functype() const override { return GE_FUNC; }
1143 enum Functype rev_functype() const override { return LE_FUNC; }
1144 cond_result eq_cmp_result() const override { return COND_TRUE; }
1145 const char *func_name() const override { return ">="; }
1146 Item *negated_item() override;
1147 bool gc_subst_analyzer(uchar **) override { return true; }
1148
1149 float get_filtering_effect(THD *thd, table_map filter_for_table,
1150 table_map read_tables,
1151 const MY_BITMAP *fields_to_ignore,
1152 double rows_in_table) override;
1153};
1154
1155/**
1156 Implements the comparison operator greater than (>)
1157*/
1159 public:
1161 longlong val_int() override;
1162 enum Functype functype() const override { return GT_FUNC; }
1163 enum Functype rev_functype() const override { return LT_FUNC; }
1164 cond_result eq_cmp_result() const override { return COND_FALSE; }
1165 const char *func_name() const override { return ">"; }
1166 Item *negated_item() override;
1167 bool gc_subst_analyzer(uchar **) override { return true; }
1168
1169 float get_filtering_effect(THD *thd, table_map filter_for_table,
1170 table_map read_tables,
1171 const MY_BITMAP *fields_to_ignore,
1172 double rows_in_table) override;
1173};
1174
1175/**
1176 Implements the comparison operator less than or equals (<=)
1177*/
1179 public:
1181 longlong val_int() override;
1182 enum Functype functype() const override { return LE_FUNC; }
1183 enum Functype rev_functype() const override { return GE_FUNC; }
1184 cond_result eq_cmp_result() const override { return COND_TRUE; }
1185 const char *func_name() const override { return "<="; }
1186 Item *negated_item() override;
1187 bool gc_subst_analyzer(uchar **) override { return true; }
1188
1189 float get_filtering_effect(THD *thd, table_map filter_for_table,
1190 table_map read_tables,
1191 const MY_BITMAP *fields_to_ignore,
1192 double rows_in_table) override;
1193};
1194
1195/**
1196 Internal function used by subquery to derived transformation to check
1197 if a subquery is scalar. We model it to check if the count is greater than
1198 1 using Item_func_gt.
1199*/
1200
1202 public:
1204 longlong val_int() override;
1205 const char *func_name() const override { return "reject_if"; }
1206 /// Redefine to avoid pushing into derived table
1207 bool is_valid_for_pushdown(uchar *arg [[maybe_unused]]) override {
1208 return true;
1209 }
1210 float get_filtering_effect(THD *thd, table_map filter_for_table,
1211 table_map read_tables,
1212 const MY_BITMAP *fields_to_ignore,
1213 double rows_in_table) override;
1214 /**
1215 We add RAND_TABLE_BIT to prevent moving this item from the JOIN condition:
1216 it might raise an error too early: only if the join condition succeeds is
1217 it relevant and should be evaluated. Cf.
1218 Query_block::decorrelate_derived_scalar_subquery_post
1219
1220 @return Always RAND_TABLE_BIT
1221 */
1223 return RAND_TABLE_BIT;
1224 }
1225};
1226
1227/**
1228 Implements the comparison operator less than (<)
1229*/
1231 public:
1233 longlong val_int() override;
1234 enum Functype functype() const override { return LT_FUNC; }
1235 enum Functype rev_functype() const override { return GT_FUNC; }
1236 cond_result eq_cmp_result() const override { return COND_FALSE; }
1237 const char *func_name() const override { return "<"; }
1238 Item *negated_item() override;
1239 bool gc_subst_analyzer(uchar **) override { return true; }
1240
1241 float get_filtering_effect(THD *thd, table_map filter_for_table,
1242 table_map read_tables,
1243 const MY_BITMAP *fields_to_ignore,
1244 double rows_in_table) override;
1245};
1246
1247/**
1248 Implements the comparison operator not equals (<>)
1249*/
1251 public:
1253 longlong val_int() override;
1254 enum Functype functype() const override { return NE_FUNC; }
1255 enum Functype rev_functype() const override { return NE_FUNC; }
1256 cond_result eq_cmp_result() const override { return COND_FALSE; }
1257 optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
1258 const char *func_name() const override { return "<>"; }
1259 Item *negated_item() override;
1260
1261 float get_filtering_effect(THD *thd, table_map filter_for_table,
1262 table_map read_tables,
1263 const MY_BITMAP *fields_to_ignore,
1264 double rows_in_table) override;
1265};
1266
1267/*
1268 The class Item_func_opt_neg is defined to factor out the functionality
1269 common for the classes Item_func_between and Item_func_in. The objects
1270 of these classes can express predicates or their negations.
1271 The alternative approach would be to create pairs Item_func_between,
1272 Item_func_notbetween and Item_func_in, Item_func_notin.
1273
1274*/
1275
1277 public:
1278 bool negated; /* <=> the item represents NOT <func> */
1279 bool pred_level; /* <=> [NOT] <func> is used on a predicate level */
1280 public:
1281 Item_func_opt_neg(const POS &pos, Item *a, Item *b, Item *c, bool is_negation)
1282 : Item_int_func(pos, a, b, c), negated(false), pred_level(false) {
1283 if (is_negation) negate();
1284 }
1285 Item_func_opt_neg(const POS &pos, PT_item_list *list, bool is_negation)
1286 : Item_int_func(pos, list), negated(false), pred_level(false) {
1287 if (is_negation) negate();
1288 }
1289
1290 public:
1291 inline void negate() { negated = !negated; }
1292 inline void apply_is_true() override { pred_level = true; }
1293 bool ignore_unknown() const { return pred_level; }
1295 if (test != BOOL_NEGATED) return nullptr;
1296 negated = !negated;
1297 return this;
1298 }
1299 bool eq(const Item *item, bool binary_cmp) const override;
1300 bool subst_argument_checker(uchar **) override { return true; }
1301};
1302
1305
1306 public:
1308 String value0, value1, value2;
1309 /* true <=> arguments will be compared as dates. */
1313
1314 /* Comparators used for DATE/DATETIME comparison. */
1316 Item_func_between(const POS &pos, Item *a, Item *b, Item *c, bool is_negation)
1317 : Item_func_opt_neg(pos, a, b, c, is_negation),
1318 compare_as_dates_with_strings(false),
1319 compare_as_temporal_dates(false),
1320 compare_as_temporal_times(false) {}
1321 longlong val_int() override;
1322 optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
1323 enum Functype functype() const override { return BETWEEN; }
1324 const char *func_name() const override { return "between"; }
1325 bool fix_fields(THD *, Item **) override;
1326 void fix_after_pullout(Query_block *parent_query_block,
1327 Query_block *removed_query_block) override;
1328 bool resolve_type(THD *) override;
1329 void print(const THD *thd, String *str,
1330 enum_query_type query_type) const override;
1331 bool is_bool_func() const override { return true; }
1332 const CHARSET_INFO *compare_collation() const override {
1333 return cmp_collation.collation;
1334 }
1335 uint decimal_precision() const override { return 1; }
1336 bool gc_subst_analyzer(uchar **) override { return true; }
1337
1338 float get_filtering_effect(THD *thd, table_map filter_for_table,
1339 table_map read_tables,
1340 const MY_BITMAP *fields_to_ignore,
1341 double rows_in_table) override;
1342 void update_used_tables() override;
1343
1345 // not_null_tables_cache == union(T1(e),T1(e1),T1(e2))
1346 if (pred_level && !negated) return;
1347
1348 /// not_null_tables_cache == union(T1(e), intersection(T1(e1),T1(e2)))
1350 args[0]->not_null_tables() |
1351 (args[1]->not_null_tables() & args[2]->not_null_tables());
1352 }
1353};
1354
1355class Item_func_strcmp final : public Item_bool_func2 {
1356 public:
1357 Item_func_strcmp(const POS &pos, Item *a, Item *b)
1358 : Item_bool_func2(pos, a, b) {}
1359 longlong val_int() override;
1360 optimize_type select_optimize(const THD *) override { return OPTIMIZE_NONE; }
1361 const char *func_name() const override { return "strcmp"; }
1362 enum Functype functype() const override { return STRCMP_FUNC; }
1363
1364 void print(const THD *thd, String *str,
1365 enum_query_type query_type) const override {
1366 Item_func::print(thd, str, query_type);
1367 }
1368 // We derive (indirectly) from Item_bool_func, but this is not a true boolean.
1369 // Override length and unsigned_flag set by set_data_type_bool().
1370 bool resolve_type(THD *thd) override {
1371 if (Item_bool_func2::resolve_type(thd)) return true;
1372 fix_char_length(2); // returns "1" or "0" or "-1"
1373 unsigned_flag = false;
1374 return false;
1375 }
1376};
1377
1380 double dbl;
1382};
1383
1384class Item_func_interval final : public Item_int_func {
1386
1390
1391 public:
1393 Item *expr2, class PT_item_list *opt_expr_list = nullptr)
1394 : super(pos, alloc_row(pos, mem_root, expr1, expr2, opt_expr_list)),
1395 row(down_cast<Item_row *>(args[0])),
1396 intervals(nullptr) {
1397 allowed_arg_cols = 0; // Fetch this value from first argument
1398 }
1399
1400 bool itemize(Parse_context *pc, Item **res) override;
1401 longlong val_int() override;
1402 bool resolve_type(THD *) override;
1403 const char *func_name() const override { return "interval"; }
1404 uint decimal_precision() const override { return 2; }
1405 void print(const THD *thd, String *str,
1406 enum_query_type query_type) const override;
1407 void update_used_tables() override;
1408
1409 private:
1410 // Runs in CTOR init list, cannot access *this as Item_func_interval
1411 static Item_row *alloc_row(const POS &pos, MEM_ROOT *mem_root, Item *expr1,
1412 Item *expr2, class PT_item_list *opt_expr_list);
1413};
1414
1416 protected:
1417 Item_func_coalesce(const POS &pos, Item *a, Item *b)
1418 : Item_func_numhybrid(pos, a, b) {
1419 null_on_null = false;
1420 }
1422 null_on_null = false;
1423 }
1425
1426 public:
1428 : Item_func_numhybrid(pos, list) {
1429 null_on_null = false;
1430 }
1432 return MYSQL_TYPE_VARCHAR;
1433 }
1435 null_on_null = false;
1436 }
1437 TYPELIB *get_typelib() const override;
1438 double real_op() override;
1439 longlong int_op() override;
1440 String *str_op(String *) override;
1441 /**
1442 Get the result of COALESCE as a JSON value.
1443 @param[in,out] wr the result value holder
1444 */
1445 bool val_json(Json_wrapper *wr) override;
1446 bool date_op(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
1447 bool time_op(MYSQL_TIME *ltime) override;
1448 my_decimal *decimal_op(my_decimal *) override;
1449 bool resolve_type(THD *thd) override;
1450 bool resolve_type_inner(THD *thd) override;
1451 void set_numeric_type() override {}
1452 enum Item_result result_type() const override { return hybrid_type; }
1453 const char *func_name() const override { return "coalesce"; }
1454 enum Functype functype() const override { return COALESCE_FUNC; }
1455};
1456
1458 protected:
1460
1461 public:
1462 Item_func_ifnull(const POS &pos, Item *a, Item *b)
1463 : Item_func_coalesce(pos, a, b) {}
1464 double real_op() override;
1465 longlong int_op() override;
1466 String *str_op(String *str) override;
1467 bool date_op(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
1468 bool time_op(MYSQL_TIME *ltime) override;
1469 my_decimal *decimal_op(my_decimal *) override;
1470 bool val_json(Json_wrapper *result) override;
1471 const char *func_name() const override { return "ifnull"; }
1472 Field *tmp_table_field(TABLE *table) override;
1473};
1474
1475/**
1476 ANY_VALUE(expr) is like expr except that it is not checked by
1477 aggregate_check logic. It serves as a solution for users who want to
1478 bypass this logic.
1479*/
1481 public:
1482 Item_func_any_value(const POS &pos, Item *a) : Item_func_coalesce(pos, a) {}
1484 const char *func_name() const override { return "any_value"; }
1485 bool aggregate_check_group(uchar *arg) override;
1486 bool aggregate_check_distinct(uchar *arg) override;
1487};
1488
1489class Item_func_if final : public Item_func {
1491
1492 public:
1494 : Item_func(a, b, c), cached_result_type(INT_RESULT) {
1495 null_on_null = false;
1496 }
1497 Item_func_if(const POS &pos, Item *a, Item *b, Item *c)
1498 : Item_func(pos, a, b, c), cached_result_type(INT_RESULT) {
1499 null_on_null = false;
1500 }
1501
1502 double val_real() override;
1503 longlong val_int() override;
1504 String *val_str(String *str) override;
1505 my_decimal *val_decimal(my_decimal *) override;
1506 bool val_json(Json_wrapper *wr) override;
1507 bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
1508 bool get_time(MYSQL_TIME *ltime) override;
1509 enum Item_result result_type() const override { return cached_result_type; }
1510 bool fix_fields(THD *, Item **) override;
1512 return MYSQL_TYPE_VARCHAR;
1513 }
1514 bool resolve_type(THD *thd) override;
1515 bool resolve_type_inner(THD *thd) override;
1516 void fix_after_pullout(Query_block *parent_query_block,
1517 Query_block *removed_query_block) override;
1518 TYPELIB *get_typelib() const override;
1519 const char *func_name() const override { return "if"; }
1520 enum Functype functype() const override { return IF_FUNC; }
1521 void update_used_tables() override;
1522
1523 ///< T1(IF(e,e1,e2)) = intersection(T1(e1),T1(e2))
1526 (args[1]->not_null_tables() & args[2]->not_null_tables());
1527 }
1528};
1529
1530class Item_func_nullif final : public Item_bool_func2 {
1532
1533 public:
1534 Item_func_nullif(const POS &pos, Item *a, Item *b)
1535 : Item_bool_func2(pos, a, b), cached_result_type(INT_RESULT) {
1536 null_on_null = false;
1537 }
1538 double val_real() override;
1539 longlong val_int() override;
1540 String *val_str(String *str) override;
1541 my_decimal *val_decimal(my_decimal *) override;
1542 bool val_json(Json_wrapper *wr) override;
1543 Item_result result_type() const override { return cached_result_type; }
1545 return MYSQL_TYPE_VARCHAR;
1546 }
1547 bool resolve_type(THD *thd) override;
1548 bool resolve_type_inner(THD *thd) override;
1549 const char *func_name() const override { return "nullif"; }
1550 enum Functype functype() const override { return NULLIF_FUNC; }
1551
1552 // No, we should NOT inherit from Item_bool_func2
1553 uint decimal_precision() const override { return Item::decimal_precision(); }
1554
1555 void print(const THD *thd, String *str,
1556 enum_query_type query_type) const override {
1557 Item_func::print(thd, str, query_type);
1558 }
1559
1560 bool is_null() override;
1561 /**
1562 This is a workaround for the broken inheritance hierarchy: this should
1563 inherit from Item_func instead of Item_bool_func2
1564 */
1565 bool is_bool_func() const override { return false; }
1566};
1567
1568/* Functions to handle the optimized IN */
1569
1570/* A vector of values of some type */
1571
1573 private:
1574 const uint m_size; ///< Size of the vector
1575 public:
1576 uint m_used_size{0}; ///< The actual size of the vector (NULL may be ignored)
1577
1578 /**
1579 See Item_func_in::resolve_type() for why we need both
1580 count and used_count.
1581 */
1582 explicit in_vector(uint elements) : m_size(elements) {}
1583
1584 virtual ~in_vector() = default;
1585
1586 /**
1587 Calls item->val_int() or item->val_str() etc.
1588 and then does binary_search if the value is non-null.
1589 @param item to evaluate, and lookup in the IN-list.
1590 @return true if evaluated value of the item was found.
1591 */
1592 virtual bool find_item(Item *item) = 0;
1593
1594 /**
1595 Create an instance of Item_{type} (e.g. Item_decimal) constant object
1596 which type allows it to hold an element of this vector without any
1597 conversions.
1598 The purpose of this function is to be able to get elements of this
1599 vector in form of Item_xxx constants without creating Item_xxx object
1600 for every array element you get (i.e. this implements "FlyWeight" pattern)
1601
1602 @param mem_root Where to allocate the Item.
1603 */
1605
1606 /**
1607 Store the value at position #pos into provided item object
1608
1609 @param pos Index of value to store
1610 @param item Constant item to store value into. The item must be of the same
1611 type that create_item() returns.
1612 */
1613 virtual void value_to_item(uint pos, Item_basic_constant *item) const = 0;
1614
1615 /** Compare values number pos1 and pos2 for equality */
1616 virtual bool compare_elems(uint pos1, uint pos2) const = 0;
1617
1618 virtual bool is_row_result() const { return false; }
1619
1620 /**
1621 Fill the vector by evaluating the items passed as arguments.
1622 Note that null values are skipped so the vector may end up containing
1623 fewer elements than the number of items.
1624 The vector is sorted so that it can be used for binary search.
1625
1626 @param items Items to evaluate
1627 @param item_count Number of items
1628
1629 @return true if any null values was found, false otherwise.
1630 */
1631 bool fill(Item **items, uint item_count);
1632
1633 private:
1634 virtual void set(uint pos, Item *item) = 0;
1635
1636 /// Sort the IN-list array, so we can do efficient lookup with binary_search.
1637 virtual void sort_array() = 0;
1638};
1639
1640class in_string final : public in_vector {
1644 // String objects are not sortable, sort pointers instead.
1647
1648 public:
1649 in_string(MEM_ROOT *mem_root, uint elements, const CHARSET_INFO *cs);
1651 return new (mem_root) Item_string(collation);
1652 }
1653 void value_to_item(uint pos, Item_basic_constant *item) const override {
1654 item->set_str_value(base_pointers[pos]);
1655 }
1656 bool find_item(Item *item) override;
1657 bool compare_elems(uint pos1, uint pos2) const override;
1658
1659 private:
1660 void set(uint pos, Item *item) override;
1661 void sort_array() override;
1662};
1663
1664class in_longlong : public in_vector {
1665 public:
1669 };
1670
1671 protected:
1673
1674 public:
1676 : in_vector(elements), base(mem_root, elements) {}
1678 /*
1679 We've created a signed INT, this may not be correct in the
1680 general case (see BUG#19342).
1681 */
1682 return new (mem_root) Item_int(0LL);
1683 }
1684 void value_to_item(uint pos, Item_basic_constant *item) const override {
1685 down_cast<Item_int *>(item)->value = base[pos].val;
1686 item->unsigned_flag = base[pos].unsigned_flag;
1687 }
1688 bool find_item(Item *item) override;
1689 bool compare_elems(uint pos1, uint pos2) const override;
1690
1691 private:
1692 void set(uint pos, Item *item) override { val_item(item, &base[pos]); }
1693 void sort_array() override;
1694 virtual void val_item(Item *item, packed_longlong *result);
1695};
1696
1698 public:
1700 : in_longlong(mem_root, elements) {}
1702 return new (mem_root) Item_temporal(MYSQL_TYPE_DATETIME, 0LL);
1703 }
1704
1705 private:
1706 void val_item(Item *item, packed_longlong *result) override;
1707};
1708
1709class in_time_as_longlong final : public in_longlong {
1710 public:
1712 : in_longlong(mem_root, elements) {}
1714 return new (mem_root) Item_temporal(MYSQL_TYPE_TIME, 0LL);
1715 }
1716
1717 private:
1718 void val_item(Item *item, packed_longlong *result) override;
1719};
1720
1721/*
1722 Class to represent a vector of constant DATE/DATETIME values.
1723 Values are obtained with help of the get_datetime_value() function.
1724*/
1725class in_datetime final : public in_longlong {
1726 /// An item used to issue warnings.
1728
1729 public:
1730 in_datetime(MEM_ROOT *mem_root, Item *warn_item_arg, uint elements)
1731 : in_longlong(mem_root, elements), warn_item(warn_item_arg) {}
1733 return new (mem_root) Item_temporal(MYSQL_TYPE_DATETIME, 0LL);
1734 }
1735
1736 private:
1737 void set(uint pos, Item *item) override;
1738 void val_item(Item *item, packed_longlong *result) override;
1739};
1740
1741class in_double final : public in_vector {
1743
1744 public:
1746 : in_vector(elements), base(mem_root, elements) {}
1748 return new (mem_root) Item_float(0.0, 0);
1749 }
1750 void value_to_item(uint pos, Item_basic_constant *item) const override {
1751 down_cast<Item_float *>(item)->value = base[pos];
1752 }
1753 bool find_item(Item *item) override;
1754 bool compare_elems(uint pos1, uint pos2) const override;
1755
1756 private:
1757 void set(uint pos, Item *item) override;
1758 void sort_array() override;
1759};
1760
1761class in_decimal final : public in_vector {
1763
1764 public:
1766 : in_vector(elements), base(mem_root, elements) {}
1768 return new (mem_root) Item_decimal(0, false);
1769 }
1770 void value_to_item(uint pos, Item_basic_constant *item) const override {
1771 down_cast<Item_decimal *>(item)->set_decimal_value(&base[pos]);
1772 }
1773 bool find_item(Item *item) override;
1774 bool compare_elems(uint pos1, uint pos2) const override;
1775
1776 private:
1777 void set(uint pos, Item *item) override;
1778 void sort_array() override;
1779};
1780
1781/*
1782** Classes for easy comparing of non const items
1783*/
1784
1786 public:
1787 cmp_item() = default;
1788 virtual ~cmp_item() = default;
1789 /**
1790 Allocate comparator objects for each value object, based on the template
1791 comparator objects. Only implemented for derived class cmp_item_row.
1792
1793 @param mem_root mem_root for allocation.
1794 @param tmpl The template item object.
1795 @param arg The value item.
1796
1797 @returns false if success, true if error.
1798 */
1799 virtual bool allocate_value_comparators(MEM_ROOT *mem_root, cmp_item *tmpl,
1800 Item *arg);
1801 virtual void store_value(Item *item) = 0;
1802 /**
1803 @returns result (true, false or UNKNOWN) of
1804 "stored argument's value <> item's value"
1805 */
1806 virtual int cmp(Item *item) = 0;
1807 // for optimized IN with row
1808 virtual int compare(const cmp_item *item) const = 0;
1809
1810 /**
1811 Create an appropriate comparator for the given type.
1812
1813 @param thd Session handle.
1814 @param result_type Used to find the appropriate comparator.
1815 @param item Item object used to distinguish temporal types.
1816 @param cs Charset
1817
1818 @returns new cmp_item_xxx object, or nullptr if error.
1819 */
1820 static cmp_item *new_comparator(THD *thd, Item_result result_type, Item *item,
1821 const CHARSET_INFO *cs);
1822 virtual cmp_item *make_same() = 0;
1823 virtual void store_value_by_template(cmp_item *, Item *item) {
1824 store_value(item);
1825 }
1826};
1827
1828/// cmp_item which stores a scalar (i.e. non-ROW).
1830 protected:
1831 bool m_null_value; ///< If stored value is NULL
1832 void set_null_value(bool nv) { m_null_value = nv; }
1833};
1834
1835class cmp_item_string final : public cmp_item_scalar {
1836 private:
1840
1841 public:
1842 cmp_item_string(const CHARSET_INFO *cs) : value(cs), cmp_charset(cs) {}
1843
1844 int compare(const cmp_item *ci) const override {
1845 const cmp_item_string *l_cmp = down_cast<const cmp_item_string *>(ci);
1846 return sortcmp(value_res, l_cmp->value_res, cmp_charset);
1847 }
1848
1849 void store_value(Item *item) override {
1850 String *res = eval_string_arg(cmp_charset, item, &value);
1851 if (res && (res != &value || !res->is_alloced())) {
1852 // 'res' may point in item's transient internal data, so make a copy
1853 value.copy(*res);
1854 }
1855 value_res = &value;
1856 set_null_value(item->null_value);
1857 }
1858
1859 int cmp(Item *arg) override;
1860 cmp_item *make_same() override;
1861};
1862
1863class cmp_item_json final : public cmp_item_scalar {
1864 private:
1865 /// Cached JSON value to look up
1867 /// Cache for the value above
1869 /// String buffer
1871
1872 public:
1873 /**
1874 Construct a cmp_item_json object.
1875 @param wrapper a Json_wrapper for holding the JSON value in the comparison
1876 @param holder pre-alloced memory for creating JSON scalar values without
1877 using the heap
1878 */
1881 ~cmp_item_json() override;
1882
1883 int compare(const cmp_item *ci) const override;
1884 void store_value(Item *item) override;
1885 int cmp(Item *arg) override;
1886 cmp_item *make_same() override;
1887};
1888
1889class cmp_item_int final : public cmp_item_scalar {
1891
1892 public:
1893 void store_value(Item *item) override {
1894 value = item->val_int();
1895 set_null_value(item->null_value);
1896 }
1897 int cmp(Item *arg) override {
1898 const bool rc = value != arg->val_int();
1899 return (m_null_value || arg->null_value) ? UNKNOWN : rc;
1900 }
1901 int compare(const cmp_item *ci) const override {
1902 const cmp_item_int *l_cmp = down_cast<const cmp_item_int *>(ci);
1903 return (value < l_cmp->value) ? -1 : ((value == l_cmp->value) ? 0 : 1);
1904 }
1905 cmp_item *make_same() override;
1906};
1907
1908/*
1909 Compare items of temporal type.
1910 Values are obtained with: get_datetime_value() (DATE/DATETIME/TIMESTAMP) and
1911 get_time_value() (TIME).
1912*/
1915
1916 public:
1917 /* Item used for issuing warnings. */
1919 /// Distinguish between DATE/DATETIME/TIMESTAMP and TIME
1921
1922 cmp_item_datetime(const Item *warn_item_arg);
1923 void store_value(Item *item) override;
1924 int cmp(Item *arg) override;
1925 int compare(const cmp_item *ci) const override;
1926 cmp_item *make_same() override;
1927};
1928
1930 double value;
1931
1932 public:
1933 void store_value(Item *item) override {
1934 value = item->val_real();
1935 set_null_value(item->null_value);
1936 }
1937 int cmp(Item *arg) override {
1938 const bool rc = value != arg->val_real();
1939 return (m_null_value || arg->null_value) ? UNKNOWN : rc;
1940 }
1941 int compare(const cmp_item *ci) const override {
1942 const cmp_item_real *l_cmp = down_cast<const cmp_item_real *>(ci);
1943 return (value < l_cmp->value) ? -1 : ((value == l_cmp->value) ? 0 : 1);
1944 }
1945 cmp_item *make_same() override;
1946};
1947
1950
1951 public:
1952 void store_value(Item *item) override;
1953 int cmp(Item *arg) override;
1954 int compare(const cmp_item *c) const override;
1955 cmp_item *make_same() override;
1956};
1957
1958/**
1959 CASE ... WHEN ... THEN ... END function implementation.
1960
1961 When there is no expression between CASE and the first WHEN
1962 (the CASE expression) then this function simple checks all WHEN expressions
1963 one after another. When some WHEN expression evaluated to TRUE then the
1964 value of the corresponding THEN expression is returned.
1965
1966 When the CASE expression is specified then it is compared to each WHEN
1967 expression individually. When an equal WHEN expression is found
1968 corresponding THEN expression is returned.
1969 In order to do correct comparisons several comparators are used. One for
1970 each result type. Different result types that are used in particular
1971 CASE ... END expression are collected in the resolve_type() member
1972 function and only comparators for there result types are used.
1973*/
1974
1975class Item_func_case final : public Item_func {
1977
1978 int first_expr_num, else_expr_num;
1979 enum Item_result cached_result_type, left_result_type;
1984 cmp_item *cmp_items[5]; /* For all result types */
1986
1987 public:
1989 Item *first_expr_arg, Item *else_expr_arg)
1990 : super(pos),
1991 first_expr_num(-1),
1992 else_expr_num(-1),
1993 cached_result_type(INT_RESULT),
1994 left_result_type(INT_RESULT),
1995 case_item(nullptr) {
1996 null_on_null = false;
1997 ncases = list->size();
1998 if (first_expr_arg) {
1999 first_expr_num = list->size();
2000 list->push_back(first_expr_arg);
2001 }
2002 if (else_expr_arg) {
2003 else_expr_num = list->size();
2004 list->push_back(else_expr_arg);
2005 }
2006 set_arguments(list, true);
2007 memset(&cmp_items, 0, sizeof(cmp_items));
2008 }
2009 ~Item_func_case() override;
2010 int get_first_expr_num() const { return first_expr_num; }
2011 int get_else_expr_num() const { return else_expr_num; }
2012 double val_real() override;
2013 longlong val_int() override;
2014 String *val_str(String *) override;
2015 my_decimal *val_decimal(my_decimal *) override;
2016 bool val_json(Json_wrapper *wr) override;
2017 bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
2018 bool get_time(MYSQL_TIME *ltime) override;
2019 bool fix_fields(THD *thd, Item **ref) override;
2021 return MYSQL_TYPE_VARCHAR;
2022 }
2023 bool resolve_type(THD *thd) override;
2024 bool resolve_type_inner(THD *thd) override;
2025 TYPELIB *get_typelib() const override;
2026 enum Item_result result_type() const override { return cached_result_type; }
2027 const char *func_name() const override { return "case"; }
2028 void print(const THD *thd, String *str,
2029 enum_query_type query_type) const override;
2030 Item *find_item(String *str);
2031 const CHARSET_INFO *compare_collation() const override {
2032 return cmp_collation.collation;
2033 }
2034 enum Functype functype() const override { return CASE_FUNC; }
2035};
2036
2037/**
2038 in_expr [NOT] IN (in_value_list).
2039
2040 The current implementation distinguishes 2 cases:
2041 1) all items in in_value_list are constants and have the same
2042 result type. This case is handled by in_vector class.
2043 2) otherwise Item_func_in employs several cmp_item objects to perform
2044 comparisons of in_expr and an item from in_value_list. One cmp_item
2045 object for each result type. Different result types are collected in the
2046 resolve_type() member function by means of collect_cmp_types() function.
2047*/
2048class Item_func_in final : public Item_func_opt_neg {
2049 public:
2050 /// An array of const values, created when the bisection lookup method is used
2051 in_vector *m_const_array{nullptr};
2052 /**
2053 If there is some NULL among @<in value list@>, during a val_int() call; for
2054 example
2055 IN ( (1,(3,'col')), ... ), where 'col' is a column which evaluates to
2056 NULL.
2057 */
2058 bool have_null{false};
2059 /// Set to true when values in const array are populated
2060 bool m_populated{false};
2061
2062 private:
2063 /// Set to true if all values in IN-list are const
2064 bool m_values_are_const{true};
2065 /// Set to true if const array must be repopulated per execution.
2066 bool m_need_populate{false};
2067 /**
2068 Set to true by resolve_type() if the IN list contains a
2069 dependent subquery, in which case condition filtering will not be
2070 calculated for this item.
2071 */
2072 bool dep_subq_in_list{false};
2073 /// True until start of 2nd call to resolve_type()
2074 bool first_resolve_call{true};
2075
2077 cmp_item *cmp_items[6]; /* One cmp_item for each result type */
2079
2080 public:
2081 Item_func_in(const POS &pos, PT_item_list *list, bool is_negation)
2082 : Item_func_opt_neg(pos, list, is_negation) {
2083 memset(&cmp_items, 0, sizeof(cmp_items));
2084 allowed_arg_cols = 0; // Fetch this value from first argument
2085 }
2086 ~Item_func_in() override;
2087 longlong val_int() override;
2088 bool fix_fields(THD *, Item **) override;
2089 void fix_after_pullout(Query_block *parent_query_block,
2090 Query_block *removed_query_block) override;
2091 bool resolve_type(THD *) override;
2092 void update_used_tables() override;
2093 uint decimal_precision() const override { return 1; }
2094
2095 /**
2096 Populate values for bisection with fresh values, should be called once
2097 per execution.
2098
2099 @param thd Thread handler
2100
2101 @returns false if success, true if error
2102 */
2103 bool populate_bisection(THD *thd);
2104 void cleanup() override;
2105 optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
2106 void print(const THD *thd, String *str,
2107 enum_query_type query_type) const override;
2108 enum Functype functype() const override { return IN_FUNC; }
2109 const char *func_name() const override { return " IN "; }
2110 bool is_bool_func() const override { return true; }
2111 const CHARSET_INFO *compare_collation() const override {
2112 return cmp_collation.collation;
2113 }
2114 bool gc_subst_analyzer(uchar **) override { return true; }
2115
2116 float get_filtering_effect(THD *thd, table_map filter_for_table,
2117 table_map read_tables,
2118 const MY_BITMAP *fields_to_ignore,
2119 double rows_in_table) override;
2120
2122 // not_null_tables_cache == union(T1(e),union(T1(ei)))
2123 if (pred_level && negated) return;
2124
2126
2127 ///< not_null_tables_cache = union(T1(e),intersection(T1(ei)))
2128 Item **arg_end = args + arg_count;
2129 for (Item **arg = args + 1; arg != arg_end; arg++)
2130 not_null_tables_cache &= (*arg)->not_null_tables();
2132 }
2133
2134 private:
2135 /**
2136 Usable if @<in value list@> is made only of constants. Returns true if one
2137 of these constants contains a NULL. Example:
2138 IN ( (-5, (12,NULL)), ... ).
2139 */
2140 bool list_contains_null();
2141 /**
2142 Utility function to help calculate the total filtering effect of
2143 IN predicates. This function calculates the filtering effect from
2144 a single field (or field reference) on the left hand side of the
2145 expression.
2146
2147 @param fieldref Field (or field reference) on left hand side of
2148 IN, i.e., this function should be called for
2149 each fi in "(f1,...,fn) IN (values)"
2150 @param filter_for_table The table we are calculating filter effect for
2151 @param fields_to_ignore Fields in 'filter_for_table' that should not
2152 be part of the filter calculation. The filtering
2153 effect of these fields are already part of the
2154 calculation somehow (e.g. because there is a
2155 predicate "col = <const>", and the optimizer
2156 has decided to do ref access on 'col').
2157 @param rows_in_table The number of rows in table 'filter_for_table'
2158
2159 @return the filtering effect (between 0 and 1) 'the_field'
2160 participates with in this IN predicate.
2161 */
2162 float get_single_col_filtering_effect(Item_ident *fieldref,
2163 table_map filter_for_table,
2164 const MY_BITMAP *fields_to_ignore,
2165 double rows_in_table);
2166 void cleanup_arrays(); ///< Helper function for this common task
2167};
2168
2169class cmp_item_row : public cmp_item {
2170 cmp_item **comparators{nullptr};
2172
2173 // Only used for Mem_root_array::resize()
2174 cmp_item_row() : n(0) {}
2175
2176 friend class Mem_root_array_YY<cmp_item_row>;
2177
2178 public:
2179 cmp_item_row(THD *thd, Item *item) : n(item->cols()) {
2180 allocate_template_comparators(thd, item);
2181 }
2182 ~cmp_item_row() override;
2183
2185 : comparators(other.comparators), n(other.n) {
2186 other.comparators = nullptr;
2187 other.n = 0;
2188 }
2189
2190 bool allocate_value_comparators(MEM_ROOT *mem_root, cmp_item *tmpl,
2191 Item *arg) override;
2192 void store_value(Item *item) override;
2193 int cmp(Item *arg) override;
2194 int compare(const cmp_item *arg) const override;
2195 cmp_item *make_same() override;
2196 void store_value_by_template(cmp_item *tmpl, Item *) override;
2197
2198 private:
2199 /**
2200 Allocate comparator objects for the LHS argument to IN, used as template
2201 for the value comparators.
2202
2203 @param thd Session handle
2204 @param item Item to allocate comparator objects for, left-hand IN operand
2205
2206 @returns false if success, true if error.
2207 */
2208 bool allocate_template_comparators(THD *thd, Item *item);
2209};
2210
2211class in_row final : public in_vector {
2214 // Sort pointers, rather than objects.
2216
2217 public:
2219 bool is_row_result() const override { return true; }
2220 /**
2221 Allocate extra objects for evaluation
2222
2223 @param mem_root Memory root for allocation.
2224 @param lhs The left-hand side object of the IN predicate.
2225 @param arg_count Number of arguments on the right-hand side of the predicate
2226
2227 @returns false if success, true if error.
2228 */
2229 bool allocate(MEM_ROOT *mem_root, Item *lhs, uint arg_count);
2230 bool find_item(Item *item) override;
2231 bool compare_elems(uint pos1, uint pos2) const override;
2232
2234 assert(false);
2235 return nullptr;
2236 }
2237 void value_to_item(uint, Item_basic_constant *) const override {
2238 assert(false);
2239 }
2240
2241 private:
2242 void set(uint pos, Item *item) override;
2243 void sort_array() override;
2244};
2245
2246/* Functions used by where clause */
2247
2250
2251 bool cache_used = false;
2253
2254 public:
2256 Item_func_isnull(const POS &pos, Item *a) : super(pos, a) {
2257 null_on_null = false;
2258 }
2259 longlong val_int() override;
2260 enum Functype functype() const override { return ISNULL_FUNC; }
2261 bool resolve_type(THD *thd) override;
2262 const char *func_name() const override { return "isnull"; }
2263 /* Optimize case of not_null_column IS NULL */
2264 void update_used_tables() override;
2265
2266 float get_filtering_effect(THD *thd, table_map filter_for_table,
2267 table_map read_tables,
2268 const MY_BITMAP *fields_to_ignore,
2269 double rows_in_table) override;
2270 optimize_type select_optimize(const THD *) override { return OPTIMIZE_NULL; }
2271 Item *truth_transformer(THD *, Bool_test test) override;
2272 void print(const THD *thd, String *str,
2273 enum_query_type query_type) const override;
2274 const CHARSET_INFO *compare_collation() const override {
2275 return args[0]->collation.collation;
2276 }
2277 bool fix_fields(THD *thd, Item **ref) override;
2278};
2279
2280/* Functions used by HAVING for rewriting IN subquery */
2281
2282/*
2283 This is like IS NOT NULL but it also remembers if it ever has
2284 encountered a NULL; it remembers this in the "was_null" property of the
2285 "owner" item.
2286*/
2289
2290 public:
2292 : Item_func_isnull(a), owner(ow) {}
2293 enum Functype functype() const override { return ISNOTNULLTEST_FUNC; }
2294 longlong val_int() override;
2295 const char *func_name() const override { return "<is_not_null_test>"; }
2296 bool resolve_type(THD *thd) override;
2297 void update_used_tables() override;
2298 /**
2299 We add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE.
2300
2301 @retval Always RAND_TABLE_BIT
2302 */
2304 return RAND_TABLE_BIT;
2305 }
2306 void print(const THD *thd, String *str,
2307 enum_query_type query_type) const override {
2308 Item_bool_func::print(thd, str, query_type);
2309 }
2310};
2311
2313 public:
2315 Item_func_isnotnull(const POS &pos, Item *a) : Item_bool_func(pos, a) {
2316 null_on_null = false;
2317 }
2318
2319 longlong val_int() override;
2320 enum Functype functype() const override { return ISNOTNULL_FUNC; }
2321 bool resolve_type(THD *thd) override {
2322 set_nullable(false);
2323 return Item_bool_func::resolve_type(thd);
2324 }
2325 const char *func_name() const override { return "isnotnull"; }
2326 optimize_type select_optimize(const THD *) override { return OPTIMIZE_NULL; }
2327 Item *truth_transformer(THD *, Bool_test test) override;
2328 void print(const THD *thd, String *str,
2329 enum_query_type query_type) const override;
2330 const CHARSET_INFO *compare_collation() const override {
2331 return args[0]->collation.collation;
2332 }
2333 void apply_is_true() override {
2334 null_on_null = true;
2335 } // Same logic as for Item_func_truth's function
2336 float get_filtering_effect(THD *thd, table_map filter_for_table,
2337 table_map read_tables,
2338 const MY_BITMAP *fields_to_ignore,
2339 double rows_in_table) override;
2340};
2341
2342class Item_func_like final : public Item_bool_func2 {
2343 /// True if escape clause is const (a literal)
2344 bool escape_is_const = false;
2345 /// Tells if the escape clause has been evaluated.
2346 bool escape_evaluated = false;
2347 bool eval_escape_clause(THD *thd);
2348 /// The escape character (0 if no escape character).
2350
2351 public:
2353 Item_func_like(Item *a, Item *b, Item *escape_arg)
2354 : Item_bool_func2(a, b, escape_arg) {
2355 assert(escape_arg != nullptr);
2356 }
2357 Item_func_like(const POS &pos, Item *a, Item *b, Item *escape_arg)
2358 : Item_bool_func2(pos, a, b, escape_arg) {
2359 assert(escape_arg != nullptr);
2360 }
2361 Item_func_like(const POS &pos, Item *a, Item *b)
2362 : Item_bool_func2(pos, a, b) {}
2363
2364 longlong val_int() override;
2365 enum Functype functype() const override { return LIKE_FUNC; }
2366 optimize_type select_optimize(const THD *thd) override;
2367 /// Result may be not equal with equal inputs if ESCAPE character is present
2368 cond_result eq_cmp_result() const override { return COND_OK; }
2369 const char *func_name() const override { return "like"; }
2370 bool fix_fields(THD *thd, Item **ref) override;
2371 bool resolve_type(THD *) override;
2372 void cleanup() override;
2373 Item *replace_scalar_subquery(uchar *) override;
2374 // Overridden because Item_bool_func2::print() doesn't print the ESCAPE
2375 // clause.
2376 void print(const THD *thd, String *str,
2377 enum_query_type query_type) const override;
2378 /**
2379 @retval true non default escape char specified
2380 using "expr LIKE pat ESCAPE 'escape_char'" syntax
2381 */
2382 bool escape_was_used_in_parsing() const { return arg_count > 2; }
2383
2384 /// Returns the escape character.
2385 int escape() const {
2386 assert(escape_is_evaluated());
2387 return m_escape;
2388 }
2389
2390 /**
2391 Has the escape clause been evaluated? It only needs to be evaluated
2392 once per execution, since we require it to be constant during execution.
2393 The escape member has a valid value if and only if this function returns
2394 true.
2395 */
2396 bool escape_is_evaluated() const { return escape_evaluated; }
2397
2398 float get_filtering_effect(THD *thd, table_map filter_for_table,
2399 table_map read_tables,
2400 const MY_BITMAP *fields_to_ignore,
2401 double rows_in_table) override;
2402
2403 private:
2404 /**
2405 The method updates covering keys depending on the
2406 length of wild string prefix.
2407
2408 @param thd Pointer to THD object.
2409
2410 @retval true if error happens during wild string prefix calculation,
2411 false otherwise.
2412 */
2413 bool check_covering_prefix_keys(THD *thd);
2414};
2415
2418
2419 protected:
2422
2423 public:
2424 /* Item_cond() is only used to create top level items */
2427 list.push_back(i1);
2428 list.push_back(i2);
2429 }
2430 Item_cond(const POS &pos, Item *i1, Item *i2)
2431 : Item_bool_func(pos), abort_on_null(false) {
2432 list.push_back(i1);
2433 list.push_back(i2);
2434 }
2435
2436 Item_cond(THD *thd, Item_cond *item);
2438 : Item_bool_func(), list(nlist), abort_on_null(false) {}
2439 bool add(Item *item) {
2440 assert(item);
2441 return list.push_back(item);
2442 }
2443 bool add_at_head(Item *item) {
2444 assert(item);
2445 return list.push_front(item);
2446 }
2448 assert(nlist->elements);
2449 list.prepend(nlist);
2450 }
2451
2452 bool itemize(Parse_context *pc, Item **res) override;
2453
2454 bool fix_fields(THD *, Item **ref) override;
2455 void fix_after_pullout(Query_block *parent_query_block,
2456 Query_block *removed_query_block) override;
2457
2458 Type type() const override { return COND_ITEM; }
2460 bool eq(const Item *item, bool binary_cmp) const override;
2461 table_map used_tables() const override { return used_tables_cache; }
2462 void update_used_tables() override;
2463 void print(const THD *thd, String *str,
2464 enum_query_type query_type) const override;
2465 void split_sum_func(THD *thd, Ref_item_array ref_item_array,
2466 mem_root_deque<Item *> *fields) override;
2467 void apply_is_true() override { abort_on_null = true; }
2468 void copy_andor_arguments(THD *thd, Item_cond *item);
2469 bool walk(Item_processor processor, enum_walk walk, uchar *arg) override;
2470 Item *transform(Item_transformer transformer, uchar *arg) override;
2471 void traverse_cond(Cond_traverser, void *arg, traverse_order order) override;
2472 bool truth_transform_arguments(THD *thd, Bool_test test);
2473 bool subst_argument_checker(uchar **) override { return true; }
2474 Item *compile(Item_analyzer analyzer, uchar **arg_p,
2475 Item_transformer transformer, uchar *arg_t) override;
2476 bool remove_const_conds(THD *thd, Item *item, Item **new_item);
2477 /// Treat UNKNOWN result like FALSE because callers see no difference
2478 bool ignore_unknown() const { return abort_on_null; }
2479 bool equality_substitution_analyzer(uchar **) override { return true; }
2480};
2481
2482/*
2483 The class Item_equal is used to represent conjunctions of equality
2484 predicates of the form field1 = field2, and field=const in where
2485 conditions and on expressions.
2486
2487 All equality predicates of the form field1=field2 contained in a
2488 conjunction are substituted for a sequence of items of this class.
2489 An item of this class Item_equal(f1,f2,...fk) represents a
2490 multiple equality f1=f2=...=fk.
2491
2492 If a conjunction contains predicates f1=f2 and f2=f3, a new item of
2493 this class is created Item_equal(f1,f2,f3) representing the multiple
2494 equality f1=f2=f3 that substitutes the above equality predicates in
2495 the conjunction.
2496 A conjunction of the predicates f2=f1 and f3=f1 and f3=f2 will be
2497 substituted for the item representing the same multiple equality
2498 f1=f2=f3.
2499 An item Item_equal(f1,f2) can appear instead of a conjunction of
2500 f2=f1 and f1=f2, or instead of just the predicate f1=f2.
2501
2502 An item of the class Item_equal inherits equalities from outer
2503 conjunctive levels.
2504
2505 Suppose we have a where condition of the following form:
2506 WHERE f1=f2 AND f3=f4 AND f3=f5 AND ... AND (...OR (f1=f3 AND ...)).
2507 In this case:
2508 f1=f2 will be substituted for Item_equal(f1,f2);
2509 f3=f4 and f3=f5 will be substituted for Item_equal(f3,f4,f5);
2510 f1=f3 will be substituted for Item_equal(f1,f2,f3,f4,f5);
2511
2512 An object of the class Item_equal can contain an optional constant
2513 item c. Then it represents a multiple equality of the form
2514 c=f1=...=fk.
2515
2516 Objects of the class Item_equal are used for the following:
2517
2518 1. An object Item_equal(t1.f1,...,tk.fk) allows us to consider any
2519 pair of tables ti and tj as joined by an equi-condition.
2520 Thus it provide us with additional access paths from table to table.
2521
2522 2. An object Item_equal(t1.f1,...,tk.fk) is applied to deduce new
2523 SARGable predicates:
2524 f1=...=fk AND P(fi) => f1=...=fk AND P(fi) AND P(fj).
2525 It also can give us additional index scans and can allow us to
2526 improve selectivity estimates.
2527
2528 3. An object Item_equal(t1.f1,...,tk.fk) is used to optimize the
2529 selected execution plan for the query: if table ti is accessed
2530 before the table tj then in any predicate P in the where condition
2531 the occurrence of tj.fj is substituted for ti.fi. This can allow
2532 an evaluation of the predicate at an earlier step.
2533
2534 When feature 1 is supported they say that join transitive closure
2535 is employed.
2536 When feature 2 is supported they say that search argument transitive
2537 closure is employed.
2538 Both features are usually supported by preprocessing original query and
2539 adding additional predicates.
2540 We do not just add predicates, we rather dynamically replace some
2541 predicates that can not be used to access tables in the investigated
2542 plan for those, obtained by substitution of some fields for equal fields,
2543 that can be used.
2544
2545 Prepared Statements/Stored Procedures note: instances of class
2546 Item_equal are created only at the time a PS/SP is executed and
2547 are deleted in the end of execution. All changes made to these
2548 objects need not be registered in the list of changes of the parse
2549 tree and do not harm PS/SP re-execution.
2550
2551 Item equal objects are employed only at the optimize phase. Usually they are
2552 not supposed to be evaluated. Yet in some cases we call the method val_int()
2553 for them. We have to take care of restricting the predicate such an
2554 object represents f1=f2= ...=fn to the projection of known fields fi1=...=fik.
2555*/
2556class Item_equal final : public Item_bool_func {
2557 /// List of equal field items.
2559 /// Optional constant item equal to all the field items.
2560 Item *m_const_arg{nullptr};
2561 /// Helper for comparing the fields.
2562 cmp_item *eval_item{nullptr};
2563 /// Helper for comparing constants.
2565 /// Flag set to true if the equality is known to be always false.
2566 bool cond_false{false};
2567 /// Should constants be compared as datetimes?
2568 bool compare_as_dates{false};
2569
2570 public:
2571 ~Item_equal() override;
2572
2574 Item_equal(Item *c, Item_field *f);
2575 explicit Item_equal(Item_equal *item_equal);
2576
2577 Item *const_arg() const { return m_const_arg; }
2578 void set_const_arg(Item *c) { m_const_arg = c; }
2579 bool compare_const(THD *thd, Item *c);
2580 bool add(THD *thd, Item *c, Item_field *f);
2581 bool add(THD *thd, Item *c);
2582 void add(Item_field *f);
2583 uint members();
2584 bool contains(const Field *field) const;
2585 /**
2586 Get the first field of multiple equality, use for semantic checking.
2587
2588 @retval First field in the multiple equality.
2589 */
2590 Item_field *get_first() { return fields.head(); }
2591 Item_field *get_subst_item(const Item_field *field);
2592 bool merge(THD *thd, Item_equal *item);
2593 bool update_const(THD *thd);
2594 enum Functype functype() const override { return MULT_EQUAL_FUNC; }
2595 longlong val_int() override;
2596 const char *func_name() const override { return "multiple equal"; }
2597 optimize_type select_optimize(const THD *) override { return OPTIMIZE_EQUAL; }
2599 // Multiple equality nodes (Item_equal) should have been
2600 // converted back to simple equalities (Item_func_eq) by
2601 // substitute_for_best_equal_field before cast nodes are injected.
2602 assert(false);
2603 return false;
2604 }
2606 return const_arg() == nullptr;
2607 }
2608
2609 /**
2610 Order field items in multiple equality according to a sorting criteria.
2611
2612 The function perform ordering of the field items in the Item_equal
2613 object according to the criteria determined by the cmp callback parameter.
2614 If cmp(item_field1,item_field2,arg)<0 than item_field1 must be
2615 placed after item_field2.
2616
2617 The function sorts field items by the exchange sort algorithm.
2618 The list of field items is looked through and whenever two neighboring
2619 members follow in a wrong order they are swapped. This is performed
2620 again and again until we get all members in a right order.
2621
2622 @param compare function to compare field item
2623 */
2624 template <typename Node_cmp_func>
2625 void sort(Node_cmp_func compare) {
2626 fields.sort(compare);
2627 }
2628
2629 // A class to iterate over fields without exposing fields directly.
2631 public:
2632 explicit FieldProxy(Item_equal *item) : m_fields(&item->fields) {}
2633 List_STL_Iterator<Item_field> begin() { return m_fields->begin(); }
2634 List_STL_Iterator<Item_field> end() { return m_fields->end(); }
2636 return m_fields->cbegin();
2637 }
2638 List_STL_Iterator<const Item_field> end() const { return m_fields->cend(); }
2640 return m_fields->cbegin();
2641 }
2643 return m_fields->cend();
2644 }
2645
2646 private:
2648 };
2650 public:
2651 explicit ConstFieldProxy(const Item_equal *item)
2652 : m_fields(&item->fields) {}
2654 return m_fields->cbegin();
2655 }
2656 List_STL_Iterator<const Item_field> end() const { return m_fields->cend(); }
2658 return m_fields->cbegin();
2659 }
2661 return m_fields->cend();
2662 }
2663 size_t size() const { return m_fields->size(); }
2664
2665 private:
2667 };
2670
2671 bool resolve_type(THD *) override;
2672 bool fix_fields(THD *thd, Item **ref) override;
2673 void update_used_tables() override;
2674 bool walk(Item_processor processor, enum_walk walk, uchar *arg) override;
2675 void print(const THD *thd, String *str,
2676 enum_query_type query_type) const override;
2677 bool eq(const Item *item, bool binary_cmp) const override;
2678 const CHARSET_INFO *compare_collation() const override {
2679 return fields.head()->collation.collation;
2680 }
2681
2682 bool equality_substitution_analyzer(uchar **) override { return true; }
2683
2685
2686 float get_filtering_effect(THD *thd, table_map filter_for_table,
2687 table_map read_tables,
2688 const MY_BITMAP *fields_to_ignore,
2689 double rows_in_table) override;
2690 Item *m_const_folding[2]; ///< temporary area used for constant folding
2691
2692 private:
2694};
2695
2697 public:
2698 uint max_members; /* max number of members the current level
2699 list and all lower level lists */
2700 COND_EQUAL *upper_levels; /* multiple equalities of upper and levels */
2701 List<Item_equal> current_level; /* list of multiple equalities of
2702 the current and level */
2703 COND_EQUAL() { upper_levels = nullptr; }
2704};
2705
2706class Item_cond_and final : public Item_cond {
2707 public:
2708 COND_EQUAL cond_equal; /* contains list of Item_equal objects for
2709 the current and level and reference
2710 to multiple equalities of upper and levels */
2712
2713 Item_cond_and(Item *i1, Item *i2) : Item_cond(i1, i2) {}
2714 Item_cond_and(const POS &pos, Item *i1, Item *i2) : Item_cond(pos, i1, i2) {}
2715
2716 Item_cond_and(THD *thd, Item_cond_and *item) : Item_cond(thd, item) {}
2717 Item_cond_and(List<Item> &list_arg) : Item_cond(list_arg) {}
2718 enum Functype functype() const override { return COND_AND_FUNC; }
2719 longlong val_int() override;
2720 const char *func_name() const override { return "and"; }
2722 Item_cond_and *item;
2723 if ((item = new Item_cond_and(thd, this)))
2724 item->copy_andor_arguments(thd, this);
2725 return item;
2726 }
2727 Item *truth_transformer(THD *, Bool_test) override;
2728 bool gc_subst_analyzer(uchar **) override { return true; }
2729
2730 float get_filtering_effect(THD *thd, table_map filter_for_table,
2731 table_map read_tables,
2732 const MY_BITMAP *fields_to_ignore,
2733 double rows_in_table) override;
2734
2735 bool contains_only_equi_join_condition() const override;
2736};
2737
2738class Item_cond_or final : public Item_cond {
2739 public:
2741
2742 Item_cond_or(Item *i1, Item *i2) : Item_cond(i1, i2) {}
2743 Item_cond_or(const POS &pos, Item *i1, Item *i2) : Item_cond(pos, i1, i2) {}
2744
2745 Item_cond_or(THD *thd, Item_cond_or *item) : Item_cond(thd, item) {}
2746 Item_cond_or(List<Item> &list_arg) : Item_cond(list_arg) {}
2747 enum Functype functype() const override { return COND_OR_FUNC; }
2748 longlong val_int() override;
2749 const char *func_name() const override { return "or"; }
2751 Item_cond_or *item;
2752 if ((item = new Item_cond_or(thd, this)))
2753 item->copy_andor_arguments(thd, this);
2754 return item;
2755 }
2756 Item *truth_transformer(THD *, Bool_test) override;
2757 bool gc_subst_analyzer(uchar **) override { return true; }
2758
2759 float get_filtering_effect(THD *thd, table_map filter_for_table,
2760 table_map read_tables,
2761 const MY_BITMAP *fields_to_ignore,
2762 double rows_in_table) override;
2763};
2764
2765/// Builds condition: (a AND b) IS TRUE
2766inline Item *and_conds(Item *a, Item *b) {
2767 if (!b) return a;
2768 if (!a) return b;
2769
2770 Item *item = new Item_cond_and(a, b);
2771 if (item == nullptr) return nullptr;
2772 item->apply_is_true();
2773 return item;
2774}
2775
2776longlong get_datetime_value(THD *thd, Item ***item_arg, Item ** /* cache_arg */,
2777 const Item *warn_item, bool *is_null);
2778
2779// TODO: the next two functions should be moved to sql_time.{h,cc}
2782
2784 enum_mysql_timestamp_type warn_type,
2785 const char *warn_name, MYSQL_TIME *l_time);
2786
2787// Helper function to ensure_multi_equality_fields_are_available().
2788// Finds and adjusts (if "replace" is set to true) an "Item_field" in a
2789// function with an equal field in the available tables. For more
2790// details look at FindEqualField().
2791void find_and_adjust_equal_fields(Item *item, table_map available_tables,
2792 bool replace, bool *found);
2793
2794/*
2795 These need definitions from this file but the variables are defined
2796 in mysqld.h. The variables really belong in this component, but for
2797 the time being we leave them in mysqld.cc to avoid merge problems.
2798*/
2799extern Eq_creator eq_creator;
2801extern Ne_creator ne_creator;
2802extern Gt_creator gt_creator;
2803extern Lt_creator lt_creator;
2804extern Ge_creator ge_creator;
2805extern Le_creator le_creator;
2806
2807/// Returns true if the item is a conjunction.
2808inline bool IsAnd(const Item *item) {
2809 return item->type() == Item::COND_ITEM &&
2810 down_cast<const Item_cond *>(item)->functype() ==
2812}
2813
2814/**
2815 Calls "func" on each term in "condition" if it's a conjunction (and
2816 recursively on any conjunction directly contained in it, thereby flattening
2817 nested AND structures). Otherwise, calls "func" on "condition". It aborts and
2818 returns true as soon as a call to "func" returns true.
2819 */
2820template <class Func>
2821bool WalkConjunction(Item *condition, Func func) {
2822 if (condition == nullptr) {
2823 return false;
2824 } else if (IsAnd(condition)) {
2825 for (Item &item : *down_cast<Item_cond_and *>(condition)->argument_list()) {
2826 if (WalkConjunction(&item, func)) {
2827 return true;
2828 }
2829 }
2830 return false;
2831 } else {
2832 return func(condition);
2833 }
2834}
2835
2836#endif /* ITEM_CMPFUNC_INCLUDED */
Definition: item_cmpfunc.h:139
bool inject_cast_nodes()
Comparison function are expected to operate on arguments having the same data types.
Definition: item_cmpfunc.cc:1319
int compare_time_packed()
Compare arguments using numeric packed temporal representation.
Definition: item_cmpfunc.cc:1857
void cleanup()
Definition: item_cmpfunc.cc:747
uint get_child_comparator_count() const
Definition: item_cmpfunc.h:244
int compare_int_signed_unsigned()
Compare signed (*left) with unsigned (*B)
Definition: item_cmpfunc.cc:1920
String value1
Definition: item_cmpfunc.h:167
void set_datetime_cmp_func(Item_result_field *owner_arg, Item **a1, Item **b1)
Definition: item_cmpfunc.cc:1477
Item * left_cache
Definition: item_cmpfunc.h:148
longlong(* get_value_a_func)(THD *thd, Item ***item_arg, Item **cache_arg, const Item *warn_item, bool *is_null)
A function pointer that is used for retrieving the value from argument "left".
Definition: item_cmpfunc.h:279
int compare_int_unsigned_signed()
Compare unsigned (*left) with signed (*B)
Definition: item_cmpfunc.cc:1941
Arg_comparator * comparators
Definition: item_cmpfunc.h:144
Item_result m_compare_type
Definition: item_cmpfunc.h:289
Arg_comparator * get_child_comparators() const
Definition: item_cmpfunc.h:246
static bool can_compare_as_dates(const Item *a, const Item *b)
Checks whether compare_datetime() can be used to compare items.
Definition: item_cmpfunc.cc:1061
double precision
Definition: item_cmpfunc.h:146
int compare_datetime()
Compare item values as dates.
Definition: item_cmpfunc.cc:1601
uint16 comparator_count
Definition: item_cmpfunc.h:145
Item ** right
Definition: item_cmpfunc.h:141
arg_cmp_func func
Definition: item_cmpfunc.h:142
String value2
Definition: item_cmpfunc.h:167
Item ** left
Definition: item_cmpfunc.h:140
Item ** get_left_ptr() const
Definition: item_cmpfunc.h:261
Json_scalar_holder * json_scalar
Only used by compare_json() in the case where a JSON value is compared to an SQL value.
Definition: item_cmpfunc.h:162
void set_cmp_context_for_datetime()
Definition: item_cmpfunc.h:236
bool set_cmp_func(Item_result_field *owner_arg, Item **left, Item **right, Item_result type)
Sets compare functions for various datatypes.
Definition: item_cmpfunc.cc:1131
static arg_cmp_func comparator_matrix[5]
Definition: item_cmpfunc.h:231
bool use_custom_value_extractors() const
Definition: item_cmpfunc.h:250
int compare()
Definition: item_cmpfunc.h:210
Item_result get_compare_type() const
Definition: item_cmpfunc.h:242
int compare_int_signed()
Definition: item_cmpfunc.cc:1831
int compare_binary_string()
Compare strings byte by byte.
Definition: item_cmpfunc.cc:1760
Arg_comparator()=default
Item * get_right() const
Definition: item_cmpfunc.h:262
int compare_json()
Compare two Item objects as JSON.
Definition: item_cmpfunc.cc:1693
int compare_real()
Definition: item_cmpfunc.cc:1778
bool set_null
Definition: item_cmpfunc.h:150
static bool get_date_from_const(Item *date_arg, Item *str_arg, ulonglong *const_value)
Check if str_arg is a constant and convert it to datetime packed value.
Definition: item_cmpfunc.cc:986
bool try_year_cmp_func(Item_result type)
Definition: item_cmpfunc.cc:1420
Item * right_cache
Definition: item_cmpfunc.h:149
Item_result_field * owner
Definition: item_cmpfunc.h:143
longlong(* get_value_b_func)(THD *thd, Item ***item_arg, Item **cache_arg, const Item *warn_item, bool *is_null)
Definition: item_cmpfunc.h:284
int compare_real_fixed()
Definition: item_cmpfunc.cc:1813
longlong extract_value_from_argument(THD *thd, Item *item, bool left_argument, bool *is_null) const
Definition: item_cmpfunc.cc:7806
int compare_string()
Definition: item_cmpfunc.cc:1728
int compare_decimal()
Definition: item_cmpfunc.cc:1796
int compare_row()
Definition: item_cmpfunc.cc:1959
bool compare_null_values()
Compare NULL values for two arguments.
Definition: item_cmpfunc.cc:2050
bool set_compare_func(Item_result_field *owner, Item_result type)
Definition: item_cmpfunc.cc:763
DTCollation cmp_collation
Definition: item_cmpfunc.h:165
Arg_comparator(Item **left, Item **right)
Definition: item_cmpfunc.h:171
int compare_int_unsigned()
Compare values as BIGINT UNSIGNED.
Definition: item_cmpfunc.cc:1893
Definition: item_cmpfunc.h:2696
uint max_members
Definition: item_cmpfunc.h:2698
COND_EQUAL * upper_levels
Definition: item_cmpfunc.h:2700
List< Item_equal > current_level
Definition: item_cmpfunc.h:2701
COND_EQUAL()
Definition: item_cmpfunc.h:2703
Abstract factory interface for creating comparison predicates.
Definition: item_cmpfunc.h:522
virtual ~Comp_creator()=default
virtual bool l_op() const =0
virtual bool eqne_op() const =0
virtual Item_bool_func * create(Item *a, Item *b) const =0
virtual const char * symbol(bool invert) const =0
This interface is only used by Item_allany_subselect.
Definition: item.h:173
const CHARSET_INFO * collation
Definition: item.h:175
Definition: item_cmpfunc.h:552
Item_bool_func * create_scalar_predicate(Item *a, Item *b) const override
Creates only an item tree node, without attempting to rewrite row constructors.
Definition: item_cmpfunc.cc:282
const char * symbol(bool invert) const override
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:554
Item_bool_func * combine(List< Item > list) const override
Combines a list of conditions exp op exp.
Definition: item_cmpfunc.cc:287
Definition: item_cmpfunc.h:561
const char * symbol(bool invert) const override
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:563
Item_bool_func * create_scalar_predicate(Item *a, Item *b) const override
Creates only an item tree node, without attempting to rewrite row constructors.
Definition: item_cmpfunc.cc:291
Item_bool_func * combine(List< Item > list) const override
Combines a list of conditions exp op exp.
Definition: item_cmpfunc.cc:296
Definition: field.h:574
Definition: item_cmpfunc.h:599
Item_bool_func * create(Item *a, Item *b) const override
Definition: item_cmpfunc.cc:317
bool l_op() const override
Definition: item_cmpfunc.h:604
bool eqne_op() const override
Definition: item_cmpfunc.h:603
const char * symbol(bool invert) const override
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:602
Definition: item_cmpfunc.h:583
bool l_op() const override
Definition: item_cmpfunc.h:588
Item_bool_func * create(Item *a, Item *b) const override
Definition: item_cmpfunc.cc:309
bool eqne_op() const override
Definition: item_cmpfunc.h:587
const char * symbol(bool invert) const override
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:586
A class that represents a join condition in a hash join.
Definition: item_cmpfunc.h:86
const size_t m_max_character_length
Definition: item_cmpfunc.h:125
const table_map m_right_used_tables
Definition: item_cmpfunc.h:119
Item_eq_base * m_join_condition
Definition: item_cmpfunc.h:111
Item * right_extractor() const
Definition: item_cmpfunc.h:93
HashJoinCondition(Item_eq_base *join_condition, MEM_ROOT *mem_root)
Definition: item_cmpfunc.cc:7771
const table_map m_left_used_tables
Definition: item_cmpfunc.h:118
bool store_full_sort_key() const
Definition: item_cmpfunc.h:104
bool left_uses_any_table(table_map tables) const
Definition: item_cmpfunc.h:94
bool m_store_full_sort_key
Definition: item_cmpfunc.h:133
Item * left_extractor() const
Definition: item_cmpfunc.h:92
Item_eq_base * join_condition() const
Definition: item_cmpfunc.h:90
bool m_null_equals_null
Definition: item_cmpfunc.h:136
Item * m_right_extractor
Definition: item_cmpfunc.h:113
bool right_uses_any_table(table_map tables) const
Definition: item_cmpfunc.h:98
Item * m_left_extractor
Definition: item_cmpfunc.h:112
size_t max_character_length() const
Definition: item_cmpfunc.h:102
bool null_equals_null() const
Returns true if this join condition evaluates to TRUE if both operands are NULL.
Definition: item_cmpfunc.h:108
Definition: item.h:3577
void set_str_value(String *str)
Definition: item.h:3599
Base class for functions that usually take two arguments, which are possibly strings,...
Definition: item_cmpfunc.h:621
bool have_rev_func() const override
Definition: item_cmpfunc.h:655
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:651
bool abort_on_null
Definition: item_cmpfunc.h:628
void apply_is_true() override
Apply the IS TRUE truth property, meaning that an UNKNOWN result and a FALSE result are treated the s...
Definition: item_cmpfunc.h:667
bool convert_constant_arg(THD *thd, Item *field, Item **item, bool *converted)
Definition: item_cmpfunc.cc:607
Item_result compare_type() const
Definition: item_cmpfunc.h:666
Arg_comparator cmp
Definition: item_cmpfunc.h:627
Item_bool_func2(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_cmpfunc.h:639
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_cmpfunc.cc:625
Item_bool_func2(Item *a, Item *b, Item *c)
Definition: item_cmpfunc.h:633
Item_bool_func2(Item *a, Item *b)
Definition: item_cmpfunc.h:630
virtual bool set_cmp_func()
Sets up a comparator of the correct type based on the type of the function's arguments.
Definition: item_cmpfunc.h:648
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:663
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item_cmpfunc.h:662
Item_bool_func2(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:636
virtual enum Functype rev_functype() const
Definition: item_cmpfunc.h:654
bool ignore_unknown() const
Treat UNKNOWN result like FALSE because callers see no difference.
Definition: item_cmpfunc.h:669
const Arg_comparator * get_comparator() const
Definition: item_cmpfunc.h:674
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:657
Item * replace_scalar_subquery(uchar *) override
When walking the item tree seeing an Item_singlerow_subselect matching a target, replace it with a su...
Definition: item_cmpfunc.cc:742
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_cmpfunc.h:670
Definition: item_cmpfunc.h:292
Item_bool_func(Item *a)
Definition: item_cmpfunc.h:299
Item_bool_func(Item *a, Item *b, Item *c)
Definition: item_cmpfunc.h:304
Item_bool_func(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:310
bool m_created_by_in2exists
True <=> this item was added by IN->EXISTS subquery transformation, and should thus be deleted if we ...
Definition: item_cmpfunc.h:346
void set_created_by_in2exists()
Definition: item_cmpfunc.h:332
bool created_by_in2exists() const override
Whether this Item was created by the IN->EXISTS subquery transformation.
Definition: item_cmpfunc.h:331
Item_bool_func(const POS &pos)
Definition: item_cmpfunc.h:295
Item_bool_func(THD *thd, Item_bool_func *item)
Definition: item_cmpfunc.h:318
Item_bool_func(Item *a, Item *b)
Definition: item_cmpfunc.h:307
Item_bool_func(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_cmpfunc.h:313
uint decimal_precision() const override
Definition: item_cmpfunc.h:330
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_cmpfunc.h:326
Item_bool_func(const POS &pos, Item *a)
Definition: item_cmpfunc.h:300
bool is_bool_func() const override
Definition: item_cmpfunc.h:325
Item_bool_func()
Definition: item_cmpfunc.h:294
static const Bool_test bool_transform[10][8]
Array that transforms a boolean test according to another.
Definition: item_cmpfunc.h:339
static const char * bool_transform_names[10]
Definition: item_cmpfunc.h:334
Definition: item.h:6611
Definition: item_cmpfunc.h:2706
Item * copy_andor_structure(THD *thd) override
Definition: item_cmpfunc.h:2721
Item_cond_and(List< Item > &list_arg)
Definition: item_cmpfunc.h:2717
COND_EQUAL cond_equal
Definition: item_cmpfunc.h:2708
const char * func_name() const override
Definition: item_cmpfunc.h:2720
enum Functype functype() const override
Definition: item_cmpfunc.h:2718
Item_cond_and()
Definition: item_cmpfunc.h:2711
Item_cond_and(const POS &pos, Item *i1, Item *i2)
Definition: item_cmpfunc.h:2714
Item_cond_and(Item *i1, Item *i2)
Definition: item_cmpfunc.h:2713
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:2728
Item_cond_and(THD *thd, Item_cond_and *item)
Definition: item_cmpfunc.h:2716
Definition: item_cmpfunc.h:2738
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:2757
enum Functype functype() const override
Definition: item_cmpfunc.h:2747
Item_cond_or(Item *i1, Item *i2)
Definition: item_cmpfunc.h:2742
Item * copy_andor_structure(THD *thd) override
Definition: item_cmpfunc.h:2750
Item_cond_or(List< Item > &list_arg)
Definition: item_cmpfunc.h:2746
Item_cond_or(const POS &pos, Item *i1, Item *i2)
Definition: item_cmpfunc.h:2743
Item_cond_or()
Definition: item_cmpfunc.h:2740
const char * func_name() const override
Definition: item_cmpfunc.h:2749
Item_cond_or(THD *thd, Item_cond_or *item)
Definition: item_cmpfunc.h:2745
Definition: item_cmpfunc.h:2416
void add_at_head(List< Item > *nlist)
Definition: item_cmpfunc.h:2447
bool add_at_head(Item *item)
Definition: item_cmpfunc.h:2443
void apply_is_true() override
Apply the IS TRUE truth property, meaning that an UNKNOWN result and a FALSE result are treated the s...
Definition: item_cmpfunc.h:2467
Item_cond(Item *i1, Item *i2)
Definition: item_cmpfunc.h:2426
Item_bool_func super
Definition: item_cmpfunc.h:2417
bool ignore_unknown() const
Treat UNKNOWN result like FALSE because callers see no difference.
Definition: item_cmpfunc.h:2478
void copy_andor_arguments(THD *thd, Item_cond *item)
Definition: item_cmpfunc.cc:5443
table_map used_tables() const override
Definition: item_cmpfunc.h:2461
Item_cond(const POS &pos, Item *i1, Item *i2)
Definition: item_cmpfunc.h:2430
Item_cond(List< Item > &nlist)
Definition: item_cmpfunc.h:2437
bool subst_argument_checker(uchar **) override
Definition: item_cmpfunc.h:2473
List< Item > * argument_list()
Definition: item_cmpfunc.h:2459
Type type() const override
Definition: item_cmpfunc.h:2458
Item_cond()
Definition: item_cmpfunc.h:2425
List< Item > list
Definition: item_cmpfunc.h:2420
bool equality_substitution_analyzer(uchar **) override
Definition: item_cmpfunc.h:2479
bool add(Item *item)
Definition: item_cmpfunc.h:2439
bool abort_on_null
Definition: item_cmpfunc.h:2421
Definition: item.h:5075
Base class for the equality comparison operators = and <=>.
Definition: item_cmpfunc.h:980
Item_eq_base(Item *a, Item *b)
Definition: item_cmpfunc.h:982
Item_equal * source_multiple_equality
If this equality originally came from a multi-equality, this documents which one it came from (otherw...
Definition: item_cmpfunc.h:1039
bool contains_only_equi_join_condition() const final
Whether this Item is an equi-join condition.
Definition: item_cmpfunc.cc:7379
Item_eq_base(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:983
Item * create_cast_if_needed(MEM_ROOT *mem_root, Item *argument) const
Wrap the argument in a typecast, if needed.
Definition: item_cmpfunc.cc:7743
bool append_join_key_for_hash_join(THD *thd, table_map tables, const HashJoinCondition &join_condition, bool is_multi_column_key, String *join_key_buffer) const
Read the value from the join condition, and append it to the output vector "join_key_buffer".
Definition: item_cmpfunc.cc:7717
Definition: item_cmpfunc.h:2649
ConstFieldProxy(const Item_equal *item)
Definition: item_cmpfunc.h:2651
List_STL_Iterator< const Item_field > cbegin() const
Definition: item_cmpfunc.h:2657
List_STL_Iterator< const Item_field > cend() const
Definition: item_cmpfunc.h:2660
List_STL_Iterator< const Item_field > begin() const
Definition: item_cmpfunc.h:2653
size_t size() const
Definition: item_cmpfunc.h:2663
const List< Item_field > * m_fields
Definition: item_cmpfunc.h:2666
List_STL_Iterator< const Item_field > end() const
Definition: item_cmpfunc.h:2656
Definition: item_cmpfunc.h:2630
List_STL_Iterator< Item_field > begin()
Definition: item_cmpfunc.h:2633
List_STL_Iterator< Item_field > end()
Definition: item_cmpfunc.h:2634
List< Item_field > * m_fields
Definition: item_cmpfunc.h:2647
List_STL_Iterator< const Item_field > begin() const
Definition: item_cmpfunc.h:2635
List_STL_Iterator< const Item_field > cbegin() const
Definition: item_cmpfunc.h:2639
List_STL_Iterator< const Item_field > cend() const
Definition: item_cmpfunc.h:2642
List_STL_Iterator< const Item_field > end() const
Definition: item_cmpfunc.h:2638
FieldProxy(Item_equal *item)
Definition: item_cmpfunc.h:2632
Definition: item_cmpfunc.h:2556
ConstFieldProxy get_fields() const
Definition: item_cmpfunc.h:2669
bool contains_only_equi_join_condition() const override
Whether this Item is an equi-join condition.
Definition: item_cmpfunc.h:2605
void set_const_arg(Item *c)
Definition: item_cmpfunc.h:2578
void check_covering_prefix_keys()
bool cast_incompatible_args(uchar *) override
Wrap incompatible arguments in CAST nodes to the expected data types.
Definition: item_cmpfunc.h:2598
Item * const_arg() const
Definition: item_cmpfunc.h:2577
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:2678
void sort(Node_cmp_func compare)
Order field items in multiple equality according to a sorting criteria.
Definition: item_cmpfunc.h:2625
Arg_comparator cmp
Helper for comparing constants.
Definition: item_cmpfunc.h:2564
Item_field * get_first()
Get the first field of multiple equality, use for semantic checking.
Definition: item_cmpfunc.h:2590
const char * func_name() const override
Definition: item_cmpfunc.h:2596
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:2597
List< Item_field > fields
List of equal field items.
Definition: item_cmpfunc.h:2558
FieldProxy get_fields()
Definition: item_cmpfunc.h:2668
enum Functype functype() const override
Definition: item_cmpfunc.h:2594
bool equality_substitution_analyzer(uchar **) override
Definition: item_cmpfunc.h:2682
Definition: item.h:4127
Definition: item.h:5121
ANY_VALUE(expr) is like expr except that it is not checked by aggregate_check logic.
Definition: item_cmpfunc.h:1480
const char * func_name() const override
Definition: item_cmpfunc.h:1484
Item_func_any_value(const POS &pos, Item *a)
Definition: item_cmpfunc.h:1482
Item_func_any_value(Item *a)
Definition: item_cmpfunc.h:1483
Definition: item_cmpfunc.h:1303
Arg_comparator ge_cmp
Definition: item_cmpfunc.h:1315
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:1322
bool compare_as_dates_with_strings
Definition: item_cmpfunc.h:1310
bool is_bool_func() const override
Definition: item_cmpfunc.h:1331
Item_func_between(const POS &pos, Item *a, Item *b, Item *c, bool is_negation)
Definition: item_cmpfunc.h:1316
Item_result cmp_type
Definition: item_cmpfunc.h:1307
bool compare_as_temporal_dates
Definition: item_cmpfunc.h:1311
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:1332
String value0
Definition: item_cmpfunc.h:1308
const char * func_name() const override
Definition: item_cmpfunc.h:1324
void update_not_null_tables()
Definition: item_cmpfunc.h:1344
uint decimal_precision() const override
Definition: item_cmpfunc.h:1335
DTCollation cmp_collation
Definition: item_cmpfunc.h:1304
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:1336
bool compare_as_temporal_times
Definition: item_cmpfunc.h:1312
enum Functype functype() const override
Definition: item_cmpfunc.h:1323
A predicate that is "always true" or "always false".
Definition: item_cmpfunc.h:355
Item_func_bool_const(const POS &pos)
Definition: item_cmpfunc.h:363
Item_func_bool_const()
Definition: item_cmpfunc.h:357
bool fix_fields(THD *, Item **) override
Definition: item_cmpfunc.h:369
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_cmpfunc.h: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_cmpfunc.h:370
CASE ... WHEN ... THEN ... END function implementation.
Definition: item_cmpfunc.h:1975
Item_result cmp_type
Definition: item_cmpfunc.h:1982
enum_field_types default_data_type() const override
Get the default data (output) type for the specific item.
Definition: item_cmpfunc.h:2020
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:2031
cmp_item * case_item
Definition: item_cmpfunc.h:1985
int else_expr_num
Definition: item_cmpfunc.h:1978
DTCollation cmp_collation
Definition: item_cmpfunc.h:1983
Item_func super
Definition: item_cmpfunc.h:1976
Item_func_case(const POS &pos, mem_root_deque< Item * > *list, Item *first_expr_arg, Item *else_expr_arg)
Definition: item_cmpfunc.h:1988
int get_first_expr_num() const
Definition: item_cmpfunc.h:2010
const char * func_name() const override
Definition: item_cmpfunc.h:2027
enum Item_result result_type() const override
Definition: item_cmpfunc.h:2026
enum Item_result cached_result_type left_result_type
Definition: item_cmpfunc.h:1979
uint ncases
Definition: item_cmpfunc.h:1981
String tmp_value
Definition: item_cmpfunc.h:1980
enum Functype functype() const override
Definition: item_cmpfunc.h:2034
int get_else_expr_num() const
Definition: item_cmpfunc.h:2011
Definition: item_cmpfunc.h:1415
Item_func_coalesce(const POS &pos, Item *a)
Definition: item_cmpfunc.h:1421
Item_func_coalesce(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:1417
enum Item_result result_type() const override
Definition: item_cmpfunc.h:1452
Item_func_coalesce(Item *a, Item *b)
Definition: item_cmpfunc.h:1434
const char * func_name() const override
Definition: item_cmpfunc.h:1453
enum_field_types default_data_type() const override
Get the default data (output) type for the specific item.
Definition: item_cmpfunc.h:1431
Item_func_coalesce(Item *a)
Definition: item_cmpfunc.h:1424
Item_func_coalesce(const POS &pos, PT_item_list *list)
Definition: item_cmpfunc.h:1427
enum Functype functype() const override
Definition: item_cmpfunc.h:1454
void set_numeric_type() override
Definition: item_cmpfunc.h:1451
Item_func_comparison is a class for comparison functions that take two arguments and return a boolean...
Definition: item_cmpfunc.h:685
bool subst_argument_checker(uchar **) override
Definition: item_cmpfunc.h:697
Item_func_comparison(Item *a, Item *b)
Definition: item_cmpfunc.h:687
Item_func_comparison(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:690
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item_cmpfunc.cc:6653
Item * truth_transformer(THD *, Bool_test) override
Informs an item that it is wrapped in a truth test, in case it wants to transforms itself to implemen...
Definition: item_cmpfunc.cc:6528
virtual Item * negated_item()
just fake method, should never be called.
Definition: item_cmpfunc.cc:6648
bool cast_incompatible_args(uchar *) override
Wrap incompatible arguments in CAST nodes to the expected data types.
Definition: item_cmpfunc.cc:6668
Implements the comparison operator equals (=)
Definition: item_cmpfunc.h:1045
enum Functype functype() const override
Definition: item_cmpfunc.h:1050
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:1057
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:1052
Item_func_eq(Item *a, Item *b)
Definition: item_cmpfunc.h:1047
Item_func_eq(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:1048
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:1051
const char * func_name() const override
Definition: item_cmpfunc.h:1053
bool equality_substitution_analyzer(uchar **) override
Definition: item_cmpfunc.h:1055
The <=> operator evaluates the same as.
Definition: item_cmpfunc.h:1108
Item * truth_transformer(THD *, Bool_test) override
Informs an item that it is wrapped in a truth test, in case it wants to transforms itself to implemen...
Definition: item_cmpfunc.h:1126
bool set_cmp_func() override
Sets up a comparator of the correct type based on the type of the function's arguments.
Definition: item_cmpfunc.h:1117
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:1124
enum Functype functype() const override
Definition: item_cmpfunc.h:1122
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:1123
const char * func_name() const override
Definition: item_cmpfunc.h:1125
Item_func_equal(Item *a, Item *b)
Definition: item_cmpfunc.h:1110
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item_cmpfunc.h:1127
Item_func_equal(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:1113
A predicate that is "always false".
Definition: item_cmpfunc.h:391
longlong val_int() override
Definition: item_cmpfunc.h:397
Item_func_false()
Definition: item_cmpfunc.h:393
const char * func_name() const override
Definition: item_cmpfunc.h:395
Item_func_false(const POS &pos)
Definition: item_cmpfunc.h:394
enum Functype functype() const override
Definition: item_cmpfunc.h:401
bool val_bool() override
Definition: item_cmpfunc.h:396
void print(const THD *, String *str, enum_query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:398
Implements the comparison operator greater than or equals (>=)
Definition: item_cmpfunc.h:1138
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:1147
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:1143
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:1144
Item_func_ge(Item *a, Item *b)
Definition: item_cmpfunc.h:1140
const char * func_name() const override
Definition: item_cmpfunc.h:1145
enum Functype functype() const override
Definition: item_cmpfunc.h:1142
Implements the comparison operator greater than (>)
Definition: item_cmpfunc.h:1158
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:1167
Item_func_gt(Item *a, Item *b)
Definition: item_cmpfunc.h:1160
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:1164
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:1163
const char * func_name() const override
Definition: item_cmpfunc.h:1165
enum Functype functype() const override
Definition: item_cmpfunc.h:1162
Definition: item_cmpfunc.h:1489
Item_func_if(Item *a, Item *b, Item *c)
Definition: item_cmpfunc.h:1493
enum Functype functype() const override
Definition: item_cmpfunc.h:1520
enum Item_result result_type() const override
Definition: item_cmpfunc.h:1509
enum_field_types default_data_type() const override
Get the default data (output) type for the specific item.
Definition: item_cmpfunc.h:1511
const char * func_name() const override
Definition: item_cmpfunc.h:1519
void update_not_null_tables()
Definition: item_cmpfunc.h:1524
enum Item_result cached_result_type
Definition: item_cmpfunc.h:1490
Item_func_if(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_cmpfunc.h:1497
Definition: item_cmpfunc.h:1457
bool field_type_defined
Definition: item_cmpfunc.h:1459
Item_func_ifnull(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:1462
const char * func_name() const override
Definition: item_cmpfunc.h:1471
in_expr [NOT] IN (in_value_list).
Definition: item_cmpfunc.h:2048
DTCollation cmp_collation
Definition: item_cmpfunc.h:2078
Item_func_in(const POS &pos, PT_item_list *list, bool is_negation)
Definition: item_cmpfunc.h:2081
enum Functype functype() const override
Definition: item_cmpfunc.h:2108
const char * func_name() const override
Definition: item_cmpfunc.h:2109
Item_result left_result_type
Definition: item_cmpfunc.h:2076
bool is_bool_func() const override
Definition: item_cmpfunc.h:2110
uint decimal_precision() const override
Definition: item_cmpfunc.h:2093
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:2111
void update_not_null_tables()
Definition: item_cmpfunc.h:2121
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:2105
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:2114
Definition: item_cmpfunc.h:1384
Item_row * row
Definition: item_cmpfunc.h:1387
bool use_decimal_comparison
Definition: item_cmpfunc.h:1388
const char * func_name() const override
Definition: item_cmpfunc.h:1403
interval_range * intervals
Definition: item_cmpfunc.h:1389
uint decimal_precision() const override
Definition: item_cmpfunc.h:1404
Item_int_func super
Definition: item_cmpfunc.h:1385
Item_func_interval(const POS &pos, MEM_ROOT *mem_root, Item *expr1, Item *expr2, class PT_item_list *opt_expr_list=nullptr)
Definition: item_cmpfunc.h:1392
Definition: item_cmpfunc.h:2312
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:2330
void apply_is_true() override
Apply the IS TRUE truth property, meaning that an UNKNOWN result and a FALSE result are treated the s...
Definition: item_cmpfunc.h:2333
const char * func_name() const override
Definition: item_cmpfunc.h:2325
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:2326
Item_func_isnotnull(Item *a)
Definition: item_cmpfunc.h:2314
enum Functype functype() const override
Definition: item_cmpfunc.h:2320
Item_func_isnotnull(const POS &pos, Item *a)
Definition: item_cmpfunc.h:2315
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_cmpfunc.h:2321
Definition: item_cmpfunc.h:2248
Item_func_isnull(Item *a)
Definition: item_cmpfunc.h:2255
Item_func_isnull(const POS &pos, Item *a)
Definition: item_cmpfunc.h:2256
const char * func_name() const override
Definition: item_cmpfunc.h:2262
Item_bool_func super
Definition: item_cmpfunc.h:2249
enum Functype functype() const override
Definition: item_cmpfunc.h:2260
bool cached_value
Definition: item_cmpfunc.h:2252
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:2274
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:2270
Implements the comparison operator less than or equals (<=)
Definition: item_cmpfunc.h:1178
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:1187
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:1184
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:1183
Item_func_le(Item *a, Item *b)
Definition: item_cmpfunc.h:1180
const char * func_name() const override
Definition: item_cmpfunc.h:1185
enum Functype functype() const override
Definition: item_cmpfunc.h:1182
Definition: item_cmpfunc.h:2342
Item_func_like(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:2361
int escape() const
Returns the escape character.
Definition: item_cmpfunc.h:2385
int m_escape
The escape character (0 if no escape character).
Definition: item_cmpfunc.h:2349
enum Functype functype() const override
Definition: item_cmpfunc.h:2365
bool escape_was_used_in_parsing() const
Definition: item_cmpfunc.h:2382
Item_func_like(Item *a, Item *b, Item *escape_arg)
Definition: item_cmpfunc.h:2353
Item_func_like(Item *a, Item *b)
Definition: item_cmpfunc.h:2352
cond_result eq_cmp_result() const override
Result may be not equal with equal inputs if ESCAPE character is present.
Definition: item_cmpfunc.h:2368
const char * func_name() const override
Definition: item_cmpfunc.h:2369
bool escape_is_evaluated() const
Has the escape clause been evaluated? It only needs to be evaluated once per execution,...
Definition: item_cmpfunc.h:2396
Item_func_like(const POS &pos, Item *a, Item *b, Item *escape_arg)
Definition: item_cmpfunc.h:2357
Implements the comparison operator less than (<)
Definition: item_cmpfunc.h:1230
Item_func_lt(Item *a, Item *b)
Definition: item_cmpfunc.h:1232
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:1236
enum Functype functype() const override
Definition: item_cmpfunc.h:1234
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:1239
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:1235
const char * func_name() const override
Definition: item_cmpfunc.h:1237
Wrapper class when MATCH function is used in WHERE clause.
Definition: item_cmpfunc.h:759
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table 'filter_for_table' for this item.
Definition: item_cmpfunc.h:771
Item_func_match_predicate(Item *a)
Definition: item_cmpfunc.h:761
const char * func_name() const override
Definition: item_cmpfunc.h:765
longlong val_int() override
Definition: item_cmpfunc.cc:7065
enum Functype functype() const override
Definition: item_cmpfunc.h:764
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:766
Implements the comparison operator not equals (<>)
Definition: item_cmpfunc.h:1250
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:1255
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:1256
const char * func_name() const override
Definition: item_cmpfunc.h:1258
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:1257
Item_func_ne(Item *a, Item *b)
Definition: item_cmpfunc.h:1252
enum Functype functype() const override
Definition: item_cmpfunc.h:1254
Definition: item_cmpfunc.h:964
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_cmpfunc.h:969
Item * truth_transformer(THD *, Bool_test) override
Apply NOT transformation to the item and return a new one.
Definition: item_cmpfunc.cc:6589
Item_func_nop_all(Item *a)
Definition: item_cmpfunc.h:966
const char * func_name() const override
Definition: item_cmpfunc.h:968
longlong val_int() override
Special NOP (No OPeration) for ALL subquery.
Definition: item_cmpfunc.cc:433
Definition: item_cmpfunc.h:909
bool empty_underlying_subquery()
Definition: item_cmpfunc.cc:397
bool abort_on_null
Definition: item_cmpfunc.h:914
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:416
const char * func_name() const override
Definition: item_cmpfunc.h:931
Item_subselect * subselect
Definition: item_cmpfunc.h:913
Item * truth_transformer(THD *, Bool_test) override
Apply NOT transformation to the item and return a new one.
Definition: item_cmpfunc.cc:6600
longlong val_int() override
special NOT for ALL subquery.
Definition: item_cmpfunc.cc:383
void set_subselect(Item_subselect *item)
Definition: item_cmpfunc.h:936
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_cmpfunc.h:937
void set_sum_test(Item_sum_hybrid *item)
Definition: item_cmpfunc.h:934
bool show
Definition: item_cmpfunc.h:917
void apply_is_true() override
Apply the IS TRUE truth property, meaning that an UNKNOWN result and a FALSE result are treated the s...
Definition: item_cmpfunc.h:926
enum Functype functype() const override
Definition: item_cmpfunc.h:930
void set_sub_test(Item_maxmin_subselect *item)
Definition: item_cmpfunc.h:935
bool ignore_unknown() const
Treat UNKNOWN result like FALSE because callers see no difference.
Definition: item_cmpfunc.h:928
Item_sum_hybrid * test_sum_item
Definition: item_cmpfunc.h:911
Item_func_not_all(Item *a)
Definition: item_cmpfunc.h:919
Item_maxmin_subselect * test_sub_item
Definition: item_cmpfunc.h:912
Definition: item_cmpfunc.h:729
Item * truth_transformer(THD *, Bool_test) override
Apply NOT transformation to the item and return a new one.
Definition: item_cmpfunc.cc:6522
enum Functype functype() const override
Definition: item_cmpfunc.h:735
const char * func_name() const override
Definition: item_cmpfunc.h:736
longlong val_int() override
Definition: item_cmpfunc.cc:351
Item_func_not(Item *a)
Definition: item_cmpfunc.h:731
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table 'filter_for_table' for this item.
Definition: item_cmpfunc.cc:325
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:372
Item_func_not(const POS &pos, Item *a)
Definition: item_cmpfunc.h:732
Definition: item_cmpfunc.h:1530
enum_field_types default_data_type() const override
Get the default data (output) type for the specific item.
Definition: item_cmpfunc.h:1544
enum Functype functype() const override
Definition: item_cmpfunc.h:1550
Item_result result_type() const override
Definition: item_cmpfunc.h:1543
bool is_bool_func() const override
This is a workaround for the broken inheritance hierarchy: this should inherit from Item_func instead...
Definition: item_cmpfunc.h:1565
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:1555
enum Item_result cached_result_type
Definition: item_cmpfunc.h:1531
Item_func_nullif(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:1534
const char * func_name() const override
Definition: item_cmpfunc.h:1549
uint decimal_precision() const override
Definition: item_cmpfunc.h:1553
Definition: item_func.h:779
Definition: item_cmpfunc.h:1276
void negate()
Definition: item_cmpfunc.h:1291
bool ignore_unknown() const
Definition: item_cmpfunc.h:1293
bool subst_argument_checker(uchar **) override
Definition: item_cmpfunc.h:1300
Item * truth_transformer(THD *, Bool_test test) override
Informs an item that it is wrapped in a truth test, in case it wants to transforms itself to implemen...
Definition: item_cmpfunc.h:1294
bool pred_level
Definition: item_cmpfunc.h:1279
Item_func_opt_neg(const POS &pos, Item *a, Item *b, Item *c, bool is_negation)
Definition: item_cmpfunc.h:1281
void apply_is_true() override
Apply the IS TRUE truth property, meaning that an UNKNOWN result and a FALSE result are treated the s...
Definition: item_cmpfunc.h:1292
Item_func_opt_neg(const POS &pos, PT_item_list *list, bool is_negation)
Definition: item_cmpfunc.h:1285
bool negated
Definition: item_cmpfunc.h:1278
Internal function used by subquery to derived transformation to check if a subquery is scalar.
Definition: item_cmpfunc.h:1201
table_map get_initial_pseudo_tables() const override
We add RAND_TABLE_BIT to prevent moving this item from the JOIN condition: it might raise an error to...
Definition: item_cmpfunc.h:1222
const char * func_name() const override
Definition: item_cmpfunc.h:1205
bool is_valid_for_pushdown(uchar *arg) override
Redefine to avoid pushing into derived table.
Definition: item_cmpfunc.h:1207
Item_func_reject_if(Item *a)
Definition: item_cmpfunc.h:1203
Definition: item_cmpfunc.h:1355
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:1364
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_cmpfunc.h:1370
const char * func_name() const override
Definition: item_cmpfunc.h:1361
Item_func_strcmp(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:1357
enum Functype functype() const override
Definition: item_cmpfunc.h:1362
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:1360
Definition: item_cmpfunc.h:811
bool fix_fields(THD *thd, Item **ref) override
Definition: item_cmpfunc.h:875
enum_trig_type
Definition: item_cmpfunc.h:813
@ FOUND_MATCH
This trigger type deactivates predicated from WHERE condition when no row satisfying the join conditi...
Definition: item_cmpfunc.h:828
@ IS_NOT_NULL_COMPL
This trigger type deactivates join conditions when a row has been NULL-complemented.
Definition: item_cmpfunc.h:819
@ OUTER_FIELD_IS_NOT_NULL
In IN->EXISTS subquery transformation, new predicates are added: WHERE inner_field=outer_field OR inn...
Definition: item_cmpfunc.h:837
const char * func_name() const override
'<if>', to distinguish from the if() SQL function
Definition: item_cmpfunc.h:870
void add_trig_func_tables()
Definition: item_cmpfunc.h:880
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_cmpfunc.h:889
enum enum_trig_type get_trig_type() const
Definition: item_cmpfunc.h:899
bool contains_only_equi_join_condition() const override
Whether this Item is an equi-join condition.
Definition: item_cmpfunc.cc:7419
Item_func_trig_cond(Item *a, bool *f, const JOIN *join, plan_idx idx, enum_trig_type trig_type_arg)
Definition: item_cmpfunc.h:860
table_map get_inner_tables() const
Get table_map of inner tables spanned by associated outer join operation.
Definition: item_cmpfunc.cc:7111
const JOIN * get_join() const
Definition: item_cmpfunc.h:898
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:7131
void get_table_range(Table_ref **first_table, Table_ref **last_table) const
Get range of inner tables spanned by associated outer join operation.
Definition: item_cmpfunc.cc:7090
bool * get_trig_var()
Definition: item_cmpfunc.h:900
plan_idx idx() const
Definition: item_cmpfunc.h:904
plan_idx m_idx
Optional: if join!=NULL: index of table.
Definition: item_cmpfunc.h:846
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_cmpfunc.h:893
longlong val_int() override
Definition: item_cmpfunc.cc:7076
enum_trig_type trig_type
Type of trig_var; for printing.
Definition: item_cmpfunc.h:848
enum Functype functype() const override
Definition: item_cmpfunc.h:868
bool * trig_var
Pointer to trigger variable.
Definition: item_cmpfunc.h:842
enum_trig_type get_trig_type()
Definition: item_cmpfunc.h:901
const JOIN * m_join
Optional: JOIN of table which is the source of trig_var.
Definition: item_cmpfunc.h:844
A predicate that is "always true".
Definition: item_cmpfunc.h:376
bool val_bool() override
Definition: item_cmpfunc.h:381
enum Functype functype() const override
Definition: item_cmpfunc.h:386
Item_func_true()
Definition: item_cmpfunc.h:378
void print(const THD *, String *str, enum_query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:383
Item_func_true(const POS &pos)
Definition: item_cmpfunc.h:379
const char * func_name() const override
Definition: item_cmpfunc.h:380
longlong val_int() override
Definition: item_cmpfunc.h:382
Item class, to represent X IS [NOT] (TRUE | FALSE) boolean predicates.
Definition: item_cmpfunc.h:408
Bool_test truth_test
The value we're testing for.
Definition: item_cmpfunc.h:467
Item_bool_func super
Definition: item_cmpfunc.h:409
longlong val_int() override
Definition: item_cmpfunc.cc:2105
void apply_is_true() override
Apply the IS TRUE truth property, meaning that an UNKNOWN result and a FALSE result are treated the s...
Definition: item_cmpfunc.h:451
enum Functype functype() const override
Definition: item_cmpfunc.h:423
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:2095
Item_func_truth(const POS &pos, Item *a, Bool_test truth_test)
Definition: item_cmpfunc.h:425
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_cmpfunc.cc:2089
Item * truth_transformer(THD *, Bool_test test) override
Informs an item that it is wrapped in a truth test, in case it wants to transforms itself to implemen...
Definition: item_cmpfunc.h:416
Item_func_truth(Item *a, Bool_test truth_test)
Definition: item_cmpfunc.h:438
const char * func_name() const override
Definition: item_cmpfunc.h:420
XOR inherits from Item_bool_func2 because it is not optimized yet.
Definition: item_cmpfunc.h:708
Item_bool_func2 super
Definition: item_cmpfunc.h:709
const char * func_name() const override
Definition: item_cmpfunc.h:717
longlong val_int() override
Make a logical XOR of the arguments.
Definition: item_cmpfunc.cc:6481
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table 'filter_for_table' for this item.
Definition: item_cmpfunc.cc:6443
bool itemize(Parse_context *pc, Item **res) override
The same as contextualize() but with additional parameter.
Definition: item_cmpfunc.cc:6428
enum Functype functype() const override
Definition: item_cmpfunc.h:716
void apply_is_true() override
Apply the IS TRUE truth property, meaning that an UNKNOWN result and a FALSE result are treated the s...
Definition: item_cmpfunc.h:720
Item_func_xor(const POS &pos, Item *i1, Item *i2)
Definition: item_cmpfunc.h:713
Item_func_xor(Item *i1, Item *i2)
Definition: item_cmpfunc.h:712
Item * truth_transformer(THD *, Bool_test) override
XOR can be negated by negating one of the operands:
Definition: item_cmpfunc.cc:6540
Definition: item_func.h:93
my_decimal * val_decimal(my_decimal *) override
Definition: item_func.cc:809
void split_sum_func(THD *thd, Ref_item_array ref_item_array, mem_root_deque< Item * > *fields) override
See comments in Item_cmp_func::split_sum_func()
Definition: item_func.cc:701
Item ** args
Array of pointers to arguments.
Definition: item_func.h:100
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_func.cc:708
void traverse_cond(Cond_traverser traverser, void *arg, traverse_order order) override
Definition: item_func.cc:620
Item * compile(Item_analyzer analyzer, uchar **arg_p, Item_transformer transformer, uchar *arg_t) override
Compile Item_func object with a processor and a transformer callback functions.
Definition: item_func.cc:678
Functype
Definition: item_func.h:176
@ TRIG_COND_FUNC
Definition: item_func.h:219
@ NOT_ALL_FUNC
Definition: item_func.h:216
@ LIKE_FUNC
Definition: item_func.h:187
@ FALSE_FUNC
Definition: item_func.h:298
@ NULLIF_FUNC
Definition: item_func.h:260
@ NOT_FUNC
Definition: item_func.h:215
@ XOR_FUNC
Definition: item_func.h:193
@ COND_OR_FUNC
Definition: item_func.h:192
@ COND_AND_FUNC
Definition: item_func.h:191
@ EQ_FUNC
Definition: item_func.h:178
@ TRUE_FUNC
Definition: item_func.h:297
@ IN_FUNC
Definition: item_func.h:195
@ LE_FUNC
Definition: item_func.h:182
@ MATCH_FUNC
Definition: item_func.h:186
@ LT_FUNC
Definition: item_func.h:181
@ ISNULL_FUNC
Definition: item_func.h:188
@ ISNOTNULLTEST_FUNC
Definition: item_func.h:198
@ MULT_EQUAL_FUNC
Definition: item_func.h:196
@ ISTRUTH_FUNC
Definition: item_func.h:190
@ BETWEEN
Definition: item_func.h:194
@ IF_FUNC
Definition: item_func.h:259
@ STRCMP_FUNC
Definition: item_func.h:296
@ NE_FUNC
Definition: item_func.h:180
@ GE_FUNC
Definition: item_func.h:183
@ EQUAL_FUNC
Definition: item_func.h:179
@ GT_FUNC
Definition: item_func.h:184
@ UNKNOWN_FUNC
Definition: item_func.h:177
@ ISNOTNULL_FUNC
Definition: item_func.h:189
@ CASE_FUNC
Definition: item_func.h:261
@ COALESCE_FUNC
Definition: item_func.h:290
void print_op(const THD *thd, String *str, enum_query_type query_type) const
Definition: item_func.cc:737
table_map used_tables_cache
Value used in calculation of result of used_tables()
Definition: item_func.h:162
optimize_type
Definition: item_func.h:300
@ OPTIMIZE_NONE
Definition: item_func.h:301
@ OPTIMIZE_EQUAL
Definition: item_func.h:305
@ OPTIMIZE_NULL
Definition: item_func.h:304
@ OPTIMIZE_KEY
Definition: item_func.h:302
@ OPTIMIZE_OP
Definition: item_func.h:303
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_func.h:624
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:721
bool fix_fields(THD *, Item **ref) override
Definition: item_func.cc:394
void fix_after_pullout(Query_block *parent_query_block, Query_block *removed_query_block) override
Fix after tables have been moved from one query_block level to the parent level, e....
Definition: item_func.cc:448
bool set_arguments(mem_root_deque< Item * > *list, bool context_free)
Copy arguments from list to args array.
Definition: item_func.cc:317
bool itemize(Parse_context *pc, Item **res) override
The same as contextualize() but with additional parameter.
Definition: item_func.cc:349
uint arg_count
How many arguments in 'args'.
Definition: item_func.h:123
Field * tmp_table_field(TABLE *t_arg) override
Definition: item_func.cc:767
bool eq(const Item *item, bool binary_cmp) const override
Definition: item_func.cc:751
table_map not_null_tables_cache
Value used in calculation of result of not_null_tables()
Definition: item_func.h:164
bool null_on_null
Affects how to determine that NULL argument implies a NULL function return.
Definition: item_func.h:155
bool walk(Item_processor processor, enum_walk walk, uchar *arg) override
Traverses a tree of Items in prefix and/or postfix order.
Definition: item_func.cc:609
Item * transform(Item_transformer transformer, uchar *arg) override
Transform an Item_func object with a transformer callback function.
Definition: item_func.cc:653
virtual bool resolve_type_inner(THD *)
Resolve type of function after all arguments have had their data types resolved.
Definition: item_func.h:456
uint allowed_arg_cols
Definition: item_func.h:160
Definition: item.h:3855
Definition: item_cmpfunc.h:489
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item_cmpfunc.cc:2405
Item_cache * cache
Definition: item_cmpfunc.h:491
const char * func_name() const override
Definition: item_cmpfunc.h:516
longlong val_int() override
The implementation of optimized <outer expression> [NOT] IN <subquery> predicates.
Definition: item_cmpfunc.cc:2320
Item_in_optimizer(Item_in_subselect *item)
Definition: item_cmpfunc.h:501
int result_for_null_param
Stores the value of "NULL IN (SELECT ...)" for uncorrelated subqueries: UNKNOWN - "NULL in (SELECT ....
Definition: item_cmpfunc.h:498
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_cmpfunc.cc:2217
bool fix_left(THD *thd, Item **ref)
Definition: item_cmpfunc.cc:2138
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_cmpfunc.cc:2410
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_cmpfunc.cc:2400
void split_sum_func(THD *thd, Ref_item_array ref_item_array, mem_root_deque< Item * > *fields) override
Definition: item_cmpfunc.cc:2228
Item_cache ** get_cache()
Definition: item_cmpfunc.h:517
bool fix_fields(THD *, Item **) override
Definition: item_cmpfunc.cc:2180
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:2235
Representation of IN subquery predicates of the form "left_expr IN (SELECT ...)".
Definition: item_subselect.h:525
Definition: item_func.h:926
String * val_str(String *str) override
Definition: item_func.cc:1436
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override
Definition: item_func.h:974
double val_real() override
Definition: item_func.cc:1430
enum Item_result result_type() const override
Definition: item_func.h:978
bool get_time(MYSQL_TIME *ltime) override
Definition: item_func.h:977
Definition: item.h:4880
Definition: item_cmpfunc.h:2287
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:2306
Item_in_subselect * owner
Definition: item_cmpfunc.h:2288
const char * func_name() const override
Definition: item_cmpfunc.h:2295
Item_is_not_null_test(Item_in_subselect *ow, Item *a)
Definition: item_cmpfunc.h:2291
table_map get_initial_pseudo_tables() const override
We add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE.
Definition: item_cmpfunc.h:2303
enum Functype functype() const override
Definition: item_cmpfunc.h:2293
Definition: item_subselect.h:370
Item with result field.
Definition: item.h:5590
Field * result_field
Definition: item.h:5592
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item.cc:10610
Item which stores (x,y,...) and ROW(x,y,...).
Definition: item_row.h:53
Definition: item.h:5219
Definition: item_subselect.h:79
Abstract base class for the MIN and MAX aggregate functions.
Definition: item_sum.h:1529
Definition: item.h:5006
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:850
virtual double val_real()=0
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:1947
void set_nullable(bool nullable)
Definition: item.h:3424
DTCollation collation
Character set and collation properties assigned for this Item.
Definition: item.h:3341
void set_data_type_bool()
Definition: item.h:1395
bool is_nullable() const
Definition: item.h:3423
void set_subquery()
Set the "has subquery" property.
Definition: item.h:3215
void fix_char_length(uint32 max_char_length_arg)
Definition: item.h:3172
virtual Item * equality_substitution_transformer(uchar *)
Definition: item.h:2814
virtual uint decimal_precision() const
Definition: item.cc:648
virtual bool val_json(Json_wrapper *result)
Get a JSON value from an Item.
Definition: item.h:1919
virtual longlong val_int()=0
virtual void print(const THD *, String *str, enum_query_type) const
This method is used for to:
Definition: item.h:2313
bool fixed
True if item has been resolved.
Definition: item.h:3412
bool null_value
True if item is null.
Definition: item.h:3449
Type
Definition: item.h:886
@ COND_ITEM
Definition: item.h:900
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:2384
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:2202
virtual TYPELIB * get_typelib() const
Get the typelib information for an item of type set or enum.
Definition: item.h:1647
bool unsigned_flag
Definition: item.h:3450
virtual bool aggregate_check_group(uchar *)
Definition: item.h:2744
virtual bool is_null()
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item.h:2365
virtual bool aggregate_check_distinct(uchar *)
Definition: item.h:2742
cond_result
Definition: item.h:919
@ COND_TRUE
Definition: item.h:919
@ COND_FALSE
Definition: item.h:919
@ COND_OK
Definition: item.h:919
traverse_order
Definition: item.h:921
Bool_test
< Modifier for result transformation
Definition: item.h:934
@ BOOL_NOT_FALSE
Definition: item.h:938
@ BOOL_NOT_TRUE
Definition: item.h:937
@ BOOL_IS_TRUE
Definition: item.h:934
@ BOOL_IS_FALSE
Definition: item.h:935
@ BOOL_NEGATED
Definition: item.h:941
uint32 max_length
Maximum length of result of evaluating this item, in number of bytes.
Definition: item.h:3359
virtual enum Type type() const =0
virtual uint cols() const
Definition: item.h:2979
Definition: sql_optimizer.h:132
A class that is capable of holding objects of any sub-type of Json_scalar.
Definition: json_dom.h:1892
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1160
Definition: item_cmpfunc.h:607
Item_bool_func * create(Item *a, Item *b) const override
Definition: item_cmpfunc.cc:321
bool l_op() const override
Definition: item_cmpfunc.h:612
const char * symbol(bool invert) const override
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:610
bool eqne_op() const override
Definition: item_cmpfunc.h:611
Abstract base class for the comparison operators =, <> and <=>.
Definition: item_cmpfunc.h:534
virtual Item_bool_func * create_scalar_predicate(Item *a, Item *b) const =0
Creates only an item tree node, without attempting to rewrite row constructors.
virtual Item_bool_func * combine(List< Item > list) const =0
Combines a list of conditions exp op exp.
bool eqne_op() const override
Definition: item_cmpfunc.h:537
Item_bool_func * create(Item *a, Item *b) const override
This implementation of the factory method also implements flattening of row constructors.
Definition: item_cmpfunc.cc:263
bool l_op() const override
Definition: item_cmpfunc.h:538
Definition: sql_list.h:619
Definition: sql_list.h:433
void sort(Node_cmp_func cmp)
Sort the list.
Definition: sql_list.h:533
T * head()
Definition: sql_list.h:459
Definition: item_cmpfunc.h:591
Item_bool_func * create(Item *a, Item *b) const override
Definition: item_cmpfunc.cc:313
bool l_op() const override
Definition: item_cmpfunc.h:596
bool eqne_op() const override
Definition: item_cmpfunc.h:595
const char * symbol(bool invert) const override
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:594
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:60
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:425
Definition: item_cmpfunc.h:574
Item_bool_func * create_scalar_predicate(Item *a, Item *b) const override
Creates only an item tree node, without attempting to rewrite row constructors.
Definition: item_cmpfunc.cc:300
const char * symbol(bool invert) const override
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:576
Item_bool_func * combine(List< Item > list) const override
Combines a list of conditions exp op exp.
Definition: item_cmpfunc.cc:305
Wrapper class for an Item list head, used to allocate Item lists in the parser in a context-independe...
Definition: parse_tree_helpers.h:104
Base class for parse tree nodes (excluding the Parse_tree_root hierarchy)
Definition: parse_tree_node_base.h:138
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1155
String class wrapper with a preallocated buffer of size buff_sz.
Definition: sql_string.h:629
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:166
bool copy()
Definition: sql_string.cc:191
bool is_alloced() const
Definition: sql_string.h:414
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
Definition: table.h:2761
uint elements
Definition: sql_list.h:135
Definition: item_cmpfunc.h:1913
longlong value
Definition: item_cmpfunc.h:1914
bool has_date
Distinguish between DATE/DATETIME/TIMESTAMP and TIME.
Definition: item_cmpfunc.h:1920
const Item * warn_item
Definition: item_cmpfunc.h:1918
Definition: item_cmpfunc.h:1948
my_decimal value
Definition: item_cmpfunc.h:1949
Definition: item_cmpfunc.h:1889
longlong value
Definition: item_cmpfunc.h:1890
void store_value(Item *item) override
Definition: item_cmpfunc.h:1893
int cmp(Item *arg) override
Definition: item_cmpfunc.h:1897
int compare(const cmp_item *ci) const override
Definition: item_cmpfunc.h:1901
Definition: item_cmpfunc.h:1863
unique_ptr_destroy_only< Json_wrapper > m_value
Cached JSON value to look up.
Definition: item_cmpfunc.h:1866
~cmp_item_json() override
String m_str_value
String buffer.
Definition: item_cmpfunc.h:1870
unique_ptr_destroy_only< Json_scalar_holder > m_holder
Cache for the value above.
Definition: item_cmpfunc.h:1868
Definition: item_cmpfunc.h:1929
int cmp(Item *arg) override
Definition: item_cmpfunc.h:1937
double value
Definition: item_cmpfunc.h:1930
void store_value(Item *item) override
Definition: item_cmpfunc.h:1933
int compare(const cmp_item *ci) const override
Definition: item_cmpfunc.h:1941
Definition: item_cmpfunc.h:2169
cmp_item_row(cmp_item_row &&other)
Definition: item_cmpfunc.h:2184
uint n
Definition: item_cmpfunc.h:2171
cmp_item_row(THD *thd, Item *item)
Definition: item_cmpfunc.h:2179
cmp_item_row()
Definition: item_cmpfunc.h:2174
cmp_item which stores a scalar (i.e. non-ROW).
Definition: item_cmpfunc.h:1829
void set_null_value(bool nv)
Definition: item_cmpfunc.h:1832
bool m_null_value
If stored value is NULL.
Definition: item_cmpfunc.h:1831
Definition: item_cmpfunc.h:1835
const String * value_res
Definition: item_cmpfunc.h:1837
int compare(const cmp_item *ci) const override
Definition: item_cmpfunc.h:1844
cmp_item_string(const CHARSET_INFO *cs)
Definition: item_cmpfunc.h:1842
void store_value(Item *item) override
Definition: item_cmpfunc.h:1849
const CHARSET_INFO * cmp_charset
Definition: item_cmpfunc.h:1839
StringBuffer< STRING_BUFFER_USUAL_SIZE > value
Definition: item_cmpfunc.h:1838
Definition: item_cmpfunc.h:1785
virtual void store_value(Item *item)=0
virtual int compare(const cmp_item *item) const =0
virtual int cmp(Item *item)=0
virtual ~cmp_item()=default
virtual cmp_item * make_same()=0
cmp_item()=default
virtual void store_value_by_template(cmp_item *, Item *item)
Definition: item_cmpfunc.h:1823
Definition: item_cmpfunc.h:1697
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1701
in_datetime_as_longlong(MEM_ROOT *mem_root, uint elements)
Definition: item_cmpfunc.h:1699
Definition: item_cmpfunc.h:1725
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1732
Item * warn_item
An item used to issue warnings.
Definition: item_cmpfunc.h:1727
in_datetime(MEM_ROOT *mem_root, Item *warn_item_arg, uint elements)
Definition: item_cmpfunc.h:1730
Definition: item_cmpfunc.h:1761
Mem_root_array< my_decimal > base
Definition: item_cmpfunc.h:1762
in_decimal(MEM_ROOT *mem_root, uint elements)
Definition: item_cmpfunc.h:1765
void value_to_item(uint pos, Item_basic_constant *item) const override
Store the value at position pos into provided item object.
Definition: item_cmpfunc.h:1770
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1767
Definition: item_cmpfunc.h:1741
in_double(MEM_ROOT *mem_root, uint elements)
Definition: item_cmpfunc.h:1745
void value_to_item(uint pos, Item_basic_constant *item) const override
Store the value at position pos into provided item object.
Definition: item_cmpfunc.h:1750
Mem_root_array< double > base
Definition: item_cmpfunc.h:1742
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1747
Definition: item_cmpfunc.h:1664
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1677
in_longlong(MEM_ROOT *mem_root, uint elements)
Definition: item_cmpfunc.h:1675
void value_to_item(uint pos, Item_basic_constant *item) const override
Store the value at position pos into provided item object.
Definition: item_cmpfunc.h:1684
void set(uint pos, Item *item) override
Definition: item_cmpfunc.h:1692
Mem_root_array< packed_longlong > base
Definition: item_cmpfunc.h:1672
Definition: item_cmpfunc.h:2211
Mem_root_array< cmp_item_row * > base_pointers
Definition: item_cmpfunc.h:2215
Mem_root_array< cmp_item_row > base_objects
Definition: item_cmpfunc.h:2213
Item_basic_constant * create_item(MEM_ROOT *) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:2233
unique_ptr_destroy_only< cmp_item_row > tmp
Definition: item_cmpfunc.h:2212
bool is_row_result() const override
Definition: item_cmpfunc.h:2219
void value_to_item(uint, Item_basic_constant *) const override
Store the value at position pos into provided item object.
Definition: item_cmpfunc.h:2237
Definition: item_cmpfunc.h:1640
Mem_root_array< String * > base_pointers
Definition: item_cmpfunc.h:1645
Mem_root_array< String > base_objects
Definition: item_cmpfunc.h:1643
void value_to_item(uint pos, Item_basic_constant *item) const override
Store the value at position pos into provided item object.
Definition: item_cmpfunc.h:1653
const CHARSET_INFO * collation
Definition: item_cmpfunc.h:1646
String tmp
Definition: item_cmpfunc.h:1642
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1650
Definition: item_cmpfunc.h:1709
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1713
in_time_as_longlong(MEM_ROOT *mem_root, uint elements)
Definition: item_cmpfunc.h:1711
Definition: item_cmpfunc.h:1572
const uint m_size
Size of the vector.
Definition: item_cmpfunc.h:1574
virtual void set(uint pos, Item *item)=0
virtual void value_to_item(uint pos, Item_basic_constant *item) const =0
Store the value at position pos into provided item object.
virtual ~in_vector()=default
virtual bool find_item(Item *item)=0
Calls item->val_int() or item->val_str() etc.
virtual bool is_row_result() const
Definition: item_cmpfunc.h:1618
virtual bool compare_elems(uint pos1, uint pos2) const =0
Compare values number pos1 and pos2 for equality.
virtual Item_basic_constant * create_item(MEM_ROOT *mem_root) const =0
Create an instance of Item_{type} (e.g.
virtual void sort_array()=0
Sort the IN-list array, so we can do efficient lookup with binary_search.
in_vector(uint elements)
See Item_func_in::resolve_type() for why we need both count and used_count.
Definition: item_cmpfunc.h:1582
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:109
my_decimal class limits 'decimal_t' type to what we need in MySQL.
Definition: my_decimal.h:93
static MEM_ROOT mem_root
Definition: client_plugin.cc:109
static bool contains(const std::vector< std::string > &container, const std::string &file)
Definition: config_files.cc:40
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:30
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
This file contains the field type.
enum_field_types
Column types for MySQL.
Definition: field_types.h:52
@ MYSQL_TYPE_VARCHAR
Definition: field_types.h:68
@ MYSQL_TYPE_TIME
Definition: field_types.h:64
@ MYSQL_TYPE_DATETIME
Definition: field_types.h:65
bool(Item::* Item_analyzer)(uchar **argp)
Definition: item.h:711
void(* Cond_traverser)(const Item *item, void *arg)
Definition: item.h:721
Item *(Item::* Item_transformer)(uchar *arg)
Type for transformers used by Item::transform and Item::compile.
Definition: item.h:720
static void ensure_multi_equality_fields_are_available(Item **args, int arg_idx, table_map available_tables, bool replace, bool *found)
Definition: item_cmpfunc.cc:7843
int(Arg_comparator::* arg_cmp_func)()
Definition: item_cmpfunc.h:73
Eq_creator eq_creator
Definition: mysqld.cc:1521
Ge_creator ge_creator
Definition: mysqld.cc:1526
Item * make_condition(Parse_context *pc, Item *item)
Ensure that all expressions involved in conditions are boolean functions.
Definition: item_cmpfunc.cc:5402
void find_and_adjust_equal_fields(Item *item, table_map available_tables, bool replace, bool *found)
Definition: item_cmpfunc.cc:7824
Lt_creator lt_creator
Definition: mysqld.cc:1525
bool get_mysql_time_from_str_no_warn(THD *thd, String *str, MYSQL_TIME *l_time, MYSQL_TIME_STATUS *status)
A minion of get_mysql_time_from_str, see its description.
Definition: item_cmpfunc.cc:872
Gt_creator gt_creator
Definition: mysqld.cc:1524
static const int UNKNOWN
Definition: item_cmpfunc.h:470
bool IsAnd(const Item *item)
Returns true if the item is a conjunction.
Definition: item_cmpfunc.h:2808
Ne_creator ne_creator
Definition: mysqld.cc:1522
Equal_creator equal_creator
Definition: mysqld.cc:1523
bool WalkConjunction(Item *condition, Func func)
Calls "func" on each term in "condition" if it's a conjunction (and recursively on any conjunction di...
Definition: item_cmpfunc.h:2821
bool get_mysql_time_from_str(THD *thd, String *str, enum_mysql_timestamp_type warn_type, const char *warn_name, MYSQL_TIME *l_time)
Parse date provided in a string to a MYSQL_TIME.
Definition: item_cmpfunc.cc:903
Le_creator le_creator
Definition: mysqld.cc:1527
longlong get_datetime_value(THD *thd, Item ***item_arg, Item **, const Item *warn_item, bool *is_null)
Retrieve correct DATETIME value from given item.
Definition: item_cmpfunc.cc:1510
Item * and_conds(Item *a, Item *b)
Builds condition: (a AND b) IS TRUE.
Definition: item_cmpfunc.h:2766
String * eval_string_arg(const CHARSET_INFO *to_cs, Item *arg, String *buffer)
Evaluate an argument string and return it in the desired character set.
Definition: item_func.cc:255
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:488
Header for compiler-dependent features.
It is interface module to fixed precision decimals library.
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
unsigned char uchar
Definition: my_inttypes.h:51
long long int longlong
Definition: my_inttypes.h:54
uint16_t uint16
Definition: my_inttypes.h:64
uint64_t table_map
Definition: my_table_map.h:29
Interface for low level time utilities.
unsigned int my_time_flags_t
Flags to str_to_datetime and number_to_datetime.
Definition: my_time.h:93
Time declarations shared between the server and client API: you should not add anything to this heade...
enum_mysql_timestamp_type
Definition: mysql_time.h:44
static bool replace
Definition: mysqlimport.cc:65
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1054
Definition: commit_order_queue.h:33
PT & ref(PT *tp)
Definition: tablespace_impl.cc:358
std::string join(Container cont, const std::string &delim)
join elements of an container into a string separated by a delimiter.
Definition: string.h:150
static mysql_service_status_t add(reference_caching_channel channel, const char *implementation_name) noexcept
Definition: component.cc:134
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2880
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2876
required uint32 status
Definition: replication_asynchronous_connection_failover.proto:60
required string type
Definition: replication_group_member_actions.proto:33