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