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