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