MySQL  8.0.18
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, 2019, Oracle and/or its affiliates. All rights reserved.
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 <string.h>
29 #include <sys/types.h>
30 
31 #include "field_types.h"
32 #include "json_dom.h" // Json_wrapper
33 //#include "extra/regex/my_regex.h" // my_regex_t
34 #include "m_ctype.h"
35 #include "my_alloc.h"
36 #include "my_compiler.h"
37 #include "my_dbug.h"
38 #include "my_inttypes.h"
39 #include "my_sys.h"
40 #include "my_table_map.h"
41 #include "my_time.h"
43 #include "mysql_time.h"
44 #include "sql/enum_query_type.h"
45 #include "sql/item.h"
46 #include "sql/item_func.h" // Item_int_func
47 #include "sql/item_row.h" // Item_row
48 #include "sql/mem_root_array.h" // Mem_root_array
49 #include "sql/my_decimal.h"
51 #include "sql/psi_memory_key.h" // key_memory_JSON
52 #include "sql/sql_const.h"
53 #include "sql/sql_list.h"
54 #include "sql/table.h"
55 #include "sql_string.h"
56 #include "template_utils.h" // down_cast
57 
58 class Arg_comparator;
59 class Field;
60 class Item_func_eq;
61 class Item_in_subselect;
62 class Item_subselect;
63 class Item_sum_hybrid;
64 class Json_scalar_holder;
65 class Json_wrapper;
66 class PT_item_list;
67 class QEP_TAB;
68 class SELECT_LEX;
69 class THD;
70 struct MY_BITMAP;
71 
73 
74 typedef int (Arg_comparator::*arg_cmp_func)();
75 
76 /// A class that represents a join condition in a hash join. The class holds an
77 /// equality condition, as well as a pre-calculated bitmap of the used tables
78 /// (Item::used_tables()) for each side of the condition.
79 ///
80 /// The class also contains one Item for each side of the condition. In most
81 /// cases, the Item is only a pointer to the left/right Item of the join
82 /// condition. But for certain data types (DECIMAL, DOUBLE(M, N), FLOAT(M, N)),
83 /// the Item might be a typecast. Either way, the caller should use these Items
84 /// when i.e. reading the values from the join condition, so that the values are
85 /// read in the right data type context. See the comments for
86 /// Item_func_eq::create_cast_if_needed for more details around this.
88  public:
90 
92 
93  Item *left_extractor() const { return m_left_extractor; }
94  Item *right_extractor() const { return m_right_extractor; }
95  bool left_uses_any_table(table_map tables) const {
96  return (m_left_used_tables & tables) != 0;
97  }
98 
99  bool right_uses_any_table(table_map tables) const {
100  return (m_right_used_tables & tables) != 0;
101  }
102 
103  size_t max_character_length() const { return m_max_character_length; }
104 
105  private:
109 
110  // Item::used_tables() is heavily used during the join to determine which side
111  // of the condition we are to read the value from, so caching the result of
112  // used_tables() gives a nice speedup.
115 
116  // The maximum number of characters among the two arguments. This is only
117  // relevant when we have a PAD SPACE collation and the SQL mode
118  // PAD_CHAR_TO_FULL_LENGTH enabled, since we will have to pad the shortest
119  // argument to the same length as the longest argument.
120  const size_t m_max_character_length{0};
121 };
122 
124  Item **left{nullptr};
125  Item **right{nullptr};
128  Arg_comparator *comparators{nullptr}; // used only for compare_row()
130  double precision;
131  /* Fields used in DATE/DATETIME comparison. */
132  Item *left_cache{nullptr}; // Cached values of "left" and "right" items
133  Item *right_cache{nullptr};
134  bool set_null{true}; // true <=> set owner->null_value
135  // when one of arguments is NULL.
136 
138  static bool get_date_from_const(Item *date_arg, Item *str_arg,
139  ulonglong *const_value);
140  /**
141  Only used by compare_json() in the case where a JSON value is
142  compared to an SQL value. This member points to pre-allocated
143  memory that can be used instead of the heap when converting the
144  SQL value to a JSON value.
145  */
147 
148  /**
149  When comparing strings, compare at most these many bytes.
150  A value of zero means "no limit".
151  */
152  size_t m_max_str_length{0};
153 
154  public:
156  /* Allow owner function to use string buffers. */
158 
159  Arg_comparator() = default;
160 
162 
164  bool set_cmp_func(Item_result_field *owner_arg, Item **left, Item **right,
165  Item_result type);
166 
167  bool set_cmp_func(Item_result_field *owner_arg, Item **left, Item **right,
168  bool set_null_arg);
169  /**
170  Comparison function are expected to operate on arguments having the
171  same data types. Since MySQL has very loosened up rules, it accepts
172  all kind of arguments which the standard SQL does not allow, and then it
173  converts the arguments internally to ones usable in the comparison.
174  This function transforms these internal conversions to explicit CASTs
175  so that the internally executed query becomes compatible with the standard
176  At the moment nodes are injected only for comparisons between:
177 
178  1) temporal types and numeric data types: in which case the
179  comparison is normally done as DOUBLE, so the arguments which are not
180  floating point, will get converted to DOUBLE, and also for
181 
182  2) comparisons between temporal types: in which case the
183  comparison happens as DATETIME if the arguments have different data
184  types, so in this case the temporal arguments that are not DATETIME
185  will get wrapped in a CAST to DATETIME.
186 
187  WL#12108; This function will limit itself to comparison between regular
188  functions, aggregation functions and fields, all of which are constant
189  for execution (so this excludes stored procedures, stored functions, GC,
190  user defined functions, as well as literals).
191  For const arguments, see type conversions done in fold_condition.
192 
193  @return false if successful, true otherwise
194  */
195  bool inject_cast_nodes();
196 
197  /**
198  When comparing strings, compare at most max_length bytes.
199  @param max_length how much to compare
200  */
201  void set_max_str_length(size_t max_length) { m_max_str_length = max_length; }
202  inline int compare() { return (this->*func)(); }
203 
204  int compare_string(); // compare args[0] & args[1]
205  int compare_binary_string(); // compare args[0] & args[1]
206  int compare_real(); // compare args[0] & args[1]
207  int compare_decimal(); // compare args[0] & args[1]
208  int compare_int_signed(); // compare args[0] & args[1]
211  int compare_int_unsigned();
212  int compare_time_packed();
213  int compare_row(); // compare args[0] & args[1]
214  int compare_real_fixed();
215  int compare_datetime(); // compare args[0] & args[1] as DATETIMEs
216  int compare_json();
217  bool compare_null_values();
218 
219  static bool can_compare_as_dates(Item *a, Item *b);
220 
221  Item **cache_converted_constant(THD *thd, Item **value, Item **cache,
222  Item_result type);
223  void set_datetime_cmp_func(Item_result_field *owner_arg, Item **a1,
224  Item **b1);
226  void cleanup();
227  /*
228  Set correct cmp_context if items would be compared as INTs.
229  */
232  if ((*left)->is_temporal()) (*left)->cmp_context = INT_RESULT;
233  if ((*right)->is_temporal()) (*right)->cmp_context = INT_RESULT;
234  }
235 
237 
238  /// @returns true if the class has decided that values should be extracted
239  /// from the Items using function pointers set up by this class.
241  return get_value_a_func != nullptr;
242  }
243 
244  // Read the value from one of the Items (decided by "left_argument"), using
245  // the function pointers that this class has set up. This can happen for DATE,
246  // TIME, DATETIME and YEAR values, and the returned value is a temporal value
247  // in packed format.
248  longlong extract_value_from_argument(THD *thd, Item *item, bool left_argument,
249  bool *is_null) const;
250 
251  private:
252  /// A function pointer that is used for retrieving the value from argument
253  /// "left". This function is only used when we are comparing in a datetime
254  /// context, and it retrieves the value as a DATE, TIME, DATETIME or YEAR,
255  /// depending on the comparison context.
256  ///
257  /// @param thd thread handle. Used to retrieve the SQL mode among other things
258  /// @param item_arg the item to retrieve the value from
259  /// @param cache_arg a pointer to an Item where we can cache the value
260  /// from "item_arg". Can be nullptr
261  /// @param warn_item if rasing an conversion warning, the warning gets the
262  /// data type and item name from this item
263  /// @param is_null whether or not "item_arg" returned SQL NULL
264  ///
265  /// @returns a DATE/TIME/YEAR/DATETIME value, in packed format
266  longlong (*get_value_a_func)(THD *thd, Item ***item_arg, Item **cache_arg,
267  const Item *warn_item, bool *is_null){nullptr};
268 
269  // This function does the same as "get_value_a_func", except that it returns
270  // the value from the argument "right" (the right side of the comparison).
271  longlong (*get_value_b_func)(THD *thd, Item ***item_arg, Item **cache_arg,
272  const Item *warn_item, bool *is_null){nullptr};
273 
274  // The data type that is used when comparing the two Items. I.e., if the type
275  // is INT_RESULT, we call val_int() on both sides and compare those.
277 };
278 
280  public:
282  explicit Item_bool_func(const POS &pos)
284 
288 
291  Item_bool_func(const POS &pos, Item *a, Item *b)
293 
295  : Item_int_func(thd, item),
297  bool is_bool_func() const override { return true; }
298  bool resolve_type(THD *) override {
299  max_length = 1;
300  return false;
301  }
302  uint decimal_precision() const override { return 1; }
303  bool created_by_in2exists() const override { return m_created_by_in2exists; }
305 
306  static const char *bool_transform_names[10];
307  /**
308  Array that transforms a boolean test according to another.
309  First dimension is existing value, second dimension is test to apply
310  */
311  static const Bool_test bool_transform[10][8];
312 
313  private:
314  /**
315  True <=> this item was added by IN->EXISTS subquery transformation, and
316  should thus be deleted if we switch to materialization.
317  */
319 };
320 
321 /**
322  A predicate that is "always true" or "always false". To be used as a
323  standalone condition or as part of conditions, together with other condition
324  and predicate objects.
325  Mostly used when generating conditions internally.
326 */
328  public:
330  max_length = 1;
331  used_tables_cache = 0;
333  fixed = true;
334  }
336  max_length = 1;
337  used_tables_cache = 0;
339  fixed = true;
340  }
341  bool fix_fields(THD *, Item **) override { return false; }
342  bool basic_const_item() const override { return true; }
343  void cleanup() override {}
344 };
345 
346 /// A predicate that is "always true".
347 
349  public:
352  const char *func_name() const override { return "true"; }
353  bool val_bool() override { return true; }
354  longlong val_int() override { return 1; }
355  void print(const THD *, String *str, enum_query_type) const override {
356  str->append("true");
357  }
358 };
359 
360 /// A predicate that is "always false".
361 
363  public:
366  const char *func_name() const override { return "false"; }
367  bool val_bool() override { return false; }
368  longlong val_int() override { return 0; }
369  void print(const THD *, String *str, enum_query_type) const override {
370  str->append("false");
371  }
372 };
373 
374 /**
375  Item class, to represent <code>X IS [NOT] (TRUE | FALSE)</code>
376  boolean predicates.
377 */
380 
381  public:
382  longlong val_int() override;
383  bool resolve_type(THD *) override;
384  void print(const THD *thd, String *str,
385  enum_query_type query_type) const override;
386  Item *truth_transformer(THD *, Bool_test test) override {
388  return this;
389  }
390  const char *func_name() const override {
392  }
393  virtual enum Functype functype() const override { return ISTRUTH_FUNC; }
394 
396  : super(pos, a), truth_test(truth_test) {
397  null_on_null = false;
398  switch (truth_test) {
399  case BOOL_IS_TRUE:
400  case BOOL_IS_FALSE:
401  case BOOL_NOT_TRUE:
402  case BOOL_NOT_FALSE:
403  break;
404  default:
405  DBUG_ASSERT(false);
406  }
407  }
409  : super(a), truth_test(truth_test) {
410  null_on_null = false;
411  switch (truth_test) {
412  case BOOL_IS_TRUE:
413  case BOOL_IS_FALSE:
414  case BOOL_NOT_TRUE:
415  case BOOL_NOT_FALSE:
416  break;
417  default:
418  DBUG_ASSERT(false);
419  }
420  }
421  void apply_is_true() override {
422  /*
423  This item cannot produce NULL result. But, if the upper item confuses
424  NULL and FALSE, we can do as if NULL input caused a NULL result when it
425  actually causes a FALSE result.
426  */
427  switch (truth_test) {
428  case BOOL_IS_TRUE:
429  case BOOL_IS_FALSE:
430  null_on_null = true;
431  default:
432  break;
433  }
434  }
435 
436  protected:
437  Bool_test truth_test; ///< The value we're testing for.
438 };
439 
440 static const int UNKNOWN = -1;
441 
442 /*
443  Item_in_optimizer(left_expr, Item_in_subselect(...))
444 
445  Item_in_optimizer is used to wrap an instance of Item_in_subselect. This
446  class does the following:
447  - Evaluate the left expression and store it in Item_cache_* object (to
448  avoid re-evaluating it many times during subquery execution)
449  - Shortcut the evaluation of "NULL IN (...)" to NULL in the cases where we
450  don't care if the result is NULL or FALSE.
451 
452  args[1] keeps a reference to the Item_in_subselect object.
453 
454  args[0] is a copy of Item_in_subselect's left expression and should be
455  kept equal also after resolving.
456 
457  NOTE
458  It is not quite clear why the above listed functionality should be
459  placed into a separate class called 'Item_in_optimizer'.
460 */
461 
463  private:
466  /*
467  Stores the value of "NULL IN (SELECT ...)" for uncorrelated subqueries:
468  UNKNOWN - "NULL in (SELECT ...)" has not yet been evaluated
469  FALSE - result is FALSE
470  TRUE - result is NULL
471  */
473 
474  public:
476  : Item_bool_func(a, reinterpret_cast<Item *>(b)),
477  cache(0),
478  save_cache(0),
480  set_subquery();
481  }
482  bool fix_fields(THD *, Item **) override;
483  bool fix_left(THD *thd, Item **ref);
484  void fix_after_pullout(SELECT_LEX *parent_select,
485  SELECT_LEX *removed_select) override;
486  bool is_null() override;
487  longlong val_int() override;
488  void cleanup() override;
489  const char *func_name() const override { return "<in_optimizer>"; }
490  Item_cache **get_cache() { return &cache; }
491  void keep_top_level_cache();
492  Item *transform(Item_transformer transformer, uchar *arg) override;
493  void replace_argument(THD *thd, Item **oldpp, Item *newp) override;
494 };
495 
496 /// Abstract factory interface for creating comparison predicates.
498  public:
499  virtual ~Comp_creator() {}
500  virtual Item_bool_func *create(Item *a, Item *b) const = 0;
501 
502  /// This interface is only used by Item_allany_subselect.
503  virtual const char *symbol(bool invert) const = 0;
504  virtual bool eqne_op() const = 0;
505  virtual bool l_op() const = 0;
506 };
507 
508 /// Abstract base class for the comparison operators =, <> and <=>.
510  public:
511  virtual Item_bool_func *create(Item *a, Item *b) const;
512  virtual bool eqne_op() const { return true; }
513  virtual bool l_op() const { return false; }
514 
515  protected:
516  /**
517  Creates only an item tree node, without attempting to rewrite row
518  constructors.
519  @see create()
520  */
521  virtual Item_bool_func *create_scalar_predicate(Item *a, Item *b) const = 0;
522 
523  /// Combines a list of conditions <code>exp op exp</code>.
524  virtual Item_bool_func *combine(List<Item> list) const = 0;
525 };
526 
528  public:
529  virtual const char *symbol(bool invert) const { return invert ? "<>" : "="; }
530 
531  protected:
532  virtual Item_bool_func *create_scalar_predicate(Item *a, Item *b) const;
533  virtual Item_bool_func *combine(List<Item> list) const;
534 };
535 
537  public:
538  virtual const char *symbol(bool invert MY_ATTRIBUTE((unused))) const {
539  // This will never be called with true.
540  DBUG_ASSERT(!invert);
541  return "<=>";
542  }
543 
544  protected:
545  virtual Item_bool_func *create_scalar_predicate(Item *a, Item *b) const;
546  virtual Item_bool_func *combine(List<Item> list) const;
547 };
548 
550  public:
551  virtual const char *symbol(bool invert) const { return invert ? "=" : "<>"; }
552 
553  protected:
554  virtual Item_bool_func *create_scalar_predicate(Item *a, Item *b) const;
555  virtual Item_bool_func *combine(List<Item> list) const;
556 };
557 
558 class Gt_creator : public Comp_creator {
559  public:
560  Gt_creator() {} /* Remove gcc warning */
561  virtual ~Gt_creator() {} /* Remove gcc warning */
562  virtual Item_bool_func *create(Item *a, Item *b) const;
563  virtual const char *symbol(bool invert) const { return invert ? "<=" : ">"; }
564  virtual bool eqne_op() const { return 0; }
565  virtual bool l_op() const { return 0; }
566 };
567 
568 class Lt_creator : public Comp_creator {
569  public:
570  Lt_creator() {} /* Remove gcc warning */
571  virtual ~Lt_creator() {} /* Remove gcc warning */
572  virtual Item_bool_func *create(Item *a, Item *b) const;
573  virtual const char *symbol(bool invert) const { return invert ? ">=" : "<"; }
574  virtual bool eqne_op() const { return 0; }
575  virtual bool l_op() const { return 1; }
576 };
577 
578 class Ge_creator : public Comp_creator {
579  public:
580  Ge_creator() {} /* Remove gcc warning */
581  virtual ~Ge_creator() {} /* Remove gcc warning */
582  virtual Item_bool_func *create(Item *a, Item *b) const;
583  virtual const char *symbol(bool invert) const { return invert ? "<" : ">="; }
584  virtual bool eqne_op() const { return 0; }
585  virtual bool l_op() const { return 0; }
586 };
587 
588 class Le_creator : public Comp_creator {
589  public:
590  Le_creator() {} /* Remove gcc warning */
591  virtual ~Le_creator() {} /* Remove gcc warning */
592  virtual Item_bool_func *create(Item *a, Item *b) const;
593  virtual const char *symbol(bool invert) const { return invert ? ">" : "<="; }
594  virtual bool eqne_op() const { return 0; }
595  virtual bool l_op() const { return 1; }
596 };
597 
598 class Item_bool_func2 : public Item_bool_func { /* Bool with 2 string args */
599  private:
600  bool convert_constant_arg(THD *thd, Item *field, Item **item,
601  bool *converted);
602 
603  protected:
606 
607  public:
610 
611  Item_bool_func2(const POS &pos, Item *a, Item *b)
612  : Item_bool_func(pos, a, b),
613  cmp(tmp_arg, tmp_arg + 1),
614  abort_on_null(false) {}
615 
616  bool resolve_type(THD *) override;
617  bool set_cmp_func() {
618  return cmp.set_cmp_func(this, tmp_arg, tmp_arg + 1, true);
619  }
620  /**
621  When comparing strings, compare at most max_str_length bytes.
622  @param max_str_length how much to compare
623  */
624  void set_max_str_length(size_t max_str_length) {
625  return cmp.set_max_str_length(max_str_length);
626  }
627  optimize_type select_optimize(const THD *) override { return OPTIMIZE_OP; }
628  virtual enum Functype rev_functype() const { return UNKNOWN_FUNC; }
629  bool have_rev_func() const override { return rev_functype() != UNKNOWN_FUNC; }
630 
631  void print(const THD *thd, String *str,
632  enum_query_type query_type) const override {
633  Item_func::print_op(thd, str, query_type);
634  }
635 
636  bool is_null() override { return args[0]->is_null() || args[1]->is_null(); }
637  const CHARSET_INFO *compare_collation() const override {
638  return cmp.cmp_collation.collation;
639  }
640  void apply_is_true() override { abort_on_null = true; }
641  /// Treat UNKNOWN result like FALSE because callers see no difference
642  bool ignore_unknown() const { return abort_on_null; }
643  void cleanup() override {
645  cmp.cleanup();
646  }
647  bool cast_incompatible_args(uchar *) override;
648  friend class Arg_comparator;
649 };
650 
651 /**
652  Item_func_comparison is a class for comparison functions that take two
653  arguments and return a boolean result.
654  It is a common class for the regular comparison operators (=, <>, <, <=,
655  >, >=) as well as the special <=> equality operator.
656 */
658  public:
660  allowed_arg_cols = 0; // Fetch this value from first argument
661  }
663  : Item_bool_func2(pos, a, b) {
664  allowed_arg_cols = 0; // Fetch this value from first argument
665  }
666 
667  Item *truth_transformer(THD *, Bool_test) override;
668  virtual Item *negated_item();
669  bool subst_argument_checker(uchar **) override { return true; }
670  bool is_null() override;
671 
672  bool has_any_non_equi_join_condition() const override;
673 };
674 
675 /**
676  XOR inherits from Item_bool_func2 because it is not optimized yet.
677  Later, when XOR is optimized, it needs to inherit from
678  Item_cond instead. See WL#5800.
679 */
682 
683  public:
684  Item_func_xor(Item *i1, Item *i2) : Item_bool_func2(i1, i2) {}
685  Item_func_xor(const POS &pos, Item *i1, Item *i2)
686  : Item_bool_func2(pos, i1, i2) {}
687 
688  enum Functype functype() const override { return XOR_FUNC; }
689  const char *func_name() const override { return "xor"; }
690  bool itemize(Parse_context *pc, Item **res) override;
691  longlong val_int() override;
692  void apply_is_true() override {}
693  Item *truth_transformer(THD *, Bool_test) override;
694 
695  float get_filtering_effect(THD *thd, table_map filter_for_table,
696  table_map read_tables,
697  const MY_BITMAP *fields_to_ignore,
698  double rows_in_table) override;
699  bool cast_incompatible_args(uchar *) override { return false; }
700 };
701 
703  public:
706 
707  longlong val_int() override;
708  enum Functype functype() const override { return NOT_FUNC; }
709  const char *func_name() const override { return "not"; }
710  Item *truth_transformer(THD *, Bool_test) override;
711  void print(const THD *thd, String *str,
712  enum_query_type query_type) const override;
713 
714  float get_filtering_effect(THD *thd, table_map filter_for_table,
715  table_map read_tables,
716  const MY_BITMAP *fields_to_ignore,
717  double rows_in_table) override;
718 };
719 
720 /**
721  Wrapper class when MATCH function is used in WHERE clause.
722  The MATCH clause can be used as a function returning a floating point value
723  in the SELECT list or in the WHERE clause. However, it may also be used as
724  a boolean function in the WHERE clause, where it has different semantics than
725  when used together with a comparison operator. With a comparison operator,
726  the match operation is performed with ranking. To preserve this behavior,
727  the Item_func_match object is wrapped inside an object of class
728  Item_func_match_predicate, which effectively transforms the function into
729  a predicate. The overridden functions implemented in this class generally
730  forward all evaluation to the underlying object.
731 */
733  public:
735 
736  longlong val_int() override { return args[0]->val_int(); }
737  enum Functype functype() const override { return MATCH_FUNC; }
738  const char *func_name() const override { return "match"; }
739  void print(const THD *thd, String *str,
740  enum_query_type query_type) const override {
741  args[0]->print(thd, str, query_type);
742  }
743 
744  float get_filtering_effect(THD *thd, table_map filter_for_table,
745  table_map read_tables,
746  const MY_BITMAP *fields_to_ignore,
747  double rows_in_table) override {
748  return args[0]->get_filtering_effect(thd, filter_for_table, read_tables,
749  fields_to_ignore, rows_in_table);
750  }
751 };
753 class JOIN;
754 
755 /*
756  trigcond<param>(arg) ::= param? arg : true
757 
758  The class Item_func_trig_cond is used for guarded predicates
759  which are employed only for internal purposes.
760  A guarded predicate is an object consisting of an a regular or
761  a guarded predicate P and a pointer to a boolean guard variable g.
762  A guarded predicate P/g is evaluated to true if the value of the
763  guard g is false, otherwise it is evaluated to the same value that
764  the predicate P: val(P/g)= g ? val(P):true.
765  Guarded predicates allow us to include predicates into a conjunction
766  conditionally. Currently they are utilized for pushed down predicates
767  in queries with outer join operations.
768 
769  In the future, probably, it makes sense to extend this class to
770  the objects consisting of three elements: a predicate P, a pointer
771  to a variable g and a firing value s with following evaluation
772  rule: val(P/g,s)= g==s? val(P) : true. It will allow us to build only
773  one item for the objects of the form P/g1/g2...
774 
775  Objects of this class are built only for query execution after
776  the execution plan has been already selected. That's why this
777  class needs only val_int out of generic methods.
778 
779  Current uses of Item_func_trig_cond objects:
780  - To wrap selection conditions when executing outer joins
781  - To wrap condition that is pushed down into subquery
782 */
783 
785  public:
787  /**
788  This trigger type deactivates join conditions when a row has been
789  NULL-complemented. For example, in t1 LEFT JOIN t2, the join condition
790  can be tested on t2's row only if that row is not NULL-complemented.
791  */
793 
794  /**
795  This trigger type deactivates predicated from WHERE condition when no
796  row satisfying the join condition has been found. For Example, in t1
797  LEFT JOIN t2, the where condition pushed to t2 can be tested only after
798  at least one t2 row has been produced, which may be a NULL-complemented
799  row.
800  */
802 
803  /**
804  In IN->EXISTS subquery transformation, new predicates are added:
805  WHERE inner_field=outer_field OR inner_field IS NULL,
806  as well as
807  HAVING inner_field IS NOT NULL,
808  are disabled if outer_field is a NULL value
809  */
811  };
812 
813  private:
814  /** Pointer to trigger variable */
815  bool *trig_var;
816  /// Optional: JOIN of table which is the source of trig_var
817  const JOIN *m_join;
818  /// Optional: if join!=NULL: index of table
820  /** Type of trig_var; for printing */
822 
823  public:
824  /**
825  @param a the item for @<condition@>
826  @param f pointer to trigger variable
827  @param join if a table's property is the source of 'f', JOIN
828  which owns this table; NULL otherwise.
829  @param idx if join!=NULL: index of this table in the
830  JOIN_TAB/QEP_TAB array. NO_PLAN_IDX otherwise.
831  @param trig_type_arg type of 'f'
832  */
834  enum_trig_type trig_type_arg)
835  : Item_bool_func(a),
836  trig_var(f),
837  m_join(join),
838  m_idx(idx),
839  trig_type(trig_type_arg) {}
840  longlong val_int() override;
841  enum Functype functype() const override { return TRIG_COND_FUNC; }
842  /// '@<if@>', to distinguish from the if() SQL function
843  const char *func_name() const override { return "<if>"; }
844  /// Get range of inner tables spanned by associated outer join operation
845  void get_table_range(TABLE_LIST **first_table, TABLE_LIST **last_table) const;
846  /// Get table_map of inner tables spanned by associated outer join operation
847  table_map get_inner_tables() const;
848  bool fix_fields(THD *thd, Item **ref) override {
849  if (Item_bool_func::fix_fields(thd, ref)) return true;
851  return false;
852  }
855  DBUG_ASSERT(m_join != nullptr);
856  // Make this function dependent on the inner tables
858  } else if (trig_type == OUTER_FIELD_IS_NOT_NULL) {
860  }
861  }
862  void update_used_tables() override {
865  }
866  enum enum_trig_type get_trig_type() const { return trig_type; }
867  bool *get_trig_var() { return trig_var; }
869  void print(const THD *thd, String *str,
870  enum_query_type query_type) const override;
871  plan_idx idx() const { return m_idx; }
872 };
873 
875  /* allow to check presence of values in max/min optimization */
880 
881  public:
882  bool show;
883 
885  : Item_func_not(a),
886  test_sum_item(0),
887  test_sub_item(0),
888  subselect(0),
889  abort_on_null(0),
890  show(0) {}
891  void apply_is_true() override { abort_on_null = true; }
892  /// Treat UNKNOWN result like FALSE because callers see no difference
893  bool ignore_unknown() const { return abort_on_null; }
894  longlong val_int() override;
895  enum Functype functype() const override { return NOT_ALL_FUNC; }
896  const char *func_name() const override { return "<not>"; }
897  void print(const THD *thd, String *str,
898  enum_query_type query_type) const override;
901  void set_subselect(Item_subselect *item) { subselect = item; }
902  table_map not_null_tables() const override {
903  /*
904  See handling of not_null_tables_cache in
905  Item_in_optimizer::fix_fields().
906 
907  This item is the result of a transformation from an ALL clause
908  such as
909  left-expr < ALL(subquery)
910  into
911  <not>(left-expr >= ANY(subquery)
912 
913  An inequality usually rejects NULLs from both operands, so the
914  not_null_tables() of the inequality is the union of the
915  null-rejecting tables of both operands. However, since this is a
916  transformed ALL clause that should return true if the subquery
917  is empty (even if left-expr is NULL), it is not null rejecting
918  for left-expr. The not null tables mask for left-expr should be
919  removed, leaving only the null-rejecting tables of the
920  subquery. Item_subselect::not_null_tables() always returns 0 (no
921  null-rejecting tables). Therefore, always return 0.
922  */
923  return 0;
924  }
926  Item *truth_transformer(THD *, Bool_test) override;
927 };
928 
930  public:
932  longlong val_int() override;
933  const char *func_name() const override { return "<nop>"; }
934  table_map not_null_tables() const override { return not_null_tables_cache; }
935  Item *truth_transformer(THD *, Bool_test) override;
936 };
937 
938 /**
939  Implements the comparison operator equals (=)
940 */
942  public:
944  Item_func_eq(const POS &pos, Item *a, Item *b)
945  : Item_func_comparison(pos, a, b) {}
946  longlong val_int() override;
947  enum Functype functype() const override { return EQ_FUNC; }
948  enum Functype rev_functype() const override { return EQ_FUNC; }
949  cond_result eq_cmp_result() const override { return COND_TRUE; }
950  const char *func_name() const override { return "="; }
951  Item *negated_item() override;
952  bool equality_substitution_analyzer(uchar **) override { return true; }
954  bool gc_subst_analyzer(uchar **) override { return true; }
955 
956  float get_filtering_effect(THD *thd, table_map filter_for_table,
957  table_map read_tables,
958  const MY_BITMAP *fields_to_ignore,
959  double rows_in_table) override;
960 
961  bool has_any_hash_join_condition(const table_map left_tables,
962  const QEP_TAB &right_table) const override;
963 
964  /// Read the value from the join condition, and append it to the output vector
965  /// "join_key_buffer". The function will determine which side of the condition
966  /// to read the value from by using the bitmap "tables".
967  ///
968  /// @param thd the thread handler
969  /// @param tables a bitmap that marks the tables that are involved in the join
970  /// @param join_condition an isntance containing the join condition together
971  /// with some pre-calculated values
972  /// @param[out] join_key_buffer a buffer where the value from the join
973  /// condition will be appended
974  ///
975  /// @returns true if an SQL NULL was encountered, false otherwise
976  bool append_join_key_for_hash_join(THD *thd, table_map tables,
977  const HashJoinCondition &join_condition,
978  String *join_key_buffer) const;
979 
980  /// Wrap the argument in a typecast, if needed.
981  ///
982  /// When computing a hash of the join value during a hash join, we want to
983  /// create a hash value that is memcmp-able. This is quite straightforward
984  /// for most data types, but it can be tricky for some types. For the
985  /// straightforward cases, this function just returns the argument it was
986  /// given in. For the complex cases, the function returns the given argument,
987  /// wrapped in a typecast node. Which typecast node it is wrapped in is
988  /// determined by the comparison context of this equality condition. The
989  /// comparison context is given by the member "cmp"; a comparator class that
990  /// is set up during query resolving.
991  ///
992  /// @param mem_root the MEM_ROOT where the typecast node is allocated
993  /// @param argument the argument that we might wrap in a typecast. This is
994  /// either the left or the right side of the Item_func_eq
995  ///
996  /// @returns either the argument it was given, or the argument wrapped in a
997  /// typecast
998  Item *create_cast_if_needed(MEM_ROOT *mem_root, Item *argument) const;
999 };
1000 
1001 /**
1002  The <=> operator evaluates the same as
1003 
1004  a IS NULL || b IS NULL ? a IS NULL == b IS NULL : a = b
1005 
1006  a <=> b is equivalent to the standard operation a IS NOT DISTINCT FROM b.
1007 
1008  Notice that the result is TRUE or FALSE, and never UNKNOWN.
1009 */
1011  public:
1013  null_on_null = false;
1014  }
1015  Item_func_equal(const POS &pos, Item *a, Item *b)
1016  : Item_func_comparison(pos, a, b) {
1017  null_on_null = false;
1018  }
1019  longlong val_int() override;
1020  bool resolve_type(THD *thd) override;
1021  enum Functype functype() const override { return EQUAL_FUNC; }
1022  enum Functype rev_functype() const override { return EQUAL_FUNC; }
1023  cond_result eq_cmp_result() const override { return COND_TRUE; }
1024  const char *func_name() const override { return "<=>"; }
1025  Item *truth_transformer(THD *, Bool_test) override { return nullptr; }
1026 
1027  float get_filtering_effect(THD *thd, table_map filter_for_table,
1028  table_map read_tables,
1029  const MY_BITMAP *fields_to_ignore,
1030  double rows_in_table) override;
1031 };
1032 
1033 /**
1034  Implements the comparison operator greater than or equals (>=)
1035 */
1037  public:
1039  longlong val_int() override;
1040  enum Functype functype() const override { return GE_FUNC; }
1041  enum Functype rev_functype() const override { return LE_FUNC; }
1042  cond_result eq_cmp_result() const override { return COND_TRUE; }
1043  const char *func_name() const override { return ">="; }
1044  Item *negated_item() override;
1045  bool gc_subst_analyzer(uchar **) override { return true; }
1046 
1047  float get_filtering_effect(THD *thd, table_map filter_for_table,
1048  table_map read_tables,
1049  const MY_BITMAP *fields_to_ignore,
1050  double rows_in_table) override;
1051 };
1052 
1053 /**
1054  Implements the comparison operator greater than (>)
1055 */
1057  public:
1059  longlong val_int() override;
1060  enum Functype functype() const override { return GT_FUNC; }
1061  enum Functype rev_functype() const override { return LT_FUNC; }
1062  cond_result eq_cmp_result() const override { return COND_FALSE; }
1063  const char *func_name() const override { return ">"; }
1064  Item *negated_item() override;
1065  bool gc_subst_analyzer(uchar **) override { return true; }
1066 
1067  float get_filtering_effect(THD *thd, table_map filter_for_table,
1068  table_map read_tables,
1069  const MY_BITMAP *fields_to_ignore,
1070  double rows_in_table) override;
1071 };
1072 
1073 /**
1074  Implements the comparison operator less than or equals (<=)
1075 */
1077  public:
1079  longlong val_int() override;
1080  enum Functype functype() const override { return LE_FUNC; }
1081  enum Functype rev_functype() const override { return GE_FUNC; }
1082  cond_result eq_cmp_result() const override { return COND_TRUE; }
1083  const char *func_name() const override { return "<="; }
1084  Item *negated_item() override;
1085  bool gc_subst_analyzer(uchar **) override { return true; }
1086 
1087  float get_filtering_effect(THD *thd, table_map filter_for_table,
1088  table_map read_tables,
1089  const MY_BITMAP *fields_to_ignore,
1090  double rows_in_table) override;
1091 };
1092 
1093 /**
1094  Implements the comparison operator less than (<)
1095 */
1097  public:
1099  longlong val_int() override;
1100  enum Functype functype() const override { return LT_FUNC; }
1101  enum Functype rev_functype() const override { return GT_FUNC; }
1102  cond_result eq_cmp_result() const override { return COND_FALSE; }
1103  const char *func_name() const override { return "<"; }
1104  Item *negated_item() override;
1105  bool gc_subst_analyzer(uchar **) override { return true; }
1106 
1107  float get_filtering_effect(THD *thd, table_map filter_for_table,
1108  table_map read_tables,
1109  const MY_BITMAP *fields_to_ignore,
1110  double rows_in_table) override;
1111 };
1112 
1113 /**
1114  Implements the comparison operator not equals (<>)
1115 */
1117  public:
1119  longlong val_int() override;
1120  enum Functype functype() const override { return NE_FUNC; }
1121  cond_result eq_cmp_result() const override { return COND_FALSE; }
1122  optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
1123  const char *func_name() const override { return "<>"; }
1124  Item *negated_item() override;
1125 
1126  float get_filtering_effect(THD *thd, table_map filter_for_table,
1127  table_map read_tables,
1128  const MY_BITMAP *fields_to_ignore,
1129  double rows_in_table) override;
1130 };
1131 
1132 /*
1133  The class Item_func_opt_neg is defined to factor out the functionality
1134  common for the classes Item_func_between and Item_func_in. The objects
1135  of these classes can express predicates or their negations.
1136  The alternative approach would be to create pairs Item_func_between,
1137  Item_func_notbetween and Item_func_in, Item_func_notin.
1138 
1139 */
1140 
1142  public:
1143  bool negated; /* <=> the item represents NOT <func> */
1144  bool pred_level; /* <=> [NOT] <func> is used on a predicate level */
1145  public:
1146  Item_func_opt_neg(const POS &pos, Item *a, Item *b, Item *c, bool is_negation)
1147  : Item_int_func(pos, a, b, c), negated(0), pred_level(0) {
1148  if (is_negation) negate();
1149  }
1150  Item_func_opt_neg(const POS &pos, PT_item_list *list, bool is_negation)
1151  : Item_int_func(pos, list), negated(0), pred_level(0) {
1152  if (is_negation) negate();
1153  }
1154 
1155  public:
1156  inline void negate() { negated = !negated; }
1157  inline void apply_is_true() override { pred_level = 1; }
1158  bool ignore_unknown() const { return pred_level; }
1159  Item *truth_transformer(THD *, Bool_test test) override {
1160  if (test != BOOL_NEGATED) return nullptr;
1161  negated = !negated;
1162  return this;
1163  }
1164  bool eq(const Item *item, bool binary_cmp) const override;
1165  bool subst_argument_checker(uchar **) override { return true; }
1166 };
1167 
1170 
1171  public:
1174  /* true <=> arguments will be compared as dates. */
1178 
1179  /* Comparators used for DATE/DATETIME comparison. */
1181  Item_func_between(const POS &pos, Item *a, Item *b, Item *c, bool is_negation)
1182  : Item_func_opt_neg(pos, a, b, c, is_negation),
1186  longlong val_int() override;
1187  optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
1188  enum Functype functype() const override { return BETWEEN; }
1189  const char *func_name() const override { return "between"; }
1190  bool fix_fields(THD *, Item **) override;
1191  void fix_after_pullout(SELECT_LEX *parent_select,
1192  SELECT_LEX *removed_select) override;
1193  bool resolve_type(THD *) override;
1194  void print(const THD *thd, String *str,
1195  enum_query_type query_type) const override;
1196  bool is_bool_func() const override { return true; }
1197  const CHARSET_INFO *compare_collation() const override {
1198  return cmp_collation.collation;
1199  }
1200  uint decimal_precision() const override { return 1; }
1201  bool gc_subst_analyzer(uchar **) override { return true; }
1202 
1203  float get_filtering_effect(THD *thd, table_map filter_for_table,
1204  table_map read_tables,
1205  const MY_BITMAP *fields_to_ignore,
1206  double rows_in_table) override;
1207 };
1208 
1210  public:
1212  : Item_bool_func2(pos, a, b) {}
1213  longlong val_int() override;
1214  optimize_type select_optimize(const THD *) override { return OPTIMIZE_NONE; }
1215  const char *func_name() const override { return "strcmp"; }
1216 
1217  void print(const THD *thd, String *str,
1218  enum_query_type query_type) const override {
1219  Item_func::print(thd, str, query_type);
1220  }
1221  bool resolve_type(THD *thd) override {
1222  if (Item_bool_func2::resolve_type(thd)) return true;
1223  fix_char_length(2); // returns "1" or "0" or "-1"
1224  return false;
1225  }
1226 };
1227 
1230  double dbl;
1232 };
1233 
1236 
1240 
1241  public:
1243  Item *expr2, class PT_item_list *opt_expr_list = NULL)
1244  : super(pos, alloc_row(pos, mem_root, expr1, expr2, opt_expr_list)),
1245  row(down_cast<Item_row *>(args[0])),
1246  intervals(0) {
1247  allowed_arg_cols = 0; // Fetch this value from first argument
1248  }
1249 
1250  bool itemize(Parse_context *pc, Item **res) override;
1251  longlong val_int() override;
1252  bool resolve_type(THD *) override;
1253  const char *func_name() const override { return "interval"; }
1254  uint decimal_precision() const override { return 2; }
1255  void print(const THD *thd, String *str,
1256  enum_query_type query_type) const override;
1257 
1258  private:
1259  // Runs in CTOR init list, cannot access *this as Item_func_interval
1260  static Item_row *alloc_row(const POS &pos, MEM_ROOT *mem_root, Item *expr1,
1261  Item *expr2, class PT_item_list *opt_expr_list);
1262 };
1263 
1265  protected:
1267  : Item_func_numhybrid(pos, a, b) {
1268  null_on_null = false;
1269  }
1271  null_on_null = false;
1272  }
1273 
1274  public:
1277  null_on_null = false;
1278  }
1279  double real_op() override;
1280  longlong int_op() override;
1281  String *str_op(String *) override;
1282  /**
1283  Get the result of COALESCE as a JSON value.
1284  @param[in,out] wr the result value holder
1285  */
1286  bool val_json(Json_wrapper *wr) override;
1287  bool date_op(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
1288  bool time_op(MYSQL_TIME *ltime) override;
1289  my_decimal *decimal_op(my_decimal *) override;
1290  bool resolve_type(THD *) override;
1291  void set_numeric_type() override {}
1292  enum Item_result result_type() const override { return hybrid_type; }
1293  const char *func_name() const override { return "coalesce"; }
1294  enum Functype functype() const override { return COALESCE_FUNC; }
1295 };
1296 
1298  protected:
1300 
1301  public:
1303  : Item_func_coalesce(pos, a, b) {}
1304  double real_op() override;
1305  longlong int_op() override;
1306  String *str_op(String *str) override;
1307  bool date_op(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
1308  bool time_op(MYSQL_TIME *ltime) override;
1309  my_decimal *decimal_op(my_decimal *) override;
1310  bool val_json(Json_wrapper *result) override;
1311  const char *func_name() const override { return "ifnull"; }
1312  Field *tmp_table_field(TABLE *table) override;
1313  uint decimal_precision() const override;
1314 };
1315 
1316 /**
1317  ANY_VALUE(expr) is like expr except that it is not checked by
1318  aggregate_check logic. It serves as a solution for users who want to
1319  bypass this logic.
1320 */
1322  public:
1324  const char *func_name() const override { return "any_value"; }
1325  bool aggregate_check_group(uchar *arg) override;
1326  bool aggregate_check_distinct(uchar *arg) override;
1327 };
1328 
1329 class Item_func_if final : public Item_func {
1331 
1332  public:
1334  : Item_func(a, b, c), cached_result_type(INT_RESULT) {
1335  null_on_null = false;
1336  }
1337  Item_func_if(const POS &pos, Item *a, Item *b, Item *c)
1338  : Item_func(pos, a, b, c), cached_result_type(INT_RESULT) {
1339  null_on_null = false;
1340  }
1341 
1342  double val_real() override;
1343  longlong val_int() override;
1344  String *val_str(String *str) override;
1345  my_decimal *val_decimal(my_decimal *) override;
1346  bool val_json(Json_wrapper *wr) override;
1347  bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
1348  bool get_time(MYSQL_TIME *ltime) override;
1349  enum Item_result result_type() const override { return cached_result_type; }
1350  bool fix_fields(THD *, Item **) override;
1351  bool resolve_type(THD *) override;
1352  void fix_after_pullout(SELECT_LEX *parent_select,
1353  SELECT_LEX *removed_select) override;
1354  uint decimal_precision() const override;
1355  const char *func_name() const override { return "if"; }
1356  enum Functype functype() const override { return IF_FUNC; }
1357 };
1358 
1361 
1362  public:
1365  null_on_null = false;
1366  }
1367  double val_real() override;
1368  longlong val_int() override;
1369  String *val_str(String *str) override;
1370  my_decimal *val_decimal(my_decimal *) override;
1371  bool val_json(Json_wrapper *wr) override;
1372  Item_result result_type() const override { return cached_result_type; }
1373  bool resolve_type(THD *thd) override;
1374  uint decimal_precision() const override {
1375  return args[0]->decimal_precision();
1376  }
1377  const char *func_name() const override { return "nullif"; }
1378  enum Functype functype() const override { return NULLIF_FUNC; }
1379 
1380  void print(const THD *thd, String *str,
1381  enum_query_type query_type) const override {
1382  Item_func::print(thd, str, query_type);
1383  }
1384 
1385  bool is_null() override;
1386  /**
1387  This is a workaround for the broken inheritance hierarchy: this should
1388  inherit from Item_func instead of Item_bool_func2
1389  */
1390  bool is_bool_func() const override { return false; }
1391  bool cast_incompatible_args(uchar *) override { return false; }
1392 };
1393 
1394 /* Functions to handle the optimized IN */
1395 
1396 /* A vector of values of some type */
1397 
1398 class in_vector {
1399  private:
1400  const uint count; ///< Original size of the vector
1401  public:
1402  uint used_count; ///< The actual size of the vector (NULL may be ignored)
1403 
1404  /**
1405  See Item_func_in::resolve_type() for why we need both
1406  count and used_count.
1407  */
1408  explicit in_vector(uint elements) : count(elements), used_count(elements) {}
1409 
1410  virtual ~in_vector() {}
1411 
1412  /**
1413  Calls item->val_int() or item->val_str() etc.
1414  and then does binary_search if the value is non-null.
1415  @param item to evaluate, and lookup in the IN-list.
1416  @return true if evaluated value of the item was found.
1417  */
1418  virtual bool find_item(Item *item) = 0;
1419 
1420  /**
1421  Create an instance of Item_{type} (e.g. Item_decimal) constant object
1422  which type allows it to hold an element of this vector without any
1423  conversions.
1424  The purpose of this function is to be able to get elements of this
1425  vector in form of Item_xxx constants without creating Item_xxx object
1426  for every array element you get (i.e. this implements "FlyWeight" pattern)
1427 
1428  @param mem_root Where to allocate the Item.
1429  */
1430  virtual Item_basic_constant *create_item(MEM_ROOT *mem_root) const = 0;
1431 
1432  /**
1433  Store the value at position #pos into provided item object
1434 
1435  @param pos Index of value to store
1436  @param item Constant item to store value into. The item must be of the same
1437  type that create_item() returns.
1438  */
1439  virtual void value_to_item(uint pos, Item_basic_constant *item) const = 0;
1440 
1441  /** Compare values number pos1 and pos2 for equality */
1442  virtual bool compare_elems(uint pos1, uint pos2) const = 0;
1443 
1444  virtual bool is_row_result() const { return false; }
1445 
1446  /**
1447  Fill the vector by evaluating the items passed as arguments.
1448  Note that null values are skipped so the vector may end up containing
1449  fewer elements than the number of items.
1450  The vector is sorted so that it can be used for binary search.
1451 
1452  @param items Items to evaluate
1453  @param item_count Number of items
1454 
1455  @return true if any null values was found, false otherwise.
1456  */
1457  bool fill(Item **items, uint item_count);
1458 
1459  private:
1460  virtual void set(uint pos, Item *item) = 0;
1461 
1462  /**
1463  Resize and then sort the IN-list array, so we can do efficient lookup with
1464  binary_search.
1465  */
1466  virtual void resize_and_sort() = 0;
1467 };
1468 
1469 class in_string final : public in_vector {
1473  // String objects are not sortable, sort pointers instead.
1476 
1477  public:
1478  in_string(MEM_ROOT *mem_root, uint elements, const CHARSET_INFO *cs);
1480  return new (mem_root) Item_string(collation);
1481  }
1482  void value_to_item(uint pos, Item_basic_constant *item) const override {
1484  }
1485  bool find_item(Item *item) override;
1486  bool compare_elems(uint pos1, uint pos2) const override;
1487 
1488  private:
1489  void set(uint pos, Item *item) override;
1490  void resize_and_sort() override;
1491 };
1492 
1493 class in_longlong : public in_vector {
1494  public:
1498  };
1499 
1500  protected:
1502 
1503  public:
1505  : in_vector(elements), base(mem_root, elements) {}
1507  /*
1508  We've created a signed INT, this may not be correct in the
1509  general case (see BUG#19342).
1510  */
1511  return new (mem_root) Item_int(0LL);
1512  }
1513  void value_to_item(uint pos, Item_basic_constant *item) const override {
1514  down_cast<Item_int *>(item)->value = base[pos].val;
1515  item->unsigned_flag = base[pos].unsigned_flag;
1516  }
1517  bool find_item(Item *item) override;
1518  bool compare_elems(uint pos1, uint pos2) const override;
1519 
1520  private:
1521  void set(uint pos, Item *item) override { val_item(item, &base[pos]); }
1522  void resize_and_sort() override;
1523  virtual void val_item(Item *item, packed_longlong *result);
1524 };
1525 
1527  public:
1529  : in_longlong(mem_root, elements) {}
1531  return new (mem_root) Item_temporal(MYSQL_TYPE_DATETIME, 0LL);
1532  }
1533 
1534  private:
1535  void val_item(Item *item, packed_longlong *result) override;
1536 };
1537 
1539  public:
1541  : in_longlong(mem_root, elements) {}
1543  return new (mem_root) Item_temporal(MYSQL_TYPE_TIME, 0LL);
1544  }
1545 
1546  private:
1547  void val_item(Item *item, packed_longlong *result) override;
1548 };
1549 
1550 /*
1551  Class to represent a vector of constant DATE/DATETIME values.
1552  Values are obtained with help of the get_datetime_value() function.
1553  If the left item is a constant one then its value is cached in the
1554  lval_cache variable.
1555 */
1557  /* An item used to issue warnings. */
1559  /* Cache for the left item. */
1561 
1562  public:
1563  in_datetime(MEM_ROOT *mem_root, Item *warn_item_arg, uint elements)
1564  : in_longlong(mem_root, elements),
1565  warn_item(warn_item_arg),
1566  lval_cache(nullptr) {}
1568  return new (mem_root) Item_temporal(MYSQL_TYPE_DATETIME, 0LL);
1569  }
1570 
1571  private:
1572  void set(uint pos, Item *item) override;
1573  void val_item(Item *item, packed_longlong *result) override;
1574 };
1575 
1576 class in_double final : public in_vector {
1578 
1579  public:
1581  : in_vector(elements), base(mem_root, elements) {}
1583  return new (mem_root) Item_float(0.0, 0);
1584  }
1585  void value_to_item(uint pos, Item_basic_constant *item) const override {
1586  down_cast<Item_float *>(item)->value = base[pos];
1587  }
1588  bool find_item(Item *item) override;
1589  bool compare_elems(uint pos1, uint pos2) const override;
1590 
1591  private:
1592  void set(uint pos, Item *item) override;
1593  void resize_and_sort() override;
1594 };
1595 
1596 class in_decimal final : public in_vector {
1598 
1599  public:
1601  : in_vector(elements), base(mem_root, elements) {}
1603  return new (mem_root) Item_decimal(0, false);
1604  }
1605  void value_to_item(uint pos, Item_basic_constant *item) const override {
1606  down_cast<Item_decimal *>(item)->set_decimal_value(&base[pos]);
1607  }
1608  bool find_item(Item *item) override;
1609  bool compare_elems(uint pos1, uint pos2) const override;
1610 
1611  private:
1612  void set(uint pos, Item *item) override;
1613  void resize_and_sort() override;
1614 };
1615 
1616 /*
1617 ** Classes for easy comparing of non const items
1618 */
1619 
1620 class cmp_item {
1621  public:
1623  virtual ~cmp_item() {}
1624  virtual void store_value(Item *item) = 0;
1625  /**
1626  @returns result (true, false or UNKNOWN) of
1627  "stored argument's value <> item's value"
1628  */
1629  virtual int cmp(Item *item) = 0;
1630  // for optimized IN with row
1631  virtual int compare(const cmp_item *item) const = 0;
1632 
1633  /**
1634  Find the appropriate comparator for the given type.
1635 
1636  @param result_type Used to find the appropriate comparator.
1637  @param item Item object used to distinguish temporal types.
1638  @param cs Charset
1639 
1640  @return
1641  New cmp_item_xxx object.
1642  */
1643  static cmp_item *get_comparator(Item_result result_type, const Item *item,
1644  const CHARSET_INFO *cs);
1645  virtual cmp_item *make_same() = 0;
1646  virtual void store_value_by_template(cmp_item *, Item *item) {
1647  store_value(item);
1648  }
1649 };
1650 
1651 /// cmp_item which stores a scalar (i.e. non-ROW).
1652 class cmp_item_scalar : public cmp_item {
1653  protected:
1654  bool m_null_value; ///< If stored value is NULL
1655  void set_null_value(bool nv) { m_null_value = nv; }
1656 };
1657 
1659  private:
1664 
1665  public:
1667  : value(value_buff, sizeof(value_buff), cs), cmp_charset(cs) {}
1668 
1669  virtual int compare(const cmp_item *ci) const {
1670  const cmp_item_string *l_cmp = down_cast<const cmp_item_string *>(ci);
1671  return sortcmp(value_res, l_cmp->value_res, cmp_charset);
1672  }
1673 
1674  virtual void store_value(Item *item) {
1675  String *res = item->val_str(&value);
1676  if (res && (res != &value || !res->is_alloced())) {
1677  // 'res' may point in item's transient internal data, so make a copy
1678  value.copy(*res);
1679  }
1680  value_res = &value;
1681  set_null_value(item->null_value);
1682  }
1683 
1684  virtual int cmp(Item *arg) {
1685  char buff[STRING_BUFFER_USUAL_SIZE];
1686  String tmp(buff, sizeof(buff), cmp_charset);
1687  String *res = arg->val_str(&tmp);
1688  if (m_null_value || arg->null_value) return UNKNOWN;
1689  if (value_res && res)
1690  return sortcmp(value_res, res, cmp_charset) != 0;
1691  else if (!value_res && !res)
1692  return false;
1693  else
1694  return true;
1695  }
1696  virtual cmp_item *make_same();
1697 };
1698 
1700  private:
1701  /// Cached JSON value to look up
1703  /// Cache for the value above
1705  /// String buffer
1707  /// Scalar holder for the RHS value
1709 
1710  public:
1712 
1713  virtual int compare(const cmp_item *ci) const;
1714  virtual void store_value(Item *item);
1715  virtual int cmp(Item *arg);
1716  virtual cmp_item *make_same();
1717 };
1718 
1721 
1722  public:
1723  cmp_item_int() {} /* Remove gcc warning */
1724  void store_value(Item *item) override {
1725  value = item->val_int();
1726  set_null_value(item->null_value);
1727  }
1728  int cmp(Item *arg) override {
1729  const bool rc = value != arg->val_int();
1730  return (m_null_value || arg->null_value) ? UNKNOWN : rc;
1731  }
1732  int compare(const cmp_item *ci) const override {
1733  const cmp_item_int *l_cmp = down_cast<const cmp_item_int *>(ci);
1734  return (value < l_cmp->value) ? -1 : ((value == l_cmp->value) ? 0 : 1);
1735  }
1736  cmp_item *make_same() override;
1737 };
1738 
1739 /*
1740  Compare items of temporal type.
1741  Values are obtained with: get_datetime_value() (DATE/DATETIME/TIMESTAMP) and
1742  get_time_value() (TIME).
1743  If the left item is a constant one then its value is cached in the
1744  lval_cache variable.
1745 */
1748 
1749  public:
1750  /* Item used for issuing warnings. */
1751  const Item *warn_item;
1752  /* Cache for the left item. */
1754  /// Distinguish between DATE/DATETIME/TIMESTAMP and TIME
1755  bool has_date;
1756 
1757  cmp_item_datetime(const Item *warn_item_arg);
1758  void store_value(Item *item) override;
1759  int cmp(Item *arg) override;
1760  int compare(const cmp_item *ci) const override;
1761  cmp_item *make_same() override;
1762 };
1763 
1765  double value;
1766 
1767  public:
1768  cmp_item_real() {} /* Remove gcc warning */
1769  void store_value(Item *item) override {
1770  value = item->val_real();
1771  set_null_value(item->null_value);
1772  }
1773  int cmp(Item *arg) override {
1774  const bool rc = value != arg->val_real();
1775  return (m_null_value || arg->null_value) ? UNKNOWN : rc;
1776  }
1777  int compare(const cmp_item *ci) const override {
1778  const cmp_item_real *l_cmp = down_cast<const cmp_item_real *>(ci);
1779  return (value < l_cmp->value) ? -1 : ((value == l_cmp->value) ? 0 : 1);
1780  }
1781  cmp_item *make_same() override;
1782 };
1783 
1786 
1787  public:
1788  cmp_item_decimal() {} /* Remove gcc warning */
1789  void store_value(Item *item);
1790  int cmp(Item *arg);
1791  int compare(const cmp_item *c) const;
1792  cmp_item *make_same();
1793 };
1794 
1795 /**
1796  CASE ... WHEN ... THEN ... END function implementation.
1797 
1798  When there is no expression between CASE and the first WHEN
1799  (the CASE expression) then this function simple checks all WHEN expressions
1800  one after another. When some WHEN expression evaluated to TRUE then the
1801  value of the corresponding THEN expression is returned.
1802 
1803  When the CASE expression is specified then it is compared to each WHEN
1804  expression individually. When an equal WHEN expression is found
1805  corresponding THEN expression is returned.
1806  In order to do correct comparisons several comparators are used. One for
1807  each result type. Different result types that are used in particular
1808  CASE ... END expression are collected in the resolve_type() member
1809  function and only comparators for there result types are used.
1810 */
1811 
1813  typedef Item_func super;
1814 
1816  enum Item_result cached_result_type, left_result_type;
1821  cmp_item *cmp_items[5]; /* For all result types */
1823 
1824  public:
1825  Item_func_case(const POS &pos, List<Item> &list, Item *first_expr_arg,
1826  Item *else_expr_arg)
1827  : super(pos),
1828  first_expr_num(-1),
1829  else_expr_num(-1),
1830  cached_result_type(INT_RESULT),
1832  case_item(0) {
1833  null_on_null = false;
1834  ncases = list.elements;
1835  if (first_expr_arg) {
1836  first_expr_num = list.elements;
1837  list.push_back(first_expr_arg);
1838  }
1839  if (else_expr_arg) {
1840  else_expr_num = list.elements;
1841  list.push_back(else_expr_arg);
1842  }
1843  set_arguments(list, true);
1844  memset(&cmp_items, 0, sizeof(cmp_items));
1845  }
1846  int get_first_expr_num() const { return first_expr_num; }
1847  int get_else_expr_num() const { return else_expr_num; }
1848  double val_real() override;
1849  longlong val_int() override;
1850  String *val_str(String *) override;
1851  my_decimal *val_decimal(my_decimal *) override;
1852  bool val_json(Json_wrapper *wr) override;
1853  bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
1854  bool get_time(MYSQL_TIME *ltime) override;
1855  bool fix_fields(THD *thd, Item **ref) override;
1856  bool resolve_type(THD *) override;
1857  uint decimal_precision() const override;
1858  enum Item_result result_type() const override { return cached_result_type; }
1859  const char *func_name() const override { return "case"; }
1860  void print(const THD *thd, String *str,
1861  enum_query_type query_type) const override;
1862  Item *find_item(String *str);
1863  const CHARSET_INFO *compare_collation() const override {
1864  return cmp_collation.collation;
1865  }
1866  void cleanup() override;
1867  enum Functype functype() const override { return CASE_FUNC; }
1868 };
1869 
1870 /**
1871  in_expr [NOT] IN (in_value_list).
1872 
1873  The current implementation distinguishes 2 cases:
1874  1) all items in in_value_list are constants and have the same
1875  result type. This case is handled by in_vector class.
1876  2) otherwise Item_func_in employs several cmp_item objects to perform
1877  comparisons of in_expr and an item from in_value_list. One cmp_item
1878  object for each result type. Different result types are collected in the
1879  resolve_type() member function by means of collect_cmp_types() function.
1880 */
1882  public:
1883  /// An array of values, created when the bisection lookup method is used
1885  /**
1886  If there is some NULL among @<in value list@>, during a val_int() call; for
1887  example
1888  IN ( (1,(3,'col')), ... ), where 'col' is a column which evaluates to
1889  NULL.
1890  */
1892  /**
1893  Set to true by resolve_type() if the IN list contains a
1894  dependent subquery, in which case condition filtering will not be
1895  calculated for this item.
1896  */
1899  cmp_item *cmp_items[6]; /* One cmp_item for each result type */
1901 
1902  Item_func_in(const POS &pos, PT_item_list *list, bool is_negation)
1903  : Item_func_opt_neg(pos, list, is_negation),
1904  array(NULL),
1905  have_null(false),
1907  memset(&cmp_items, 0, sizeof(cmp_items));
1908  allowed_arg_cols = 0; // Fetch this value from first argument
1909  }
1910  longlong val_int() override;
1911  bool fix_fields(THD *, Item **) override;
1912  void fix_after_pullout(SELECT_LEX *parent_select,
1913  SELECT_LEX *removed_select) override;
1914  bool resolve_type(THD *) override;
1915  uint decimal_precision() const override { return 1; }
1916 
1917  /**
1918  Cleanup data and comparator arrays.
1919 
1920  @note Used during regular cleanup and to free arrays after GC substitution.
1921  @see substitute_gc().
1922  */
1924  uint i;
1925  destroy(array);
1926  array = 0;
1927  for (i = 0; i <= (uint)DECIMAL_RESULT + 1; i++) {
1928  destroy(cmp_items[i]);
1929  cmp_items[i] = 0;
1930  }
1931  }
1932 
1933  void cleanup() override {
1934  DBUG_TRACE;
1936  cleanup_arrays();
1937  return;
1938  }
1939  optimize_type select_optimize(const THD *) override { return OPTIMIZE_KEY; }
1940  void print(const THD *thd, String *str,
1941  enum_query_type query_type) const override;
1942  enum Functype functype() const override { return IN_FUNC; }
1943  const char *func_name() const override { return " IN "; }
1944  bool is_bool_func() const override { return true; }
1945  const CHARSET_INFO *compare_collation() const override {
1946  return cmp_collation.collation;
1947  }
1948  bool gc_subst_analyzer(uchar **) override { return true; }
1949 
1950  float get_filtering_effect(THD *thd, table_map filter_for_table,
1951  table_map read_tables,
1952  const MY_BITMAP *fields_to_ignore,
1953  double rows_in_table) override;
1954 
1955  private:
1956  /**
1957  Usable if @<in value list@> is made only of constants. Returns true if one
1958  of these constants contains a NULL. Example:
1959  IN ( (-5, (12,NULL)), ... ).
1960  */
1961  bool list_contains_null();
1962  /**
1963  Utility function to help calculate the total filtering effect of
1964  IN predicates. This function calculates the filtering effect from
1965  a single field (or field reference) on the left hand side of the
1966  expression.
1967 
1968  @param fieldref Field (or field reference) on left hand side of
1969  IN, i.e., this function should be called for
1970  each fi in "(f1,...,fn) IN (values)"
1971  @param filter_for_table The table we are calculating filter effect for
1972  @param fields_to_ignore Fields in 'filter_for_table' that should not
1973  be part of the filter calculation. The filtering
1974  effect of these fields are already part of the
1975  calculation somehow (e.g. because there is a
1976  predicate "col = <const>", and the optimizer
1977  has decided to do ref access on 'col').
1978  @param rows_in_table The number of rows in table 'filter_for_table'
1979 
1980  @return the filtering effect (between 0 and 1) 'the_field'
1981  participates with in this IN predicate.
1982  */
1984  table_map filter_for_table,
1985  const MY_BITMAP *fields_to_ignore,
1986  double rows_in_table);
1987 };
1988 
1989 class cmp_item_row : public cmp_item {
1992 
1993  public:
1994  cmp_item_row() : comparators(nullptr), n(0) {}
1995  cmp_item_row(THD *thd, Item *item) : comparators(nullptr), n(item->cols()) {
1996  alloc_comparators(thd, item);
1997  }
1998  ~cmp_item_row();
1999 
2001  : comparators(other.comparators), n(other.n) {
2002  other.comparators = nullptr;
2003  other.n = 0;
2004  }
2005 
2006  void store_value(Item *item);
2007  int cmp(Item *arg);
2008  int compare(const cmp_item *arg) const;
2009  cmp_item *make_same();
2010  void store_value_by_template(cmp_item *tmpl, Item *);
2011  void set_comparator(uint col, cmp_item *comparator) {
2012  comparators[col] = comparator;
2013  }
2014 
2015  private:
2016  bool alloc_comparators(THD *thd, Item *item);
2017 };
2018 
2019 class in_row final : public in_vector {
2022  // Sort pointers, rather than objects.
2024 
2025  public:
2026  in_row(MEM_ROOT *mem_root, uint elements, cmp_item_row *cmp);
2027  bool is_row_result() const override { return true; }
2028  bool find_item(Item *item) override;
2029  bool compare_elems(uint pos1, uint pos2) const override;
2030  void set_comparator(uint col, cmp_item *comparator) {
2031  tmp->set_comparator(col, comparator);
2032  }
2034  DBUG_ASSERT(false);
2035  return nullptr;
2036  }
2037  void value_to_item(uint, Item_basic_constant *) const override {
2038  DBUG_ASSERT(false);
2039  }
2040 
2041  private:
2042  void set(uint pos, Item *item) override;
2043  void resize_and_sort() override;
2044 };
2045 
2046 /* Functions used by where clause */
2047 
2050 
2051  protected:
2053 
2054  public:
2055  Item_func_isnull(Item *a) : super(a) { null_on_null = false; }
2056  Item_func_isnull(const POS &pos, Item *a) : super(pos, a) {
2057  null_on_null = false;
2058  }
2059  longlong val_int() override;
2060  enum Functype functype() const override { return ISNULL_FUNC; }
2061  bool resolve_type(THD *thd) override;
2062  const char *func_name() const override { return "isnull"; }
2063  /* Optimize case of not_null_column IS NULL */
2064  void update_used_tables() override;
2065 
2066  float get_filtering_effect(THD *thd, table_map filter_for_table,
2067  table_map read_tables,
2068  const MY_BITMAP *fields_to_ignore,
2069  double rows_in_table) override;
2070  optimize_type select_optimize(const THD *) override { return OPTIMIZE_NULL; }
2071  Item *truth_transformer(THD *, Bool_test test) override;
2072  void print(const THD *thd, String *str,
2073  enum_query_type query_type) const override;
2074  const CHARSET_INFO *compare_collation() const override {
2075  return args[0]->collation.collation;
2076  }
2077  bool fix_fields(THD *thd, Item **ref) override;
2078 };
2079 
2080 /* Functions used by HAVING for rewriting IN subquery */
2081 
2082 /*
2083  This is like IS NOT NULL but it also remembers if it ever has
2084  encountered a NULL; it remembers this in the "was_null" property of the
2085  "owner" item.
2086 */
2089 
2090  public:
2092  : Item_func_isnull(a), owner(ow) {}
2093  enum Functype functype() const override { return ISNOTNULLTEST_FUNC; }
2094  longlong val_int() override;
2095  const char *func_name() const override { return "<is_not_null_test>"; }
2096  void update_used_tables() override;
2097  /**
2098  We add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE.
2099 
2100  @retval Always RAND_TABLE_BIT
2101  */
2103  return RAND_TABLE_BIT;
2104  }
2105  void print(const THD *thd, String *str,
2106  enum_query_type query_type) const override {
2107  Item_bool_func::print(thd, str, query_type);
2108  }
2109 };
2110 
2112  public:
2115  null_on_null = false;
2116  }
2117 
2118  longlong val_int() override;
2119  enum Functype functype() const override { return ISNOTNULL_FUNC; }
2120  bool resolve_type(THD *) override {
2121  max_length = 1;
2122  maybe_null = false;
2123  return false;
2124  }
2125  const char *func_name() const override { return "isnotnull"; }
2126  optimize_type select_optimize(const THD *) override { return OPTIMIZE_NULL; }
2127  Item *truth_transformer(THD *, Bool_test test) override;
2128  void print(const THD *thd, String *str,
2129  enum_query_type query_type) const override;
2130  const CHARSET_INFO *compare_collation() const override {
2131  return args[0]->collation.collation;
2132  }
2133  void apply_is_true() override {
2134  null_on_null = true;
2135  } // Same logic as for Item_func_truth's function
2136  float get_filtering_effect(THD *thd, table_map filter_for_table,
2137  table_map read_tables,
2138  const MY_BITMAP *fields_to_ignore,
2139  double rows_in_table) override;
2140 };
2141 
2144 
2146 
2148 
2149  bool escape_evaluated; ///< Tells if the escape clause has been evaluated.
2150  bool eval_escape_clause(THD *thd);
2151 
2152  public:
2153  int escape;
2154 
2155  Item_func_like(Item *a, Item *b, Item *escape_arg, bool escape_used)
2156  : Item_bool_func2(a, b),
2157  escape_item(escape_arg),
2158  escape_used_in_parsing(escape_used),
2160  Item_func_like(const POS &pos, Item *a, Item *b, Item *opt_escape_arg)
2161  : super(pos, a, b),
2162  escape_item(opt_escape_arg),
2163  escape_used_in_parsing(opt_escape_arg != NULL),
2165 
2166  bool itemize(Parse_context *pc, Item **res) override;
2167 
2168  longlong val_int() override;
2169  enum Functype functype() const override { return LIKE_FUNC; }
2170  optimize_type select_optimize(const THD *thd) override;
2171  cond_result eq_cmp_result() const override { return COND_TRUE; }
2172  const char *func_name() const override { return "like"; }
2173  bool fix_fields(THD *thd, Item **ref) override;
2174  bool resolve_type(THD *) override;
2175  void cleanup() override;
2176  bool cast_incompatible_args(uchar *) override { return false; }
2177  /**
2178  @retval true non default escape char specified
2179  using "expr LIKE pat ESCAPE 'escape_char'" syntax
2180  */
2182 
2183  /**
2184  Has the escape clause been evaluated? It only needs to be evaluated
2185  once per execution, since we require it to be constant during execution.
2186  The escape member has a valid value if and only if this function returns
2187  true.
2188  */
2189  bool escape_is_evaluated() const { return escape_evaluated; }
2190 
2191  float get_filtering_effect(THD *thd, table_map filter_for_table,
2192  table_map read_tables,
2193  const MY_BITMAP *fields_to_ignore,
2194  double rows_in_table) override;
2195 
2196  void update_used_tables() override;
2197 
2198  private:
2199  /**
2200  The method updates covering keys depending on the
2201  length of wild string prefix.
2202 
2203  @param thd Pointer to THD object.
2204 
2205  @retval true if error happens during wild string prefix claculation,
2206  false otherwise.
2207  */
2208  bool check_covering_prefix_keys(THD *thd);
2209 };
2210 
2211 class Item_cond : public Item_bool_func {
2213 
2214  protected:
2217 
2218  public:
2219  /* Item_cond() is only used to create top level items */
2222  list.push_back(i1);
2223  list.push_back(i2);
2224  }
2225  Item_cond(const POS &pos, Item *i1, Item *i2)
2227  list.push_back(i1);
2228  list.push_back(i2);
2229  }
2230 
2231  Item_cond(THD *thd, Item_cond *item);
2233  : Item_bool_func(), list(nlist), abort_on_null(0) {}
2234  bool add(Item *item) {
2235  DBUG_ASSERT(item);
2236  return list.push_back(item);
2237  }
2238  bool add_at_head(Item *item) {
2239  DBUG_ASSERT(item);
2240  return list.push_front(item);
2241  }
2242  void add_at_head(List<Item> *nlist) {
2243  DBUG_ASSERT(nlist->elements);
2244  list.prepend(nlist);
2245  }
2246 
2247  bool itemize(Parse_context *pc, Item **res) override;
2248 
2249  bool fix_fields(THD *, Item **ref) override;
2250  void fix_after_pullout(SELECT_LEX *parent_select,
2251  SELECT_LEX *removed_select) override;
2252 
2253  Type type() const override { return COND_ITEM; }
2255  bool eq(const Item *item, bool binary_cmp) const override;
2256  table_map used_tables() const override { return used_tables_cache; }
2257  void update_used_tables() override;
2258  void print(const THD *thd, String *str,
2259  enum_query_type query_type) const override;
2260  void split_sum_func(THD *thd, Ref_item_array ref_item_array,
2261  List<Item> &fields) override;
2262  void apply_is_true() override { abort_on_null = true; }
2263  void copy_andor_arguments(THD *thd, Item_cond *item);
2264  bool walk(Item_processor processor, enum_walk walk, uchar *arg) override;
2265  Item *transform(Item_transformer transformer, uchar *arg) override;
2266  void traverse_cond(Cond_traverser, void *arg, traverse_order order) override;
2267  bool truth_transform_arguments(THD *thd, Bool_test test);
2268  bool subst_argument_checker(uchar **) override { return true; }
2269  Item *compile(Item_analyzer analyzer, uchar **arg_p,
2270  Item_transformer transformer, uchar *arg_t) override;
2271  bool remove_const_conds(THD *thd, Item *item, Item **new_item);
2272  /// Treat UNKNOWN result like FALSE because callers see no difference
2273  bool ignore_unknown() const { return abort_on_null; }
2274  bool equality_substitution_analyzer(uchar **) override { return true; }
2275 };
2276 
2277 /*
2278  The class Item_equal is used to represent conjunctions of equality
2279  predicates of the form field1 = field2, and field=const in where
2280  conditions and on expressions.
2281 
2282  All equality predicates of the form field1=field2 contained in a
2283  conjunction are substituted for a sequence of items of this class.
2284  An item of this class Item_equal(f1,f2,...fk) represents a
2285  multiple equality f1=f2=...=fk.
2286 
2287  If a conjunction contains predicates f1=f2 and f2=f3, a new item of
2288  this class is created Item_equal(f1,f2,f3) representing the multiple
2289  equality f1=f2=f3 that substitutes the above equality predicates in
2290  the conjunction.
2291  A conjunction of the predicates f2=f1 and f3=f1 and f3=f2 will be
2292  substituted for the item representing the same multiple equality
2293  f1=f2=f3.
2294  An item Item_equal(f1,f2) can appear instead of a conjunction of
2295  f2=f1 and f1=f2, or instead of just the predicate f1=f2.
2296 
2297  An item of the class Item_equal inherits equalities from outer
2298  conjunctive levels.
2299 
2300  Suppose we have a where condition of the following form:
2301  WHERE f1=f2 AND f3=f4 AND f3=f5 AND ... AND (...OR (f1=f3 AND ...)).
2302  In this case:
2303  f1=f2 will be substituted for Item_equal(f1,f2);
2304  f3=f4 and f3=f5 will be substituted for Item_equal(f3,f4,f5);
2305  f1=f3 will be substituted for Item_equal(f1,f2,f3,f4,f5);
2306 
2307  An object of the class Item_equal can contain an optional constant
2308  item c. Then it represents a multiple equality of the form
2309  c=f1=...=fk.
2310 
2311  Objects of the class Item_equal are used for the following:
2312 
2313  1. An object Item_equal(t1.f1,...,tk.fk) allows us to consider any
2314  pair of tables ti and tj as joined by an equi-condition.
2315  Thus it provide us with additional access paths from table to table.
2316 
2317  2. An object Item_equal(t1.f1,...,tk.fk) is applied to deduce new
2318  SARGable predicates:
2319  f1=...=fk AND P(fi) => f1=...=fk AND P(fi) AND P(fj).
2320  It also can give us additional index scans and can allow us to
2321  improve selectivity estimates.
2322 
2323  3. An object Item_equal(t1.f1,...,tk.fk) is used to optimize the
2324  selected execution plan for the query: if table ti is accessed
2325  before the table tj then in any predicate P in the where condition
2326  the occurrence of tj.fj is substituted for ti.fi. This can allow
2327  an evaluation of the predicate at an earlier step.
2328 
2329  When feature 1 is supported they say that join transitive closure
2330  is employed.
2331  When feature 2 is supported they say that search argument transitive
2332  closure is employed.
2333  Both features are usually supported by preprocessing original query and
2334  adding additional predicates.
2335  We do not just add predicates, we rather dynamically replace some
2336  predicates that can not be used to access tables in the investigated
2337  plan for those, obtained by substitution of some fields for equal fields,
2338  that can be used.
2339 
2340  Prepared Statements/Stored Procedures note: instances of class
2341  Item_equal are created only at the time a PS/SP is executed and
2342  are deleted in the end of execution. All changes made to these
2343  objects need not be registered in the list of changes of the parse
2344  tree and do not harm PS/SP re-execution.
2345 
2346  Item equal objects are employed only at the optimize phase. Usually they are
2347  not supposed to be evaluated. Yet in some cases we call the method val_int()
2348  for them. We have to take care of restricting the predicate such an
2349  object represents f1=f2= ...=fn to the projection of known fields fi1=...=fik.
2350 */
2352  List<Item_field> fields; /* list of equal field items */
2353  Item *const_item; /* optional constant item equal to fields items */
2358 
2359  public:
2360  inline Item_equal()
2361  : Item_bool_func(), const_item(0), eval_item(0), cond_false(0) {}
2362  Item_equal(Item_field *f1, Item_field *f2);
2363  Item_equal(Item *c, Item_field *f);
2364  Item_equal(Item_equal *item_equal);
2365  ~Item_equal() override { destroy(eval_item); }
2366 
2367  inline Item *get_const() { return const_item; }
2368  void set_const(Item *c) { const_item = c; }
2369  bool compare_const(THD *thd, Item *c);
2370  bool add(THD *thd, Item *c, Item_field *f);
2371  bool add(THD *thd, Item *c);
2372  void add(Item_field *f);
2373  uint members();
2374  bool contains(const Field *field) const;
2375  /**
2376  Get the first field of multiple equality, use for semantic checking.
2377 
2378  @retval First field in the multiple equality.
2379  */
2380  Item_field *get_first() { return fields.head(); }
2381  Item_field *get_subst_item(const Item_field *field);
2382  bool merge(THD *thd, Item_equal *item);
2383  bool update_const(THD *thd);
2384  enum Functype functype() const override { return MULT_EQUAL_FUNC; }
2385  longlong val_int() override;
2386  const char *func_name() const override { return "multiple equal"; }
2387  optimize_type select_optimize(const THD *) override { return OPTIMIZE_EQUAL; }
2388  virtual bool cast_incompatible_args(uchar *) override {
2389  // Multiple equality nodes (Item_equal) should have been
2390  // converted back to simple equalities (Item_func_eq) by
2391  // substitute_for_best_equal_field before cast nodes are injected.
2392  DBUG_ASSERT(false);
2393  return false;
2394  }
2395 
2396  /**
2397  Order field items in multiple equality according to a sorting criteria.
2398 
2399  The function perform ordering of the field items in the Item_equal
2400  object according to the criteria determined by the cmp callback parameter.
2401  If cmp(item_field1,item_field2,arg)<0 than item_field1 must be
2402  placed after item_field2.
2403 
2404  The function sorts field items by the exchange sort algorithm.
2405  The list of field items is looked through and whenever two neighboring
2406  members follow in a wrong order they are swapped. This is performed
2407  again and again until we get all members in a right order.
2408 
2409  @param compare function to compare field item
2410  */
2411  template <typename Node_cmp_func>
2412  void sort(Node_cmp_func compare) {
2413  fields.sort(compare);
2414  }
2415  friend class Item_equal_iterator;
2416  bool resolve_type(THD *) override;
2417  bool fix_fields(THD *thd, Item **ref) override;
2418  void update_used_tables() override;
2419  bool walk(Item_processor processor, enum_walk walk, uchar *arg) override;
2420  Item *transform(Item_transformer transformer, uchar *arg) override;
2421  void print(const THD *thd, String *str,
2422  enum_query_type query_type) const override;
2423  const CHARSET_INFO *compare_collation() const override {
2424  return fields.head()->collation.collation;
2425  }
2426 
2427  bool equality_substitution_analyzer(uchar **) override { return true; }
2428 
2430 
2431  float get_filtering_effect(THD *thd, table_map filter_for_table,
2432  table_map read_tables,
2433  const MY_BITMAP *fields_to_ignore,
2434  double rows_in_table) override;
2435  Item *m_const_folding[2]; ///< temporary area used for constant folding
2436  private:
2438 };
2439 
2440 class COND_EQUAL {
2441  public:
2442  uint max_members; /* max number of members the current level
2443  list and all lower level lists */
2444  COND_EQUAL *upper_levels; /* multiple equalities of upper and levels */
2445  List<Item_equal> current_level; /* list of multiple equalities of
2446  the current and level */
2448 };
2449 
2450 class Item_equal_iterator : public List_iterator_fast<Item_field> {
2451  public:
2452  inline Item_equal_iterator(Item_equal &item_equal)
2453  : List_iterator_fast<Item_field>(item_equal.fields) {}
2454  inline Item_field *operator++(int) {
2455  Item_field *item = (*(List_iterator_fast<Item_field> *)this)++;
2456  return item;
2457  }
2459 };
2460 
2462  public:
2463  COND_EQUAL cond_equal; /* contains list of Item_equal objects for
2464  the current and level and reference
2465  to multiple equalities of upper and levels */
2467 
2468  Item_cond_and(Item *i1, Item *i2) : Item_cond(i1, i2) {}
2469  Item_cond_and(const POS &pos, Item *i1, Item *i2) : Item_cond(pos, i1, i2) {}
2470 
2471  Item_cond_and(THD *thd, Item_cond_and *item) : Item_cond(thd, item) {}
2472  Item_cond_and(List<Item> &list_arg) : Item_cond(list_arg) {}
2473  enum Functype functype() const override { return COND_AND_FUNC; }
2474  longlong val_int() override;
2475  const char *func_name() const override { return "and"; }
2476  Item *copy_andor_structure(THD *thd) override {
2477  Item_cond_and *item;
2478  if ((item = new Item_cond_and(thd, this)))
2479  item->copy_andor_arguments(thd, this);
2480  return item;
2481  }
2482  Item *truth_transformer(THD *, Bool_test) override;
2483  bool gc_subst_analyzer(uchar **) override { return true; }
2484 
2485  float get_filtering_effect(THD *thd, table_map filter_for_table,
2486  table_map read_tables,
2487  const MY_BITMAP *fields_to_ignore,
2488  double rows_in_table) override;
2489 
2490  bool has_any_hash_join_condition(const table_map left_tables,
2491  const QEP_TAB &right_table) const override;
2492 
2493  bool has_any_non_equi_join_condition() const override;
2494 };
2495 
2496 class Item_cond_or final : public Item_cond {
2497  public:
2499 
2500  Item_cond_or(Item *i1, Item *i2) : Item_cond(i1, i2) {}
2501  Item_cond_or(const POS &pos, Item *i1, Item *i2) : Item_cond(pos, i1, i2) {}
2502 
2503  Item_cond_or(THD *thd, Item_cond_or *item) : Item_cond(thd, item) {}
2504  Item_cond_or(List<Item> &list_arg) : Item_cond(list_arg) {}
2505  enum Functype functype() const override { return COND_OR_FUNC; }
2506  longlong val_int() override;
2507  const char *func_name() const override { return "or"; }
2508  Item *copy_andor_structure(THD *thd) override {
2509  Item_cond_or *item;
2510  if ((item = new Item_cond_or(thd, this)))
2511  item->copy_andor_arguments(thd, this);
2512  return item;
2513  }
2514  Item *truth_transformer(THD *, Bool_test) override;
2515  bool gc_subst_analyzer(uchar **) override { return true; }
2516 
2517  float get_filtering_effect(THD *thd, table_map filter_for_table,
2518  table_map read_tables,
2519  const MY_BITMAP *fields_to_ignore,
2520  double rows_in_table) override;
2521 };
2522 
2523 /// Builds condition: (a AND b) IS TRUE
2524 inline Item *and_conds(Item *a, Item *b) {
2525  if (!b) return a;
2526  if (!a) return b;
2527 
2528  Item *item = new Item_cond_and(a, b);
2529  if (item == nullptr) return nullptr;
2530  item->apply_is_true();
2531  return item;
2532 }
2533 
2534 longlong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
2535  const Item *warn_item, bool *is_null);
2536 
2537 // TODO: the next two functions should be moved to sql_time.{h,cc}
2538 bool get_mysql_time_from_str_no_warn(THD *thd, String *str, MYSQL_TIME *l_time,
2540 
2541 bool get_mysql_time_from_str(THD *thd, String *str,
2542  enum_mysql_timestamp_type warn_type,
2543  const char *warn_name, MYSQL_TIME *l_time);
2544 /*
2545  These need definitions from this file but the variables are defined
2546  in mysqld.h. The variables really belong in this component, but for
2547  the time being we leave them in mysqld.cc to avoid merge problems.
2548 */
2549 extern Eq_creator eq_creator;
2551 extern Ne_creator ne_creator;
2552 extern Gt_creator gt_creator;
2553 extern Lt_creator lt_creator;
2554 extern Ge_creator ge_creator;
2555 extern Le_creator le_creator;
2556 
2557 #endif /* ITEM_CMPFUNC_INCLUDED */
Definition: item.h:737
bool list_contains_null()
Usable if <in value list> is made only of constants.
Definition: item_cmpfunc.cc:4536
enum Item_result result_type() const override
Definition: item_cmpfunc.h:1349
virtual int cmp(Item *arg)
Definition: item_cmpfunc.h:1684
optimize_type select_optimize(const THD *thd) override
We can optimize a where if first character isn&#39;t a wildcard.
Definition: item_cmpfunc.cc:5823
Definition: item_func.h:160
bool val_json(Json_wrapper *wr) override
Get the result of COALESCE as a JSON value.
Definition: item_cmpfunc.cc:3757
int compare_time_packed()
Compare arguments using numeric packed temporal representation.
Definition: item_cmpfunc.cc:1769
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1141
Item *(Item::* Item_transformer)(uchar *arg)
Definition: item.h:665
static int cmp(Bigint *a, Bigint *b)
Definition: dtoa.cc:1074
bool has_any_hash_join_condition(const table_map left_tables, const QEP_TAB &right_table) const override
Returns true if this Item has at least one condition that can be implemented as hash join...
Definition: item_cmpfunc.cc:6904
Definition: item_cmpfunc.h:2496
const CHARSET_INFO * cmp_charset
Definition: item_cmpfunc.h:1663
Item_result result_type() const override
Definition: item_cmpfunc.h:1372
Definition: result.h:33
Definition: item.h:3341
unsigned long long int ulonglong
Definition: my_inttypes.h:55
cmp_item_string(const CHARSET_INFO *cs)
Definition: item_cmpfunc.h:1666
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:5672
not valid for UDFs
Definition: udf_registration_types.h:44
Item_result left_result_type
Definition: item_cmpfunc.h:1898
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:2130
DTCollation cmp_collation
Definition: item_cmpfunc.h:1820
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:2074
enum Functype functype() const override
Definition: item_cmpfunc.h:1867
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:2171
const Item * warn_item
Definition: item_cmpfunc.h:1751
This file contains the field type.
Item_cond(const POS &pos, Item *i1, Item *i2)
Definition: item_cmpfunc.h:2225
in_expr [NOT] IN (in_value_list).
Definition: item_cmpfunc.h:1881
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:631
int compare_row()
Definition: item_cmpfunc.cc:1859
bool equality_substitution_analyzer(uchar **) override
Definition: item_cmpfunc.h:2274
virtual double val_real()=0
int compare(const cmp_item *ci) const override
Definition: item_cmpfunc.cc:4388
Definition: item_func.h:126
Item * negated_item() override
just fake method, should never be called.
Definition: item_cmpfunc.cc:6181
Item_cond(List< Item > &nlist)
Definition: item_cmpfunc.h:2232
virtual const char * symbol(bool invert) const
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:538
void val_item(Item *item, packed_longlong *result) override
Definition: item_cmpfunc.cc:4082
void update_used_tables() override
Definition: item_cmpfunc.cc:5393
unsigned char uchar
Definition: my_inttypes.h:51
Item_func_eq * m_join_condition
Definition: item_cmpfunc.h:106
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:2551
enum Functype functype() const override
Definition: item_cmpfunc.h:2093
Item_func_coalesce(const POS &pos, PT_item_list *list)
Definition: item_cmpfunc.h:1275
List< Item_field > fields
Definition: item_cmpfunc.h:2352
static const Bool_test bool_transform[10][8]
Array that transforms a boolean test according to another.
Definition: item_cmpfunc.h:311
Definition: item.h:3126
Definition: sql_optimizer.h:177
Definition: item.h:4049
bool use_custom_value_extractors() const
Definition: item_cmpfunc.h:240
Our own string classes, used pervasively throughout the executor.
bool fix_fields(THD *, Item **) override
Definition: item_cmpfunc.cc:2067
const char * func_name() const override
Definition: item_cmpfunc.h:352
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:2632
Definition: item_cmpfunc.h:874
optimize_type
Definition: item_func.h:219
my_decimal * decimal_op(my_decimal *) override
Performs the operation that this functions implements when the result type is DECIMAL.
Definition: item_cmpfunc.cc:3792
longlong val_int() override
Definition: item_cmpfunc.cc:2980
A predicate that is "always true" or "always false".
Definition: item_cmpfunc.h:327
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:421
Item_func super
Definition: item_cmpfunc.h:1813
longlong value
Definition: item_cmpfunc.h:1720
const char * func_name() const override
Definition: item_cmpfunc.h:489
Item_result
Type of the user defined function return slot and arguments
Definition: udf_registration_types.h:38
bool cast_incompatible_args(uchar *) override
Wrap incompatible arguments in CAST nodes to the expected data types.
Definition: item_cmpfunc.h:1391
Definition: item_cmpfunc.h:578
const char * func_name() const override
Definition: item_cmpfunc.h:933
uint decimal_precision() const override
Definition: item_cmpfunc.h:1254
Item_in_optimizer(Item *a, Item_in_subselect *b)
Definition: item_cmpfunc.h:475
const uint count
Original size of the vector.
Definition: item_cmpfunc.h:1400
Item_cond_or(List< Item > &list_arg)
Definition: item_cmpfunc.h:2504
ulonglong table_map
Definition: my_table_map.h:32
Definition: item.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
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:329
Item_func_false(const POS &pos)
Definition: item_cmpfunc.h:365
Item * m_right_extractor
Definition: item_cmpfunc.h:108
uint decimal_precision() const override
Definition: item_cmpfunc.h:1200
Item_bool_func2 super
Definition: item_cmpfunc.h:681
enum Functype functype() const override
Definition: item_cmpfunc.h:1942
Item_func_between(const POS &pos, Item *a, Item *b, Item *c, bool is_negation)
Definition: item_cmpfunc.h:1181
Item_func_false()
Definition: item_cmpfunc.h:364
uint used_count
The actual size of the vector (NULL may be ignored)
Definition: item_cmpfunc.h:1402
HashJoinCondition(Item_func_eq *join_condition, MEM_ROOT *mem_root)
Definition: item_cmpfunc.cc:7163
Definition: item_func.h:196
virtual Item_basic_constant * create_item(MEM_ROOT *mem_root) const =0
Create an instance of Item_{type} (e.g.
Arg_comparator(Item **left, Item **right)
Definition: item_cmpfunc.h:161
longlong val_int() override
Definition: item_cmpfunc.h:368
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:6793
Definition: item_func.h:162
Item * truth_transformer(THD *, Bool_test) override
Informs an item that it is wrapped in a truth test, in case it wants to transforms itself to implemen...
Definition: item_cmpfunc.cc:6121
longlong val_int() override
Definition: item_cmpfunc.cc:4904
cmp_item_datetime(const Item *warn_item_arg)
Definition: item_cmpfunc.cc:4358
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:342
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:954
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:1585
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:2515
bool try_year_cmp_func(Item_result type)
Definition: item_cmpfunc.cc:1313
bool get_mysql_time_from_str(THD *thd, String *str, enum_mysql_timestamp_type warn_type, const char *warn_name, MYSQL_TIME *l_time)
Parse date provided in a string to a MYSQL_TIME.
Definition: item_cmpfunc.cc:848
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:1045
void check_covering_prefix_keys()
Item_result cmp_type
Definition: item_cmpfunc.h:1172
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:2884
Definition: item_func.h:195
cmp_item_row()
Definition: item_cmpfunc.h:1994
Definition: item_func.h:138
virtual bool find_item(Item *item)=0
Calls item->val_int() or item->val_str() etc.
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.
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:2418
enum Item_result cached_result_type left_result_type
Definition: item_cmpfunc.h:1816
bool merge(THD *thd, Item_equal *item)
Join members of another Item_equal object.
Definition: item_cmpfunc.cc:6317
Item_cond_and(Item *i1, Item *i2)
Definition: item_cmpfunc.h:2468
const table_map m_right_used_tables
Definition: item_cmpfunc.h:114
void replace_argument(THD *thd, Item **oldpp, Item *newp) override
Does essentially the same as THD::change_item_tree, plus maintains any necessary any invariants...
Definition: item_cmpfunc.cc:2341
virtual Item_bool_func * create_scalar_predicate(Item *a, Item *b) const
Creates only an item tree node, without attempting to rewrite row constructors.
Definition: item_cmpfunc.cc:295
bool is_null() override
Definition: item_cmpfunc.cc:6199
bool check_covering_prefix_keys(THD *thd)
The method updates covering keys depending on the length of wild string prefix.
Definition: item_cmpfunc.cc:5846
Item_func_in(const POS &pos, PT_item_list *list, bool is_negation)
Definition: item_cmpfunc.h:1902
Item_func_comparison is a class for comparison functions that take two arguments and return a boolean...
Definition: item_cmpfunc.h:657
Item_func_isnull(const POS &pos, Item *a)
Definition: item_cmpfunc.h:2056
my_decimal * val_decimal(my_decimal *) override
Definition: item_cmpfunc.cc:3356
Arg_comparator le_cmp
Definition: item_cmpfunc.h:1180
Item_bool_func super
Definition: item_cmpfunc.h:379
Json_scalar_holder m_holder
Cache for the value above.
Definition: item_cmpfunc.h:1704
Definition: item_cmpfunc.h:1359
Definition: item.h:3980
bool subst_argument_checker(uchar **) override
Definition: item_cmpfunc.h:2268
void fix_char_length(uint32 max_char_length_arg)
Definition: item.h:2485
longlong val_int() override
Definition: item_cmpfunc.cc:3232
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:419
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_cmpfunc.cc:3508
int compare_real()
Definition: item_cmpfunc.cc:1694
bool left_uses_any_table(table_map tables) const
Definition: item_cmpfunc.h:95
Item_func_gt(Item *a, Item *b)
Definition: item_cmpfunc.h:1058
Item_func_comparison(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:662
Definition: item_func.h:130
File containing constants that can be used throughout the server.
virtual int compare(const cmp_item *ci) const
Definition: item_cmpfunc.cc:4196
bool compare_null_values()
Compare NULL values for two arguments.
Definition: item_cmpfunc.cc:1950
const char * func_name() const override
Definition: item_cmpfunc.h:2125
bool unsigned_flag
Definition: item.h:2733
Item_func_if(Item *a, Item *b, Item *c)
Definition: item_cmpfunc.h:1333
Some integer typedefs for easier portability.
Definition: item_cmpfunc.h:1620
Item * m_const_folding[2]
temporary area used for constant folding
Definition: item_cmpfunc.h:2435
virtual Item_bool_func * create(Item *a, Item *b) const
Definition: item_cmpfunc.cc:317
bool val_json(Json_wrapper *result) override
Get the result of COALESCE as a JSON value.
Definition: item_cmpfunc.cc:3120
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:1042
char value_buff[STRING_BUFFER_USUAL_SIZE]
Definition: item_cmpfunc.h:1661
longlong val_int() override
Evaluation of AND(expr, expr, expr ...).
Definition: item_cmpfunc.cc:5478
bool ignore_unknown() const
Definition: item_cmpfunc.h:1158
longlong val_int() override
Definition: item_cmpfunc.cc:2497
bool is_bool_func() const override
Definition: item_cmpfunc.h:297
Item_func_nop_all(Item *a)
Definition: item_cmpfunc.h:931
void rewind(void)
Definition: sql_list.h:598
longlong val_int() override
Definition: item_cmpfunc.cc:5792
bool has_any_non_equi_join_condition() const override
Returns true if this Item has at least one non equi-join condition.
Definition: item_cmpfunc.cc:6879
bool set_compare_func(Item_result_field *owner, Item_result type)
Definition: item_cmpfunc.cc:713
A wrapper class which provides array bounds checking.
Definition: sql_array.h:41
bool val_bool() override
Definition: item_cmpfunc.h:367
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_cmpfunc.cc:3368
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:948
const char * func_name() const override
Definition: item_cmpfunc.h:1311
Definition: item_func.h:127
double value
Definition: item_cmpfunc.h:1765
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:891
Gt_creator gt_creator
Definition: mysqld.cc:1302
void fix_after_pullout(SELECT_LEX *parent_select, SELECT_LEX *removed_select) override
Fix after tables have been moved from one select_lex level to the parent level, e.g by semijoin conversion.
Definition: item_cmpfunc.cc:2105
Item * negated_item() override
just fake method, should never be called.
Definition: item_cmpfunc.cc:6186
Definition: item_func.h:142
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:3132
Implements the comparison operator less than or equals (<=)
Definition: item_cmpfunc.h:1076
XOR inherits from Item_bool_func2 because it is not optimized yet.
Definition: item_cmpfunc.h:680
Item_row * row
Definition: item_cmpfunc.h:1237
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:1923
in_vector(uint elements)
See Item_func_in::resolve_type() for why we need both count and used_count.
Definition: item_cmpfunc.h:1408
Item_field * get_first()
Get the first field of multiple equality, use for semantic checking.
Definition: item_cmpfunc.h:2380
uint ncases
Definition: item_cmpfunc.h:1818
bool copy()
Definition: sql_string.cc:189
A class that is capable of holding objects of any sub-type of Json_scalar.
Definition: json_dom.h:1856
int compare_string()
Definition: item_cmpfunc.cc:1633
Definition: item_func.h:137
bool compare_as_dates_with_strings
Definition: item_cmpfunc.h:1175
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_cmpfunc.cc:3273
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:5551
virtual Item_bool_func * combine(List< Item > list) const
Combines a list of conditions exp op exp.
Definition: item_cmpfunc.cc:300
Le_creator()
Definition: item_cmpfunc.h:590
Eq_creator eq_creator
Definition: mysqld.cc:1299
virtual ~Gt_creator()
Definition: item_cmpfunc.h:561
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.h:1221
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:2126
Item_cond_or(THD *thd, Item_cond_or *item)
Definition: item_cmpfunc.h:2503
virtual float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table)
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item.h:1581
bool time_op(MYSQL_TIME *ltime) override
Definition: item_cmpfunc.cc:3811
Definition: item_cmpfunc.h:588
int compare(const cmp_item *arg) const
Definition: item_cmpfunc.cc:4327
virtual Item_bool_func * create(Item *a, Item *b) const
Definition: item_cmpfunc.cc:325
Item_cond_and(const POS &pos, Item *i1, Item *i2)
Definition: item_cmpfunc.h:2469
bool(Item::* Item_analyzer)(uchar **argp)
Definition: item.h:664
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.h:744
void fix_after_pullout(SELECT_LEX *parent_select, SELECT_LEX *removed_select) override
Fix after tables have been moved from one select_lex level to the parent level, e.g by semijoin conversion.
Definition: item_cmpfunc.cc:3196
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:1201
bool escape_used_in_parsing
Definition: item_cmpfunc.h:2147
longlong val_int() override
Special NOP (No OPeration) for ALL subquery.
Definition: item_cmpfunc.cc:436
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:971
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1506
String value2
Definition: item_cmpfunc.h:1173
enum Item_result result_type() const override
Definition: item_cmpfunc.h:1858
virtual cmp_item * make_same()
Definition: item_cmpfunc.cc:4192
Implements the comparison operator greater than (>)
Definition: item_cmpfunc.h:1056
Definition: field.h:700
Definition: item_func.h:124
in_longlong(MEM_ROOT *mem_root, uint elements)
Definition: item_cmpfunc.h:1504
const char * func_name() const override
Definition: item_cmpfunc.h:2062
Item * transform(Item_transformer transformer, uchar *arg) override
Transform an Item_cond object with a transformer callback function.
Definition: item_cmpfunc.cc:5294
Item_equal()
Definition: item_cmpfunc.h:2360
Item * right_cache
Definition: item_cmpfunc.h:133
Definition: item_func.h:82
int compare(const cmp_item *ci) const override
Definition: item_cmpfunc.h:1732
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:2105
Definition: item.h:5678
Definition: field_types.h:68
virtual bool l_op() const
Definition: item_cmpfunc.h:565
in_double(MEM_ROOT *mem_root, uint elements)
Definition: item_cmpfunc.h:1580
Gt_creator()
Definition: item_cmpfunc.h:560
Definition: item.h:4193
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:949
Implements the comparison operator equals (=)
Definition: item_cmpfunc.h:941
Json_wrapper m_value
Cached JSON value to look up.
Definition: item_cmpfunc.h:1702
bool eval_escape_clause(THD *thd)
Evaluate the expression in the escape clause.
Definition: item_cmpfunc.cc:5922
Definition: item_cmpfunc.h:1329
const char * func_name() const override
Definition: item_cmpfunc.h:1123
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:2070
String * value_res
Definition: item_cmpfunc.h:1660
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:5720
Definition: item_cmpfunc.h:598
Item_equal_iterator(Item_equal &item_equal)
Definition: item_cmpfunc.h:2452
Definition: item_cmpfunc.h:462
const char * func_name() const override
Definition: item_cmpfunc.h:2172
bool eq(const Item *item, bool binary_cmp) const override
Definition: item_cmpfunc.cc:5256
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:1121
virtual longlong val_int()=0
Definition: item_cmpfunc.h:2211
int escape
Definition: item_cmpfunc.h:2153
int result_for_null_param
Definition: item_cmpfunc.h:472
Item_bool_func(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:291
virtual bool l_op() const
Definition: item_cmpfunc.h:595
COND_EQUAL * upper_levels
Definition: item_cmpfunc.h:2444
const char * func_name() const override
Definition: item_cmpfunc.h:2507
Item_func_le(Item *a, Item *b)
Definition: item_cmpfunc.h:1078
uint decimal_precision() const override
Definition: item_cmpfunc.cc:3217
const char * func_name() const override
Definition: item_cmpfunc.h:1043
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:467
Item * truth_transformer(THD *, Bool_test test) override
Informs an item that it is wrapped in a truth test, in case it wants to transforms itself to implemen...
Definition: item_cmpfunc.h:386
bool is_bool_func() const override
Definition: item_cmpfunc.h:1196
void set_sub_test(Item_maxmin_subselect *item)
Definition: item_cmpfunc.h:900
A predicate that is "always false".
Definition: item_cmpfunc.h:362
bool add(Item *item)
Definition: item_cmpfunc.h:2234
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:1989
Item ** left
Definition: item_cmpfunc.h:124
bool get_time(MYSQL_TIME *ltime) override
Definition: item_cmpfunc.cc:3535
const char * func_name() const override
Definition: item_cmpfunc.h:1024
Item_func_isnull(Item *a)
Definition: item_cmpfunc.h:2055
Item_result type
Definition: item_cmpfunc.h:1229
const char * func_name() const override
Definition: item_cmpfunc.h:2475
Lt_creator lt_creator
Definition: mysqld.cc:1303
Item_subselect * subselect
Definition: item_cmpfunc.h:878
Item_func_like(Item *a, Item *b, Item *escape_arg, bool escape_used)
Definition: item_cmpfunc.h:2155
Definition: item_cmpfunc.h:1746
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:5749
Item * lval_cache
Definition: item_cmpfunc.h:1560
bool cond_false
Definition: item_cmpfunc.h:2356
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:1482
virtual bool l_op() const
Definition: item_cmpfunc.h:513
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:5742
String * str_op(String *) override
Coalesce - return first not NULL argument.
Definition: item_cmpfunc.cc:3746
std::string join(Container cont, const std::string &delim)
join elements of an container into a string seperated by a delimiter.
Definition: string.h:144
bool has_any_hash_join_condition(const table_map left_tables, const QEP_TAB &right_table) const override
Returns true if this Item has at least one condition that can be implemented as hash join...
Definition: item_cmpfunc.cc:6920
virtual Item_bool_func * create(Item *a, Item *b) const =0
virtual ~Comp_creator()
Definition: item_cmpfunc.h:499
void val_item(Item *item, packed_longlong *result) override
Definition: item_cmpfunc.cc:4102
int get_else_expr_num() const
Definition: item_cmpfunc.h:1847
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:3060
bool add_at_head(Item *item)
Definition: item_cmpfunc.h:2238
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1567
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:1085
cmp_item_decimal()
Definition: item_cmpfunc.h:1788
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:2483
List< Item > * argument_list()
Definition: item_cmpfunc.h:2254
bool escape_was_used_in_parsing() const
Definition: item_cmpfunc.h:2181
virtual uint decimal_precision() const
Definition: item.cc:605
Item * m_left_extractor
Definition: item_cmpfunc.h:107
class udf_list * list
void set_str_value(String *str)
Definition: item.h:2859
void update_used_tables() override
Optimize case of not_null_column IS NULL.
Definition: item_cmpfunc.cc:5704
const CHARSET_INFO * collation
Definition: item_cmpfunc.h:1475
longlong val_int() override
Definition: item_cmpfunc.h:354
Item * right_extractor() const
Definition: item_cmpfunc.h:94
int else_expr_num
Definition: item_cmpfunc.h:1815
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:2437
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:5438
in_vector * array
An array of values, created when the bisection lookup method is used.
Definition: item_cmpfunc.h:1884
bool right_uses_any_table(table_map tables) const
Definition: item_cmpfunc.h:99
This trigger type deactivates join conditions when a row has been NULL-complemented.
Definition: item_cmpfunc.h:792
virtual int compare(const cmp_item *item) const =0
bool get_time(MYSQL_TIME *ltime) override
Definition: item_cmpfunc.cc:3288
#define RAND_TABLE_BIT
Definition: sql_const.h:114
enum_walk
Enumeration for {Item,SELECT_LEX[_UNIT],Table_function}walk.
Definition: sql_const.h:435
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:2382
bool itemize(Parse_context *pc, Item **res) override
Contextualization for Item_cond functional items.
Definition: item_cmpfunc.cc:4992
Definition: item_func.h:220
virtual const char * symbol(bool invert) const
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:563
void set_numeric_type() override
Definition: item_cmpfunc.h:1291
const char * func_name() const override
Definition: item_cmpfunc.h:1324
DTCollation cmp_collation
Definition: item_cmpfunc.h:155
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:6404
void value_to_item(uint, Item_basic_constant *) const override
Store the value at position pos into provided item object.
Definition: item_cmpfunc.h:2037
Item_bool_func(Item *a)
Definition: item_cmpfunc.h:285
arg_cmp_func func
Definition: item_cmpfunc.h:126
longlong int_op() override
Performs the operation that this functions implements when the result type is INT.
Definition: item_cmpfunc.cc:3770
cmp_item_real()
Definition: item_cmpfunc.h:1768
cmp_item_row(cmp_item_row &&other)
Definition: item_cmpfunc.h:2000
Wrapper class for an Item list head, used to allocate Item lists in the parser in a context-independe...
Definition: parse_tree_helpers.h:96
double val_real() override
Definition: item_cmpfunc.cc:3224
const char * func_name() const override
Definition: item_cmpfunc.h:1377
bool inject_cast_nodes()
Comparison function are expected to operate on arguments having the same data types.
Definition: item_cmpfunc.cc:1255
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:1122
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:1945
int compare_int_signed_unsigned()
Compare signed (*left) with unsigned (*B)
Definition: item_cmpfunc.cc:1824
bool compare_elems(uint pos1, uint pos2) const override
Compare values number pos1 and pos2 for equality.
Definition: item_cmpfunc.cc:3991
Definition: item_subselect.h:73
void add_trig_func_tables()
Definition: item_cmpfunc.h:853
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:30
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:1062
int compare()
Definition: item_cmpfunc.h:202
Definition: item_cmpfunc.h:1469
enum Functype functype() const override
Definition: item_cmpfunc.h:2119
void split_sum_func(THD *thd, Ref_item_array ref_item_array, List< Item > &fields) override
Move SUM items out from item tree and replace with reference.
Definition: item_cmpfunc.cc:5385
virtual cmp_item * make_same()
Definition: item_cmpfunc.cc:4180
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:318
void store_value(Item *item) override
Definition: item_cmpfunc.h:1769
enum Functype functype() const override
Definition: item_cmpfunc.h:947
longlong val_int() override
Definition: item_cmpfunc.cc:5521
const char * func_name() const override
Definition: item_cmpfunc.h:2386
void set_null_value(bool nv)
Definition: item_cmpfunc.h:1655
Using this class is fraught with peril, and you need to be very careful when doing so...
Definition: sql_string.h:161
~cmp_item_row()
Definition: item_cmpfunc.cc:4229
bool fix_left(THD *thd, Item **ref)
Definition: item_cmpfunc.cc:2039
bool escape_evaluated
Tells if the escape clause has been evaluated.
Definition: item_cmpfunc.h:2149
Definition: item.h:718
enum_trig_type get_trig_type()
Definition: item_cmpfunc.h:868
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:2262
const char * func_name() const override
Definition: item_cmpfunc.h:1083
in_datetime(MEM_ROOT *mem_root, Item *warn_item_arg, uint elements)
Definition: item_cmpfunc.h:1563
const char * func_name() const override
Definition: item_cmpfunc.h:1063
const char * func_name() const override
Definition: item_cmpfunc.h:1103
longlong val_int() override
Execute Item_func_interval().
Definition: item_cmpfunc.cc:2652
Item * negated_item() override
just fake method, should never be called.
Definition: item_cmpfunc.cc:6166
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:7116
enum Functype functype() const override
Definition: item_cmpfunc.h:1040
void update_used_tables() override
Definition: item_cmpfunc.cc:5536
int get_first_expr_num() const
Definition: item_cmpfunc.h:1846
Definition: item_cmpfunc.h:1764
bool resolve_type(THD *thd) override
Same as Item_func_eq, but NULL = NULL.
Definition: item_cmpfunc.cc:2364
Item_field ** ref(void)
Definition: sql_list.h:591
DTCollation cmp_collation
Definition: item_cmpfunc.h:1169
interval_range * intervals
Definition: item_cmpfunc.h:1239
Definition: table.h:1301
cmp_item * cmp_items[5]
Definition: item_cmpfunc.h:1821
void cleanup() override
Definition: item_cmpfunc.cc:5911
longlong val_int() override
Definition: item_cmpfunc.cc:2006
String value0
Definition: item_cmpfunc.h:1173
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:1157
Item * truth_transformer(THD *, Bool_test test) override
Informs an item that it is wrapped in a truth test, in case it wants to transforms itself to implemen...
Definition: item_cmpfunc.h:1159
table_map used_tables() const override
Definition: item_cmpfunc.h:2256
Field * tmp_table_field()
Definition: item_func.h:400
enum_trig_type
Definition: item_cmpfunc.h:786
Json_scalar_holder m_itm_holder
Scalar holder for the RHS value.
Definition: item_cmpfunc.h:1708
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:1513
bool find_item(Item *item) override
Calls item->val_int() or item->val_str() etc.
Definition: item_cmpfunc.cc:3983
uint32 max_length
Maximum length of result of evaluating this item, in number of bytes.
Definition: item.h:2667
int compare_binary_string()
Compare strings byte by byte.
Definition: item_cmpfunc.cc:1667
Definition: item_cmpfunc.h:2019
String value2
Definition: item_cmpfunc.h:157
Structure to return status from str_to_datetime(), str_to_time(), number_to_datetime(), number_to_time()
Definition: my_time.h:143
cond_result
Definition: item.h:737
longlong val_int() override
special NOT for ALL subquery.
Definition: item_cmpfunc.cc:387
Item * const_item
Definition: item_cmpfunc.h:2353
Definition: item_func.h:121
enum Item_result result_type() const override
Definition: item_cmpfunc.h:1292
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:3954
virtual void val_item(Item *item, packed_longlong *result)
Definition: item_cmpfunc.cc:4077
Definition: item_func.h:139
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:376
in_row(MEM_ROOT *mem_root, uint elements, cmp_item_row *cmp)
Definition: item_cmpfunc.cc:4061
bool subst_argument_checker(uchar **) override
Definition: item_cmpfunc.h:669
virtual const char * symbol(bool invert) const
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:529
Mem_root_array< cmp_item_row > base_objects
Definition: item_cmpfunc.h:2021
Item_func_match_predicate(Item *a)
Definition: item_cmpfunc.h:734
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:1082
In IN->EXISTS subquery transformation, new predicates are added: WHERE inner_field=outer_field OR inn...
Definition: item_cmpfunc.h:810
Definition: item_cmpfunc.h:536
void fix_after_pullout(SELECT_LEX *parent_select, SELECT_LEX *removed_select) override
Fix after tables have been moved from one select_lex level to the parent level, e.g by semijoin conversion.
Definition: item_cmpfunc.cc:2759
Item_func_xor(Item *i1, Item *i2)
Definition: item_cmpfunc.h:684
virtual ~cmp_item()
Definition: item_cmpfunc.h:1623
Ge_creator ge_creator
Definition: mysqld.cc:1304
String value
Definition: item_cmpfunc.h:1662
virtual void store_value(Item *item)
Definition: item_cmpfunc.h:1674
Item_func_ne(Item *a, Item *b)
Definition: item_cmpfunc.h:1118
virtual Item_bool_func * create_scalar_predicate(Item *a, Item *b) const
Creates only an item tree node, without attempting to rewrite row constructors.
Definition: item_cmpfunc.cc:304
Item * negated_item() override
just fake method, should never be called.
Definition: item_cmpfunc.cc:6171
cmp_item * case_item
Definition: item_cmpfunc.h:1822
cmp_item * make_same()
Definition: item_cmpfunc.cc:4190
bool is_null() override
Definition: item_cmpfunc.cc:2286
int8 plan_idx
This represents the index of a JOIN_TAB/QEP_TAB in an array.
Definition: sql_opt_exec_shared.h:39
Item * lval_cache
Definition: item_cmpfunc.h:1753
const table_map m_left_used_tables
Definition: item_cmpfunc.h:113
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:3294
Item_func_equal(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:1015
A predicate that is "always true".
Definition: item_cmpfunc.h:348
uint members()
Definition: item_cmpfunc.cc:6280
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:1101
enum Functype functype() const override
Definition: item_cmpfunc.h:1021
void set_datetime_cmp_func(Item_result_field *owner_arg, Item **a1, Item **b1)
Definition: item_cmpfunc.cc:1371
String value1
Definition: item_cmpfunc.h:1173
bool find_item(Item *item) override
Calls item->val_int() or item->val_str() etc.
Definition: item_cmpfunc.cc:4049
bool fix_fields(THD *, Item **ref) override
Definition: item_func.cc:256
virtual bool l_op() const
Definition: item_cmpfunc.h:585
virtual int cmp(Item *arg)
Definition: item_cmpfunc.cc:4213
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:1041
bool fix_fields(THD *, Item **) override
Perform context analysis of an IN item tree.
Definition: item_cmpfunc.cc:4572
cmp_item_json()
Definition: item_cmpfunc.h:1711
virtual void value_to_item(uint pos, Item_basic_constant *item) const =0
Store the value at position pos into provided item object.
Definition: item_cmpfunc.h:279
Item_func_like(const POS &pos, Item *a, Item *b, Item *opt_escape_arg)
Definition: item_cmpfunc.h:2160
longlong val_int() override
Definition: item_cmpfunc.h:736
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:266
enum_trig_type trig_type
Type of trig_var; for printing.
Definition: item_cmpfunc.h:821
Definition: item_func.h:222
#define DBUG_ASSERT(A)
Definition: my_dbug.h:197
in_decimal(MEM_ROOT *mem_root, uint elements)
Definition: item_cmpfunc.h:1600
void store_value_by_template(cmp_item *tmpl, Item *)
Definition: item_cmpfunc.cc:4282
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:4418
Arg_comparator * comparators
Definition: item_cmpfunc.h:128
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.h:2120
bool is_alloced() const
Definition: sql_string.h:409
Item_bool_func(const POS &pos, Item *a)
Definition: item_cmpfunc.h:286
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:2387
Definition: item_cmpfunc.h:123
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:2772
enum Functype functype() const override
Definition: item_cmpfunc.h:1100
void keep_top_level_cache()
Definition: item_cmpfunc.cc:2275
Definition: item_cmpfunc.h:2351
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:1022
Item_cache ** get_cache()
Definition: item_cmpfunc.h:490
Item_func_truth(const POS &pos, Item *a, Bool_test truth_test)
Definition: item_cmpfunc.h:395
longlong val_int() override
Definition: item_cmpfunc.cc:355
plan_idx idx() const
Definition: item_cmpfunc.h:871
Item_func_any_value(const POS &pos, Item *a)
Definition: item_cmpfunc.h:1323
bool truth_transform_arguments(THD *thd, Bool_test test)
Definition: item_cmpfunc.cc:5423
int compare_int_signed()
Definition: item_cmpfunc.cc:1751
virtual bool eqne_op() const
Definition: item_cmpfunc.h:584
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:3803
bool fix_fields(THD *, Item **) override
Perform context analysis of a BETWEEN item tree.
Definition: item_cmpfunc.cc:2743
Definition: item.h:2836
Mem_root_array< String > base_objects
Definition: item_cmpfunc.h:1472
bool set_cmp_func()
Definition: item_cmpfunc.h:617
longlong val_int() override
Definition: item_cmpfunc.cc:3459
bool append(const String &s)
Definition: sql_string.cc:447
Definition: item_cmpfunc.h:1495
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:6646
void print(const THD *, String *str, enum_query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:355
void val_item(Item *item, packed_longlong *result) override
Definition: item_cmpfunc.cc:4087
virtual ~Ge_creator()
Definition: item_cmpfunc.h:581
void store_value(Item *item)
Definition: item_cmpfunc.cc:4336
Mem_root_array< double > base
Definition: item_cmpfunc.h:1577
char * pos
Definition: do_ctype.cc:76
void set_arguments(List< Item > &list, bool context_free)
Copy arguments from list to args array.
Definition: item_func.cc:166
Item * negated_item() override
just fake method, should never be called.
Definition: item_cmpfunc.cc:6176
A class that represents a join condition in a hash join.
Definition: item_cmpfunc.h:87
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:668
Definition: item.h:4095
enum enum_trig_type get_trig_type() const
Definition: item_cmpfunc.h:866
Definition: item_func.h:132
virtual const char * symbol(bool invert) const
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:551
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:3819
virtual ~Lt_creator()
Definition: item_cmpfunc.h:571
int cmp(Item *arg)
Definition: item_cmpfunc.cc:4303
const char * func_name() const override
Definition: item_cmpfunc.h:738
bool equality_substitution_analyzer(uchar **) override
Definition: item_cmpfunc.h:952
virtual const char * symbol(bool invert) const
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:583
void store_value(Item *item)
Definition: item_cmpfunc.cc:4269
Implements the comparison operator not equals (<>)
Definition: item_cmpfunc.h:1116
bool eq(const Item *item, bool binary_cmp) const override
Definition: item_cmpfunc.cc:2528
Item_bool_func()
Definition: item_cmpfunc.h:281
int compare(const cmp_item *ci) const override
Definition: item_cmpfunc.h:1777
Bison "location" class.
Definition: parse_location.h:43
Definition: item_func.h:224
Item_func_eq(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:944
Bool_test truth_test
The value we&#39;re testing for.
Definition: item_cmpfunc.h:437
Item_func_eq * join_condition() const
Definition: item_cmpfunc.h:91
Item * truth_transformer(THD *, Bool_test test) override
a IS NOT NULL -> a IS NULL.
Definition: item_cmpfunc.cc:6117
Item_func_opt_neg(const POS &pos, PT_item_list *list, bool is_negation)
Definition: item_cmpfunc.h:1150
Item * warn_item
Definition: item_cmpfunc.h:1558
const char * func_name() const override
Definition: item_cmpfunc.h:1253
Definition: item_cmpfunc.h:1658
enum Functype functype() const override
Definition: item_cmpfunc.h:737
bool fix_fields(THD *thd, Item **ref) override
Definition: item_cmpfunc.cc:6374
Item_func_opt_neg(const POS &pos, Item *a, Item *b, Item *c, bool is_negation)
Definition: item_cmpfunc.h:1146
Item * truth_transformer(THD *, Bool_test) override
Apply NOT transformation to the item and return a new one.
Definition: item_cmpfunc.cc:6072
longlong val_int() override
Definition: item_cmpfunc.cc:2515
cmp_item_int()
Definition: item_cmpfunc.h:1723
bool add(THD *thd, Item *c, Item_field *f)
Definition: item_cmpfunc.cc:6258
Item_func_comparison(Item *a, Item *b)
Definition: item_cmpfunc.h:659
Item_result hybrid_type
Definition: item_func.h:700
Item * get_const()
Definition: item_cmpfunc.h:2367
Item * make_condition(Parse_context *pc, Item *item)
Ensure that all expressions involved in conditions are boolean functions.
Definition: item_cmpfunc.cc:4968
bool is_null() override
Definition: item_cmpfunc.h:636
Item * truth_transformer(THD *, Bool_test) override
Informs an item that it is wrapped in a truth test, in case it wants to transforms itself to implemen...
Definition: item_cmpfunc.cc:6078
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:624
Item_bool_func2(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:611
bool compare_const(THD *thd, Item *c)
Definition: item_cmpfunc.cc:6241
virtual int compare(const cmp_item *ci) const
Definition: item_cmpfunc.h:1669
Definition: item.h:753
Item class, to represent X IS [NOT] (TRUE | FALSE) boolean predicates.
Definition: item_cmpfunc.h:378
Definition: item_cmpfunc.h:1141
virtual bool eqne_op() const
Definition: item_cmpfunc.h:594
Definition: my_bitmap.h:42
Item_cond_or(Item *i1, Item *i2)
Definition: item_cmpfunc.h:2500
cmp_item()
Definition: item_cmpfunc.h:1622
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:3579
void set_max_str_length(size_t max_str_length)
When comparing strings, compare at most max_str_length bytes.
Definition: item_cmpfunc.h:624
Definition: item_func.h:134
Item_func_strcmp(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:1211
Item_field * operator++(int)
Definition: item_cmpfunc.h:2454
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:2562
virtual cmp_item * make_same()=0
bool find_item(Item *item) override
Calls item->val_int() or item->val_str() etc.
Definition: item_cmpfunc.cc:4117
uint n
Definition: item_cmpfunc.h:1991
my_decimal class limits &#39;decimal_t&#39; type to what we need in MySQL.
Definition: my_decimal.h:91
int compare_json()
Compare two Item objects as JSON.
Definition: item_cmpfunc.cc:1604
bool equality_substitution_analyzer(uchar **) override
Definition: item_cmpfunc.h:2427
Item_func_coalesce(const POS &pos, Item *a)
Definition: item_cmpfunc.h:1270
Definition: item_cmpfunc.h:2142
Functype
Definition: item_func.h:120
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:4044
Definition: item_cmpfunc.h:2087
Definition: udf_registration_types.h:39
Item * tmp_arg[2]
Definition: item_func.h:86
Definition: item.h:752
cmp_item_row(THD *thd, Item *item)
Definition: item_cmpfunc.h:1995
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:2406
double
Definition: udf_registration_types.h:42
bool subst_argument_checker(uchar **) override
Definition: item_cmpfunc.h:1165
String value1
Definition: item_cmpfunc.h:157
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:1023
uint decimal_precision() const override
Definition: item_cmpfunc.cc:3695
longlong val_int() override
Definition: item_cmpfunc.cc:5679
Definition: item_func.h:221
bool unsigned_flag
Definition: item_cmpfunc.h:1497
bool compare_elems(uint pos1, uint pos2) const override
Compare values number pos1 and pos2 for equality.
Definition: item_cmpfunc.cc:4057
enum Functype functype() const override
Definition: item_cmpfunc.h:708
List< Item_equal > current_level
Definition: item_cmpfunc.h:2445
longlong val_int() override
Definition: item_cmpfunc.cc:5662
virtual void resize_and_sort()=0
Resize and then sort the IN-list array, so we can do efficient lookup with binary_search.
virtual void store_value(Item *item)
Definition: item_cmpfunc.cc:4201
Item * truth_transformer(THD *, Bool_test) override
Apply NOT transformation to the item and return a new one.
Definition: item_cmpfunc.cc:6150
Implements the comparison operator greater than or equals (>=)
Definition: item_cmpfunc.h:1036
Definition: item_cmpfunc.h:1576
longlong(* get_value_b_func)(THD *thd, Item ***item_arg, Item **cache_arg, const Item *warn_item, bool *is_null)
Definition: item_cmpfunc.h:271
cmp_item * cmp_items[6]
Definition: item_cmpfunc.h:1899
void set_created_by_in2exists()
Definition: item_cmpfunc.h:304
Header for compiler-dependent features.
Abstract factory interface for creating comparison predicates.
Definition: item_cmpfunc.h:497
Arg_comparator()=default
JSON DOM.
enum Item_result cached_result_type
Definition: item_cmpfunc.h:1360
Definition: item_cmpfunc.h:1297
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:1948
int cmp(Item *arg)
Definition: item_cmpfunc.cc:4343
static const int UNKNOWN
Definition: item_cmpfunc.h:440
my_decimal * val_decimal(my_decimal *) override
Definition: item_cmpfunc.cc:3491
virtual enum Functype functype() const override
Definition: item_cmpfunc.h:393
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:146
Item_is_not_null_test(Item_in_subselect *ow, Item *a)
Definition: item_cmpfunc.h:2091
Definition: item_cmpfunc.h:1234
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:4869
Definition: item_func.h:213
longlong val_int() override
Make a logical XOR of the arguments.
Definition: item_cmpfunc.cc:6032
enum Functype functype() const override
Definition: item_cmpfunc.h:2384
Arg_comparator ge_cmp
Definition: item_cmpfunc.h:1180
longlong val_int() override
Definition: item_cmpfunc.cc:2503
virtual bool eqne_op() const =0
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:5654
uint16_t uint16
Definition: my_inttypes.h:64
Item_bool_func(THD *thd, Item_bool_func *item)
Definition: item_cmpfunc.h:294
Definition: item.h:668
bool compare_elems(uint pos1, uint pos2) const override
Compare values number pos1 and pos2 for equality.
Definition: item_cmpfunc.cc:3967
unsigned int uint
Definition: uca-dump.cc:29
#define final(a, b, c)
Definition: hash.c:109
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override
Definition: item_cmpfunc.cc:3526
Item_cond_or()
Definition: item_cmpfunc.h:2498
virtual Item_bool_func * combine(List< Item > list) const
Combines a list of conditions exp op exp.
Definition: item_cmpfunc.cc:309
Base class for parse tree nodes (excluding the Parse_tree_root hierarchy)
Definition: parse_tree_node_base.h:111
virtual bool is_row_result() const
Definition: item_cmpfunc.h:1444
Definition: item_cmpfunc.h:784
my_decimal * val_decimal(my_decimal *) override
Definition: item_cmpfunc.cc:3265
bool null_value
True if item is null.
Definition: item.h:2732
plan_idx m_idx
Optional: if join!=NULL: index of table.
Definition: item_cmpfunc.h:819
void(* Cond_traverser)(const Item *item, void *arg)
Definition: item.h:666
void copy_andor_arguments(THD *thd, Item_cond *item)
Definition: item_cmpfunc.cc:5009
bool field_type_defined
Definition: item_cmpfunc.h:1299
long long int longlong
Definition: my_inttypes.h:54
virtual ~in_vector()
Definition: item_cmpfunc.h:1410
bool const_item() const
Returns true if item is constant, regardless of query evaluation state.
Definition: item.h:1825
Definition: item_cmpfunc.h:702
COND_EQUAL()
Definition: item_cmpfunc.h:2447
void traverse_cond(Cond_traverser, void *arg, traverse_order order) override
Definition: item_cmpfunc.cc:5347
void cleanup() override
Definition: item.cc:9447
const char * func_name() const override
Definition: item_cmpfunc.h:2095
int first_expr_num
Definition: item_cmpfunc.h:1815
longlong val_int() override
Definition: item_cmpfunc.cc:2509
virtual Item_bool_func * create(Item *a, Item *b) const
This implementation of the factory method also implements flattening of row constructors.
Definition: item_cmpfunc.cc:267
Type
Definition: item.h:704
Definition: item.h:169
const CHARSET_INFO * collation
Definition: item.h:171
bool is_null() override
Definition: item_cmpfunc.cc:3379
Definition: item_func.h:159
void sort(Node_cmp_func cmp)
Sort the list.
Definition: sql_list.h:528
List< Item > list
Definition: item_cmpfunc.h:2215
Item_bool_func2 super
Definition: item_cmpfunc.h:2143
void set_comparator(uint col, cmp_item *comparator)
Definition: item_cmpfunc.h:2030
Item_func_ifnull(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:1302
const char * func_name() const override
Definition: item_cmpfunc.h:709
COND_EQUAL cond_equal
Definition: item_cmpfunc.h:2463
enum Functype functype() const override
Definition: item_cmpfunc.h:895
const char * func_name() const override
Definition: item_cmpfunc.h:1293
virtual void store_value(Item *item)=0
Item_int_func super
Definition: item_cmpfunc.h:1235
table_map not_null_tables() const override
Definition: item_cmpfunc.h:934
Bool_test
< Modifier for result transformation
Definition: item.h:751
Le_creator le_creator
Definition: mysqld.cc:1305
virtual Item_bool_func * combine(List< Item > list) const
Combines a list of conditions exp op exp.
Definition: item_cmpfunc.cc:291
longlong val_int() override
Definition: item_cmpfunc.cc:2400
longlong val_int() override
Definition: item_cmpfunc.cc:2356
bool find_item(Item *item) override
Calls item->val_int() or item->val_str() etc.
Definition: item_cmpfunc.cc:3959
virtual Item_bool_func * create_scalar_predicate(Item *a, Item *b) const
Creates only an item tree node, without attempting to rewrite row constructors.
Definition: item_cmpfunc.cc:286
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:627
const char * func_name() const override
Definition: item_cmpfunc.h:1859
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:3404
bool remove_const_conds(THD *thd, Item *item, Item **new_item)
Remove constant conditions over literals.
Definition: item_cmpfunc.cc:5195
It is interface module to fixed precision decimals library.
void set_subquery()
Set the "has subquery" property.
Definition: item.h:2519
double precision
Definition: item_cmpfunc.h:130
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:1187
virtual ~Le_creator()
Definition: item_cmpfunc.h:591
Definition: item_func.h:848
bool get_mysql_time_from_str_no_warn(THD *thd, String *str, MYSQL_TIME *l_time, MYSQL_TIME_STATUS *status)
A minion of get_mysql_time_from_str, see its description.
Definition: item_cmpfunc.cc:817
Item_func_ge(Item *a, Item *b)
Definition: item_cmpfunc.h:1038
Item_func_eq(Item *a, Item *b)
Definition: item_cmpfunc.h:943
Definition: m_ctype.h:359
Item_func_isnotnull(Item *a)
Definition: item_cmpfunc.h:2113
virtual String * val_str(String *str)=0
Definition: item_cmpfunc.h:2450
bool empty_underlying_subquery()
Definition: item_cmpfunc.cc:401
Item which stores (x,y,...) and ROW(x,y,...).
Definition: item_row.h:50
bool time_op(MYSQL_TIME *ltime) override
Definition: item_cmpfunc.cc:3138
Item_func_case(const POS &pos, List< Item > &list, Item *first_expr_arg, Item *else_expr_arg)
Definition: item_cmpfunc.h:1825
int sortcmp(const String *a, const String *b, const CHARSET_INFO *cs)
Definition: sql_string.cc:740
bool fix_fields(THD *thd, Item **ref) override
Definition: item_cmpfunc.h:848
int compare_datetime()
Compare item values as dates.
Definition: item_cmpfunc.cc:1512
in_string(MEM_ROOT *mem_root, uint elements, const CHARSET_INFO *cs)
Definition: item_cmpfunc.cc:3995
void update_used_tables() override
Definition: item_cmpfunc.h:862
Item ** args
Definition: item_func.h:86
Item_basic_constant * create_item(MEM_ROOT *) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:2033
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:1863
String * val_str(String *str) override
Definition: item_cmpfunc.cc:3240
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:99
size_t m_max_str_length
When comparing strings, compare at most these many bytes.
Definition: item_cmpfunc.h:152
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:4112
longlong int_op() override
Performs the operation that this functions implements when the result type is INT.
Definition: item_cmpfunc.cc:3096
Definition: item_cmpfunc.h:549
Common header for many mysys elements.
longlong val_int() override
The implementation of optimized <outer expression> [NOT] IN <subquery> predicates.
Definition: item_cmpfunc.cc:2196
#define OUTER_REF_TABLE_BIT
Definition: sql_const.h:113
enum Functype functype() const override
Definition: item_cmpfunc.h:1378
virtual bool l_op() const
Definition: item_cmpfunc.h:575
bool show
Definition: item_cmpfunc.h:882
Item * transform(Item_transformer transformer, uchar *arg) override
Transform an Item_in_optimizer and its arguments with a callback function.
Definition: item_cmpfunc.cc:2305
bool ignore_unknown() const
Treat UNKNOWN result like FALSE because callers see no difference.
Definition: item_cmpfunc.h:642
Arg_comparator cmp
Definition: item_cmpfunc.h:2355
longlong val_int() override
Definition: item_cmpfunc.cc:2491
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:1390
void cleanup() override
Definition: item_cmpfunc.h:643
Item * copy_andor_structure(THD *thd) override
Definition: item_cmpfunc.h:2508
void sort(Node_cmp_func compare)
Order field items in multiple equality according to a sorting criteria.
Definition: item_cmpfunc.h:2412
longlong val_int() override
Definition: item_cmpfunc.cc:6587
table_map not_null_tables_cache
Value used in calculation of result of not_null_tables()
Definition: item_func.h:107
longlong extract_value_from_argument(THD *thd, Item *item, bool left_argument, bool *is_null) const
Definition: item_cmpfunc.cc:7175
enum Functype functype() const override
Definition: item_cmpfunc.h:1080
Definition: item_cmpfunc.h:1398
Item * left_extractor() const
Definition: item_cmpfunc.h:93
Definition: item_func.h:698
Item_func_coalesce(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:1266
DBUG_TRACE
Definition: do_ctype.cc:46
enum Functype functype() const override
Definition: item_cmpfunc.h:1356
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:5492
virtual bool eqne_op() const
Definition: item_cmpfunc.h:564
virtual const char * symbol(bool invert) const
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:573
CASE ...
Definition: item_cmpfunc.h:1812
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override
Definition: item_cmpfunc.cc:3282
Item_func_not(const POS &pos, Item *a)
Definition: item_cmpfunc.h:705
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:2102
bool itemize(Parse_context *pc, Item **res) override
The same as contextualize()/contextualize_() but with additional parameter.
Definition: item_cmpfunc.cc:5776
Definition: sql_executor.h:406
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:1214
char buff[STRING_BUFFER_USUAL_SIZE]
Definition: item_cmpfunc.h:1470
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:692
Item_func_true()
Definition: item_cmpfunc.h:350
Item ** cache_converted_constant(THD *thd, Item **value, Item **cache, Item_result type)
Convert and cache a constant.
Definition: item_cmpfunc.cc:1357
Item_func_not(Item *a)
Definition: item_cmpfunc.h:704
static MEM_ROOT mem_root
Definition: client_plugin.cc:107
Definition: item_cmpfunc.h:568
String tmp_value
Definition: item_cmpfunc.h:1817
optimize_type select_optimize(const THD *) override
Definition: item_cmpfunc.h:1939
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:1061
cmp_item which stores a scalar (i.e. non-ROW).
Definition: item_cmpfunc.h:1652
virtual bool cast_incompatible_args(uchar *) override
Wrap incompatible arguments in CAST nodes to the expected data types.
Definition: item_cmpfunc.h:2388
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:1065
Definition: item_cmpfunc.h:2111
Type type() const override
Definition: item_cmpfunc.h:2253
void cleanup() override
Definition: item_cmpfunc.cc:3732
Item_cache * cache
Definition: item_cmpfunc.h:464
Item_func_xor(const POS &pos, Item *i1, Item *i2)
Definition: item_cmpfunc.h:685
bool(Item::* Item_processor)(uchar *arg)
Processor type for {Item,SELECT_LEX[_UNIT],Table_function}walk.
Definition: sql_const.h:453
Item_cond()
Definition: item_cmpfunc.h:2220
unsigned int my_time_flags_t
Flags to str_to_datetime and number_to_datetime.
Definition: my_time.h:82
String * val_str(String *) override
Definition: item_cmpfunc.cc:3433
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1530
bool compare_elems(uint pos1, uint pos2) const override
Compare values number pos1 and pos2 for equality.
Definition: item_cmpfunc.cc:4149
const JOIN * m_join
Optional: JOIN of table which is the source of trig_var.
Definition: item_cmpfunc.h:817
Definition: item_cmpfunc.h:1228
Mem_root_array< packed_longlong > base
Definition: item_cmpfunc.h:1501
Item_maxmin_subselect * test_sub_item
Definition: item_cmpfunc.h:877
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:2473
void store_value(Item *item) override
Definition: item_cmpfunc.h:1724
Item * left_cache
Definition: item_cmpfunc.h:132
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:1084
bool fix_fields(THD *, Item **ref) override
Definition: item_cmpfunc.cc:5017
Definition: item_cmpfunc.h:1699
Item * create_cast_if_needed(MEM_ROOT *mem_root, Item *argument) const
Wrap the argument in a typecast, if needed.
Definition: item_cmpfunc.cc:7135
Abstract base class for the comparison operators =, <> and <=>.
Definition: item_cmpfunc.h:509
bool use_decimal_comparison
Definition: item_cmpfunc.h:1238
Item_result_field * owner
Definition: item_cmpfunc.h:127
bool escape_is_evaluated() const
Has the escape clause been evaluated? It only needs to be evaluated once per execution, since we require it to be constant during execution.
Definition: item_cmpfunc.h:2189
virtual bool eqne_op() const
Definition: item_cmpfunc.h:574
traverse_order
Definition: item.h:739
Definition: item_cmpfunc.h:1526
Item_bool_func(Item *a, Item *b)
Definition: item_cmpfunc.h:289
Definition: item_cmpfunc.h:1556
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:6830
Item_func_isnotnull(const POS &pos, Item *a)
Definition: item_cmpfunc.h:2114
bool save_cache
Definition: item_cmpfunc.h:465
Arg_comparator cmp
Definition: item_cmpfunc.h:604
virtual bool is_null()
Definition: item.h:1909
double val_real() override
Definition: item_cmpfunc.cc:3475
const char * func_name() const override
Definition: item_cmpfunc.h:1215
bool itemize(Parse_context *pc, Item **res) override
The same as contextualize()/contextualize_() but with additional parameter.
Definition: item_cmpfunc.cc:2542
ANY_VALUE(expr) is like expr except that it is not checked by aggregate_check logic.
Definition: item_cmpfunc.h:1321
Definition: item_cmpfunc.h:1596
bool fix_fields(THD *, Item **) override
Definition: item_cmpfunc.h:341
Definition: mysql_time.h:64
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:739
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:1081
Definition: item.h:755
Definition: item.h:759
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:6533
void print(const THD *, String *str, enum_query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:369
int cmp(Item *arg) override
Definition: item_cmpfunc.cc:4375
Item * transform(Item_transformer transformer, uchar *arg) override
Perform a generic transformation of the Item tree, by adding zero or more additional Item objects to ...
Definition: item_cmpfunc.cc:6552
virtual bool eqne_op() const
Definition: item_cmpfunc.h:512
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1542
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:1605
const char * func_name() const override
Definition: item_cmpfunc.h:366
bool maybe_null
True if this item may be null.
Definition: item.h:2731
enum_mysql_timestamp_type
Definition: mysql_time.h:44
my_decimal * decimal_op(my_decimal *) override
Performs the operation that this functions implements when the result type is DECIMAL.
Definition: item_cmpfunc.cc:3108
Mem_root_array< my_decimal > base
Definition: item_cmpfunc.h:1597
cmp_item * make_same() override
Definition: item_cmpfunc.cc:4393
void cleanup() override
Definition: item_cmpfunc.h:343
Definition: item_func.h:223
table_map used_tables_cache
Value used in calculation of result of used_tables()
Definition: item_func.h:105
Definition: item_func.h:197
Item_result get_compare_type() const
Definition: item_cmpfunc.h:236
uint decimal_precision() const override
Definition: item_cmpfunc.h:1374
Wrapper class when MATCH function is used in WHERE clause.
Definition: item_cmpfunc.h:732
const char * func_name() const override
Definition: item_cmpfunc.h:950
enum Functype functype() const override
Definition: item_cmpfunc.h:2060
int type
Definition: http_common.h:411
Equal_creator equal_creator
Definition: mysqld.cc:1301
enum Functype functype() const override
Definition: item_cmpfunc.h:1120
Item * truth_transformer(THD *, Bool_test) override
Informs an item that it is wrapped in a truth test, in case it wants to transforms itself to implemen...
Definition: item_cmpfunc.cc:6130
int(Arg_comparator::* arg_cmp_func)()
Definition: item_cmpfunc.h:74
virtual Item_bool_func * combine(List< Item > list) const =0
Combines a list of conditions exp op exp.
bool compare_elems(uint pos1, uint pos2) const override
Compare values number pos1 and pos2 for equality.
Definition: item_cmpfunc.cc:4124
void update_used_tables() override
Definition: item_func.cc:448
DTCollation collation
Character set and collation properties assigned for this Item.
Definition: item.h:2649
Item ** right
Definition: item_cmpfunc.h:125
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:640
in_time_as_longlong(MEM_ROOT *mem_root, uint elements)
Definition: item_cmpfunc.h:1540
String * str_op(String *str) override
Coalesce - return first not NULL argument.
Definition: item_cmpfunc.cc:3144
Mem_root_array< cmp_item_row * > base_pointers
Definition: item_cmpfunc.h:2023
Definition: item_cmpfunc.h:1719
uint elements
Definition: sql_list.h:135
bool alloc_comparators(THD *thd, Item *item)
Allocate comparator objects.
Definition: item_cmpfunc.cc:4248
void store_value(Item *item) override
Definition: item_cmpfunc.cc:4363
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:6847
virtual const char * symbol(bool invert) const =0
This interface is only used by Item_allany_subselect.
Item_func_if(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_cmpfunc.h:1337
table_map not_null_tables() const override
Definition: item_cmpfunc.h:902
my_decimal dec
Definition: item_cmpfunc.h:1231
bool is_row_result() const override
Definition: item_cmpfunc.h:2027
bool walk(Item_processor processor, enum_walk walk, uchar *arg) override
Traverses a tree of Items in prefix and/or postfix order.
Definition: item_cmpfunc.cc:5272
bool compare_as_temporal_times
Definition: item_cmpfunc.h:1177
longlong val
Definition: item_cmpfunc.h:1496
cmp_item_row * tmp
Definition: item_cmpfunc.h:2020
static bool can_compare_as_dates(Item *a, Item *b)
Checks whether compare_datetime() can be used to compare items.
Definition: item_cmpfunc.cc:1004
cmp_item * make_same() override
Definition: item_cmpfunc.cc:4184
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:3204
Item * copy_andor_structure(THD *thd) override
Definition: item_cmpfunc.h:2476
Definition: item_cmpfunc.h:2440
Item * and_conds(Item *a, Item *b)
Builds condition: (a AND b) IS TRUE.
Definition: item_cmpfunc.h:2524
double real_op() override
Performs the operation that this functions implements when the result type is REAL.
Definition: item_cmpfunc.cc:3781
bool cast_incompatible_args(uchar *) override
Wrap incompatible arguments in CAST nodes to the expected data types.
Definition: item_cmpfunc.h:2176
DTCollation cmp_collation
Definition: item_cmpfunc.h:1900
Item * negated_item() override
just fake method, should never be called.
Definition: item_cmpfunc.cc:6161
Item * truth_transformer(THD *, Bool_test) override
XOR can be negated by negating one of the operands:
Definition: item_cmpfunc.cc:6090
bool abort_on_null
Definition: item_cmpfunc.h:605
Item_func_bool_const(const POS &pos)
Definition: item_cmpfunc.h:335
table_map get_inner_tables() const
Get table_map of inner tables spanned by associated outer join operation.
Definition: item_cmpfunc.cc:6626
Definition: sql_list.h:585
uint max_members
Definition: item_cmpfunc.h:2442
longlong val_int() override
Definition: item_cmpfunc.cc:3332
Item_func_true(const POS &pos)
Definition: item_cmpfunc.h:351
void prepend(List< T > *list)
Definition: sql_list.h:462
Item_bool_func super
Definition: item_cmpfunc.h:2049
void print_op(const THD *thd, String *str, enum_query_type query_type) const
Definition: item_func.cc:483
uint decimal_precision() const override
Definition: item_cmpfunc.cc:3072
void fix_after_pullout(SELECT_LEX *parent_select, SELECT_LEX *removed_select) override
Fix after tables have been moved from one select_lex level to the parent level, e.g by semijoin conversion.
Definition: item_cmpfunc.cc:5234
Item_bool_func(const POS &pos)
Definition: item_cmpfunc.h:282
enum Functype functype() const override
Definition: item_cmpfunc.h:1060
int compare_int_unsigned_signed()
Compare unsigned (*left) with signed (*B)
Definition: item_cmpfunc.cc:1843
Ne_creator ne_creator
Definition: mysqld.cc:1300
void destroy(T *ptr)
Definition: my_alloc.h:381
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1582
bool cast_incompatible_args(uchar *) override
Wrap incompatible arguments in CAST nodes to the expected data types.
Definition: item_cmpfunc.cc:693
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:1102
Definition: item.h:3858
Definition: item.h:737
Definition: field_types.h:69
bool fixed
True if item has been resolved.
Definition: item.h:2711
Definition: item_func.h:122
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:5326
void set_max_str_length(size_t max_length)
When comparing strings, compare at most max_length bytes.
Definition: item_cmpfunc.h:201
if(!(yy_init))
Definition: lexyy.cc:1144
longlong cached_value
Definition: item_cmpfunc.h:2052
Definition: item_cmpfunc.h:1538
bool created_by_in2exists() const override
Whether this Item was created by the IN->EXISTS subquery transformation.
Definition: item_cmpfunc.h:303
Item_result m_compare_type
Definition: item_cmpfunc.h:276
bool contains(const Field *field) const
Check whether a field is referred in the multiple equality.
Definition: item_cmpfunc.cc:6295
virtual Item_bool_func * create(Item *a, Item *b) const
Definition: item_cmpfunc.cc:313
Time declarations shared between the server and client API: you should not add anything to this heade...
Item with result field.
Definition: item.h:4559
const char * func_name() const override
Definition: item_cmpfunc.h:390
void update_used_tables() override
Definition: item_cmpfunc.cc:5972
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:1197
Definition: item_func.h:133
uint allowed_arg_cols
Definition: item_func.h:103
bool has_any_non_equi_join_condition() const override
Returns true if this Item has at least one non equi-join condition.
Definition: item_cmpfunc.cc:6889
Item_func_equal(Item *a, Item *b)
Definition: item_cmpfunc.h:1012
bool fill(Item **items, uint item_count)
Fill the vector by evaluating the items passed as arguments.
Definition: item_cmpfunc.cc:3841
#define NULL
Definition: types.h:55
virtual int cmp(Item *item)=0
Mem_root_array< String * > base_pointers
Definition: item_cmpfunc.h:1474
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:2133
enum Functype functype() const override
Definition: item_cmpfunc.h:688
double dbl
Definition: item_cmpfunc.h:1230
bool ignore_unknown() const
Treat UNKNOWN result like FALSE because callers see no difference.
Definition: item_cmpfunc.h:2273
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:6605
void set_cmp_context_for_datetime()
Definition: item_cmpfunc.h:230
enum Item_result cached_result_type
Definition: item_cmpfunc.h:1330
void negate()
Definition: item_cmpfunc.h:1156
Definition: item_cmpfunc.h:1264
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:2423
cmp_item * make_same() override
Definition: item_cmpfunc.cc:4186
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:4603
Implements the comparison operator less than (<)
Definition: item_cmpfunc.h:1096
String * val_str(String *str) override
Definition: item_cmpfunc.cc:3344
enum Functype functype() const override
Definition: item_cmpfunc.h:841
Target down_cast(Source *arg)
Casts from one pointer type to another in a type hierarchy.
Definition: template_utils.h:91
bool convert_constant_arg(THD *thd, Item *field, Item **item, bool *converted)
Definition: item_cmpfunc.cc:606
uint16 comparator_count
Definition: item_cmpfunc.h:129
A better implementation of the UNIX ctype(3) library.
Item_cond(Item *i1, Item *i2)
Definition: item_cmpfunc.h:2221
Item_func_trig_cond(Item *a, bool *f, JOIN *join, plan_idx idx, enum_trig_type trig_type_arg)
Definition: item_cmpfunc.h:833
Definition: item_cmpfunc.h:2048
void set_comparator(uint col, cmp_item *comparator)
Definition: item_cmpfunc.h:2011
Definition: item_cmpfunc.h:1784
Definition: item_subselect.h:316
Definition: item_func.h:131
enum Functype functype() const override
Definition: item_cmpfunc.h:2169
void print(const THD *thd, String *str, enum_query_type query_type) const override
Definition: item_cmpfunc.cc:3710
virtual bool compare_elems(uint pos1, uint pos2) const =0
Compare values number pos1 and pos2 for equality.
int compare_real_fixed()
Definition: item_cmpfunc.cc:1730
Definition: item_func.h:135
void set_const(Item *c)
Definition: item_cmpfunc.h:2368
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:4153
bool * trig_var
Pointer to trigger variable.
Definition: item_cmpfunc.h:815
bool * get_trig_var()
Definition: item_cmpfunc.h:867
Definition: item_cmpfunc.h:929
cmp_item * make_same()
Definition: item_cmpfunc.cc:4354
const string value("\alue\)
double real_op() override
Performs the operation that this functions implements when the result type is REAL.
Definition: item_cmpfunc.cc:3084
Item * truth_transformer(THD *, Bool_test) override
Informs an item that it is wrapped in a truth test, in case it wants to transforms itself to implemen...
Definition: item_cmpfunc.h:1025
const size_t m_max_character_length
Definition: item_cmpfunc.h:120
~Item_equal() override
Definition: item_cmpfunc.h:2365
virtual enum Functype rev_functype() const
Definition: item_cmpfunc.h:628
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:1380
Definition: item_cmpfunc.h:1989
static STATUS status
Definition: mysql.cc:193
bool fix_fields(THD *thd, Item **ref) override
Definition: item_cmpfunc.cc:5570
Interface for low level time utilities.
Item_func_lt(Item *a, Item *b)
Definition: item_cmpfunc.h:1098
Item * truth_transformer(THD *, Bool_test) override
Apply NOT transformation to the item and return a new one.
Definition: item_cmpfunc.cc:6139
Representation of IN subquery predicates of the form "left_expr IN (SELECT ...)". ...
Definition: item_subselect.h:472
const char * func_name() const override
Definition: item_cmpfunc.h:896
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:1891
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:929
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:3978
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:1996
int cmp(Item *arg) override
Definition: item_cmpfunc.h:1773
Definition: item_func.h:140
bool has_date
Distinguish between DATE/DATETIME/TIMESTAMP and TIME.
Definition: item_cmpfunc.h:1755
virtual void print(const THD *, String *str, enum_query_type) const
This method is used for to:
Definition: item.h:1872
void cleanup_arrays()
Cleanup data and comparator arrays.
Definition: item_cmpfunc.h:1923
Abstract base class for the MIN and MAX aggregate functions.
Definition: item_sum.h:1487
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:77
bool is_bool_func() const override
Definition: item_cmpfunc.h:1944
bool val_bool() override
Definition: item_cmpfunc.h:353
bool compare_as_dates
Definition: item_cmpfunc.h:2357
longlong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg, const Item *warn_item, bool *is_null)
Definition: item_cmpfunc.cc:1413
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:2455
bool update_const(THD *thd)
Check appearance of new constant items in the multiple equality object.
Definition: item_cmpfunc.cc:6348
Definition: item_func.h:128
Definition: table.h:2468
Item_cond_or(const POS &pos, Item *i1, Item *i2)
Definition: item_cmpfunc.h:2501
#define STRING_BUFFER_USUAL_SIZE
Definition: sql_const.h:130
bool aggregate_check_distinct(uchar *arg) override
Definition: item_cmpfunc.cc:6872
bool push_back(T *a)
Definition: sql_list.h:442
bool aggregate_check_group(uchar *arg) override
Definition: item_cmpfunc.cc:6865
int cmp(Item *arg) override
Definition: item_cmpfunc.h:1728
virtual bool l_op() const =0
void cleanup() override
Definition: item_cmpfunc.h:1933
Definition: item_func.h:136
static const char * bool_transform_names[10]
Definition: item_cmpfunc.h:306
void cleanup() override
Definition: item_cmpfunc.cc:2280
longlong val_int() override
Definition: item_cmpfunc.cc:6516
uint decimal_precision() const override
Definition: item_cmpfunc.h:302
void fix_after_pullout(SELECT_LEX *parent_select, SELECT_LEX *removed_select) override
Fix after tables have been moved from one select_lex level to the parent level, e.g by semijoin conversion.
Definition: item_cmpfunc.cc:4588
bool fix_fields(THD *, Item **) override
Perform context analysis of an IF item tree.
Definition: item_cmpfunc.cc:3184
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:1217
Definition: item_cmpfunc.h:558
Item_sum_hybrid * test_sum_item
Definition: item_cmpfunc.h:876
bool have_rev_func() const override
Definition: item_cmpfunc.h:629
Item_func_truth(Item *a, Bool_test truth_test)
Definition: item_cmpfunc.h:408
cmp_item * eval_item
Definition: item_cmpfunc.h:2354
const char * func_name() const override
Definition: item_cmpfunc.h:1189
const char * func_name() const override
Definition: item_cmpfunc.h:1943
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:1897
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1479
Ge_creator()
Definition: item_cmpfunc.h:580
void set_subselect(Item_subselect *item)
Definition: item_cmpfunc.h:901
bool fix_fields(THD *thd, Item **ref) override
Definition: item_cmpfunc.cc:5873
enum Functype functype() const override
Definition: item_cmpfunc.h:1294
bool abort_on_null
Definition: item_cmpfunc.h:879
void set_sum_test(Item_sum_hybrid *item)
Definition: item_cmpfunc.h:899
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:6571
static arg_cmp_func comparator_matrix[5]
Definition: item_cmpfunc.h:225
Definition: item_cmpfunc.h:1168
bool abort_on_null
Definition: item_cmpfunc.h:2216
my_decimal value
Definition: item_cmpfunc.h:1785
Definition: item_func.h:123
T * head()
Definition: sql_list.h:454
Item_field * get_subst_item(const Item_field *field)
Get item that can be substituted for the supplied item.
Definition: item_cmpfunc.cc:6708
longlong value
Definition: item_cmpfunc.h:1747
uint decimal_precision() const override
Definition: item_cmpfunc.h:1915
bool m_null_value
If stored value is NULL.
Definition: item_cmpfunc.h:1654
String tmp
Definition: item_cmpfunc.h:1471
bool cast_incompatible_args(uchar *) override
Wrap incompatible arguments in CAST nodes to the expected data types.
Definition: item_cmpfunc.h:699
#define false
Definition: config_static.h:43
virtual const char * symbol(bool invert) const
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:593
Lt_creator()
Definition: item_cmpfunc.h:570
int compare(const cmp_item *c) const
Definition: item_cmpfunc.cc:4349
virtual Item * negated_item()
just fake method, should never be called.
Definition: item_cmpfunc.cc:6194
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:5407
virtual Item_bool_func * create(Item *a, Item *b) const
Definition: item_cmpfunc.cc:321
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.h:298
bool set_null
Definition: item_cmpfunc.h:134
bool itemize(Parse_context *pc, Item **res) override
The same as contextualize()/contextualize_() but with additional parameter.
Definition: item_cmpfunc.cc:5979
double val_real() override
Definition: item_cmpfunc.cc:3320
enum Functype functype() const override
Definition: item_cmpfunc.h:1188
Definition: item_cmpfunc.h:527
bool pred_level
Definition: item_cmpfunc.h:1144
Definition: item_cmpfunc.h:1493
bool find_item(Item *item) override
Calls item->val_int() or item->val_str() etc.
Definition: item_cmpfunc.cc:4141
bool walk(Item_processor processor, enum_walk walk, uchar *arg) override
Traverses a tree of Items in prefix and/or postfix order.
Definition: item_cmpfunc.cc:6540
void rewind(void)
Definition: item_cmpfunc.h:2458
longlong val_int() override
Definition: item_cmpfunc.cc:2371
Item * truth_transformer(THD *, Bool_test test) override
a IS NULL -> a IS NOT NULL.
Definition: item_cmpfunc.cc:6110
void add_at_head(List< Item > *nlist)
Definition: item_cmpfunc.h:2242
Item_func_interval(const POS &pos, MEM_ROOT *mem_root, Item *expr1, Item *expr2, class PT_item_list *opt_expr_list=NULL)
Definition: item_cmpfunc.h:1242
bool compare_as_temporal_dates
Definition: item_cmpfunc.h:1176
static int compare(size_t a, size_t b)
Function to compare two size_t integers for their relative order.
Definition: rpl_utility.cc:102
Definition: item_cmpfunc.h:2461
const char * func_name() const override
Definition: item_cmpfunc.h:689
Item_cond_and(THD *thd, Item_cond_and *item)
Definition: item_cmpfunc.h:2471
longlong val_int() override
Definition: item_cmpfunc.cc:5737
Item_func_not_all(Item *a)
Definition: item_cmpfunc.h:884
Definition: item_func.h:125
void cleanup()
Definition: item_cmpfunc.cc:697
Definition: items.h:34
Item_result cmp_type
Definition: item_cmpfunc.h:1819
Item_in_subselect * owner
Definition: item_cmpfunc.h:2088
size_t max_character_length() const
Definition: item_cmpfunc.h:103
const char * func_name() const override
Definition: item_cmpfunc.h:1355
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1602
Definition: item_cmpfunc.h:1209
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:637
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:4397
String m_str_value
String buffer.
Definition: item_cmpfunc.h:1706
This trigger type deactivates predicated from WHERE condition when no row satisfying the join conditi...
Definition: item_cmpfunc.h:801
Item_func_bool_const()
Definition: item_cmpfunc.h:329
void update_used_tables() override
Definition: item_cmpfunc.cc:6502
Item_func_nullif(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:1363
bool ignore_unknown() const
Treat UNKNOWN result like FALSE because callers see no difference.
Definition: item_cmpfunc.h:893
The <=> operator evaluates the same as.
Definition: item_cmpfunc.h:1010
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
float get_filtering_effect(THD *thd, table_map filter_for_table, table_map read_tables, const MY_BITMAP *fields_to_ignore, double rows_in_table) override
Calculate the filter contribution that is relevant for table &#39;filter_for_table&#39; for this item...
Definition: item_cmpfunc.cc:5994
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:778
Item_bool_func super
Definition: item_cmpfunc.h:2212
int compare_decimal()
Definition: item_cmpfunc.cc:1715
enum Functype functype() const override
Definition: item_cmpfunc.h:2505
Item * escape_item
Definition: item_cmpfunc.h:2145
in_datetime_as_longlong(MEM_ROOT *mem_root, uint elements)
Definition: item_cmpfunc.h:1528
bool fix_fields(THD *thd, Item **ref) override
Definition: item_cmpfunc.cc:3544
bool push_front(T *a)
Definition: sql_list.h:448
int compare_int_unsigned()
Compare values as BIGINT UNSIGNED.
Definition: item_cmpfunc.cc:1805
const char * func_name() const override
&#39;<if>&#39;, to distinguish from the if() SQL function
Definition: item_cmpfunc.h:843
Item_cond_and()
Definition: item_cmpfunc.h:2466
enum Functype functype() const override
Definition: item_cmpfunc.h:2473
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:4136
Item_cond_and(List< Item > &list_arg)
Definition: item_cmpfunc.h:2472
Item_bool_func2(Item *a, Item *b)
Definition: item_cmpfunc.h:608
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:1105
cmp_item ** comparators
Definition: item_cmpfunc.h:1990
bool null_on_null
Affects how to determine that NULL argument implies a NULL function return.
Definition: item_func.h:98
virtual void store_value_by_template(cmp_item *, Item *item)
Definition: item_cmpfunc.h:1646
bool negated
Definition: item_cmpfunc.h:1143