MySQL 9.1.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};
1844
1845/// cmp_item which stores a scalar (i.e. non-ROW).
1847 protected:
1848 bool m_null_value; ///< If stored value is NULL
1849 void set_null_value(bool nv) { m_null_value = nv; }
1850};
1851
1852class cmp_item_string final : public cmp_item_scalar {
1853 private:
1857
1858 public:
1859 cmp_item_string(const CHARSET_INFO *cs) : value(cs), cmp_charset(cs) {}
1860
1861 int compare(const cmp_item *ci) const override {
1862 const cmp_item_string *l_cmp = down_cast<const cmp_item_string *>(ci);
1863 return sortcmp(value_res, l_cmp->value_res, cmp_charset);
1864 }
1865
1866 void store_value(Item *item) override {
1867 String *res = eval_string_arg(cmp_charset, item, &value);
1868 if (res && (res != &value || !res->is_alloced())) {
1869 // 'res' may point in item's transient internal data, so make a copy
1870 value.copy(*res);
1871 }
1872 value_res = &value;
1873 set_null_value(item->null_value);
1874 }
1875
1876 int cmp(Item *arg) override;
1877 cmp_item *make_same() override;
1878};
1879
1880class cmp_item_json final : public cmp_item_scalar {
1881 private:
1882 /// Cached JSON value to look up
1884 /// Cache for the value above
1886 /// String buffer
1888
1889 public:
1890 /**
1891 Construct a cmp_item_json object.
1892 @param wrapper a Json_wrapper for holding the JSON value in the comparison
1893 @param holder pre-alloced memory for creating JSON scalar values without
1894 using the heap
1895 */
1898 ~cmp_item_json() override;
1899
1900 int compare(const cmp_item *ci) const override;
1901 void store_value(Item *item) override;
1902 int cmp(Item *arg) override;
1903 cmp_item *make_same() override;
1904};
1905
1906class cmp_item_int final : public cmp_item_scalar {
1908
1909 public:
1910 void store_value(Item *item) override {
1911 value = item->val_int();
1912 set_null_value(item->null_value);
1913 }
1914 int cmp(Item *arg) override {
1915 const bool rc = value != arg->val_int();
1916 return (m_null_value || arg->null_value) ? UNKNOWN : rc;
1917 }
1918 int compare(const cmp_item *ci) const override {
1919 const cmp_item_int *l_cmp = down_cast<const cmp_item_int *>(ci);
1920 return (value < l_cmp->value) ? -1 : ((value == l_cmp->value) ? 0 : 1);
1921 }
1922 cmp_item *make_same() override;
1923};
1924
1925/*
1926 Compare items of temporal type.
1927 Values are obtained with: get_datetime_value() (DATE/DATETIME/TIMESTAMP) and
1928 get_time_value() (TIME).
1929*/
1932
1933 public:
1934 /* Item used for issuing warnings. */
1936 /// Distinguish between DATE/DATETIME/TIMESTAMP and TIME
1938
1939 cmp_item_datetime(const Item *warn_item_arg);
1940 void store_value(Item *item) override;
1941 int cmp(Item *arg) override;
1942 int compare(const cmp_item *ci) const override;
1943 cmp_item *make_same() override;
1944};
1945
1947 double value;
1948
1949 public:
1950 void store_value(Item *item) override {
1951 value = item->val_real();
1952 set_null_value(item->null_value);
1953 }
1954 int cmp(Item *arg) override {
1955 const bool rc = value != arg->val_real();
1956 return (m_null_value || arg->null_value) ? UNKNOWN : rc;
1957 }
1958 int compare(const cmp_item *ci) const override {
1959 const cmp_item_real *l_cmp = down_cast<const cmp_item_real *>(ci);
1960 return (value < l_cmp->value) ? -1 : ((value == l_cmp->value) ? 0 : 1);
1961 }
1962 cmp_item *make_same() override;
1963};
1964
1967
1968 public:
1969 void store_value(Item *item) override;
1970 int cmp(Item *arg) override;
1971 int compare(const cmp_item *c) const override;
1972 cmp_item *make_same() override;
1973};
1974
1975/**
1976 CASE ... WHEN ... THEN ... END function implementation.
1977
1978 When there is no expression between CASE and the first WHEN
1979 (the CASE expression) then this function simple checks all WHEN expressions
1980 one after another. When some WHEN expression evaluated to TRUE then the
1981 value of the corresponding THEN expression is returned.
1982
1983 When the CASE expression is specified then it is compared to each WHEN
1984 expression individually. When an equal WHEN expression is found
1985 corresponding THEN expression is returned.
1986 In order to do correct comparisons several comparators are used. One for
1987 each result type. Different result types that are used in particular
1988 CASE ... END expression are collected in the resolve_type() member
1989 function and only comparators for there result types are used.
1990*/
1991
1992class Item_func_case final : public Item_func {
1994
1995 int first_expr_num, else_expr_num;
1996 enum Item_result cached_result_type, left_result_type;
2001 cmp_item *cmp_items[5]; /* For all result types */
2003
2004 protected:
2005 void add_json_info(Json_object *obj) override {
2006 obj->add_alias("has_case_expression",
2007 create_dom_ptr<Json_boolean>(get_first_expr_num() != -1));
2008 }
2009
2010 public:
2012 Item *first_expr_arg, Item *else_expr_arg)
2013 : super(pos),
2014 first_expr_num(-1),
2015 else_expr_num(-1),
2016 cached_result_type(INT_RESULT),
2017 left_result_type(INT_RESULT),
2018 case_item(nullptr) {
2019 null_on_null = false;
2020 ncases = list->size();
2021 if (first_expr_arg) {
2022 first_expr_num = list->size();
2023 list->push_back(first_expr_arg);
2024 }
2025 if (else_expr_arg) {
2026 else_expr_num = list->size();
2027 list->push_back(else_expr_arg);
2028 }
2029 set_arguments(list, true);
2030 memset(&cmp_items, 0, sizeof(cmp_items));
2031 }
2032 ~Item_func_case() override;
2033 int get_first_expr_num() const { return first_expr_num; }
2034 int get_else_expr_num() const { return else_expr_num; }
2035 double val_real() override;
2036 longlong val_int() override;
2037 String *val_str(String *) override;
2038 my_decimal *val_decimal(my_decimal *) override;
2039 bool val_json(Json_wrapper *wr) override;
2040 bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
2041 bool get_time(MYSQL_TIME *ltime) override;
2042 bool fix_fields(THD *thd, Item **ref) override;
2044 return MYSQL_TYPE_VARCHAR;
2045 }
2046 bool resolve_type(THD *thd) override;
2047 bool resolve_type_inner(THD *thd) override;
2048 TYPELIB *get_typelib() const override;
2049 enum Item_result result_type() const override { return cached_result_type; }
2050 const char *func_name() const override { return "case"; }
2051 void print(const THD *thd, String *str,
2052 enum_query_type query_type) const override;
2053 Item *find_item(String *str);
2054 const CHARSET_INFO *compare_collation() const override {
2055 return cmp_collation.collation;
2056 }
2057 enum Functype functype() const override { return CASE_FUNC; }
2058};
2059
2060/**
2061 in_expr [NOT] IN (in_value_list).
2062
2063 The current implementation distinguishes 2 cases:
2064 1) all items in in_value_list are constants and have the same
2065 result type. This case is handled by in_vector class.
2066 2) otherwise Item_func_in employs several cmp_item objects to perform
2067 comparisons of in_expr and an item from in_value_list. One cmp_item
2068 object for each result type. Different result types are collected in the
2069 resolve_type() member function by means of collect_cmp_types() function.
2070*/
2071class Item_func_in final : public Item_func_opt_neg {
2072 public:
2073 /// An array of const values, created when the bisection lookup method is used
2074 in_vector *m_const_array{nullptr};
2075 /**
2076 If there is some NULL among @<in value list@>, during a val_int() call; for
2077 example
2078 IN ( (1,(3,'col')), ... ), where 'col' is a column which evaluates to
2079 NULL.
2080 */
2081 bool have_null{false};
2082 /// Set to true when values in const array are populated
2083 bool m_populated{false};
2084
2085 private:
2086 /// Set to true if all values in IN-list are const
2087 bool m_values_are_const{true};
2088 /// Set to true if const array must be repopulated per execution.
2089 bool m_need_populate{false};
2090 /**
2091 Set to true by resolve_type() if the IN list contains a
2092 dependent subquery, in which case condition filtering will not be
2093 calculated for this item.
2094 */
2095 bool dep_subq_in_list{false};
2096 /// True until start of 2nd call to resolve_type()
2097 bool first_resolve_call{true};
2098
2100 cmp_item *cmp_items[6]; /* One cmp_item for each result type */
2102
2103 public:
2104 Item_func_in(const POS &pos, PT_item_list *list, bool is_negation)
2105 : Item_func_opt_neg(pos, list, is_negation) {
2106 memset(&cmp_items, 0, sizeof(cmp_items));
2107 allowed_arg_cols = 0; // Fetch this value from first argument
2108 }
2109 ~Item_func_in() override;
2110 longlong val_int() override;
2111 bool fix_fields(THD *, Item **) override;
2112 void fix_after_pullout(Query_block *parent_query_block,
2113 Query_block *removed_query_block) override;
2114 bool resolve_type(THD *) override;
2115 void update_used_tables() override;
2116 uint decimal_precision() const override { return 1; }
2117
2118 /**
2119 Populate values for bisection with fresh values, should be called once
2120 per execution.
2121
2122 @param thd Thread handler
2123
2124 @returns false if success, true if error
2125 */
2126 bool populate_bisection(THD *thd);
2127 void cleanup() override;
2128 optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
2129 void print(const THD *thd, String *str,
2130 enum_query_type query_type) const override;
2131 enum Functype functype() const override { return IN_FUNC; }
2132 const char *func_name() const override { return " IN "; }
2133 bool is_bool_func() const override { return true; }
2134 const CHARSET_INFO *compare_collation() const override {
2135 return cmp_collation.collation;
2136 }
2137 bool gc_subst_analyzer(uchar **) override { return true; }
2138
2139 float get_filtering_effect(THD *thd, table_map filter_for_table,
2140 table_map read_tables,
2141 const MY_BITMAP *fields_to_ignore,
2142 double rows_in_table) override;
2143
2145 // not_null_tables_cache == union(T1(e),union(T1(ei)))
2146 if (pred_level && negated) return;
2147
2149
2150 ///< not_null_tables_cache = union(T1(e),intersection(T1(ei)))
2151 Item **arg_end = args + arg_count;
2152 for (Item **arg = args + 1; arg != arg_end; arg++)
2153 not_null_tables_cache &= (*arg)->not_null_tables();
2155 }
2156
2157 private:
2158 /**
2159 Usable if @<in value list@> is made only of constants. Returns true if one
2160 of these constants contains a NULL. Example:
2161 IN ( (-5, (12,NULL)), ... ).
2162 */
2163 bool list_contains_null();
2164 /**
2165 Utility function to help calculate the total filtering effect of
2166 IN predicates. This function calculates the filtering effect from
2167 a single field (or field reference) on the left hand side of the
2168 expression.
2169
2170 @param fieldref Field (or field reference) on left hand side of
2171 IN, i.e., this function should be called for
2172 each fi in "(f1,...,fn) IN (values)"
2173 @param filter_for_table The table we are calculating filter effect for
2174 @param fields_to_ignore Fields in 'filter_for_table' that should not
2175 be part of the filter calculation. The filtering
2176 effect of these fields are already part of the
2177 calculation somehow (e.g. because there is a
2178 predicate "col = <const>", and the optimizer
2179 has decided to do ref access on 'col').
2180 @param rows_in_table The number of rows in table 'filter_for_table'
2181
2182 @return the filtering effect (between 0 and 1) 'the_field'
2183 participates with in this IN predicate.
2184 */
2185 float get_single_col_filtering_effect(Item_ident *fieldref,
2186 table_map filter_for_table,
2187 const MY_BITMAP *fields_to_ignore,
2188 double rows_in_table);
2189 void cleanup_arrays(); ///< Helper function for this common task
2190};
2191
2192class cmp_item_row : public cmp_item {
2193 cmp_item **comparators{nullptr};
2194 uint n;
2195
2196 // Only used for Mem_root_array::resize()
2197 cmp_item_row() : n(0) {}
2198
2199 friend class Mem_root_array_YY<cmp_item_row>;
2200
2201 public:
2202 cmp_item_row(THD *thd, Item *item) : n(item->cols()) {
2203 allocate_template_comparators(thd, item);
2204 }
2205 ~cmp_item_row() override;
2206
2208 : comparators(other.comparators), n(other.n) {
2209 other.comparators = nullptr;
2210 other.n = 0;
2211 }
2212
2213 bool allocate_value_comparators(MEM_ROOT *mem_root, cmp_item *tmpl,
2214 Item *arg) override;
2215 void store_value(Item *item) override;
2216 int cmp(Item *arg) override;
2217 int compare(const cmp_item *arg) const override;
2218 cmp_item *make_same() override;
2219 void store_value_by_template(cmp_item *tmpl, Item *) override;
2220
2221 private:
2222 /**
2223 Allocate comparator objects for the LHS argument to IN, used as template
2224 for the value comparators.
2225
2226 @param thd Session handle
2227 @param item Item to allocate comparator objects for, left-hand IN operand
2228
2229 @returns false if success, true if error.
2230 */
2231 bool allocate_template_comparators(THD *thd, Item *item);
2232};
2233
2234class in_row final : public in_vector {
2237 // Sort pointers, rather than objects.
2239
2240 public:
2241 in_row(MEM_ROOT *mem_root, uint elements, cmp_item_row *cmp);
2242 bool is_row_result() const override { return true; }
2243 /**
2244 Allocate extra objects for evaluation
2245
2246 @param mem_root Memory root for allocation.
2247 @param lhs The left-hand side object of the IN predicate.
2248 @param arg_count Number of arguments on the right-hand side of the predicate
2249
2250 @returns false if success, true if error.
2251 */
2252 bool allocate(MEM_ROOT *mem_root, Item *lhs, uint arg_count);
2253 bool find_item(Item *item) override;
2254 bool compare_elems(uint pos1, uint pos2) const override;
2255
2257 assert(false);
2258 return nullptr;
2259 }
2260 void value_to_item(uint, Item_basic_constant *) const override {
2261 assert(false);
2262 }
2263
2264 private:
2265 void set(uint pos, Item *item) override;
2266 void sort_array() override;
2267};
2268
2269/* Functions used by where clause */
2270
2273
2274 bool cache_used = false;
2276
2277 public:
2279 Item_func_isnull(const POS &pos, Item *a) : super(pos, a) {
2280 null_on_null = false;
2281 }
2282 longlong val_int() override;
2283 enum Functype functype() const override { return ISNULL_FUNC; }
2284 bool resolve_type(THD *thd) override;
2285 const char *func_name() const override { return "isnull"; }
2286 /* Optimize case of not_null_column IS NULL */
2287 void update_used_tables() override;
2288
2289 float get_filtering_effect(THD *thd, table_map filter_for_table,
2290 table_map read_tables,
2291 const MY_BITMAP *fields_to_ignore,
2292 double rows_in_table) override;
2293 optimize_type select_optimize(const THD *) override { return OPTIMIZE_NULL; }
2294 Item *truth_transformer(THD *, Bool_test test) override;
2295 void print(const THD *thd, String *str,
2296 enum_query_type query_type) const override;
2297 const CHARSET_INFO *compare_collation() const override {
2298 return args[0]->collation.collation;
2299 }
2300 bool fix_fields(THD *thd, Item **ref) override;
2301};
2302
2303/* Functions used by HAVING for rewriting IN subquery */
2304
2305/*
2306 This is like IS NOT NULL but it also remembers if it ever has
2307 encountered a NULL; it remembers this in the "was_null" property of the
2308 "owner" item.
2309*/
2312
2313 public:
2315 : Item_func_isnull(a), owner(ow) {}
2316 enum Functype functype() const override { return ISNOTNULLTEST_FUNC; }
2317 longlong val_int() override;
2318 const char *func_name() const override { return "<is_not_null_test>"; }
2319 bool resolve_type(THD *thd) override;
2320 void update_used_tables() override;
2321 /**
2322 We add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE.
2323
2324 @retval Always RAND_TABLE_BIT
2325 */
2327 return RAND_TABLE_BIT;
2328 }
2329 void print(const THD *thd, String *str,
2330 enum_query_type query_type) const override {
2331 Item_bool_func::print(thd, str, query_type);
2332 }
2333};
2334
2336 public:
2338 Item_func_isnotnull(const POS &pos, Item *a) : Item_bool_func(pos, a) {
2339 null_on_null = false;
2340 }
2341
2342 longlong val_int() override;
2343 enum Functype functype() const override { return ISNOTNULL_FUNC; }
2344 bool resolve_type(THD *thd) override {
2345 set_nullable(false);
2346 return Item_bool_func::resolve_type(thd);
2347 }
2348 const char *func_name() const override { return "isnotnull"; }
2349 optimize_type select_optimize(const THD *) override { return OPTIMIZE_NULL; }
2350 Item *truth_transformer(THD *, Bool_test test) override;
2351 void print(const THD *thd, String *str,
2352 enum_query_type query_type) const override;
2353 const CHARSET_INFO *compare_collation() const override {
2354 return args[0]->collation.collation;
2355 }
2356 void apply_is_true() override {
2357 null_on_null = true;
2358 } // Same logic as for Item_func_truth's function
2359 float get_filtering_effect(THD *thd, table_map filter_for_table,
2360 table_map read_tables,
2361 const MY_BITMAP *fields_to_ignore,
2362 double rows_in_table) override;
2363};
2364
2365class Item_func_like final : public Item_bool_func2 {
2366 /// True if escape clause is const (a literal)
2367 bool escape_is_const = false;
2368 /// Tells if the escape clause has been evaluated.
2369 bool escape_evaluated = false;
2370 bool eval_escape_clause(THD *thd);
2371 /// The escape character (0 if no escape character).
2373
2374 public:
2376 Item_func_like(Item *a, Item *b, Item *escape_arg)
2377 : Item_bool_func2(a, b, escape_arg) {
2378 assert(escape_arg != nullptr);
2379 }
2380 Item_func_like(const POS &pos, Item *a, Item *b, Item *escape_arg)
2381 : Item_bool_func2(pos, a, b, escape_arg) {
2382 assert(escape_arg != nullptr);
2383 }
2384 Item_func_like(const POS &pos, Item *a, Item *b)
2385 : Item_bool_func2(pos, a, b) {}
2386
2387 longlong val_int() override;
2388 enum Functype functype() const override { return LIKE_FUNC; }
2389 optimize_type select_optimize(const THD *thd) override;
2390 /// Result may be not equal with equal inputs if ESCAPE character is present
2391 cond_result eq_cmp_result() const override { return COND_OK; }
2392 const char *func_name() const override { return "like"; }
2393 bool fix_fields(THD *thd, Item **ref) override;
2394 bool resolve_type(THD *) override;
2395 void cleanup() override;
2396 Item *replace_scalar_subquery(uchar *) override;
2397 // Overridden because Item_bool_func2::print() doesn't print the ESCAPE
2398 // clause.
2399 void print(const THD *thd, String *str,
2400 enum_query_type query_type) const override;
2401 /**
2402 @retval true non default escape char specified
2403 using "expr LIKE pat ESCAPE 'escape_char'" syntax
2404 */
2405 bool escape_was_used_in_parsing() const { return arg_count > 2; }
2406
2407 /// Returns the escape character.
2408 int escape() const {
2409 assert(escape_is_evaluated());
2410 return m_escape;
2411 }
2412
2413 /**
2414 Has the escape clause been evaluated? It only needs to be evaluated
2415 once per execution, since we require it to be constant during execution.
2416 The escape member has a valid value if and only if this function returns
2417 true.
2418 */
2419 bool escape_is_evaluated() const { return escape_evaluated; }
2420
2421 float get_filtering_effect(THD *thd, table_map filter_for_table,
2422 table_map read_tables,
2423 const MY_BITMAP *fields_to_ignore,
2424 double rows_in_table) override;
2425
2426 private:
2427 /**
2428 The method updates covering keys depending on the
2429 length of wild string prefix.
2430
2431 @param thd Pointer to THD object.
2432
2433 @retval true if error happens during wild string prefix calculation,
2434 false otherwise.
2435 */
2436 bool check_covering_prefix_keys(THD *thd);
2437};
2438
2441
2442 protected:
2445
2446 public:
2447 /* Item_cond() is only used to create top level items */
2450 list.push_back(i1);
2451 list.push_back(i2);
2452 }
2453 Item_cond(const POS &pos, Item *i1, Item *i2)
2454 : Item_bool_func(pos), abort_on_null(false) {
2455 list.push_back(i1);
2456 list.push_back(i2);
2457 }
2458
2459 Item_cond(THD *thd, Item_cond *item);
2461 : Item_bool_func(), list(nlist), abort_on_null(false) {}
2462 bool add(Item *item) {
2463 assert(item);
2464 return list.push_back(item);
2465 }
2466 bool add_at_head(Item *item) {
2467 assert(item);
2468 return list.push_front(item);
2469 }
2471 assert(nlist->elements);
2472 list.prepend(nlist);
2473 }
2474
2475 bool do_itemize(Parse_context *pc, Item **res) override;
2476
2477 bool fix_fields(THD *, Item **ref) override;
2478 void fix_after_pullout(Query_block *parent_query_block,
2479 Query_block *removed_query_block) override;
2480
2481 Type type() const override { return COND_ITEM; }
2483 bool eq(const Item *item) const override;
2484 table_map used_tables() const override { return used_tables_cache; }
2485 void update_used_tables() override;
2486 void print(const THD *thd, String *str,
2487 enum_query_type query_type) const override;
2488 bool split_sum_func(THD *thd, Ref_item_array ref_item_array,
2489 mem_root_deque<Item *> *fields) override;
2490 void apply_is_true() override { abort_on_null = true; }
2491 void copy_andor_arguments(THD *thd, Item_cond *item);
2492 bool walk(Item_processor processor, enum_walk walk, uchar *arg) override;
2493 Item *transform(Item_transformer transformer, uchar *arg) override;
2494 void traverse_cond(Cond_traverser, void *arg, traverse_order order) override;
2495 bool truth_transform_arguments(THD *thd, Bool_test test);
2496 bool subst_argument_checker(uchar **) override { return true; }
2497 Item *compile(Item_analyzer analyzer, uchar **arg_p,
2498 Item_transformer transformer, uchar *arg_t) override;
2499 bool remove_const_conds(THD *thd, Item *item, Item **new_item);
2500 /// Treat UNKNOWN result like FALSE because callers see no difference
2501 bool ignore_unknown() const { return abort_on_null; }
2502 bool equality_substitution_analyzer(uchar **) override { return true; }
2503};
2504
2505/**
2506 The class Item_multi_eq is used to represent conjunctions of equality
2507 predicates of the form field1 = field2, and field = const in where
2508 conditions and on join conditions.
2509
2510 All equality predicates of the form field1=field2 contained in a
2511 conjunction are substituted for a sequence of items of this class.
2512 An item of this class Item_multi_eq(f1,f2,...fk) represents a
2513 multiple equality f1=f2=...=fk.
2514
2515 If a conjunction contains predicates f1=f2 and f2=f3, a new item of
2516 this class is created Item_multi_eq(f1,f2,f3) representing the multiple
2517 equality f1=f2=f3 that substitutes the above equality predicates in
2518 the conjunction.
2519 A conjunction of the predicates f2=f1 and f3=f1 and f3=f2 will be
2520 substituted for the item representing the same multiple equality
2521 f1=f2=f3.
2522 An item Item_multi_eq(f1,f2) can appear instead of a conjunction of
2523 f2=f1 and f1=f2, or instead of just the predicate f1=f2.
2524
2525 An item of the class Item_multi_eq inherits equalities from outer
2526 conjunctive levels.
2527
2528 Suppose we have a where condition of the following form:
2529 WHERE f1=f2 AND f3=f4 AND f3=f5 AND ... AND (...OR (f1=f3 AND ...)).
2530 In this case:
2531 f1=f2 will be substituted for Item_multi_eq(f1,f2);
2532 f3=f4 and f3=f5 will be substituted for Item_multi_eq(f3,f4,f5);
2533 f1=f3 will be substituted for Item_multi_eq(f1,f2,f3,f4,f5);
2534
2535 An object of the class Item_multi_eq can contain an optional constant
2536 item c. Then it represents a multiple equality of the form
2537 c=f1=...=fk.
2538
2539 Objects of the class Item_multi_eq are used for the following:
2540
2541 1. An object Item_multi_eq(t1.f1,...,tk.fk) allows us to consider any
2542 pair of tables ti and tj as joined by an equi-condition.
2543 Thus it provide us with additional access paths from table to table.
2544
2545 2. An object Item_multi_eq(t1.f1,...,tk.fk) is applied to deduce new
2546 SARGable predicates:
2547 f1=...=fk AND P(fi) => f1=...=fk AND P(fi) AND P(fj).
2548 It also can give us additional index scans and can allow us to
2549 improve selectivity estimates.
2550
2551 3. An object Item_multi_eq(t1.f1,...,tk.fk) is used to optimize the
2552 selected execution plan for the query: if table ti is accessed
2553 before the table tj then in any predicate P in the where condition
2554 the occurrence of tj.fj is substituted for ti.fi. This can allow
2555 an evaluation of the predicate at an earlier step.
2556
2557 When feature 1 is supported they say that join transitive closure
2558 is employed.
2559 When feature 2 is supported they say that search argument transitive
2560 closure is employed.
2561 Both features are usually supported by preprocessing original query and
2562 adding additional predicates.
2563 We do not just add predicates, we rather dynamically replace some
2564 predicates that can not be used to access tables in the investigated
2565 plan for those, obtained by substitution of some fields for equal fields,
2566 that can be used.
2567
2568 Multiple equality objects are employed only at the optimize phase. Usually
2569 they are not supposed to be evaluated. Yet in some cases we call the method
2570 val_int() for them. We have to take care of restricting the predicate such an
2571 object represents f1=f2= ...=fn to the projection of known fields fi1=...=fik.
2572*/
2573class Item_multi_eq final : public Item_bool_func {
2574 /// List of equal field items.
2576 /// Optional constant item equal to all the field items.
2577 Item *m_const_arg{nullptr};
2578 /// Helper for comparing the fields.
2579 cmp_item *eval_item{nullptr};
2580 /// Helper for comparing constants.
2582 /// Flag set to true if the equality is known to be always false.
2583 bool m_always_false{false};
2584 /// Should constants be compared as datetimes?
2585 bool compare_as_dates{false};
2586 /// Checks if the current constant value m_const_arg (that each field
2587 /// in fields needs to be equal to during execution) is the same as
2588 /// the provided constant item. If that's not the case, it sets
2589 /// m_always_false to true as a field cannot be equal to different
2590 /// constant values at the same time.
2591 /// @returns false on success, true on error.
2592 bool compare_const(THD *thd, Item *const_item);
2593
2594 public:
2595 ~Item_multi_eq() override;
2596
2597 Item_multi_eq(Item_field *lhs_field, Item_field *rhs_field);
2599 explicit Item_multi_eq(Item_multi_eq *item_multi_eq);
2600
2601 Item_multi_eq(const Item_multi_eq &) = delete;
2603 Item_multi_eq(const Item_multi_eq &&) = delete;
2605
2606 /// Returns the constant Item that this multi equality is equal to(if any).
2607 Item *const_arg() const { return m_const_arg; }
2608 void set_const_arg(Item *const_item) { m_const_arg = const_item; }
2609 bool add(THD *thd, Item *const_item, Item_field *field);
2610 bool add(THD *thd, Item *const_item);
2611 void add(Item_field *field);
2612 uint members();
2613 bool contains(const Item_field *field) const;
2614 /**
2615 Get the first field of multiple equality, use for semantic checking.
2616
2617 @retval First field in the multiple equality.
2618 */
2619 Item_field *get_first() { return fields.head(); }
2620 Item_field *get_subst_item(const Item_field *field);
2621 bool merge(THD *thd, Item_multi_eq *item);
2622 bool update_const(THD *thd);
2623 enum Functype functype() const override { return MULTI_EQ_FUNC; }
2624 longlong val_int() override;
2625 const char *func_name() const override { return "multiple equal"; }
2626 optimize_type select_optimize(const THD *) override { return OPTIMIZE_EQUAL; }
2628 // Multiple equality nodes (Item_multi_eq) should have been
2629 // converted back to simple equalities (Item_func_eq) by
2630 // substitute_for_best_equal_field before cast nodes are injected.
2631 assert(false);
2632 return false;
2633 }
2635 return const_arg() == nullptr;
2636 }
2637
2638 /**
2639 Order field items in multiple equality according to a sorting criteria.
2640
2641 The function perform ordering of the field items in the Item_multi_eq
2642 object according to the criteria determined by the cmp callback parameter.
2643 If cmp(item_field1,item_field2,arg)<0 than item_field1 must be
2644 placed after item_field2.
2645
2646 The function sorts field items by the exchange sort algorithm.
2647 The list of field items is looked through and whenever two neighboring
2648 members follow in a wrong order they are swapped. This is performed
2649 again and again until we get all members in a right order.
2650
2651 @param compare function to compare field item
2652 */
2653 template <typename Node_cmp_func>
2654 void sort(Node_cmp_func compare) {
2655 fields.sort(compare);
2656 }
2657
2658 // A class to iterate over fields without exposing fields directly.
2660 public:
2661 explicit FieldProxy(Item_multi_eq *item) : m_fields(&item->fields) {}
2662 List_STL_Iterator<Item_field> begin() { return m_fields->begin(); }
2663 List_STL_Iterator<Item_field> end() { return m_fields->end(); }
2665 return m_fields->cbegin();
2666 }
2667 List_STL_Iterator<const Item_field> end() const { return m_fields->cend(); }
2669 return m_fields->cbegin();
2670 }
2672 return m_fields->cend();
2673 }
2674
2675 private:
2677 };
2679 public:
2680 explicit ConstFieldProxy(const Item_multi_eq *item)
2681 : m_fields(&item->fields) {}
2683 return m_fields->cbegin();
2684 }
2685 List_STL_Iterator<const Item_field> end() const { return m_fields->cend(); }
2687 return m_fields->cbegin();
2688 }
2690 return m_fields->cend();
2691 }
2692 size_t size() const { return m_fields->size(); }
2693
2694 private:
2696 };
2699
2700 bool resolve_type(THD *) override;
2701 bool fix_fields(THD *thd, Item **ref) override;
2702 void update_used_tables() override;
2703 bool walk(Item_processor processor, enum_walk walk, uchar *arg) override;
2704 void print(const THD *thd, String *str,
2705 enum_query_type query_type) const override;
2706 bool eq_specific(const Item *item) const override;
2707 const CHARSET_INFO *compare_collation() const override {
2708 return fields.head()->collation.collation;
2709 }
2710
2711 bool equality_substitution_analyzer(uchar **) override { return true; }
2712
2714
2715 float get_filtering_effect(THD *thd, table_map filter_for_table,
2716 table_map read_tables,
2717 const MY_BITMAP *fields_to_ignore,
2718 double rows_in_table) override;
2719 ///< temporary area used for constant folding
2720 Item *m_const_folding[2]{nullptr, nullptr};
2721
2722 private:
2724};
2725
2727 /// Reference to the multiple equalities of outer level.
2728 COND_EQUAL *upper_levels{nullptr};
2729 /// List of multiple equalities in the current conjunction.
2731};
2732
2733class Item_cond_and final : public Item_cond {
2734 public:
2735 /// Contains list of Item_multi_eq objects for the current conjunction
2736 /// and references to multiple equalities of outer levels.
2739
2740 Item_cond_and(Item *i1, Item *i2) : Item_cond(i1, i2) {}
2741 Item_cond_and(const POS &pos, Item *i1, Item *i2) : Item_cond(pos, i1, i2) {}
2742
2743 Item_cond_and(THD *thd, Item_cond_and *item) : Item_cond(thd, item) {}
2744 Item_cond_and(List<Item> &list_arg) : Item_cond(list_arg) {}
2745 enum Functype functype() const override { return COND_AND_FUNC; }
2746 longlong val_int() override;
2747 const char *func_name() const override { return "and"; }
2749 Item_cond_and *item;
2750 if ((item = new Item_cond_and(thd, this)))
2751 item->copy_andor_arguments(thd, this);
2752 return item;
2753 }
2754 Item *truth_transformer(THD *, Bool_test) override;
2755 bool gc_subst_analyzer(uchar **) override { return true; }
2756
2757 float get_filtering_effect(THD *thd, table_map filter_for_table,
2758 table_map read_tables,
2759 const MY_BITMAP *fields_to_ignore,
2760 double rows_in_table) override;
2761
2762 bool contains_only_equi_join_condition() const override;
2763};
2764
2765class Item_cond_or final : public Item_cond {
2766 public:
2768
2769 Item_cond_or(Item *i1, Item *i2) : Item_cond(i1, i2) {}
2770 Item_cond_or(const POS &pos, Item *i1, Item *i2) : Item_cond(pos, i1, i2) {}
2771
2772 Item_cond_or(THD *thd, Item_cond_or *item) : Item_cond(thd, item) {}
2773 Item_cond_or(List<Item> &list_arg) : Item_cond(list_arg) {}
2774 enum Functype functype() const override { return COND_OR_FUNC; }
2775 longlong val_int() override;
2776 const char *func_name() const override { return "or"; }
2778 Item_cond_or *item;
2779 if ((item = new Item_cond_or(thd, this)))
2780 item->copy_andor_arguments(thd, this);
2781 return item;
2782 }
2783 Item *truth_transformer(THD *, Bool_test) override;
2784 bool gc_subst_analyzer(uchar **) override { return true; }
2785
2786 float get_filtering_effect(THD *thd, table_map filter_for_table,
2787 table_map read_tables,
2788 const MY_BITMAP *fields_to_ignore,
2789 double rows_in_table) override;
2790};
2791
2792/// Builds condition: (a AND b) IS TRUE
2793inline Item *and_conds(Item *a, Item *b) {
2794 if (!b) return a;
2795 if (!a) return b;
2796
2797 Item *item = new Item_cond_and(a, b);
2798 if (item == nullptr) return nullptr;
2799 item->apply_is_true();
2800 return item;
2801}
2802
2803longlong get_datetime_value(THD *thd, Item ***item_arg, Item ** /* cache_arg */,
2804 const Item *warn_item, bool *is_null);
2805
2806// TODO: the next two functions should be moved to sql_time.{h,cc}
2809
2811 enum_mysql_timestamp_type warn_type,
2812 const char *warn_name, MYSQL_TIME *l_time);
2813
2814// Helper function to ensure_multi_equality_fields_are_available().
2815// Finds and adjusts (if "replace" is set to true) an "Item_field" in a
2816// function with an equal field in the available tables. For more
2817// details look at FindEqualField().
2818void find_and_adjust_equal_fields(Item *item, table_map available_tables,
2819 bool replace, bool *found);
2820
2821/*
2822 These need definitions from this file but the variables are defined
2823 in mysqld.h. The variables really belong in this component, but for
2824 the time being we leave them in mysqld.cc to avoid merge problems.
2825*/
2826extern Eq_creator eq_creator;
2828extern Ne_creator ne_creator;
2829extern Gt_creator gt_creator;
2830extern Lt_creator lt_creator;
2831extern Ge_creator ge_creator;
2832extern Le_creator le_creator;
2833
2834/// Returns true if the item is a conjunction.
2835inline bool IsAnd(const Item *item) {
2836 return item->type() == Item::COND_ITEM &&
2837 down_cast<const Item_cond *>(item)->functype() ==
2839}
2840
2841/**
2842 Calls "func" on each term in "condition" if it's a conjunction (and
2843 recursively on any conjunction directly contained in it, thereby flattening
2844 nested AND structures). Otherwise, calls "func" on "condition". It aborts and
2845 returns true as soon as a call to "func" returns true.
2846 */
2847template <class Func>
2848bool WalkConjunction(Item *condition, Func func) {
2849 if (condition == nullptr) {
2850 return false;
2851 } else if (IsAnd(condition)) {
2852 for (Item &item : *down_cast<Item_cond_and *>(condition)->argument_list()) {
2853 if (WalkConjunction(&item, func)) {
2854 return true;
2855 }
2856 }
2857 return false;
2858 } else {
2859 return func(condition);
2860 }
2861}
2862
2863#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:1452
int compare_time_packed()
Compare arguments using numeric packed temporal representation.
Definition: item_cmpfunc.cc:1990
void cleanup()
Definition: item_cmpfunc.cc:876
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:2053
String value1
Definition: item_cmpfunc.h:168
bool set_compare_func(Item_func *owner, Item_result type)
Definition: item_cmpfunc.cc:894
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:2074
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:1190
double precision
Definition: item_cmpfunc.h:147
int compare_datetime()
Compare item values as dates.
Definition: item_cmpfunc.cc:1734
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:1964
int compare_binary_string()
Compare strings byte by byte.
Definition: item_cmpfunc.cc:1893
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:1260
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:1826
int compare_real()
Definition: item_cmpfunc.cc:1911
void set_datetime_cmp_func(Item_func *owner_arg, Item **a1, Item **b1)
Definition: item_cmpfunc.cc:1610
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:1116
bool try_year_cmp_func(Item_result type)
Definition: item_cmpfunc.cc:1553
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:1946
longlong extract_value_from_argument(THD *thd, Item *item, bool left_argument, bool *is_null) const
Definition: item_cmpfunc.cc:8090
int compare_string()
Definition: item_cmpfunc.cc:1861
int compare_decimal()
Definition: item_cmpfunc.cc:1929
int compare_row()
Definition: item_cmpfunc.cc:2092
bool compare_null_values()
Compare NULL values for two arguments.
Definition: item_cmpfunc.cc:2186
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:2026
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:399
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:404
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:408
Item_bool_func * combine(List< Item > list) const override
Combines a list of conditions exp op exp.
Definition: item_cmpfunc.cc:413
Definition: field.h:577
Definition: item_cmpfunc.h:601
Item_bool_func * create(Item *a, Item *b) const override
Definition: item_cmpfunc.cc:434
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:426
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:8055
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:3848
void set_str_value(String *str)
Definition: item.h:3870
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:726
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:744
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:869
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:2193
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:6800
Definition: item_cmpfunc.h:2733
Item * copy_andor_structure(THD *thd) override
Definition: item_cmpfunc.h:2748
Item_cond_and(List< Item > &list_arg)
Definition: item_cmpfunc.h:2744
COND_EQUAL cond_equal
Contains list of Item_multi_eq objects for the current conjunction and references to multiple equalit...
Definition: item_cmpfunc.h:2737
const char * func_name() const override
Definition: item_cmpfunc.h:2747
enum Functype functype() const override
Definition: item_cmpfunc.h:2745
Item_cond_and()
Definition: item_cmpfunc.h:2738
Item_cond_and(const POS &pos, Item *i1, Item *i2)
Definition: item_cmpfunc.h:2741
Item_cond_and(Item *i1, Item *i2)
Definition: item_cmpfunc.h:2740
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:2755
Item_cond_and(THD *thd, Item_cond_and *item)
Definition: item_cmpfunc.h:2743
Definition: item_cmpfunc.h:2765
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:2784
enum Functype functype() const override
Definition: item_cmpfunc.h:2774
Item_cond_or(Item *i1, Item *i2)
Definition: item_cmpfunc.h:2769
Item * copy_andor_structure(THD *thd) override
Definition: item_cmpfunc.h:2777
Item_cond_or(List< Item > &list_arg)
Definition: item_cmpfunc.h:2773
Item_cond_or(const POS &pos, Item *i1, Item *i2)
Definition: item_cmpfunc.h:2770
Item_cond_or()
Definition: item_cmpfunc.h:2767
const char * func_name() const override
Definition: item_cmpfunc.h:2776
Item_cond_or(THD *thd, Item_cond_or *item)
Definition: item_cmpfunc.h:2772
Definition: item_cmpfunc.h:2439
void add_at_head(List< Item > *nlist)
Definition: item_cmpfunc.h:2470
bool add_at_head(Item *item)
Definition: item_cmpfunc.h:2466
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:2490
Item_cond(Item *i1, Item *i2)
Definition: item_cmpfunc.h:2449
Item_bool_func super
Definition: item_cmpfunc.h:2440
bool ignore_unknown() const
Treat UNKNOWN result like FALSE because callers see no difference.
Definition: item_cmpfunc.h:2501
void copy_andor_arguments(THD *thd, Item_cond *item)
Definition: item_cmpfunc.cc:5700
table_map used_tables() const override
Definition: item_cmpfunc.h:2484
Item_cond(const POS &pos, Item *i1, Item *i2)
Definition: item_cmpfunc.h:2453
Item_cond(List< Item > &nlist)
Definition: item_cmpfunc.h:2460
bool subst_argument_checker(uchar **) override
Definition: item_cmpfunc.h:2496
List< Item > * argument_list()
Definition: item_cmpfunc.h:2482
Type type() const override
Definition: item_cmpfunc.h:2481
Item_cond()
Definition: item_cmpfunc.h:2448
List< Item > list
Definition: item_cmpfunc.h:2443
bool equality_substitution_analyzer(uchar **) override
Definition: item_cmpfunc.h:2502
bool add(Item *item)
Definition: item_cmpfunc.h:2462
bool abort_on_null
Definition: item_cmpfunc.h:2444
Definition: item.h:5317
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:7641
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:8027
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:8001
Definition: item.h:4385
Definition: item.h:5363
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:1992
Item_result cmp_type
Definition: item_cmpfunc.h:1999
enum_field_types default_data_type() const override
Get the default data (output) type for the specific item.
Definition: item_cmpfunc.h:2043
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:2054
cmp_item * case_item
Definition: item_cmpfunc.h:2002
int else_expr_num
Definition: item_cmpfunc.h:1995
DTCollation cmp_collation
Definition: item_cmpfunc.h:2000
Item_func super
Definition: item_cmpfunc.h:1993
Item_func_case(const POS &pos, mem_root_deque< Item * > *list, Item *first_expr_arg, Item *else_expr_arg)
Definition: item_cmpfunc.h:2011
int get_first_expr_num() const
Definition: item_cmpfunc.h:2033
const char * func_name() const override
Definition: item_cmpfunc.h:2050
enum Item_result result_type() const override
Definition: item_cmpfunc.h:2049
enum Item_result cached_result_type left_result_type
Definition: item_cmpfunc.h:1996
uint ncases
Definition: item_cmpfunc.h:1998
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_cmpfunc.h:2005
String tmp_value
Definition: item_cmpfunc.h:1997
enum Functype functype() const override
Definition: item_cmpfunc.h:2057
int get_else_expr_num() const
Definition: item_cmpfunc.h:2034
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:6905
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:2775
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:6782
virtual Item * negated_item()
just fake method, should never be called.
Definition: item_cmpfunc.cc:6900
bool cast_incompatible_args(uchar *) override
Wrap incompatible arguments in CAST nodes to the expected data types.
Definition: item_cmpfunc.cc:6920
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:2071
DTCollation cmp_collation
Definition: item_cmpfunc.h:2101
Item_func_in(const POS &pos, PT_item_list *list, bool is_negation)
Definition: item_cmpfunc.h:2104
enum Functype functype() const override
Definition: item_cmpfunc.h:2131
const char * func_name() const override
Definition: item_cmpfunc.h:2132
Item_result left_result_type
Definition: item_cmpfunc.h:2099
bool is_bool_func() const override
Definition: item_cmpfunc.h:2133
uint decimal_precision() const override
Definition: item_cmpfunc.h:2116
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:2134
void update_not_null_tables()
Definition: item_cmpfunc.h:2144
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:2128
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:2137
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:2335
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:2353
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:2356
const char * func_name() const override
Definition: item_cmpfunc.h:2348
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:2349
Item_func_isnotnull(Item *a)
Definition: item_cmpfunc.h:2337
enum Functype functype() const override
Definition: item_cmpfunc.h:2343
Item_func_isnotnull(const POS &pos, Item *a)
Definition: item_cmpfunc.h:2338
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_cmpfunc.h:2344
Definition: item_cmpfunc.h:2271
Item_func_isnull(Item *a)
Definition: item_cmpfunc.h:2278
Item_func_isnull(const POS &pos, Item *a)
Definition: item_cmpfunc.h:2279
const char * func_name() const override
Definition: item_cmpfunc.h:2285
Item_bool_func super
Definition: item_cmpfunc.h:2272
enum Functype functype() const override
Definition: item_cmpfunc.h:2283
bool cached_value
Definition: item_cmpfunc.h:2275
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:2297
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:2293
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:2365
Item_func_like(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:2384
int escape() const
Returns the escape character.
Definition: item_cmpfunc.h:2408
int m_escape
The escape character (0 if no escape character).
Definition: item_cmpfunc.h:2372
enum Functype functype() const override
Definition: item_cmpfunc.h:2388
bool escape_was_used_in_parsing() const
Definition: item_cmpfunc.h:2405
Item_func_like(Item *a, Item *b, Item *escape_arg)
Definition: item_cmpfunc.h:2376
Item_func_like(Item *a, Item *b)
Definition: item_cmpfunc.h:2375
cond_result eq_cmp_result() const override
Result may be not equal with equal inputs if ESCAPE character is present.
Definition: item_cmpfunc.h:2391
const char * func_name() const override
Definition: item_cmpfunc.h:2392
bool escape_is_evaluated() const
Has the escape clause been evaluated? It only needs to be evaluated once per execution,...
Definition: item_cmpfunc.h:2419
Item_func_like(const POS &pos, Item *a, Item *b, Item *escape_arg)
Definition: item_cmpfunc.h:2380
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:7315
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:6843
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:552
Definition: item_cmpfunc.h:924
bool empty_underlying_subquery()
Definition: item_cmpfunc.cc:514
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:535
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:6853
longlong val_int() override
special NOT for ALL subquery.
Definition: item_cmpfunc.cc:500
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:6776
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:468
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:442
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:489
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:7681
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:7361
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:7381
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:7340
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:7326
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:2257
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:2247
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:2241
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:6735
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:6697
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:6794
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_cmpfunc.cc:6682
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:4123
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:2375
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item_cmpfunc.cc:2565
bool fix_left(THD *thd)
Definition: item_cmpfunc.cc:2290
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:2472
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:2364
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_cmpfunc.cc:2570
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_cmpfunc.cc:2552
Item_cache ** get_cache()
Definition: item_cmpfunc.h:519
bool fix_fields(THD *, Item **) override
Definition: item_cmpfunc.cc:2332
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:2387
Representation of IN subquery predicates of the form "left_expr IN (SELECT ...)".
Definition: item_subselect.h:592
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:5122
Definition: item_cmpfunc.h:2310
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:2329
Item_in_subselect * owner
Definition: item_cmpfunc.h:2311
const char * func_name() const override
Definition: item_cmpfunc.h:2318
Item_is_not_null_test(Item_in_subselect *ow, Item *a)
Definition: item_cmpfunc.h:2314
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:2326
enum Functype functype() const override
Definition: item_cmpfunc.h:2316
Definition: item_subselect.h:392
Definition: item_cmpfunc.h:2678
size_t size() const
Definition: item_cmpfunc.h:2692
const List< Item_field > * m_fields
Definition: item_cmpfunc.h:2695
List_STL_Iterator< const Item_field > cend() const
Definition: item_cmpfunc.h:2689
ConstFieldProxy(const Item_multi_eq *item)
Definition: item_cmpfunc.h:2680
List_STL_Iterator< const Item_field > end() const
Definition: item_cmpfunc.h:2685
List_STL_Iterator< const Item_field > begin() const
Definition: item_cmpfunc.h:2682
List_STL_Iterator< const Item_field > cbegin() const
Definition: item_cmpfunc.h:2686
Definition: item_cmpfunc.h:2659
FieldProxy(Item_multi_eq *item)
Definition: item_cmpfunc.h:2661
List_STL_Iterator< Item_field > begin()
Definition: item_cmpfunc.h:2662
List_STL_Iterator< const Item_field > cbegin() const
Definition: item_cmpfunc.h:2668
List_STL_Iterator< const Item_field > end() const
Definition: item_cmpfunc.h:2667
List< Item_field > * m_fields
Definition: item_cmpfunc.h:2676
List_STL_Iterator< const Item_field > cend() const
Definition: item_cmpfunc.h:2671
List_STL_Iterator< const Item_field > begin() const
Definition: item_cmpfunc.h:2664
List_STL_Iterator< Item_field > end()
Definition: item_cmpfunc.h:2663
The class Item_multi_eq is used to represent conjunctions of equality predicates of the form field1 =...
Definition: item_cmpfunc.h:2573
bool equality_substitution_analyzer(uchar **) override
Definition: item_cmpfunc.h:2711
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:2654
const char * func_name() const override
Definition: item_cmpfunc.h:2625
ConstFieldProxy get_fields() const
Definition: item_cmpfunc.h:2698
FieldProxy get_fields()
Definition: item_cmpfunc.h:2697
Item_multi_eq(const Item_multi_eq &&)=delete
List< Item_field > fields
List of equal field items.
Definition: item_cmpfunc.h:2575
void set_const_arg(Item *const_item)
Definition: item_cmpfunc.h:2608
bool cast_incompatible_args(uchar *) override
Wrap incompatible arguments in CAST nodes to the expected data types.
Definition: item_cmpfunc.h:2627
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:2707
enum Functype functype() const override
Definition: item_cmpfunc.h:2623
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:2626
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:2634
Item * const_arg() const
Returns the constant Item that this multi equality is equal to(if any).
Definition: item_cmpfunc.h:2607
Item_field * get_first()
Get the first field of multiple equality, use for semantic checking.
Definition: item_cmpfunc.h:2619
Arg_comparator cmp
Helper for comparing constants.
Definition: item_cmpfunc.h:2581
Field * result_field
Definition: item.h:5831
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item.cc:10763
Item which stores (x,y,...) and ROW(x,y,...).
Definition: item_row.h:54
Definition: item.h:5459
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:5248
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:3687
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:3686
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:3675
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:3712
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:3713
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:438
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:380
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:430
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:61
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:426
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:417
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:422
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:1159
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:1930
longlong value
Definition: item_cmpfunc.h:1931
bool has_date
Distinguish between DATE/DATETIME/TIMESTAMP and TIME.
Definition: item_cmpfunc.h:1937
const Item * warn_item
Definition: item_cmpfunc.h:1935
Definition: item_cmpfunc.h:1965
my_decimal value
Definition: item_cmpfunc.h:1966
Definition: item_cmpfunc.h:1906
longlong value
Definition: item_cmpfunc.h:1907
void store_value(Item *item) override
Definition: item_cmpfunc.h:1910
int cmp(Item *arg) override
Definition: item_cmpfunc.h:1914
int compare(const cmp_item *ci) const override
Definition: item_cmpfunc.h:1918
Definition: item_cmpfunc.h:1880
unique_ptr_destroy_only< Json_wrapper > m_value
Cached JSON value to look up.
Definition: item_cmpfunc.h:1883
~cmp_item_json() override
String m_str_value
String buffer.
Definition: item_cmpfunc.h:1887
unique_ptr_destroy_only< Json_scalar_holder > m_holder
Cache for the value above.
Definition: item_cmpfunc.h:1885
Definition: item_cmpfunc.h:1946
int cmp(Item *arg) override
Definition: item_cmpfunc.h:1954
double value
Definition: item_cmpfunc.h:1947
void store_value(Item *item) override
Definition: item_cmpfunc.h:1950
int compare(const cmp_item *ci) const override
Definition: item_cmpfunc.h:1958
Definition: item_cmpfunc.h:2192
cmp_item_row(cmp_item_row &&other)
Definition: item_cmpfunc.h:2207
uint n
Definition: item_cmpfunc.h:2194
cmp_item_row(THD *thd, Item *item)
Definition: item_cmpfunc.h:2202
cmp_item_row()
Definition: item_cmpfunc.h:2197
cmp_item which stores a scalar (i.e. non-ROW).
Definition: item_cmpfunc.h:1846
void set_null_value(bool nv)
Definition: item_cmpfunc.h:1849
bool m_null_value
If stored value is NULL.
Definition: item_cmpfunc.h:1848
Definition: item_cmpfunc.h:1852
const String * value_res
Definition: item_cmpfunc.h:1854
int compare(const cmp_item *ci) const override
Definition: item_cmpfunc.h:1861
cmp_item_string(const CHARSET_INFO *cs)
Definition: item_cmpfunc.h:1859
void store_value(Item *item) override
Definition: item_cmpfunc.h:1866
const CHARSET_INFO * cmp_charset
Definition: item_cmpfunc.h:1856
StringBuffer< STRING_BUFFER_USUAL_SIZE > value
Definition: item_cmpfunc.h:1855
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 ~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:2234
Mem_root_array< cmp_item_row * > base_pointers
Definition: item_cmpfunc.h:2238
Mem_root_array< cmp_item_row > base_objects
Definition: item_cmpfunc.h:2236
Item_basic_constant * create_item(MEM_ROOT *) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:2256
unique_ptr_destroy_only< cmp_item_row > tmp
Definition: item_cmpfunc.h:2235
bool is_row_result() const override
Definition: item_cmpfunc.h:2242
void value_to_item(uint, Item_basic_constant *) const override
Store the value at position pos into provided item object.
Definition: item_cmpfunc.h:2260
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:8127
int(Arg_comparator::* arg_cmp_func)()
Definition: item_cmpfunc.h:74
Eq_creator eq_creator
Definition: mysqld.cc:1533
Ge_creator ge_creator
Definition: mysqld.cc:1538
Item * make_condition(Parse_context *pc, Item *item)
Ensure that all expressions involved in conditions are boolean functions.
Definition: item_cmpfunc.cc:5659
void find_and_adjust_equal_fields(Item *item, table_map available_tables, bool replace, bool *found)
Definition: item_cmpfunc.cc:8108
Lt_creator lt_creator
Definition: mysqld.cc:1537
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:1002
Gt_creator gt_creator
Definition: mysqld.cc:1536
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:2835
Ne_creator ne_creator
Definition: mysqld.cc:1534
Equal_creator equal_creator
Definition: mysqld.cc:1535
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:2848
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:1033
Le_creator le_creator
Definition: mysqld.cc:1539
longlong get_datetime_value(THD *thd, Item ***item_arg, Item **, const Item *warn_item, bool *is_null)
Retrieve correct DATETIME value from given item.
Definition: item_cmpfunc.cc:1643
Item * and_conds(Item *a, Item *b)
Builds condition: (a AND b) IS TRUE.
Definition: item_cmpfunc.h:2793
String * eval_string_arg(const CHARSET_INFO *to_cs, Item *arg, String *buffer)
Definition: item_func.h:93
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:480
Header for compiler-dependent features.
It is interface module to fixed precision decimals library.
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
unsigned char uchar
Definition: my_inttypes.h:52
long long int longlong
Definition: my_inttypes.h:55
uint16_t uint16
Definition: my_inttypes.h:65
uint64_t table_map
Definition: my_table_map.h:30
Interface for low level time utilities.
unsigned int my_time_flags_t
Flags to str_to_datetime and number_to_datetime.
Definition: my_time.h:94
Time declarations shared between the server and client API: you should not add anything to this heade...
enum_mysql_timestamp_type
Definition: mysql_time.h:45
static bool replace
Definition: mysqlimport.cc:70
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1105
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Definition: commit_order_queue.h:34
PT & ref(PT *tp)
Definition: tablespace_impl.cc:359
std::string join(const detail::range auto &rng, std::string_view delim)
join elements of a range into a string separated by a delimiter.
Definition: string.h:74
static mysql_service_status_t add(reference_caching_channel channel, const char *implementation_name) noexcept
Definition: component.cc:127
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2884
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2880
required uint32 status
Definition: replication_asynchronous_connection_failover.proto:61
required string type
Definition: replication_group_member_actions.proto:34
static int compare(size_t a, size_t b)
Function to compare two size_t integers for their relative order.
Definition: rpl_utility.cc:107
File containing constants that can be used throughout the server.
constexpr const table_map RAND_TABLE_BIT
Definition: sql_const.h:113
constexpr const size_t STRING_BUFFER_USUAL_SIZE
Definition: sql_const.h:126
constexpr const table_map OUTER_REF_TABLE_BIT
Definition: sql_const.h:112
enum_walk
Enumeration for {Item,Query_block[_UNIT],Table_function}walk.
Definition: sql_const.h:289
bool(Item::*)(unsigned char *) Item_processor
Processor type for {Item,Query_block[_UNIT],Table_function}walk.
Definition: sql_const.h:307
int plan_idx
This represents the index of a JOIN_TAB/QEP_TAB in an array.
Definition: sql_opt_exec_shared.h:54
Our own string classes, used pervasively throughout the executor.
int sortcmp(const String *a, const String *b, const CHARSET_INFO *cs)
Definition: sql_string.cc:689
Definition: m_ctype.h:421
Definition: item_cmpfunc.h:2726
List< Item_multi_eq > current_level
List of multiple equalities in the current conjunction.
Definition: item_cmpfunc.h:2730
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
Structure to return status from str_to_datetime(), str_to_time(), number_to_datetime(),...
Definition: my_time.h:170
Definition: mysql_time.h:82
Definition: my_bitmap.h:43
Bison "location" class.
Definition: parse_location.h:43
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:420
Definition: table.h:1421
Definition: typelib.h:35
Definition: item_cmpfunc.h:1683
bool unsigned_flag
Definition: item_cmpfunc.h:1685
longlong val
Definition: item_cmpfunc.h:1684
Definition: item_cmpfunc.h:1387
Item_result type
Definition: item_cmpfunc.h:1388
double dbl
Definition: item_cmpfunc.h:1389
my_decimal dec
Definition: item_cmpfunc.h:1390
Definition: result.h:30
Target down_cast(Source *arg)
Casts from one pointer type to another in a type hierarchy.
Definition: template_utils.h:96
constexpr T pointer_cast(void *p)
Casts from one pointer type, to another, without using reinterpret_cast or C-style cast: foo f; bar *...
Definition: template_utils.h:75
Item_result
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:39
@ INT_RESULT
double
Definition: udf_registration_types.h:43
@ INVALID_RESULT
Definition: udf_registration_types.h:40
int n
Definition: xcom_base.cc:509