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