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