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