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