MySQL  8.0.16
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 "extra/regex/my_regex.h" // my_regex_t
32 
33 #include "m_ctype.h"
34 #include "my_alloc.h"
35 #include "my_compiler.h"
36 #include "my_dbug.h"
37 #include "my_inttypes.h"
38 #include "my_sys.h"
39 #include "my_table_map.h"
40 #include "my_time.h"
42 #include "mysql_time.h"
43 #include "sql/enum_query_type.h"
44 #include "sql/item.h"
45 #include "sql/item_func.h" // Item_int_func
46 #include "sql/item_row.h" // Item_row
47 #include "sql/mem_root_array.h" // Mem_root_array
48 #include "sql/my_decimal.h"
50 #include "sql/sql_const.h"
51 #include "sql/sql_list.h"
52 #include "sql/table.h"
53 #include "sql_string.h"
54 #include "template_utils.h" // down_cast
55 
56 class Arg_comparator;
57 class Field;
58 class Item_in_subselect;
59 class Item_subselect;
60 class Item_sum_hybrid;
61 class Json_scalar_holder;
62 class Json_wrapper;
63 class PT_item_list;
64 class SELECT_LEX;
65 class THD;
66 struct MY_BITMAP;
67 
68 typedef int (Arg_comparator::*arg_cmp_func)();
69 
71  Item **a, **b;
74  Arg_comparator *comparators; // used only for compare_row()
76  double precision;
77  /* Fields used in DATE/DATETIME comparison. */
78  Item *a_cache, *b_cache; // Cached values of a and b items
79  bool set_null; // true <=> set owner->null_value
80  // when one of arguments is NULL.
81  longlong (*get_value_a_func)(THD *thd, Item ***item_arg, Item **cache_arg,
82  const Item *warn_item, bool *is_null);
83  longlong (*get_value_b_func)(THD *thd, Item ***item_arg, Item **cache_arg,
84  const Item *warn_item, bool *is_null);
86  static bool get_date_from_const(Item *date_arg, Item *str_arg,
87  ulonglong *const_value);
88  /**
89  Only used by compare_json() in the case where a JSON value is
90  compared to an SQL value. This member points to pre-allocated
91  memory that can be used instead of the heap when converting the
92  SQL value to a JSON value.
93  */
95 
96  /**
97  When comparing strings, compare at most these many bytes.
98  A value of zero means "no limit".
99  */
100  size_t m_max_str_length{0};
101 
102  public:
104  /* Allow owner function to use string buffers. */
106 
108  : comparators(0),
109  comparator_count(0),
110  a_cache(0),
111  b_cache(0),
112  set_null(true),
113  get_value_a_func(0),
114  get_value_b_func(0),
115  json_scalar(0) {}
117  : a(a1),
118  b(a2),
119  comparators(0),
120  comparator_count(0),
121  a_cache(0),
122  b_cache(0),
123  set_null(true),
124  get_value_a_func(0),
125  get_value_b_func(0),
126  json_scalar(0) {}
127 
129  bool set_cmp_func(Item_result_field *owner_arg, Item **a1, Item **a2,
130  Item_result type);
131 
132  bool set_cmp_func(Item_result_field *owner_arg, Item **a1, Item **a2,
133  bool set_null_arg);
134 
135  /**
136  When comparing strings, compare at most max_length bytes.
137  @param max_length how much to compare
138  */
139  void set_max_str_length(size_t max_length) { m_max_str_length = max_length; }
140  inline int compare() { return (this->*func)(); }
141 
142  int compare_string(); // compare args[0] & args[1]
143  int compare_binary_string(); // compare args[0] & args[1]
144  int compare_real(); // compare args[0] & args[1]
145  int compare_decimal(); // compare args[0] & args[1]
146  int compare_int_signed(); // compare args[0] & args[1]
149  int compare_int_unsigned();
150  int compare_time_packed();
151  int compare_row(); // compare args[0] & args[1]
152  int compare_real_fixed();
153  int compare_datetime(); // compare args[0] & args[1] as DATETIMEs
154  int compare_json();
155  bool compare_null_values();
156 
157  static bool can_compare_as_dates(Item *a, Item *b);
158 
159  Item **cache_converted_constant(THD *thd, Item **value, Item **cache,
160  Item_result type);
161  void set_datetime_cmp_func(Item_result_field *owner_arg, Item **a1,
162  Item **b1);
164  void cleanup();
165  /*
166  Set correct cmp_context if items would be compared as INTs.
167  */
170  if ((*a)->is_temporal()) (*a)->cmp_context = INT_RESULT;
171  if ((*b)->is_temporal()) (*b)->cmp_context = INT_RESULT;
172  }
173 };
174 
176  public:
178  explicit Item_bool_func(const POS &pos)
180 
184 
187  Item_bool_func(const POS &pos, Item *a, Item *b)
189 
191  : Item_int_func(thd, item),
193  bool is_bool_func() const override { return true; }
194  bool resolve_type(THD *) override {
195  max_length = 1;
196  return false;
197  }
198  uint decimal_precision() const override { return 1; }
199  bool created_by_in2exists() const override { return m_created_by_in2exists; }
201 
202  private:
203  /**
204  True <=> this item was added by IN->EXISTS subquery transformation, and
205  should thus be deleted if we switch to materialization.
206  */
208 };
209 
210 /**
211  Abstract Item class, to represent <code>X IS [NOT] (TRUE | FALSE)</code>
212  boolean predicates.
213 */
214 
216  public:
217  bool val_bool() override;
218  longlong val_int() override;
219  bool resolve_type(THD *) override;
220  void print(const THD *thd, String *str,
221  enum_query_type query_type) const override;
222 
223  protected:
224  Item_func_truth(const POS &pos, Item *a, bool a_value, bool a_affirmative)
225  : Item_bool_func(pos, a), value(a_value), affirmative(a_affirmative) {}
226 
227  private:
228  /**
229  True for <code>X IS [NOT] TRUE</code>,
230  false for <code>X IS [NOT] FALSE</code> predicates.
231  */
232  const bool value;
233  /**
234  True for <code>X IS Y</code>, false for <code>X IS NOT Y</code> predicates.
235  */
236  const bool affirmative;
237 };
238 
239 /**
240  This Item represents a <code>X IS TRUE</code> boolean predicate.
241 */
242 
244  public:
246  : Item_func_truth(pos, a, true, true) {}
247  const char *func_name() const override { return "istrue"; }
248 };
249 
250 /**
251  This Item represents a <code>X IS NOT TRUE</code> boolean predicate.
252 */
253 
255  public:
257  : Item_func_truth(pos, a, true, false) {}
258  const char *func_name() const override { return "isnottrue"; }
259 };
260 
261 /**
262  This Item represents a <code>X IS FALSE</code> boolean predicate.
263 */
264 
266  public:
268  : Item_func_truth(pos, a, false, true) {}
269  const char *func_name() const override { return "isfalse"; }
270 };
271 
272 /**
273  This Item represents a <code>X IS NOT FALSE</code> boolean predicate.
274 */
275 
277  public:
279  : Item_func_truth(pos, a, false, false) {}
280  const char *func_name() const override { return "isnotfalse"; }
281 };
282 
283 static const int UNKNOWN = -1;
284 
285 /*
286  Item_in_optimizer(left_expr, Item_in_subselect(...))
287 
288  Item_in_optimizer is used to wrap an instance of Item_in_subselect. This
289  class does the following:
290  - Evaluate the left expression and store it in Item_cache_* object (to
291  avoid re-evaluating it many times during subquery execution)
292  - Shortcut the evaluation of "NULL IN (...)" to NULL in the cases where we
293  don't care if the result is NULL or FALSE.
294 
295  args[1] keeps a reference to the Item_in_subselect object.
296 
297  args[0] is a copy of Item_in_subselect's left expression and should be
298  kept equal also after resolving.
299 
300  NOTE
301  It is not quite clear why the above listed functionality should be
302  placed into a separate class called 'Item_in_optimizer'.
303 */
304 
306  private:
309  /*
310  Stores the value of "NULL IN (SELECT ...)" for uncorrelated subqueries:
311  UNKNOWN - "NULL in (SELECT ...)" has not yet been evaluated
312  FALSE - result is FALSE
313  TRUE - result is NULL
314  */
316 
317  public:
319  : Item_bool_func(a, reinterpret_cast<Item *>(b)),
320  cache(0),
321  save_cache(0),
323  set_subquery();
324  }
325  bool fix_fields(THD *, Item **) override;
326  bool fix_left(THD *thd, Item **ref);
327  void fix_after_pullout(SELECT_LEX *parent_select,
328  SELECT_LEX *removed_select) override;
329  bool is_null() override;
330  longlong val_int() override;
331  void cleanup() override;
332  const char *func_name() const override { return "<in_optimizer>"; }
333  Item_cache **get_cache() { return &cache; }
334  void keep_top_level_cache();
335  Item *transform(Item_transformer transformer, uchar *arg) override;
336  void replace_argument(THD *thd, Item **oldpp, Item *newp) override;
337 };
338 
339 /// Abstract factory interface for creating comparison predicates.
341  public:
342  virtual ~Comp_creator() {}
343  virtual Item_bool_func *create(Item *a, Item *b) const = 0;
344 
345  /// This interface is only used by Item_allany_subselect.
346  virtual const char *symbol(bool invert) const = 0;
347  virtual bool eqne_op() const = 0;
348  virtual bool l_op() const = 0;
349 };
350 
351 /// Abstract base class for the comparison operators =, <> and <=>.
353  public:
354  virtual Item_bool_func *create(Item *a, Item *b) const;
355  virtual bool eqne_op() const { return true; }
356  virtual bool l_op() const { return false; }
357 
358  protected:
359  /**
360  Creates only an item tree node, without attempting to rewrite row
361  constructors.
362  @see create()
363  */
364  virtual Item_bool_func *create_scalar_predicate(Item *a, Item *b) const = 0;
365 
366  /// Combines a list of conditions <code>exp op exp</code>.
367  virtual Item_bool_func *combine(List<Item> list) const = 0;
368 };
369 
371  public:
372  virtual const char *symbol(bool invert) const { return invert ? "<>" : "="; }
373 
374  protected:
375  virtual Item_bool_func *create_scalar_predicate(Item *a, Item *b) const;
376  virtual Item_bool_func *combine(List<Item> list) const;
377 };
378 
380  public:
381  virtual const char *symbol(bool invert MY_ATTRIBUTE((unused))) const {
382  // This will never be called with true.
383  DBUG_ASSERT(!invert);
384  return "<=>";
385  }
386 
387  protected:
388  virtual Item_bool_func *create_scalar_predicate(Item *a, Item *b) const;
389  virtual Item_bool_func *combine(List<Item> list) const;
390 };
391 
393  public:
394  virtual const char *symbol(bool invert) const { return invert ? "=" : "<>"; }
395 
396  protected:
397  virtual Item_bool_func *create_scalar_predicate(Item *a, Item *b) const;
398  virtual Item_bool_func *combine(List<Item> list) const;
399 };
400 
401 class Gt_creator : public Comp_creator {
402  public:
403  Gt_creator() {} /* Remove gcc warning */
404  virtual ~Gt_creator() {} /* Remove gcc warning */
405  virtual Item_bool_func *create(Item *a, Item *b) const;
406  virtual const char *symbol(bool invert) const { return invert ? "<=" : ">"; }
407  virtual bool eqne_op() const { return 0; }
408  virtual bool l_op() const { return 0; }
409 };
410 
411 class Lt_creator : public Comp_creator {
412  public:
413  Lt_creator() {} /* Remove gcc warning */
414  virtual ~Lt_creator() {} /* Remove gcc warning */
415  virtual Item_bool_func *create(Item *a, Item *b) const;
416  virtual const char *symbol(bool invert) const { return invert ? ">=" : "<"; }
417  virtual bool eqne_op() const { return 0; }
418  virtual bool l_op() const { return 1; }
419 };
420 
421 class Ge_creator : public Comp_creator {
422  public:
423  Ge_creator() {} /* Remove gcc warning */
424  virtual ~Ge_creator() {} /* Remove gcc warning */
425  virtual Item_bool_func *create(Item *a, Item *b) const;
426  virtual const char *symbol(bool invert) const { return invert ? "<" : ">="; }
427  virtual bool eqne_op() const { return 0; }
428  virtual bool l_op() const { return 0; }
429 };
430 
431 class Le_creator : public Comp_creator {
432  public:
433  Le_creator() {} /* Remove gcc warning */
434  virtual ~Le_creator() {} /* Remove gcc warning */
435  virtual Item_bool_func *create(Item *a, Item *b) const;
436  virtual const char *symbol(bool invert) const { return invert ? ">" : "<="; }
437  virtual bool eqne_op() const { return 0; }
438  virtual bool l_op() const { return 1; }
439 };
440 
441 class Item_bool_func2 : public Item_bool_func { /* Bool with 2 string args */
442  private:
443  bool convert_constant_arg(THD *thd, Item *field, Item **item,
444  bool *converted);
445 
446  protected:
449 
450  public:
453 
454  Item_bool_func2(const POS &pos, Item *a, Item *b)
455  : Item_bool_func(pos, a, b),
456  cmp(tmp_arg, tmp_arg + 1),
457  abort_on_null(false) {}
458 
459  bool resolve_type(THD *) override;
460  bool set_cmp_func() {
461  return cmp.set_cmp_func(this, tmp_arg, tmp_arg + 1, true);
462  }
463  /**
464  When comparing strings, compare at most max_str_length bytes.
465  @param max_str_length how much to compare
466  */
467  void set_max_str_length(size_t max_str_length) {
468  return cmp.set_max_str_length(max_str_length);
469  }
470  optimize_type select_optimize() const override { return OPTIMIZE_OP; }
471  virtual enum Functype rev_functype() const { return UNKNOWN_FUNC; }
472  bool have_rev_func() const override { return rev_functype() != UNKNOWN_FUNC; }
473 
474  void print(const THD *thd, String *str,
475  enum_query_type query_type) const override {
476  Item_func::print_op(thd, str, query_type);
477  }
478 
479  bool is_null() override { return args[0]->is_null() || args[1]->is_null(); }
480  const CHARSET_INFO *compare_collation() const override {
481  return cmp.cmp_collation.collation;
482  }
483  void top_level_item() override { abort_on_null = true; }
484  bool is_top_level_item() const { return abort_on_null; }
485  void cleanup() override {
487  cmp.cleanup();
488  }
489  friend class Arg_comparator;
490 };
491 
492 /**
493  Item_func_comparison is a class for comparison functions that take two
494  arguments and return a boolean result.
495  It is a common class for the regular comparison operators (=, <>, <, <=,
496  >, >=) as well as the special <=> equality operator.
497 */
499  public:
501  allowed_arg_cols = 0; // Fetch this value from first argument
502  }
504  : Item_bool_func2(pos, a, b) {
505  allowed_arg_cols = 0; // Fetch this value from first argument
506  }
507 
508  Item *neg_transformer(THD *thd) override;
509  virtual Item *negated_item();
510  bool subst_argument_checker(uchar **) override { return true; }
511 };
512 
513 /**
514  XOR inherits from Item_bool_func2 because it is not optimized yet.
515  Later, when XOR is optimized, it needs to inherit from
516  Item_cond instead. See WL#5800.
517 */
519  public:
520  Item_func_xor(Item *i1, Item *i2) : Item_bool_func2(i1, i2) {}
521  Item_func_xor(const POS &pos, Item *i1, Item *i2)
522  : Item_bool_func2(pos, i1, i2) {}
523 
524  enum Functype functype() const override { return XOR_FUNC; }
525  const char *func_name() const override { return "xor"; }
526  longlong val_int() override;
527  void top_level_item() override {}
528  Item *neg_transformer(THD *thd) override;
529 
530  float get_filtering_effect(THD *thd, table_map filter_for_table,
531  table_map read_tables,
532  const MY_BITMAP *fields_to_ignore,
533  double rows_in_table) override;
534 };
535 
537  public:
540 
541  longlong val_int() override;
542  enum Functype functype() const override { return NOT_FUNC; }
543  const char *func_name() const override { return "not"; }
544  Item *neg_transformer(THD *) override;
545  void print(const THD *thd, String *str,
546  enum_query_type query_type) const override;
547 
548  float get_filtering_effect(THD *thd, table_map filter_for_table,
549  table_map read_tables,
550  const MY_BITMAP *fields_to_ignore,
551  double rows_in_table) override;
552 };
553 
555 class JOIN;
556 
557 /*
558  trigcond<param>(arg) ::= param? arg : true
559 
560  The class Item_func_trig_cond is used for guarded predicates
561  which are employed only for internal purposes.
562  A guarded predicate is an object consisting of an a regular or
563  a guarded predicate P and a pointer to a boolean guard variable g.
564  A guarded predicate P/g is evaluated to true if the value of the
565  guard g is false, otherwise it is evaluated to the same value that
566  the predicate P: val(P/g)= g ? val(P):true.
567  Guarded predicates allow us to include predicates into a conjunction
568  conditionally. Currently they are utilized for pushed down predicates
569  in queries with outer join operations.
570 
571  In the future, probably, it makes sense to extend this class to
572  the objects consisting of three elements: a predicate P, a pointer
573  to a variable g and a firing value s with following evaluation
574  rule: val(P/g,s)= g==s? val(P) : true. It will allow us to build only
575  one item for the objects of the form P/g1/g2...
576 
577  Objects of this class are built only for query execution after
578  the execution plan has been already selected. That's why this
579  class needs only val_int out of generic methods.
580 
581  Current uses of Item_func_trig_cond objects:
582  - To wrap selection conditions when executing outer joins
583  - To wrap condition that is pushed down into subquery
584 */
585 
587  public:
589  /**
590  This trigger type deactivates join conditions when a row has been
591  NULL-complemented. For example, in t1 LEFT JOIN t2, the join condition
592  can be tested on t2's row only if that row is not NULL-complemented.
593  */
595 
596  /**
597  This trigger type deactivates predicated from WHERE condition when no
598  row satisfying the join condition has been found. For Example, in t1
599  LEFT JOIN t2, the where condition pushed to t2 can be tested only after
600  at least one t2 row has been produced, which may be a NULL-complemented
601  row.
602  */
604 
605  /**
606  In IN->EXISTS subquery transformation, new predicates are added:
607  WHERE inner_field=outer_field OR inner_field IS NULL,
608  as well as
609  HAVING inner_field IS NOT NULL,
610  are disabled if outer_field is a NULL value
611  */
613  };
614 
615  private:
616  /** Pointer to trigger variable */
617  bool *trig_var;
618  /// Optional: JOIN of table which is the source of trig_var
619  const JOIN *m_join;
620  /// Optional: if join!=NULL: index of table
622  /** Type of trig_var; for printing */
624 
625  public:
626  /**
627  @param a the item for @<condition@>
628  @param f pointer to trigger variable
629  @param join if a table's property is the source of 'f', JOIN
630  which owns this table; NULL otherwise.
631  @param idx if join!=NULL: index of this table in the
632  JOIN_TAB/QEP_TAB array. NO_PLAN_IDX otherwise.
633  @param trig_type_arg type of 'f'
634  */
636  enum_trig_type trig_type_arg)
637  : Item_bool_func(a),
638  trig_var(f),
639  m_join(join),
640  m_idx(idx),
641  trig_type(trig_type_arg) {}
642  longlong val_int() override;
643  enum Functype functype() const override { return TRIG_COND_FUNC; }
644  /// '@<if@>', to distinguish from the if() SQL function
645  const char *func_name() const override { return "<if>"; }
646  /// Get range of inner tables spanned by associated outer join operation
647  void get_table_range(TABLE_LIST **first_table, TABLE_LIST **last_table) const;
648  /// Get table_map of inner tables spanned by associated outer join operation
649  table_map get_inner_tables() const;
650  bool fix_fields(THD *thd, Item **ref) override {
651  if (Item_bool_func::fix_fields(thd, ref)) return true;
653  return false;
654  }
657  DBUG_ASSERT(m_join != nullptr);
658  // Make this function dependent on the inner tables
660  } else if (trig_type == OUTER_FIELD_IS_NOT_NULL) {
662  }
663  }
664  void update_used_tables() override {
667  }
668  enum enum_trig_type get_trig_type() const { return trig_type; }
669  bool *get_trig_var() { return trig_var; }
671  void print(const THD *thd, String *str,
672  enum_query_type query_type) const override;
673  plan_idx idx() const { return m_idx; }
674 };
675 
677  /* allow to check presence of values in max/min optimization */
681 
683 
684  public:
685  bool show;
686 
688  : Item_func_not(a),
689  test_sum_item(0),
690  test_sub_item(0),
691  subselect(0),
692  abort_on_null(0),
693  show(0) {}
694  void top_level_item() override { abort_on_null = true; }
695  bool is_top_level_item() const { return abort_on_null; }
696  longlong val_int() override;
697  enum Functype functype() const override { return NOT_ALL_FUNC; }
698  const char *func_name() const override { return "<not>"; }
699  void print(const THD *thd, String *str,
700  enum_query_type query_type) const override;
703  void set_subselect(Item_subselect *item) { subselect = item; }
704  table_map not_null_tables() const override {
705  /*
706  See handling of not_null_tables_cache in
707  Item_in_optimizer::fix_fields().
708 
709  This item is the result of a transformation from an ALL clause
710  such as
711  left-expr < ALL(subquery)
712  into
713  <not>(left-expr >= (subquery)
714 
715  An inequality usually rejects NULLs from both operands, so the
716  not_null_tables() of the inequality is the union of the
717  null-rejecting tables of both operands. However, since this is a
718  transformed ALL clause that should return true if the subquery
719  is empty (even if left-expr is NULL), it is not null rejecting
720  for left-expr. The not null tables mask for left-expr should be
721  removed, leaving only the null-rejecting tables of the
722  subquery. Item_subselect::not_null_tables() always returns 0 (no
723  null-rejecting tables). Therefore, always return 0.
724  */
725  return 0;
726  }
728  Item *neg_transformer(THD *) override;
729 };
730 
732  public:
734  longlong val_int() override;
735  const char *func_name() const override { return "<nop>"; }
736  table_map not_null_tables() const override { return not_null_tables_cache; }
737  Item *neg_transformer(THD *thd) override;
738 };
739 
740 /**
741  Implements the comparison operator equals (=)
742 */
744  public:
746  Item_func_eq(const POS &pos, Item *a, Item *b)
747  : Item_func_comparison(pos, a, b) {}
748  longlong val_int() override;
749  enum Functype functype() const override { return EQ_FUNC; }
750  enum Functype rev_functype() const override { return EQ_FUNC; }
751  cond_result eq_cmp_result() const override { return COND_TRUE; }
752  const char *func_name() const override { return "="; }
753  Item *negated_item() override;
754  bool equality_substitution_analyzer(uchar **) override { return true; }
756  bool gc_subst_analyzer(uchar **) override { return true; }
757 
758  float get_filtering_effect(THD *thd, table_map filter_for_table,
759  table_map read_tables,
760  const MY_BITMAP *fields_to_ignore,
761  double rows_in_table) override;
762 };
763 
764 /**
765  The <=> operator evaluates the same as
766 
767  a IS NULL || b IS NULL ? a IS NULL == b IS NULL : a = b
768 
769  a <=> b is equivalent to the standard operation a IS NOT DISTINCT FROM b.
770 
771  Notice that the result is TRUE or FALSE, and never UNKNOWN.
772 */
774  public:
776  null_on_null = false;
777  }
778  Item_func_equal(const POS &pos, Item *a, Item *b)
779  : Item_func_comparison(pos, a, b) {
780  null_on_null = false;
781  }
782  longlong val_int() override;
783  bool resolve_type(THD *thd) override;
784  enum Functype functype() const override { return EQUAL_FUNC; }
785  enum Functype rev_functype() const override { return EQUAL_FUNC; }
786  cond_result eq_cmp_result() const override { return COND_TRUE; }
787  const char *func_name() const override { return "<=>"; }
788  Item *neg_transformer(THD *) override { return nullptr; }
789 
790  float get_filtering_effect(THD *thd, table_map filter_for_table,
791  table_map read_tables,
792  const MY_BITMAP *fields_to_ignore,
793  double rows_in_table) override;
794 };
795 
796 /**
797  Implements the comparison operator greater than or equals (>=)
798 */
800  public:
802  longlong val_int() override;
803  enum Functype functype() const override { return GE_FUNC; }
804  enum Functype rev_functype() const override { return LE_FUNC; }
805  cond_result eq_cmp_result() const override { return COND_TRUE; }
806  const char *func_name() const override { return ">="; }
807  Item *negated_item() override;
808  bool gc_subst_analyzer(uchar **) override { return true; }
809 
810  float get_filtering_effect(THD *thd, table_map filter_for_table,
811  table_map read_tables,
812  const MY_BITMAP *fields_to_ignore,
813  double rows_in_table) override;
814 };
815 
816 /**
817  Implements the comparison operator greater than (>)
818 */
820  public:
822  longlong val_int() override;
823  enum Functype functype() const override { return GT_FUNC; }
824  enum Functype rev_functype() const override { return LT_FUNC; }
825  cond_result eq_cmp_result() const override { return COND_FALSE; }
826  const char *func_name() const override { return ">"; }
827  Item *negated_item() override;
828  bool gc_subst_analyzer(uchar **) override { return true; }
829 
830  float get_filtering_effect(THD *thd, table_map filter_for_table,
831  table_map read_tables,
832  const MY_BITMAP *fields_to_ignore,
833  double rows_in_table) override;
834 };
835 
836 /**
837  Implements the comparison operator less than or equals (<=)
838 */
840  public:
842  longlong val_int() override;
843  enum Functype functype() const override { return LE_FUNC; }
844  enum Functype rev_functype() const override { return GE_FUNC; }
845  cond_result eq_cmp_result() const override { return COND_TRUE; }
846  const char *func_name() const override { return "<="; }
847  Item *negated_item() override;
848  bool gc_subst_analyzer(uchar **) override { return true; }
849 
850  float get_filtering_effect(THD *thd, table_map filter_for_table,
851  table_map read_tables,
852  const MY_BITMAP *fields_to_ignore,
853  double rows_in_table) override;
854 };
855 
856 /**
857  Implements the comparison operator less than (<)
858 */
860  public:
862  longlong val_int() override;
863  enum Functype functype() const override { return LT_FUNC; }
864  enum Functype rev_functype() const override { return GT_FUNC; }
865  cond_result eq_cmp_result() const override { return COND_FALSE; }
866  const char *func_name() const override { return "<"; }
867  Item *negated_item() override;
868  bool gc_subst_analyzer(uchar **) override { return true; }
869 
870  float get_filtering_effect(THD *thd, table_map filter_for_table,
871  table_map read_tables,
872  const MY_BITMAP *fields_to_ignore,
873  double rows_in_table) override;
874 };
875 
876 /**
877  Implements the comparison operator not equals (<>)
878 */
880  public:
882  longlong val_int() override;
883  enum Functype functype() const override { return NE_FUNC; }
884  cond_result eq_cmp_result() const override { return COND_FALSE; }
885  optimize_type select_optimize() const override { return OPTIMIZE_KEY; }
886  const char *func_name() const override { return "<>"; }
887  Item *negated_item() override;
888 
889  float get_filtering_effect(THD *thd, table_map filter_for_table,
890  table_map read_tables,
891  const MY_BITMAP *fields_to_ignore,
892  double rows_in_table) override;
893 };
894 
895 /*
896  The class Item_func_opt_neg is defined to factor out the functionality
897  common for the classes Item_func_between and Item_func_in. The objects
898  of these classes can express predicates or there negations.
899  The alternative approach would be to create pairs Item_func_between,
900  Item_func_notbetween and Item_func_in, Item_func_notin.
901 
902 */
903 
905  public:
906  bool negated; /* <=> the item represents NOT <func> */
907  bool pred_level; /* <=> [NOT] <func> is used on a predicate level */
908  public:
909  Item_func_opt_neg(const POS &pos, Item *a, Item *b, Item *c, bool is_negation)
910  : Item_int_func(pos, a, b, c), negated(0), pred_level(0) {
911  if (is_negation) negate();
912  }
913  Item_func_opt_neg(const POS &pos, PT_item_list *list, bool is_negation)
914  : Item_int_func(pos, list), negated(0), pred_level(0) {
915  if (is_negation) negate();
916  }
917 
918  public:
919  inline void negate() { negated = !negated; }
920  inline void top_level_item() override { pred_level = 1; }
921  bool is_top_level_item() const { return pred_level; }
922  Item *neg_transformer(THD *) override {
923  negated = !negated;
924  return this;
925  }
926  bool eq(const Item *item, bool binary_cmp) const override;
927  bool subst_argument_checker(uchar **) override { return true; }
928 };
929 
932 
933  public:
936  /* true <=> arguments will be compared as dates. */
940 
941  /* Comparators used for DATE/DATETIME comparison. */
943  Item_func_between(const POS &pos, Item *a, Item *b, Item *c, bool is_negation)
944  : Item_func_opt_neg(pos, a, b, c, is_negation),
948  longlong val_int() override;
949  optimize_type select_optimize() const override { return OPTIMIZE_KEY; }
950  enum Functype functype() const override { return BETWEEN; }
951  const char *func_name() const override { return "between"; }
952  bool fix_fields(THD *, Item **) override;
953  void fix_after_pullout(SELECT_LEX *parent_select,
954  SELECT_LEX *removed_select) override;
955  bool resolve_type(THD *) override;
956  void print(const THD *thd, String *str,
957  enum_query_type query_type) const override;
958  bool is_bool_func() const override { return true; }
959  const CHARSET_INFO *compare_collation() const override {
960  return cmp_collation.collation;
961  }
962  uint decimal_precision() const override { return 1; }
963  bool gc_subst_analyzer(uchar **) override { return true; }
964 
965  float get_filtering_effect(THD *thd, table_map filter_for_table,
966  table_map read_tables,
967  const MY_BITMAP *fields_to_ignore,
968  double rows_in_table) override;
969 };
970 
972  public:
973  Item_func_strcmp(const POS &pos, Item *a, Item *b)
974  : Item_bool_func2(pos, a, b) {}
975  longlong val_int() override;
976  optimize_type select_optimize() const override { return OPTIMIZE_NONE; }
977  const char *func_name() const override { return "strcmp"; }
978 
979  void print(const THD *thd, String *str,
980  enum_query_type query_type) const override {
981  Item_func::print(thd, str, query_type);
982  }
983  bool resolve_type(THD *thd) override {
984  if (Item_bool_func2::resolve_type(thd)) return true;
985  fix_char_length(2); // returns "1" or "0" or "-1"
986  return false;
987  }
988 };
989 
992  double dbl;
994 };
995 
998 
1002 
1003  public:
1005  Item *expr2, class PT_item_list *opt_expr_list = NULL)
1006  : super(pos, alloc_row(pos, mem_root, expr1, expr2, opt_expr_list)),
1007  row(down_cast<Item_row *>(args[0])),
1008  intervals(0) {
1009  allowed_arg_cols = 0; // Fetch this value from first argument
1010  }
1011 
1012  bool itemize(Parse_context *pc, Item **res) override;
1013  longlong val_int() override;
1014  bool resolve_type(THD *) override;
1015  const char *func_name() const override { return "interval"; }
1016  uint decimal_precision() const override { return 2; }
1017  void print(const THD *thd, String *str,
1018  enum_query_type query_type) const override;
1019 
1020  private:
1021  // Runs in CTOR init list, cannot access *this as Item_func_interval
1022  static Item_row *alloc_row(const POS &pos, MEM_ROOT *mem_root, Item *expr1,
1023  Item *expr2, class PT_item_list *opt_expr_list);
1024 };
1025 
1027  protected:
1029  : Item_func_numhybrid(pos, a, b) {
1030  null_on_null = false;
1031  }
1033  null_on_null = false;
1034  }
1035 
1036  public:
1039  null_on_null = false;
1040  }
1041  double real_op() override;
1042  longlong int_op() override;
1043  String *str_op(String *) override;
1044  /**
1045  Get the result of COALESCE as a JSON value.
1046  @param[in,out] wr the result value holder
1047  */
1048  bool val_json(Json_wrapper *wr) override;
1049  bool date_op(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
1050  bool time_op(MYSQL_TIME *ltime) override;
1051  my_decimal *decimal_op(my_decimal *) override;
1052  bool resolve_type(THD *) override;
1053  void set_numeric_type() override {}
1054  enum Item_result result_type() const override { return hybrid_type; }
1055  const char *func_name() const override { return "coalesce"; }
1056 };
1057 
1059  protected:
1061 
1062  public:
1064  : Item_func_coalesce(pos, a, b) {}
1065  double real_op() override;
1066  longlong int_op() override;
1067  String *str_op(String *str) override;
1068  bool date_op(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
1069  bool time_op(MYSQL_TIME *ltime) override;
1070  my_decimal *decimal_op(my_decimal *) override;
1071  bool val_json(Json_wrapper *result) override;
1072  bool resolve_type(THD *) override;
1073  const char *func_name() const override { return "ifnull"; }
1074  Field *tmp_table_field(TABLE *table) override;
1075  uint decimal_precision() const override;
1076 };
1077 
1078 /**
1079  ANY_VALUE(expr) is like expr except that it is not checked by
1080  aggregate_check logic. It serves as a solution for users who want to
1081  bypass this logic.
1082 */
1084  public:
1086  const char *func_name() const override { return "any_value"; }
1087  bool aggregate_check_group(uchar *arg) override;
1088  bool aggregate_check_distinct(uchar *arg) override;
1089 };
1090 
1091 class Item_func_if final : public Item_func {
1093 
1094  public:
1096  : Item_func(a, b, c), cached_result_type(INT_RESULT) {
1097  null_on_null = false;
1098  }
1099  Item_func_if(const POS &pos, Item *a, Item *b, Item *c)
1100  : Item_func(pos, a, b, c), cached_result_type(INT_RESULT) {
1101  null_on_null = false;
1102  }
1103 
1104  double val_real() override;
1105  longlong val_int() override;
1106  String *val_str(String *str) override;
1107  my_decimal *val_decimal(my_decimal *) override;
1108  bool val_json(Json_wrapper *wr) override;
1109  bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
1110  bool get_time(MYSQL_TIME *ltime) override;
1111  enum Item_result result_type() const override { return cached_result_type; }
1112  bool fix_fields(THD *, Item **) override;
1113  bool resolve_type(THD *) override;
1114  void fix_after_pullout(SELECT_LEX *parent_select,
1115  SELECT_LEX *removed_select) override;
1116  uint decimal_precision() const override;
1117  const char *func_name() const override { return "if"; }
1118  enum Functype functype() const override { return IF_FUNC; }
1119 };
1120 
1123 
1124  public:
1127  null_on_null = false;
1128  }
1129  double val_real() override;
1130  longlong val_int() override;
1131  String *val_str(String *str) override;
1132  my_decimal *val_decimal(my_decimal *) override;
1133  bool val_json(Json_wrapper *wr) override;
1134  Item_result result_type() const override { return cached_result_type; }
1135  bool resolve_type(THD *thd) override;
1136  uint decimal_precision() const override {
1137  return args[0]->decimal_precision();
1138  }
1139  const char *func_name() const override { return "nullif"; }
1140 
1141  void print(const THD *thd, String *str,
1142  enum_query_type query_type) const override {
1143  Item_func::print(thd, str, query_type);
1144  }
1145 
1146  bool is_null() override;
1147  /**
1148  This is a workaround for the broken inheritance hierarchy: this should
1149  inherit from Item_func instead of Item_bool_func2
1150  */
1151  bool is_bool_func() const override { return false; }
1152 };
1153 
1154 /* Functions to handle the optimized IN */
1155 
1156 /* A vector of values of some type */
1157 
1158 class in_vector {
1159  private:
1160  const uint count; ///< Original size of the vector
1161  public:
1162  uint used_count; ///< The actual size of the vector (NULL may be ignored)
1163 
1164  /**
1165  See Item_func_in::resolve_type() for why we need both
1166  count and used_count.
1167  */
1168  explicit in_vector(uint elements) : count(elements), used_count(elements) {}
1169 
1170  virtual ~in_vector() {}
1171 
1172  /**
1173  Calls item->val_int() or item->val_str() etc.
1174  and then does binary_search if the value is non-null.
1175  @param item to evaluate, and lookup in the IN-list.
1176  @return true if evaluated value of the item was found.
1177  */
1178  virtual bool find_item(Item *item) = 0;
1179 
1180  /**
1181  Create an instance of Item_{type} (e.g. Item_decimal) constant object
1182  which type allows it to hold an element of this vector without any
1183  conversions.
1184  The purpose of this function is to be able to get elements of this
1185  vector in form of Item_xxx constants without creating Item_xxx object
1186  for every array element you get (i.e. this implements "FlyWeight" pattern)
1187 
1188  @param mem_root Where to allocate the Item.
1189  */
1190  virtual Item_basic_constant *create_item(MEM_ROOT *mem_root) const = 0;
1191 
1192  /**
1193  Store the value at position #pos into provided item object
1194 
1195  @param pos Index of value to store
1196  @param item Constant item to store value into. The item must be of the same
1197  type that create_item() returns.
1198  */
1199  virtual void value_to_item(uint pos, Item_basic_constant *item) const = 0;
1200 
1201  /** Compare values number pos1 and pos2 for equality */
1202  virtual bool compare_elems(uint pos1, uint pos2) const = 0;
1203 
1204  virtual bool is_row_result() const { return false; }
1205 
1206  /**
1207  Fill the vector by evaluating the items passed as arguments.
1208  Note that null values are skipped so the vector may end up containing
1209  fewer elements than the number of items.
1210  The vector is sorted so that it can be used for binary search.
1211 
1212  @param items Items to evaluate
1213  @param item_count Number of items
1214 
1215  @return true if any null values was found, false otherwise.
1216  */
1217  bool fill(Item **items, uint item_count);
1218 
1219  private:
1220  virtual void set(uint pos, Item *item) = 0;
1221 
1222  /**
1223  Resize and then sort the IN-list array, so we can do efficient lookup with
1224  binary_search.
1225  */
1226  virtual void resize_and_sort() = 0;
1227 };
1228 
1229 class in_string final : public in_vector {
1233  // String objects are not sortable, sort pointers instead.
1236 
1237  public:
1238  in_string(MEM_ROOT *mem_root, uint elements, const CHARSET_INFO *cs);
1240  return new (mem_root) Item_string(collation);
1241  }
1242  void value_to_item(uint pos, Item_basic_constant *item) const override {
1244  }
1245  bool find_item(Item *item) override;
1246  bool compare_elems(uint pos1, uint pos2) const override;
1247 
1248  private:
1249  void set(uint pos, Item *item) override;
1250  void resize_and_sort() override;
1251 };
1252 
1253 class in_longlong : public in_vector {
1254  public:
1258  };
1259 
1260  protected:
1262 
1263  public:
1265  : in_vector(elements), base(mem_root, elements) {}
1267  /*
1268  We've created a signed INT, this may not be correct in the
1269  general case (see BUG#19342).
1270  */
1271  return new (mem_root) Item_int(0LL);
1272  }
1273  void value_to_item(uint pos, Item_basic_constant *item) const override {
1274  down_cast<Item_int *>(item)->value = base[pos].val;
1275  item->unsigned_flag = base[pos].unsigned_flag;
1276  }
1277  bool find_item(Item *item) override;
1278  bool compare_elems(uint pos1, uint pos2) const override;
1279 
1280  private:
1281  void set(uint pos, Item *item) override { val_item(item, &base[pos]); }
1282  void resize_and_sort() override;
1283  virtual void val_item(Item *item, packed_longlong *result);
1284 };
1285 
1287  public:
1289  : in_longlong(mem_root, elements) {}
1291  return new (mem_root) Item_temporal(MYSQL_TYPE_DATETIME, 0LL);
1292  }
1293 
1294  private:
1295  void val_item(Item *item, packed_longlong *result) override;
1296 };
1297 
1299  public:
1301  : in_longlong(mem_root, elements) {}
1303  return new (mem_root) Item_temporal(MYSQL_TYPE_TIME, 0LL);
1304  }
1305 
1306  private:
1307  void val_item(Item *item, packed_longlong *result) override;
1308 };
1309 
1310 /*
1311  Class to represent a vector of constant DATE/DATETIME values.
1312  Values are obtained with help of the get_datetime_value() function.
1313  If the left item is a constant one then its value is cached in the
1314  lval_cache variable.
1315 */
1317  /* An item used to issue warnings. */
1319  /* Cache for the left item. */
1321 
1322  public:
1323  in_datetime(MEM_ROOT *mem_root, Item *warn_item_arg, uint elements)
1324  : in_longlong(mem_root, elements),
1325  warn_item(warn_item_arg),
1326  lval_cache(nullptr) {}
1328  return new (mem_root) Item_temporal(MYSQL_TYPE_DATETIME, 0LL);
1329  }
1330 
1331  private:
1332  void set(uint pos, Item *item) override;
1333  void val_item(Item *item, packed_longlong *result) override;
1334 };
1335 
1336 class in_double final : public in_vector {
1338 
1339  public:
1341  : in_vector(elements), base(mem_root, elements) {}
1343  return new (mem_root) Item_float(0.0, 0);
1344  }
1345  void value_to_item(uint pos, Item_basic_constant *item) const override {
1346  down_cast<Item_float *>(item)->value = base[pos];
1347  }
1348  bool find_item(Item *item) override;
1349  bool compare_elems(uint pos1, uint pos2) const override;
1350 
1351  private:
1352  void set(uint pos, Item *item) override;
1353  void resize_and_sort() override;
1354 };
1355 
1356 class in_decimal final : public in_vector {
1358 
1359  public:
1361  : in_vector(elements), base(mem_root, elements) {}
1363  return new (mem_root) Item_decimal(0, false);
1364  }
1365  void value_to_item(uint pos, Item_basic_constant *item) const override {
1366  down_cast<Item_decimal *>(item)->set_decimal_value(&base[pos]);
1367  }
1368  bool find_item(Item *item) override;
1369  bool compare_elems(uint pos1, uint pos2) const override;
1370 
1371  private:
1372  void set(uint pos, Item *item) override;
1373  void resize_and_sort() override;
1374 };
1375 
1376 /*
1377 ** Classes for easy comparing of non const items
1378 */
1379 
1380 class cmp_item {
1381  public:
1383  virtual ~cmp_item() {}
1384  virtual void store_value(Item *item) = 0;
1385  /**
1386  @returns result (true, false or UNKNOWN) of
1387  "stored argument's value <> item's value"
1388  */
1389  virtual int cmp(Item *item) = 0;
1390  // for optimized IN with row
1391  virtual int compare(const cmp_item *item) const = 0;
1392 
1393  /**
1394  Find the appropriate comparator for the given type.
1395 
1396  @param result_type Used to find the appropriate comparator.
1397  @param item Item object used to distinguish temporal types.
1398  @param cs Charset
1399 
1400  @return
1401  New cmp_item_xxx object.
1402  */
1403  static cmp_item *get_comparator(Item_result result_type, const Item *item,
1404  const CHARSET_INFO *cs);
1405  virtual cmp_item *make_same() = 0;
1406  virtual void store_value_by_template(cmp_item *, Item *item) {
1407  store_value(item);
1408  }
1409 };
1410 
1411 /// cmp_item which stores a scalar (i.e. non-ROW).
1412 class cmp_item_scalar : public cmp_item {
1413  protected:
1414  bool m_null_value; ///< If stored value is NULL
1415  void set_null_value(bool nv) { m_null_value = nv; }
1416 };
1417 
1419  private:
1424 
1425  public:
1427  : value(value_buff, sizeof(value_buff), cs), cmp_charset(cs) {}
1428 
1429  virtual int compare(const cmp_item *ci) const {
1430  const cmp_item_string *l_cmp = down_cast<const cmp_item_string *>(ci);
1431  return sortcmp(value_res, l_cmp->value_res, cmp_charset);
1432  }
1433 
1434  virtual void store_value(Item *item) {
1435  String *res = item->val_str(&value);
1436  if (res && (res != &value || !res->is_alloced())) {
1437  // 'res' may point in item's transient internal data, so make a copy
1438  value.copy(*res);
1439  }
1440  value_res = &value;
1441  set_null_value(item->null_value);
1442  }
1443 
1444  virtual int cmp(Item *arg) {
1445  char buff[STRING_BUFFER_USUAL_SIZE];
1446  String tmp(buff, sizeof(buff), cmp_charset);
1447  String *res = arg->val_str(&tmp);
1448  if (m_null_value || arg->null_value) return UNKNOWN;
1449  if (value_res && res)
1450  return sortcmp(value_res, res, cmp_charset) != 0;
1451  else if (!value_res && !res)
1452  return false;
1453  else
1454  return true;
1455  }
1456  virtual cmp_item *make_same();
1457 };
1458 
1461 
1462  public:
1463  cmp_item_int() {} /* Remove gcc warning */
1464  void store_value(Item *item) override {
1465  value = item->val_int();
1466  set_null_value(item->null_value);
1467  }
1468  int cmp(Item *arg) override {
1469  const bool rc = value != arg->val_int();
1470  return (m_null_value || arg->null_value) ? UNKNOWN : rc;
1471  }
1472  int compare(const cmp_item *ci) const override {
1473  const cmp_item_int *l_cmp = down_cast<const cmp_item_int *>(ci);
1474  return (value < l_cmp->value) ? -1 : ((value == l_cmp->value) ? 0 : 1);
1475  }
1476  cmp_item *make_same() override;
1477 };
1478 
1479 /*
1480  Compare items of temporal type.
1481  Values are obtained with: get_datetime_value() (DATE/DATETIME/TIMESTAMP) and
1482  get_time_value() (TIME).
1483  If the left item is a constant one then its value is cached in the
1484  lval_cache variable.
1485 */
1488 
1489  public:
1490  /* Item used for issuing warnings. */
1491  const Item *warn_item;
1492  /* Cache for the left item. */
1494  /// Distinguish between DATE/DATETIME/TIMESTAMP and TIME
1495  bool has_date;
1496 
1497  cmp_item_datetime(const Item *warn_item_arg);
1498  void store_value(Item *item) override;
1499  int cmp(Item *arg) override;
1500  int compare(const cmp_item *ci) const override;
1501  cmp_item *make_same() override;
1502 };
1503 
1505  double value;
1506 
1507  public:
1508  cmp_item_real() {} /* Remove gcc warning */
1509  void store_value(Item *item) override {
1510  value = item->val_real();
1511  set_null_value(item->null_value);
1512  }
1513  int cmp(Item *arg) override {
1514  const bool rc = value != arg->val_real();
1515  return (m_null_value || arg->null_value) ? UNKNOWN : rc;
1516  }
1517  int compare(const cmp_item *ci) const override {
1518  const cmp_item_real *l_cmp = down_cast<const cmp_item_real *>(ci);
1519  return (value < l_cmp->value) ? -1 : ((value == l_cmp->value) ? 0 : 1);
1520  }
1521  cmp_item *make_same() override;
1522 };
1523 
1526 
1527  public:
1528  cmp_item_decimal() {} /* Remove gcc warning */
1529  void store_value(Item *item);
1530  int cmp(Item *arg);
1531  int compare(const cmp_item *c) const;
1532  cmp_item *make_same();
1533 };
1534 
1535 /**
1536  CASE ... WHEN ... THEN ... END function implementation.
1537 
1538  When there is no expression between CASE and the first WHEN
1539  (the CASE expression) then this function simple checks all WHEN expressions
1540  one after another. When some WHEN expression evaluated to TRUE then the
1541  value of the corresponding THEN expression is returned.
1542 
1543  When the CASE expression is specified then it is compared to each WHEN
1544  expression individually. When an equal WHEN expression is found
1545  corresponding THEN expression is returned.
1546  In order to do correct comparisons several comparators are used. One for
1547  each result type. Different result types that are used in particular
1548  CASE ... END expression are collected in the resolve_type() member
1549  function and only comparators for there result types are used.
1550 */
1551 
1553  typedef Item_func super;
1554 
1556  enum Item_result cached_result_type, left_result_type;
1561  cmp_item *cmp_items[5]; /* For all result types */
1563 
1564  public:
1565  Item_func_case(const POS &pos, List<Item> &list, Item *first_expr_arg,
1566  Item *else_expr_arg)
1567  : super(pos),
1568  first_expr_num(-1),
1569  else_expr_num(-1),
1570  cached_result_type(INT_RESULT),
1572  case_item(0) {
1573  null_on_null = false;
1574  ncases = list.elements;
1575  if (first_expr_arg) {
1576  first_expr_num = list.elements;
1577  list.push_back(first_expr_arg);
1578  }
1579  if (else_expr_arg) {
1580  else_expr_num = list.elements;
1581  list.push_back(else_expr_arg);
1582  }
1583  set_arguments(list, true);
1584  memset(&cmp_items, 0, sizeof(cmp_items));
1585  }
1586  int get_first_expr_num() const { return first_expr_num; }
1587  int get_else_expr_num() const { return else_expr_num; }
1588  double val_real() override;
1589  longlong val_int() override;
1590  String *val_str(String *) override;
1591  my_decimal *val_decimal(my_decimal *) override;
1592  bool val_json(Json_wrapper *wr) override;
1593  bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
1594  bool get_time(MYSQL_TIME *ltime) override;
1595  bool fix_fields(THD *thd, Item **ref) override;
1596  bool resolve_type(THD *) override;
1597  uint decimal_precision() const override;
1598  enum Item_result result_type() const override { return cached_result_type; }
1599  const char *func_name() const override { return "case"; }
1600  void print(const THD *thd, String *str,
1601  enum_query_type query_type) const override;
1602  Item *find_item(String *str);
1603  const CHARSET_INFO *compare_collation() const override {
1604  return cmp_collation.collation;
1605  }
1606  void cleanup() override;
1607  enum Functype functype() const override { return CASE_FUNC; }
1608 };
1609 
1610 /**
1611  in_expr [NOT] IN (in_value_list).
1612 
1613  The current implementation distinguishes 2 cases:
1614  1) all items in in_value_list are constants and have the same
1615  result type. This case is handled by in_vector class.
1616  2) otherwise Item_func_in employs several cmp_item objects to perform
1617  comparisons of in_expr and an item from in_value_list. One cmp_item
1618  object for each result type. Different result types are collected in the
1619  resolve_type() member function by means of collect_cmp_types() function.
1620 */
1622  public:
1623  /// An array of values, created when the bisection lookup method is used
1625  /**
1626  If there is some NULL among @<in value list@>, during a val_int() call; for
1627  example
1628  IN ( (1,(3,'col')), ... ), where 'col' is a column which evaluates to
1629  NULL.
1630  */
1632  /**
1633  Set to true by resolve_type() if the IN list contains a
1634  dependent subquery, in which case condition filtering will not be
1635  calculated for this item.
1636  */
1639  cmp_item *cmp_items[6]; /* One cmp_item for each result type */
1641 
1642  Item_func_in(const POS &pos, PT_item_list *list, bool is_negation)
1643  : Item_func_opt_neg(pos, list, is_negation),
1644  array(NULL),
1645  have_null(false),
1647  memset(&cmp_items, 0, sizeof(cmp_items));
1648  allowed_arg_cols = 0; // Fetch this value from first argument
1649  }
1650  longlong val_int() override;
1651  bool fix_fields(THD *, Item **) override;
1652  void fix_after_pullout(SELECT_LEX *parent_select,
1653  SELECT_LEX *removed_select) override;
1654  bool resolve_type(THD *) override;
1655  uint decimal_precision() const override { return 1; }
1656 
1657  /**
1658  Cleanup data and comparator arrays.
1659 
1660  @note Used during regular cleanup and to free arrays after GC substitution.
1661  @see substitute_gc().
1662  */
1664  uint i;
1665  destroy(array);
1666  array = 0;
1667  for (i = 0; i <= (uint)DECIMAL_RESULT + 1; i++) {
1668  destroy(cmp_items[i]);
1669  cmp_items[i] = 0;
1670  }
1671  }
1672 
1673  void cleanup() override {
1674  DBUG_ENTER("Item_func_in::cleanup");
1676  cleanup_arrays();
1678  }
1679  optimize_type select_optimize() const override { return OPTIMIZE_KEY; }
1680  void print(const THD *thd, String *str,
1681  enum_query_type query_type) const override;
1682  enum Functype functype() const override { return IN_FUNC; }
1683  const char *func_name() const override { return " IN "; }
1684  bool is_bool_func() const override { return true; }
1685  const CHARSET_INFO *compare_collation() const override {
1686  return cmp_collation.collation;
1687  }
1688  bool gc_subst_analyzer(uchar **) override { return true; }
1689 
1690  float get_filtering_effect(THD *thd, table_map filter_for_table,
1691  table_map read_tables,
1692  const MY_BITMAP *fields_to_ignore,
1693  double rows_in_table) override;
1694 
1695  private:
1696  /**
1697  Usable if @<in value list@> is made only of constants. Returns true if one
1698  of these constants contains a NULL. Example:
1699  IN ( (-5, (12,NULL)), ... ).
1700  */
1701  bool list_contains_null();
1702  /**
1703  Utility function to help calculate the total filtering effect of
1704  IN predicates. This function calculates the filtering effect from
1705  a single field (or field reference) on the left hand side of the
1706  expression.
1707 
1708  @param fieldref Field (or field reference) on left hand side of
1709  IN, i.e., this function should be called for
1710  each fi in "(f1,...,fn) IN (values)"
1711  @param filter_for_table The table we are calculating filter effect for
1712  @param fields_to_ignore Fields in 'filter_for_table' that should not
1713  be part of the filter calculation. The filtering
1714  effect of these fields are already part of the
1715  calculation somehow (e.g. because there is a
1716  predicate "col = <const>", and the optimizer
1717  has decided to do ref access on 'col').
1718  @param rows_in_table The number of rows in table 'filter_for_table'
1719 
1720  @return the filtering effect (between 0 and 1) 'the_field'
1721  participates with in this IN predicate.
1722  */
1724  table_map filter_for_table,
1725  const MY_BITMAP *fields_to_ignore,
1726  double rows_in_table);
1727 };
1728 
1729 class cmp_item_row : public cmp_item {
1732 
1733  public:
1734  cmp_item_row() : comparators(nullptr), n(0) {}
1735  cmp_item_row(THD *thd, Item *item) : comparators(nullptr), n(item->cols()) {
1736  alloc_comparators(thd, item);
1737  }
1738  ~cmp_item_row();
1739 
1741  : comparators(other.comparators), n(other.n) {
1742  other.comparators = nullptr;
1743  other.n = 0;
1744  }
1745 
1746  void store_value(Item *item);
1747  int cmp(Item *arg);
1748  int compare(const cmp_item *arg) const;
1749  cmp_item *make_same();
1750  void store_value_by_template(cmp_item *tmpl, Item *);
1751  void set_comparator(uint col, cmp_item *comparator) {
1752  comparators[col] = comparator;
1753  }
1754 
1755  private:
1756  bool alloc_comparators(THD *thd, Item *item);
1757 };
1758 
1759 class in_row final : public in_vector {
1762  // Sort pointers, rather than objects.
1764 
1765  public:
1766  in_row(MEM_ROOT *mem_root, uint elements, cmp_item_row *cmp);
1767  bool is_row_result() const override { return true; }
1768  bool find_item(Item *item) override;
1769  bool compare_elems(uint pos1, uint pos2) const override;
1770  void set_comparator(uint col, cmp_item *comparator) {
1771  tmp->set_comparator(col, comparator);
1772  }
1774  DBUG_ASSERT(false);
1775  return nullptr;
1776  }
1777  void value_to_item(uint, Item_basic_constant *) const override {
1778  DBUG_ASSERT(false);
1779  }
1780 
1781  private:
1782  void set(uint pos, Item *item) override;
1783  void resize_and_sort() override;
1784 };
1785 
1786 /* Functions used by where clause */
1787 
1789  protected:
1791 
1792  public:
1795  null_on_null = false;
1796  }
1797  longlong val_int() override;
1798  enum Functype functype() const override { return ISNULL_FUNC; }
1799  bool resolve_type(THD *thd) override;
1800  const char *func_name() const override { return "isnull"; }
1801  /* Optimize case of not_null_column IS NULL */
1802  void update_used_tables() override;
1803 
1804  float get_filtering_effect(THD *thd, table_map filter_for_table,
1805  table_map read_tables,
1806  const MY_BITMAP *fields_to_ignore,
1807  double rows_in_table) override;
1808  optimize_type select_optimize() const override { return OPTIMIZE_NULL; }
1809  Item *neg_transformer(THD *thd) override;
1810  const CHARSET_INFO *compare_collation() const override {
1811  return args[0]->collation.collation;
1812  }
1813  bool fix_fields(THD *thd, Item **ref) override;
1814 };
1815 
1816 /* Functions used by HAVING for rewriting IN subquery */
1817 
1818 /*
1819  This is like IS NOT NULL but it also remembers if it ever has
1820  encountered a NULL; it remembers this in the "was_null" property of the
1821  "owner" item.
1822 */
1825 
1826  public:
1828  : Item_func_isnull(a), owner(ow) {}
1829  enum Functype functype() const override { return ISNOTNULLTEST_FUNC; }
1830  longlong val_int() override;
1831  const char *func_name() const override { return "<is_not_null_test>"; }
1832  void update_used_tables() override;
1833  /**
1834  We add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE.
1835 
1836  @retval Always RAND_TABLE_BIT
1837  */
1839  return RAND_TABLE_BIT;
1840  }
1841 };
1842 
1845 
1846  public:
1849  : Item_bool_func(pos, a), abort_on_null(0) {}
1850 
1851  longlong val_int() override;
1852  enum Functype functype() const override { return ISNOTNULL_FUNC; }
1853  bool resolve_type(THD *) override {
1854  max_length = 1;
1855  maybe_null = false;
1856  return false;
1857  }
1858  const char *func_name() const override { return "isnotnull"; }
1859  optimize_type select_optimize() const override { return OPTIMIZE_NULL; }
1860  table_map not_null_tables() const override {
1861  return abort_on_null ? not_null_tables_cache : 0;
1862  }
1863  Item *neg_transformer(THD *thd) override;
1864  void print(const THD *thd, String *str,
1865  enum_query_type query_type) const override;
1866  const CHARSET_INFO *compare_collation() const override {
1867  return args[0]->collation.collation;
1868  }
1869  void top_level_item() override { abort_on_null = true; }
1870 
1871  float get_filtering_effect(THD *thd, table_map filter_for_table,
1872  table_map read_tables,
1873  const MY_BITMAP *fields_to_ignore,
1874  double rows_in_table) override;
1875 };
1876 
1879 
1881 
1883 
1884  bool escape_evaluated; ///< Tells if the escape clause has been evaluated.
1885  bool eval_escape_clause(THD *thd);
1886 
1887  public:
1888  int escape;
1889 
1890  Item_func_like(Item *a, Item *b, Item *escape_arg, bool escape_used)
1891  : Item_bool_func2(a, b),
1892  escape_item(escape_arg),
1893  escape_used_in_parsing(escape_used),
1895  Item_func_like(const POS &pos, Item *a, Item *b, Item *opt_escape_arg)
1896  : super(pos, a, b),
1897  escape_item(opt_escape_arg),
1898  escape_used_in_parsing(opt_escape_arg != NULL),
1900 
1901  bool itemize(Parse_context *pc, Item **res) override;
1902 
1903  longlong val_int() override;
1904  enum Functype functype() const override { return LIKE_FUNC; }
1905  optimize_type select_optimize() const override;
1906  cond_result eq_cmp_result() const override { return COND_TRUE; }
1907  const char *func_name() const override { return "like"; }
1908  bool fix_fields(THD *thd, Item **ref) override;
1909  void cleanup() override;
1910  /**
1911  @retval true non default escape char specified
1912  using "expr LIKE pat ESCAPE 'escape_char'" syntax
1913  */
1915 
1916  /**
1917  Has the escape clause been evaluated? It only needs to be evaluated
1918  once per execution, since we require it to be constant during execution.
1919  The escape member has a valid value if and only if this function returns
1920  true.
1921  */
1922  bool escape_is_evaluated() const { return escape_evaluated; }
1923 
1924  float get_filtering_effect(THD *thd, table_map filter_for_table,
1925  table_map read_tables,
1926  const MY_BITMAP *fields_to_ignore,
1927  double rows_in_table) override;
1928 
1929  private:
1930  /**
1931  The method updates covering keys depending on the
1932  length of wild string prefix.
1933 
1934  @param thd Pointer to THD object.
1935 
1936  @retval true if error happens during wild string prefix claculation,
1937  false otherwise.
1938  */
1939  bool check_covering_prefix_keys(THD *thd);
1940 };
1941 
1942 class Item_cond : public Item_bool_func {
1944 
1945  protected:
1948 
1949  public:
1950  /* Item_cond() is only used to create top level items */
1953  list.push_back(i1);
1954  list.push_back(i2);
1955  }
1956  Item_cond(const POS &pos, Item *i1, Item *i2)
1958  list.push_back(i1);
1959  list.push_back(i2);
1960  }
1961 
1962  Item_cond(THD *thd, Item_cond *item);
1964  : Item_bool_func(), list(nlist), abort_on_null(0) {}
1965  bool add(Item *item) {
1966  DBUG_ASSERT(item);
1967  return list.push_back(item);
1968  }
1969  bool add_at_head(Item *item) {
1970  DBUG_ASSERT(item);
1971  return list.push_front(item);
1972  }
1973  void add_at_head(List<Item> *nlist) {
1974  DBUG_ASSERT(nlist->elements);
1975  list.prepend(nlist);
1976  }
1977 
1978  bool itemize(Parse_context *pc, Item **res) override;
1979 
1980  bool fix_fields(THD *, Item **ref) override;
1981  void fix_after_pullout(SELECT_LEX *parent_select,
1982  SELECT_LEX *removed_select) override;
1983 
1984  Type type() const override { return COND_ITEM; }
1986  bool eq(const Item *item, bool binary_cmp) const override;
1987  table_map used_tables() const override { return used_tables_cache; }
1988  void update_used_tables() override;
1989  void print(const THD *thd, String *str,
1990  enum_query_type query_type) const override;
1991  void split_sum_func(THD *thd, Ref_item_array ref_item_array,
1992  List<Item> &fields) override;
1993  void top_level_item() override { abort_on_null = true; }
1994  void copy_andor_arguments(THD *thd, Item_cond *item);
1995  bool walk(Item_processor processor, enum_walk walk, uchar *arg) override;
1996  Item *transform(Item_transformer transformer, uchar *arg) override;
1997  void traverse_cond(Cond_traverser, void *arg, traverse_order order) override;
1998  void neg_arguments(THD *thd);
1999  bool subst_argument_checker(uchar **) override { return true; }
2000  Item *compile(Item_analyzer analyzer, uchar **arg_p,
2001  Item_transformer transformer, uchar *arg_t) override;
2002  bool remove_const_conds(THD *thd, Item *item, Item **new_item);
2003  bool is_top_level_item() const { return abort_on_null; }
2004  bool equality_substitution_analyzer(uchar **) override { return true; }
2005 };
2006 
2007 /*
2008  The class Item_equal is used to represent conjunctions of equality
2009  predicates of the form field1 = field2, and field=const in where
2010  conditions and on expressions.
2011 
2012  All equality predicates of the form field1=field2 contained in a
2013  conjunction are substituted for a sequence of items of this class.
2014  An item of this class Item_equal(f1,f2,...fk) represents a
2015  multiple equality f1=f2=...=fk.
2016 
2017  If a conjunction contains predicates f1=f2 and f2=f3, a new item of
2018  this class is created Item_equal(f1,f2,f3) representing the multiple
2019  equality f1=f2=f3 that substitutes the above equality predicates in
2020  the conjunction.
2021  A conjunction of the predicates f2=f1 and f3=f1 and f3=f2 will be
2022  substituted for the item representing the same multiple equality
2023  f1=f2=f3.
2024  An item Item_equal(f1,f2) can appear instead of a conjunction of
2025  f2=f1 and f1=f2, or instead of just the predicate f1=f2.
2026 
2027  An item of the class Item_equal inherits equalities from outer
2028  conjunctive levels.
2029 
2030  Suppose we have a where condition of the following form:
2031  WHERE f1=f2 AND f3=f4 AND f3=f5 AND ... AND (...OR (f1=f3 AND ...)).
2032  In this case:
2033  f1=f2 will be substituted for Item_equal(f1,f2);
2034  f3=f4 and f3=f5 will be substituted for Item_equal(f3,f4,f5);
2035  f1=f3 will be substituted for Item_equal(f1,f2,f3,f4,f5);
2036 
2037  An object of the class Item_equal can contain an optional constant
2038  item c. Then it represents a multiple equality of the form
2039  c=f1=...=fk.
2040 
2041  Objects of the class Item_equal are used for the following:
2042 
2043  1. An object Item_equal(t1.f1,...,tk.fk) allows us to consider any
2044  pair of tables ti and tj as joined by an equi-condition.
2045  Thus it provide us with additional access paths from table to table.
2046 
2047  2. An object Item_equal(t1.f1,...,tk.fk) is applied to deduce new
2048  SARGable predicates:
2049  f1=...=fk AND P(fi) => f1=...=fk AND P(fi) AND P(fj).
2050  It also can give us additional index scans and can allow us to
2051  improve selectivity estimates.
2052 
2053  3. An object Item_equal(t1.f1,...,tk.fk) is used to optimize the
2054  selected execution plan for the query: if table ti is accessed
2055  before the table tj then in any predicate P in the where condition
2056  the occurrence of tj.fj is substituted for ti.fi. This can allow
2057  an evaluation of the predicate at an earlier step.
2058 
2059  When feature 1 is supported they say that join transitive closure
2060  is employed.
2061  When feature 2 is supported they say that search argument transitive
2062  closure is employed.
2063  Both features are usually supported by preprocessing original query and
2064  adding additional predicates.
2065  We do not just add predicates, we rather dynamically replace some
2066  predicates that can not be used to access tables in the investigated
2067  plan for those, obtained by substitution of some fields for equal fields,
2068  that can be used.
2069 
2070  Prepared Statements/Stored Procedures note: instances of class
2071  Item_equal are created only at the time a PS/SP is executed and
2072  are deleted in the end of execution. All changes made to these
2073  objects need not be registered in the list of changes of the parse
2074  tree and do not harm PS/SP re-execution.
2075 
2076  Item equal objects are employed only at the optimize phase. Usually they are
2077  not supposed to be evaluated. Yet in some cases we call the method val_int()
2078  for them. We have to take care of restricting the predicate such an
2079  object represents f1=f2= ...=fn to the projection of known fields fi1=...=fik.
2080 */
2082  List<Item_field> fields; /* list of equal field items */
2083  Item *const_item; /* optional constant item equal to fields items */
2088 
2089  public:
2090  inline Item_equal()
2091  : Item_bool_func(), const_item(0), eval_item(0), cond_false(0) {}
2092  Item_equal(Item_field *f1, Item_field *f2);
2093  Item_equal(Item *c, Item_field *f);
2094  Item_equal(Item_equal *item_equal);
2095  ~Item_equal() override { destroy(eval_item); }
2096 
2097  inline Item *get_const() { return const_item; }
2098  void set_const(Item *c) { const_item = c; }
2099  bool compare_const(THD *thd, Item *c);
2100  bool add(THD *thd, Item *c, Item_field *f);
2101  bool add(THD *thd, Item *c);
2102  void add(Item_field *f);
2103  uint members();
2104  bool contains(Field *field);
2105  /**
2106  Get the first field of multiple equality, use for semantic checking.
2107 
2108  @retval First field in the multiple equality.
2109  */
2110  Item_field *get_first() { return fields.head(); }
2111  Item_field *get_subst_item(const Item_field *field);
2112  bool merge(THD *thd, Item_equal *item);
2113  bool update_const(THD *thd);
2114  enum Functype functype() const override { return MULT_EQUAL_FUNC; }
2115  longlong val_int() override;
2116  const char *func_name() const override { return "multiple equal"; }
2117  optimize_type select_optimize() const override { return OPTIMIZE_EQUAL; }
2118  /**
2119  Order field items in multiple equality according to a sorting criteria.
2120 
2121  The function perform ordering of the field items in the Item_equal
2122  object according to the criteria determined by the cmp callback parameter.
2123  If cmp(item_field1,item_field2,arg)<0 than item_field1 must be
2124  placed after item_field2.
2125 
2126  The function sorts field items by the exchange sort algorithm.
2127  The list of field items is looked through and whenever two neighboring
2128  members follow in a wrong order they are swapped. This is performed
2129  again and again until we get all members in a right order.
2130 
2131  @param compare function to compare field item
2132  */
2133  template <typename Node_cmp_func>
2134  void sort(Node_cmp_func compare) {
2135  fields.sort(compare);
2136  }
2137  friend class Item_equal_iterator;
2138  bool resolve_type(THD *) override;
2139  bool fix_fields(THD *thd, Item **ref) override;
2140  void update_used_tables() override;
2141  bool walk(Item_processor processor, enum_walk walk, uchar *arg) override;
2142  Item *transform(Item_transformer transformer, uchar *arg) override;
2143  void print(const THD *thd, String *str,
2144  enum_query_type query_type) const override;
2145  const CHARSET_INFO *compare_collation() const override {
2146  return fields.head()->collation.collation;
2147  }
2148 
2149  bool equality_substitution_analyzer(uchar **) override { return true; }
2150 
2152 
2153  float get_filtering_effect(THD *thd, table_map filter_for_table,
2154  table_map read_tables,
2155  const MY_BITMAP *fields_to_ignore,
2156  double rows_in_table) override;
2157  Item *m_const_folding[2]; ///< temporary area used for constant folding
2158  private:
2160 };
2161 
2162 class COND_EQUAL {
2163  public:
2164  uint max_members; /* max number of members the current level
2165  list and all lower level lists */
2166  COND_EQUAL *upper_levels; /* multiple equalities of upper and levels */
2167  List<Item_equal> current_level; /* list of multiple equalities of
2168  the current and level */
2170 };
2171 
2172 class Item_equal_iterator : public List_iterator_fast<Item_field> {
2173  public:
2174  inline Item_equal_iterator(Item_equal &item_equal)
2175  : List_iterator_fast<Item_field>(item_equal.fields) {}
2176  inline Item_field *operator++(int) {
2177  Item_field *item = (*(List_iterator_fast<Item_field> *)this)++;
2178  return item;
2179  }
2181 };
2182 
2184  public:
2185  COND_EQUAL cond_equal; /* contains list of Item_equal objects for
2186  the current and level and reference
2187  to multiple equalities of upper and levels */
2189 
2190  Item_cond_and(Item *i1, Item *i2) : Item_cond(i1, i2) {}
2191  Item_cond_and(const POS &pos, Item *i1, Item *i2) : Item_cond(pos, i1, i2) {}
2192 
2193  Item_cond_and(THD *thd, Item_cond_and *item) : Item_cond(thd, item) {}
2194  Item_cond_and(List<Item> &list_arg) : Item_cond(list_arg) {}
2195  enum Functype functype() const override { return COND_AND_FUNC; }
2196  longlong val_int() override;
2197  const char *func_name() const override { return "and"; }
2198  Item *copy_andor_structure(THD *thd) override {
2199  Item_cond_and *item;
2200  if ((item = new Item_cond_and(thd, this)))
2201  item->copy_andor_arguments(thd, this);
2202  return item;
2203  }
2204  Item *neg_transformer(THD *thd) override;
2205  bool gc_subst_analyzer(uchar **) override { return true; }
2206 
2207  float get_filtering_effect(THD *thd, table_map filter_for_table,
2208  table_map read_tables,
2209  const MY_BITMAP *fields_to_ignore,
2210  double rows_in_table) override;
2211 };
2212 
2213 class Item_cond_or final : public Item_cond {
2214  public:
2216 
2217  Item_cond_or(Item *i1, Item *i2) : Item_cond(i1, i2) {}
2218  Item_cond_or(const POS &pos, Item *i1, Item *i2) : Item_cond(pos, i1, i2) {}
2219 
2220  Item_cond_or(THD *thd, Item_cond_or *item) : Item_cond(thd, item) {}
2221  Item_cond_or(List<Item> &list_arg) : Item_cond(list_arg) {}
2222  enum Functype functype() const override { return COND_OR_FUNC; }
2223  longlong val_int() override;
2224  const char *func_name() const override { return "or"; }
2225  Item *copy_andor_structure(THD *thd) override {
2226  Item_cond_or *item;
2227  if ((item = new Item_cond_or(thd, this)))
2228  item->copy_andor_arguments(thd, this);
2229  return item;
2230  }
2231  Item *neg_transformer(THD *thd) override;
2232  bool gc_subst_analyzer(uchar **) override { return true; }
2233 
2234  float get_filtering_effect(THD *thd, table_map filter_for_table,
2235  table_map read_tables,
2236  const MY_BITMAP *fields_to_ignore,
2237  double rows_in_table) override;
2238 };
2239 
2240 /* Some useful inline functions */
2241 
2242 inline Item *and_conds(Item *a, Item *b) {
2243  if (!b) return a;
2244  if (!a) return b;
2245 
2246  Item *item = new Item_cond_and(a, b);
2247  if (item == nullptr) return nullptr;
2248  item->top_level_item();
2249  return item;
2250 }
2251 
2252 longlong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
2253  const Item *warn_item, bool *is_null);
2254 
2255 // TODO: the next two functions should be moved to sql_time.{h,cc}
2256 bool get_mysql_time_from_str_no_warn(THD *thd, String *str, MYSQL_TIME *l_time,
2258 
2259 bool get_mysql_time_from_str(THD *thd, String *str,
2260  enum_mysql_timestamp_type warn_type,
2261  const char *warn_name, MYSQL_TIME *l_time);
2262 /*
2263  These need definitions from this file but the variables are defined
2264  in mysqld.h. The variables really belong in this component, but for
2265  the time being we leave them in mysqld.cc to avoid merge problems.
2266 */
2267 extern Eq_creator eq_creator;
2269 extern Ne_creator ne_creator;
2270 extern Gt_creator gt_creator;
2271 extern Lt_creator lt_creator;
2272 extern Ge_creator ge_creator;
2273 extern Le_creator le_creator;
2274 
2275 #endif /* ITEM_CMPFUNC_INCLUDED */
Definition: item.h:733
bool list_contains_null()
Usable if <in value list> is made only of constants.
Definition: item_cmpfunc.cc:4340
bool contains(Field *field)
Check whether a field is referred in the multiple equality.
Definition: item_cmpfunc.cc:5934
enum Item_result result_type() const override
Definition: item_cmpfunc.h:1111
virtual int cmp(Item *arg)
Definition: item_cmpfunc.h:1444
Definition: item_func.h:157
bool val_json(Json_wrapper *wr) override
Get the result of COALESCE as a JSON value.
Definition: item_cmpfunc.cc:3599
int compare_time_packed()
Compare arguments using numeric packed temporal representation.
Definition: item_cmpfunc.cc:1623
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1118
Item *(Item::* Item_transformer)(uchar *arg)
Definition: item.h:663
optimize_type select_optimize() const override
Definition: item_cmpfunc.h:1808
Definition: item_cmpfunc.h:2213
const CHARSET_INFO * cmp_charset
Definition: item_cmpfunc.h:1423
Item_result result_type() const override
Definition: item_cmpfunc.h:1134
bool val_bool() override
Definition: item_cmpfunc.cc:1830
Definition: item.h:3287
unsigned long long int ulonglong
Definition: my_inttypes.h:69
Item * neg_transformer(THD *thd) override
Definition: item_cmpfunc.cc:5777
cmp_item_string(const CHARSET_INFO *cs)
Definition: item_cmpfunc.h:1426
not valid for UDFs
Definition: udf_registration_types.h:44
Item_result left_result_type
Definition: item_cmpfunc.h:1638
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:1866
DTCollation cmp_collation
Definition: item_cmpfunc.h:1560
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:1810
enum Functype functype() const override
Definition: item_cmpfunc.h:1607
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:1906
const Item * warn_item
Definition: item_cmpfunc.h:1491
Item_cond(const POS &pos, Item *i1, Item *i2)
Definition: item_cmpfunc.h:1956
in_expr [NOT] IN (in_value_list).
Definition: item_cmpfunc.h:1621
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:474
int compare_row()
Definition: item_cmpfunc.cc:1713
bool equality_substitution_analyzer(uchar **) override
Definition: item_cmpfunc.h:2004
virtual double val_real()=0
int compare(const cmp_item *ci) const override
Definition: item_cmpfunc.cc:4192
Definition: item_func.h:125
Item * negated_item() override
just fake method, should never be called.
Definition: item_cmpfunc.cc:5833
Item_cond(List< Item > &nlist)
Definition: item_cmpfunc.h:1963
virtual const char * symbol(bool invert) const
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:381
void val_item(Item *item, packed_longlong *result) override
Definition: item_cmpfunc.cc:3922
void update_used_tables() override
Definition: item_cmpfunc.cc:5146
unsigned char uchar
Definition: my_inttypes.h:49
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:2353
enum Functype functype() const override
Definition: item_cmpfunc.h:1829
Item_func_coalesce(const POS &pos, PT_item_list *list)
Definition: item_cmpfunc.h:1037
List< Item_field > fields
Definition: item_cmpfunc.h:2082
Definition: item.h:3072
Definition: sql_optimizer.h:177
Definition: item.h:3984
optimize_type select_optimize() const override
Definition: item_cmpfunc.h:2117
Our own string classes, used pervasively throughout the executor.
bool fix_fields(THD *, Item **) override
Definition: item_cmpfunc.cc:1879
This Item represents a X IS NOT TRUE boolean predicate.
Definition: item_cmpfunc.h:254
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:2434
Definition: item_cmpfunc.h:676
optimize_type
Definition: item_func.h:204
my_decimal * decimal_op(my_decimal *) override
Performs the operation that this functions implements when the result type is DECIMAL.
Definition: item_cmpfunc.cc:3634
longlong val_int() override
Definition: item_cmpfunc.cc:2782
Item_func super
Definition: item_cmpfunc.h:1553
longlong value
Definition: item_cmpfunc.h:1460
t pos
Definition: dbug_analyze.cc:148
const char * func_name() const override
Definition: item_cmpfunc.h:332
Item_result
Type of the user defined function return slot and arguments
Definition: udf_registration_types.h:38
Definition: item_cmpfunc.h:421
Item_func_isnottrue(const POS &pos, Item *a)
Definition: item_cmpfunc.h:256
const char * func_name() const override
Definition: item_cmpfunc.h:735
uint decimal_precision() const override
Definition: item_cmpfunc.h:1016
Item_in_optimizer(Item *a, Item_in_subselect *b)
Definition: item_cmpfunc.h:318
const uint count
Original size of the vector.
Definition: item_cmpfunc.h:1160
Item_func_isfalse(const POS &pos, Item *a)
Definition: item_cmpfunc.h:267
Item_cond_or(List< Item > &list_arg)
Definition: item_cmpfunc.h:2221
ulonglong table_map
Definition: my_table_map.h:32
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:327
bool is_top_level_item() const
Definition: item_cmpfunc.h:484
uint decimal_precision() const override
Definition: item_cmpfunc.h:962
enum Functype functype() const override
Definition: item_cmpfunc.h:1682
Item_func_between(const POS &pos, Item *a, Item *b, Item *c, bool is_negation)
Definition: item_cmpfunc.h:943
uint used_count
The actual size of the vector (NULL may be ignored)
Definition: item_cmpfunc.h:1162
const char * func_name() const override
Definition: item_cmpfunc.h:258
virtual Item_basic_constant * create_item(MEM_ROOT *mem_root) const =0
Create an instance of Item_{type} (e.g.
const char * func_name() const override
Definition: item_cmpfunc.h:269
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:6434
Definition: item_func.h:159
longlong val_int() override
Definition: item_cmpfunc.cc:4689
cmp_item_datetime(const Item *warn_item_arg)
Definition: item_cmpfunc.cc:4162
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:756
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:1345
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:2232
bool try_year_cmp_func(Item_result type)
Definition: item_cmpfunc.cc:1172
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:815
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:808
void check_covering_prefix_keys()
Item_result cmp_type
Definition: item_cmpfunc.h:934
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:2686
Arg_comparator(Item **a1, Item **a2)
Definition: item_cmpfunc.h:116
Definition: item_func.h:188
cmp_item_row()
Definition: item_cmpfunc.h:1734
Definition: item_func.h:135
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:2221
enum Item_result cached_result_type left_result_type
Definition: item_cmpfunc.h:1556
bool merge(THD *thd, Item_equal *item)
Join members of another Item_equal object.
Definition: item_cmpfunc.cc:5958
This Item represents a X IS NOT FALSE boolean predicate.
Definition: item_cmpfunc.h:276
Item_cond_and(Item *i1, Item *i2)
Definition: item_cmpfunc.h:2190
int cmp
Definition: dbug_analyze.cc:237
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:2144
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:293
bool check_covering_prefix_keys(THD *thd)
The method updates covering keys depending on the length of wild string prefix.
Definition: item_cmpfunc.cc:5524
Item_func_in(const POS &pos, PT_item_list *list, bool is_negation)
Definition: item_cmpfunc.h:1642
Item_func_comparison is a class for comparison functions that take two arguments and return a boolean...
Definition: item_cmpfunc.h:498
Item_func_isnull(const POS &pos, Item *a)
Definition: item_cmpfunc.h:1794
my_decimal * val_decimal(my_decimal *) override
Definition: item_cmpfunc.cc:3197
Arg_comparator le_cmp
Definition: item_cmpfunc.h:942
Definition: item_cmpfunc.h:1121
Definition: item.h:3915
bool subst_argument_checker(uchar **) override
Definition: item_cmpfunc.h:1999
void fix_char_length(uint32 max_char_length_arg)
Definition: item.h:2454
longlong val_int() override
Definition: item_cmpfunc.cc:3073
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:412
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_cmpfunc.cc:3349
int compare_real()
Definition: item_cmpfunc.cc:1548
Item_func_gt(Item *a, Item *b)
Definition: item_cmpfunc.h:821
Item_func_comparison(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:503
File containing constants that can be used throughout the server.
bool compare_null_values()
Compare NULL values for two arguments.
Definition: item_cmpfunc.cc:1804
const char * func_name() const override
Definition: item_cmpfunc.h:1858
bool unsigned_flag
Definition: item.h:2701
Item_func_if(Item *a, Item *b, Item *c)
Definition: item_cmpfunc.h:1095
Some integer typedefs for easier portability.
Definition: item_cmpfunc.h:1380
Item * m_const_folding[2]
temporary area used for constant folding
Definition: item_cmpfunc.h:2157
virtual Item_bool_func * create(Item *a, Item *b) const
Definition: item_cmpfunc.cc:315
bool val_json(Json_wrapper *result) override
Get the result of COALESCE as a JSON value.
Definition: item_cmpfunc.cc:2961
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:805
char value_buff[STRING_BUFFER_USUAL_SIZE]
Definition: item_cmpfunc.h:1421
longlong val_int() override
Evaluation of AND(expr, expr, expr ...).
Definition: item_cmpfunc.cc:5229
longlong val_int() override
Definition: item_cmpfunc.cc:2300
bool is_bool_func() const override
Definition: item_cmpfunc.h:193
Item_func_nop_all(Item *a)
Definition: item_cmpfunc.h:733
void rewind(void)
Definition: sql_list.h:580
longlong val_int() override
Definition: item_cmpfunc.cc:5482
bool set_compare_func(Item_result_field *owner, Item_result type)
Definition: item_cmpfunc.cc:685
A wrapper class which provides array bounds checking.
Definition: sql_array.h:41
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_cmpfunc.cc:3209
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:750
const char * func_name() const override
Definition: item_cmpfunc.h:1073
Definition: item_func.h:126
double value
Definition: item_cmpfunc.h:1505
Gt_creator gt_creator
Definition: mysqld.cc:1260
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:1908
Item * negated_item() override
just fake method, should never be called.
Definition: item_cmpfunc.cc:5838
Definition: item_func.h:139
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:2973
Implements the comparison operator less than or equals (<=)
Definition: item_cmpfunc.h:839
XOR inherits from Item_bool_func2 because it is not optimized yet.
Definition: item_cmpfunc.h:518
Item_row * row
Definition: item_cmpfunc.h:999
in_vector(uint elements)
See Item_func_in::resolve_type() for why we need both count and used_count.
Definition: item_cmpfunc.h:1168
Item_field * get_first()
Get the first field of multiple equality, use for semantic checking.
Definition: item_cmpfunc.h:2110
uint ncases
Definition: item_cmpfunc.h:1558
bool copy()
Definition: sql_string.cc:191
A class that is capable of holding objects of any sub-type of Json_scalar.
Definition: json_dom.h:1817
int compare_string()
Definition: item_cmpfunc.cc:1487
Definition: item_func.h:134
bool compare_as_dates_with_strings
Definition: item_cmpfunc.h:937
bool val_json(Json_wrapper *wr) override
Get a JSON value from an Item.
Definition: item_cmpfunc.cc:3114
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:5302
virtual Item_bool_func * combine(List< Item > list) const
Combines a list of conditions exp op exp.
Definition: item_cmpfunc.cc:298
Le_creator()
Definition: item_cmpfunc.h:433
Eq_creator eq_creator
Definition: mysqld.cc:1257
virtual ~Gt_creator()
Definition: item_cmpfunc.h:404
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.h:983
Item_cond_or(THD *thd, Item_cond_or *item)
Definition: item_cmpfunc.h:2220
bool time_op(MYSQL_TIME *ltime) override
Definition: item_cmpfunc.cc:3653
Definition: item_cmpfunc.h:431
int compare(const cmp_item *arg) const
Definition: item_cmpfunc.cc:4131
virtual Item_bool_func * create(Item *a, Item *b) const
Definition: item_cmpfunc.cc:323
Item_cond_and(const POS &pos, Item *i1, Item *i2)
Definition: item_cmpfunc.h:2191
bool(Item::* Item_analyzer)(uchar **argp)
Definition: item.h:662
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:3037
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:963
bool escape_used_in_parsing
Definition: item_cmpfunc.h:1882
longlong val_int() override
Special NOP (No OPeration) for ALL subquery.
Definition: item_cmpfunc.cc:429
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:922
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1266
String value2
Definition: item_cmpfunc.h:935
enum Item_result result_type() const override
Definition: item_cmpfunc.h:1598
Implements the comparison operator greater than (>)
Definition: item_cmpfunc.h:819
Definition: field.h:707
Definition: item_func.h:123
in_longlong(MEM_ROOT *mem_root, uint elements)
Definition: item_cmpfunc.h:1264
const char * func_name() const override
Definition: item_cmpfunc.h:1800
Item * transform(Item_transformer transformer, uchar *arg) override
Transform an Item_cond object with a transformer callback function.
Definition: item_cmpfunc.cc:5047
Item_equal()
Definition: item_cmpfunc.h:2090
Definition: item_func.h:81
int compare(const cmp_item *ci) const override
Definition: item_cmpfunc.h:1472
Definition: item.h:5610
Definition: field_types.h:68
virtual bool l_op() const
Definition: item_cmpfunc.h:408
in_double(MEM_ROOT *mem_root, uint elements)
Definition: item_cmpfunc.h:1340
Gt_creator()
Definition: item_cmpfunc.h:403
Definition: item.h:4127
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:751
Implements the comparison operator equals (=)
Definition: item_cmpfunc.h:743
virtual void top_level_item()
Definition: item.h:1894
bool eval_escape_clause(THD *thd)
Evaluate the expression in the escape clause.
Definition: item_cmpfunc.cc:5600
Definition: item_cmpfunc.h:1091
const char * func_name() const override
Definition: item_cmpfunc.h:886
Item * neg_transformer(THD *thd) override
Definition: item_cmpfunc.cc:5731
optimize_type select_optimize() const override
Definition: item_cmpfunc.h:885
String * value_res
Definition: item_cmpfunc.h:1420
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:5410
Definition: item_cmpfunc.h:441
Item_equal_iterator(Item_equal &item_equal)
Definition: item_cmpfunc.h:2174
Definition: item_cmpfunc.h:305
const char * func_name() const override
Definition: item_cmpfunc.h:1907
bool eq(const Item *item, bool binary_cmp) const override
Definition: item_cmpfunc.cc:5007
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:884
virtual longlong val_int()=0
Definition: item_cmpfunc.h:1942
int escape
Definition: item_cmpfunc.h:1888
Sergei Dialog Client Authentication NULL
Definition: dialog.cc:352
int result_for_null_param
Definition: item_cmpfunc.h:315
Item_bool_func(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:187
virtual bool l_op() const
Definition: item_cmpfunc.h:438
COND_EQUAL * upper_levels
Definition: item_cmpfunc.h:2166
const char * func_name() const override
Definition: item_cmpfunc.h:2224
Item_func_le(Item *a, Item *b)
Definition: item_cmpfunc.h:841
uint decimal_precision() const override
Definition: item_cmpfunc.cc:3058
const char * func_name() const override
Definition: item_cmpfunc.h:806
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_func.cc:466
bool is_bool_func() const override
Definition: item_cmpfunc.h:958
void set_sub_test(Item_maxmin_subselect *item)
Definition: item_cmpfunc.h:702
const char * func_name() const override
Definition: item_cmpfunc.h:247
bool add(Item *item)
Definition: item_cmpfunc.h:1965
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:1810
bool get_time(MYSQL_TIME *ltime) override
Definition: item_cmpfunc.cc:3376
const char * func_name() const override
Definition: item_cmpfunc.h:787
Item_func_isnull(Item *a)
Definition: item_cmpfunc.h:1793
Item_result type
Definition: item_cmpfunc.h:991
const char * func_name() const override
Definition: item_cmpfunc.h:2197
Lt_creator lt_creator
Definition: mysqld.cc:1261
Item_subselect * subselect
Definition: item_cmpfunc.h:680
Item_func_like(Item *a, Item *b, Item *escape_arg, bool escape_used)
Definition: item_cmpfunc.h:1890
Definition: item_cmpfunc.h:1486
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:5439
Item * lval_cache
Definition: item_cmpfunc.h:1320
bool cond_false
Definition: item_cmpfunc.h:2086
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:1242
virtual bool l_op() const
Definition: item_cmpfunc.h:356
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:5432
String * str_op(String *) override
Coalesce - return first not NULL argument.
Definition: item_cmpfunc.cc:3588
std::string join(Container cont, const std::string &delim)
join elements of an container into a string seperated by a delimiter.
Definition: string.h:125
virtual Item_bool_func * create(Item *a, Item *b) const =0
virtual ~Comp_creator()
Definition: item_cmpfunc.h:342
void val_item(Item *item, packed_longlong *result) override
Definition: item_cmpfunc.cc:3942
int get_else_expr_num() const
Definition: item_cmpfunc.h:1587
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:2862
bool add_at_head(Item *item)
Definition: item_cmpfunc.h:1969
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1327
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:848
cmp_item_decimal()
Definition: item_cmpfunc.h:1528
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:2205
List< Item > * argument_list()
Definition: item_cmpfunc.h:1985
bool escape_was_used_in_parsing() const
Definition: item_cmpfunc.h:1914
virtual uint decimal_precision() const
Definition: item.cc:605
class udf_list * list
void set_str_value(String *str)
Definition: item.h:2801
void update_used_tables() override
Optimize case of not_null_column IS NULL.
Definition: item_cmpfunc.cc:5394
const CHARSET_INFO * collation
Definition: item_cmpfunc.h:1235
int else_expr_num
Definition: item_cmpfunc.h:1555
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:2240
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:5189
DBUG_VOID_RETURN
Definition: dbug_analyze.cc:151
in_vector * array
An array of values, created when the bisection lookup method is used.
Definition: item_cmpfunc.h:1624
This trigger type deactivates join conditions when a row has been NULL-complemented.
Definition: item_cmpfunc.h:594
virtual int compare(const cmp_item *item) const =0
bool get_time(MYSQL_TIME *ltime) override
Definition: item_cmpfunc.cc:3129
#define RAND_TABLE_BIT
Definition: sql_const.h:115
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:2185
bool itemize(Parse_context *pc, Item **res) override
Contextualization for Item_cond functional items.
Definition: item_cmpfunc.cc:4747
Definition: item_func.h:205
virtual const char * symbol(bool invert) const
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:406
void set_numeric_type() override
Definition: item_cmpfunc.h:1053
const char * func_name() const override
Definition: item_cmpfunc.h:1086
DTCollation cmp_collation
Definition: item_cmpfunc.h:103
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:6045
void value_to_item(uint, Item_basic_constant *) const override
Store the value at position pos into provided item object.
Definition: item_cmpfunc.h:1777
Item_bool_func(Item *a)
Definition: item_cmpfunc.h:181
Item * neg_transformer(THD *thd) override
a IS NULL -> a IS NOT NULL.
Definition: item_cmpfunc.cc:5764
arg_cmp_func func
Definition: item_cmpfunc.h:72
longlong int_op() override
Performs the operation that this functions implements when the result type is INT.
Definition: item_cmpfunc.cc:3612
cmp_item_real()
Definition: item_cmpfunc.h:1508
cmp_item_row(cmp_item_row &&other)
Definition: item_cmpfunc.h:1740
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:3065
const char * func_name() const override
Definition: item_cmpfunc.h:1139
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:1685
This Item represents a X IS FALSE boolean predicate.
Definition: item_cmpfunc.h:265
int compare_int_signed_unsigned()
Compare signed (*a) with unsigned (*B)
Definition: item_cmpfunc.cc:1678
optimize_type select_optimize() const override
Definition: item_cmpfunc.h:949
bool compare_elems(uint pos1, uint pos2) const override
Compare values number pos1 and pos2 for equality.
Definition: item_cmpfunc.cc:3830
Definition: item_subselect.h:73
void add_trig_func_tables()
Definition: item_cmpfunc.h:655
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:30
Item * neg_transformer(THD *thd) override
Definition: item_cmpfunc.cc:5785
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:825
int compare()
Definition: item_cmpfunc.h:140
Definition: item_cmpfunc.h:1229
enum Functype functype() const override
Definition: item_cmpfunc.h:1852
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:5138
virtual cmp_item * make_same()
Definition: item_cmpfunc.cc:4020
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:207
void store_value(Item *item) override
Definition: item_cmpfunc.h:1509
enum Functype functype() const override
Definition: item_cmpfunc.h:749
longlong val_int() override
Definition: item_cmpfunc.cc:5272
const char * func_name() const override
Definition: item_cmpfunc.h:2116
void set_null_value(bool nv)
Definition: item_cmpfunc.h:1415
Using this class is fraught with peril, and you need to be very careful when doing so...
Definition: sql_string.h:159
~cmp_item_row()
Definition: item_cmpfunc.cc:4032
bool fix_left(THD *thd, Item **ref)
Definition: item_cmpfunc.cc:1851
bool escape_evaluated
Tells if the escape clause has been evaluated.
Definition: item_cmpfunc.h:1884
Definition: item.h:714
enum_trig_type get_trig_type()
Definition: item_cmpfunc.h:670
const char * func_name() const override
Definition: item_cmpfunc.h:846
bool abort_on_null
Definition: item_cmpfunc.h:1844
in_datetime(MEM_ROOT *mem_root, Item *warn_item_arg, uint elements)
Definition: item_cmpfunc.h:1323
const char * func_name() const override
Definition: item_cmpfunc.h:826
const char * func_name() const override
Definition: item_cmpfunc.h:866
longlong val_int() override
Execute Item_func_interval().
Definition: item_cmpfunc.cc:2454
Item * negated_item() override
just fake method, should never be called.
Definition: item_cmpfunc.cc:5818
enum Functype functype() const override
Definition: item_cmpfunc.h:803
void update_used_tables() override
Definition: item_cmpfunc.cc:5287
int get_first_expr_num() const
Definition: item_cmpfunc.h:1586
Definition: item_cmpfunc.h:1504
bool resolve_type(THD *thd) override
Same as Item_func_eq, but NULL = NULL.
Definition: item_cmpfunc.cc:2167
Item_field ** ref(void)
Definition: sql_list.h:573
DTCollation cmp_collation
Definition: item_cmpfunc.h:931
interval_range * intervals
Definition: item_cmpfunc.h:1001
Definition: table.h:1294
cmp_item * cmp_items[5]
Definition: item_cmpfunc.h:1561
void cleanup() override
Definition: item_cmpfunc.cc:5589
longlong val_int() override
Definition: item_cmpfunc.cc:1849
String value0
Definition: item_cmpfunc.h:935
table_map used_tables() const override
Definition: item_cmpfunc.h:1987
Field * tmp_table_field()
Definition: item_func.h:385
enum_trig_type
Definition: item_cmpfunc.h:588
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:1273
bool find_item(Item *item) override
Calls item->val_int() or item->val_str() etc.
Definition: item_cmpfunc.cc:3822
uint32 max_length
Maximum length of result of evaluating this item, in number of bytes.
Definition: item.h:2635
int compare_binary_string()
Compare strings byte by byte.
Definition: item_cmpfunc.cc:1521
Definition: item_cmpfunc.h:1759
Item * neg_transformer(THD *thd) override
XOR can be negated by negating one of the operands:
Definition: item_cmpfunc.cc:5745
String value2
Definition: item_cmpfunc.h:105
Structure to return status from str_to_datetime(), str_to_time(), number_to_datetime(), number_to_time()
Definition: my_time.h:140
cond_result
Definition: item.h:733
longlong val_int() override
special NOT for ALL subquery.
Definition: item_cmpfunc.cc:380
Item * const_item
Definition: item_cmpfunc.h:2083
Definition: item_func.h:120
enum Item_result result_type() const override
Definition: item_cmpfunc.h:1054
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:3792
virtual void val_item(Item *item, packed_longlong *result)
Definition: item_cmpfunc.cc:3917
Definition: item_func.h:136
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:369
in_row(MEM_ROOT *mem_root, uint elements, cmp_item_row *cmp)
Definition: item_cmpfunc.cc:3900
bool subst_argument_checker(uchar **) override
Definition: item_cmpfunc.h:510
virtual const char * symbol(bool invert) const
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:372
Mem_root_array< cmp_item_row > base_objects
Definition: item_cmpfunc.h:1761
Item * neg_transformer(THD *thd) override
Apply NOT transformation to the item and return a new one.
Definition: item_cmpfunc.cc:5793
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:845
In IN->EXISTS subquery transformation, new predicates are added: WHERE inner_field=outer_field OR inn...
Definition: item_cmpfunc.h:612
Definition: item_cmpfunc.h:379
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:2561
optimize_type select_optimize() const override
Definition: item_cmpfunc.h:976
Item_func_xor(Item *i1, Item *i2)
Definition: item_cmpfunc.h:520
virtual ~cmp_item()
Definition: item_cmpfunc.h:1383
Ge_creator ge_creator
Definition: mysqld.cc:1262
String value
Definition: item_cmpfunc.h:1422
virtual void store_value(Item *item)
Definition: item_cmpfunc.h:1434
Item_func_ne(Item *a, Item *b)
Definition: item_cmpfunc.h:881
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:302
Item * negated_item() override
just fake method, should never be called.
Definition: item_cmpfunc.cc:5823
cmp_item * case_item
Definition: item_cmpfunc.h:1562
cmp_item * make_same()
Definition: item_cmpfunc.cc:4030
bool is_null() override
Definition: item_cmpfunc.cc:2089
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:1493
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:3135
Item_func_equal(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:778
uint members()
Definition: item_cmpfunc.cc:5919
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:864
enum Functype functype() const override
Definition: item_cmpfunc.h:784
void set_datetime_cmp_func(Item_result_field *owner_arg, Item **a1, Item **b1)
Definition: item_cmpfunc.cc:1230
String value1
Definition: item_cmpfunc.h:935
bool find_item(Item *item) override
Calls item->val_int() or item->val_str() etc.
Definition: item_cmpfunc.cc:3888
table_map not_null_tables() const override
Definition: item_cmpfunc.h:1860
bool fix_fields(THD *, Item **ref) override
Definition: item_func.cc:255
virtual bool l_op() const
Definition: item_cmpfunc.h:428
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:804
bool fix_fields(THD *, Item **) override
Perform context analysis of an IN item tree.
Definition: item_cmpfunc.cc:4376
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:175
Item_func_like(const POS &pos, Item *a, Item *b, Item *opt_escape_arg)
Definition: item_cmpfunc.h:1895
Item * b_cache
Definition: item_cmpfunc.h:78
longlong(* get_value_a_func)(THD *thd, Item ***item_arg, Item **cache_arg, const Item *warn_item, bool *is_null)
Definition: item_cmpfunc.h:81
enum_trig_type trig_type
Type of trig_var; for printing.
Definition: item_cmpfunc.h:623
Definition: item_func.h:207
#define DBUG_ASSERT(A)
Definition: my_dbug.h:128
in_decimal(MEM_ROOT *mem_root, uint elements)
Definition: item_cmpfunc.h:1360
void store_value_by_template(cmp_item *tmpl, Item *)
Definition: item_cmpfunc.cc:4087
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:4222
Arg_comparator * comparators
Definition: item_cmpfunc.h:74
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.h:1853
bool is_alloced() const
Definition: sql_string.h:395
Item_bool_func(const POS &pos, Item *a)
Definition: item_cmpfunc.h:182
Definition: item_cmpfunc.h:70
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:2574
enum Functype functype() const override
Definition: item_cmpfunc.h:863
void keep_top_level_cache()
Definition: item_cmpfunc.cc:2077
Definition: item_cmpfunc.h:2081
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:785
Item_cache ** get_cache()
Definition: item_cmpfunc.h:333
longlong val_int() override
Definition: item_cmpfunc.cc:353
plan_idx idx() const
Definition: item_cmpfunc.h:673
Item_func_any_value(const POS &pos, Item *a)
Definition: item_cmpfunc.h:1085
int compare_int_signed()
Definition: item_cmpfunc.cc:1605
virtual bool eqne_op() const
Definition: item_cmpfunc.h:427
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:3645
void neg_arguments(THD *thd)
Definition: item_cmpfunc.cc:5176
bool fix_fields(THD *, Item **) override
Perform context analysis of a BETWEEN item tree.
Definition: item_cmpfunc.cc:2545
Definition: item.h:2778
Mem_root_array< String > base_objects
Definition: item_cmpfunc.h:1232
bool set_cmp_func()
Definition: item_cmpfunc.h:460
longlong val_int() override
Definition: item_cmpfunc.cc:3300
Definition: item_cmpfunc.h:1255
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:6287
void val_item(Item *item, packed_longlong *result) override
Definition: item_cmpfunc.cc:3927
virtual ~Ge_creator()
Definition: item_cmpfunc.h:424
void store_value(Item *item)
Definition: item_cmpfunc.cc:4140
Mem_root_array< double > base
Definition: item_cmpfunc.h:1337
void set_arguments(List< Item > &list, bool context_free)
Copy arguments from list to args array.
Definition: item_func.cc:165
Item * negated_item() override
just fake method, should never be called.
Definition: item_cmpfunc.cc:5828
#define DBUG_ENTER(a)
Definition: my_dbug.h:80
Item_func_isnotfalse(const POS &pos, Item *a)
Definition: item_cmpfunc.h:278
Definition: item.h:4030
enum enum_trig_type get_trig_type() const
Definition: item_cmpfunc.h:668
Definition: item_func.h:130
virtual const char * symbol(bool invert) const
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:394
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:3661
virtual ~Lt_creator()
Definition: item_cmpfunc.h:414
int cmp(Item *arg)
Definition: item_cmpfunc.cc:4107
bool equality_substitution_analyzer(uchar **) override
Definition: item_cmpfunc.h:754
virtual const char * symbol(bool invert) const
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:426
void store_value(Item *item)
Definition: item_cmpfunc.cc:4073
Implements the comparison operator not equals (<>)
Definition: item_cmpfunc.h:879
bool eq(const Item *item, bool binary_cmp) const override
Definition: item_cmpfunc.cc:2331
Item_bool_func()
Definition: item_cmpfunc.h:177
int compare(const cmp_item *ci) const override
Definition: item_cmpfunc.h:1517
Bison "location" class.
Definition: parse_location.h:43
bool set_cmp_func(Item_result_field *owner_arg, Item **a1, Item **a2, Item_result type)
Sets compare functions for various datatypes.
Definition: item_cmpfunc.cc:1050
Definition: item_func.h:209
Item_func_eq(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:746
optimize_type select_optimize() const override
Definition: item_cmpfunc.h:470
Item_func_opt_neg(const POS &pos, PT_item_list *list, bool is_negation)
Definition: item_cmpfunc.h:913
Item * warn_item
Definition: item_cmpfunc.h:1318
const char * func_name() const override
Definition: item_cmpfunc.h:1015
Definition: item_cmpfunc.h:1418
bool is_top_level_item() const
Definition: item_cmpfunc.h:2003
bool fix_fields(THD *thd, Item **ref) override
Definition: item_cmpfunc.cc:6015
Item_func_opt_neg(const POS &pos, Item *a, Item *b, Item *c, bool is_negation)
Definition: item_cmpfunc.h:909
longlong val_int() override
Definition: item_cmpfunc.cc:2318
cmp_item_int()
Definition: item_cmpfunc.h:1463
bool add(THD *thd, Item *c, Item_field *f)
Definition: item_cmpfunc.cc:5897
Item_func_comparison(Item *a, Item *b)
Definition: item_cmpfunc.h:500
Item_result hybrid_type
Definition: item_func.h:679
Item * get_const()
Definition: item_cmpfunc.h:2097
bool is_null() override
Definition: item_cmpfunc.h:479
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:617
void top_level_item() override
Definition: item_cmpfunc.h:483
Item_bool_func2(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:454
bool compare_const(THD *thd, Item *c)
Definition: item_cmpfunc.cc:5880
virtual int compare(const cmp_item *ci) const
Definition: item_cmpfunc.h:1429
Abstract Item class, to represent X IS [NOT] (TRUE | FALSE) boolean predicates.
Definition: item_cmpfunc.h:215
Definition: item_cmpfunc.h:904
virtual bool eqne_op() const
Definition: item_cmpfunc.h:437
Definition: my_bitmap.h:42
Item_cond_or(Item *i1, Item *i2)
Definition: item_cmpfunc.h:2217
optimize_type select_optimize() const override
Definition: item_cmpfunc.h:1859
cmp_item()
Definition: item_cmpfunc.h:1382
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:3420
void set_max_str_length(size_t max_str_length)
When comparing strings, compare at most max_str_length bytes.
Definition: item_cmpfunc.h:467
Item_func_strcmp(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:973
Item_field * operator++(int)
Definition: item_cmpfunc.h:2176
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:2364
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:3957
uint n
Definition: item_cmpfunc.h:1731
my_decimal class limits &#39;decimal_t&#39; type to what we need in MySQL.
Definition: my_decimal.h:100
int compare_json()
Compare two Item objects as JSON.
Definition: item_cmpfunc.cc:1458
bool equality_substitution_analyzer(uchar **) override
Definition: item_cmpfunc.h:2149
Item_func_coalesce(const POS &pos, Item *a)
Definition: item_cmpfunc.h:1032
Definition: item_cmpfunc.h:1877
optimize_type select_optimize() const override
We can optimize a where if first character isn&#39;t a wildcard.
Definition: item_cmpfunc.cc:5509
Functype
Definition: item_func.h:119
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:3883
Definition: item_cmpfunc.h:1823
Item * tmp_arg[2]
Definition: item_func.h:85
cmp_item_row(THD *thd, Item *item)
Definition: item_cmpfunc.h:1735
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:2209
double
Definition: udf_registration_types.h:42
const char * func_name() const override
Definition: item_cmpfunc.h:280
bool subst_argument_checker(uchar **) override
Definition: item_cmpfunc.h:927
String value1
Definition: item_cmpfunc.h:105
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:786
uint decimal_precision() const override
Definition: item_cmpfunc.cc:3536
longlong val_int() override
Definition: item_cmpfunc.cc:5369
Definition: item_func.h:206
bool unsigned_flag
Definition: item_cmpfunc.h:1257
bool compare_elems(uint pos1, uint pos2) const override
Compare values number pos1 and pos2 for equality.
Definition: item_cmpfunc.cc:3896
enum Functype functype() const override
Definition: item_cmpfunc.h:542
List< Item_equal > current_level
Definition: item_cmpfunc.h:2167
longlong val_int() override
Definition: item_cmpfunc.cc:5359
virtual void resize_and_sort()=0
Resize and then sort the IN-list array, so we can do efficient lookup with binary_search.
void top_level_item() override
Definition: item_cmpfunc.h:1869
Implements the comparison operator greater than or equals (>=)
Definition: item_cmpfunc.h:799
Definition: item_cmpfunc.h:1336
longlong(* get_value_b_func)(THD *thd, Item ***item_arg, Item **cache_arg, const Item *warn_item, bool *is_null)
Definition: item_cmpfunc.h:83
cmp_item * cmp_items[6]
Definition: item_cmpfunc.h:1639
void set_created_by_in2exists()
Definition: item_cmpfunc.h:200
Header for compiler-dependent features.
Abstract factory interface for creating comparison predicates.
Definition: item_cmpfunc.h:340
enum Item_result cached_result_type
Definition: item_cmpfunc.h:1122
Definition: item_cmpfunc.h:1058
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:1688
int cmp(Item *arg)
Definition: item_cmpfunc.cc:4147
static const int UNKNOWN
Definition: item_cmpfunc.h:283
my_decimal * val_decimal(my_decimal *) override
Definition: item_cmpfunc.cc:3332
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:94
void top_level_item() override
Definition: item_cmpfunc.h:527
Item_is_not_null_test(Item_in_subselect *ow, Item *a)
Definition: item_cmpfunc.h:1827
Definition: item_cmpfunc.h:996
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:4654
longlong val_int() override
Make a logical XOR of the arguments.
Definition: item_cmpfunc.cc:5688
enum Functype functype() const override
Definition: item_cmpfunc.h:2114
Arg_comparator ge_cmp
Definition: item_cmpfunc.h:942
longlong val_int() override
Definition: item_cmpfunc.cc:2306
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:5352
Item_bool_func(THD *thd, Item_bool_func *item)
Definition: item_cmpfunc.h:190
Definition: item.h:666
bool compare_elems(uint pos1, uint pos2) const override
Compare values number pos1 and pos2 for equality.
Definition: item_cmpfunc.cc:3805
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:3367
Item_cond_or()
Definition: item_cmpfunc.h:2215
Base class for parse tree nodes (excluding the Parse_tree_root hierarchy)
Definition: parse_tree_node_base.h:111
virtual Item_bool_func * combine(List< Item > list) const
Combines a list of conditions exp op exp.
Definition: item_cmpfunc.cc:307
virtual bool is_row_result() const
Definition: item_cmpfunc.h:1204
Definition: item_cmpfunc.h:586
my_decimal * val_decimal(my_decimal *) override
Definition: item_cmpfunc.cc:3106
bool null_value
True if item is null.
Definition: item.h:2700
plan_idx m_idx
Optional: if join!=NULL: index of table.
Definition: item_cmpfunc.h:621
#define true
Definition: config_static.h:44
void(* Cond_traverser)(const Item *item, void *arg)
Definition: item.h:664
void copy_andor_arguments(THD *thd, Item_cond *item)
Definition: item_cmpfunc.cc:4760
bool field_type_defined
Definition: item_cmpfunc.h:1060
long long int longlong
Definition: my_inttypes.h:70
virtual ~in_vector()
Definition: item_cmpfunc.h:1170
bool const_item() const
Returns true if item is constant, regardless of query evaluation state.
Definition: item.h:1795
Definition: item_cmpfunc.h:536
COND_EQUAL()
Definition: item_cmpfunc.h:2169
void traverse_cond(Cond_traverser, void *arg, traverse_order order) override
Definition: item_cmpfunc.cc:5100
void cleanup() override
Definition: item.cc:9387
const char * func_name() const override
Definition: item_cmpfunc.h:1831
int first_expr_num
Definition: item_cmpfunc.h:1555
longlong val_int() override
Definition: item_cmpfunc.cc:2312
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:265
Type
Definition: item.h:700
Definition: item.h:168
const CHARSET_INFO * collation
Definition: item.h:170
bool is_null() override
Definition: item_cmpfunc.cc:3220
Definition: item_func.h:156
void sort(Node_cmp_func cmp)
Sort the list.
Definition: sql_list.h:523
bool is_top_level_item() const
Definition: item_cmpfunc.h:695
List< Item > list
Definition: item_cmpfunc.h:1946
Item_bool_func2 super
Definition: item_cmpfunc.h:1878
void set_comparator(uint col, cmp_item *comparator)
Definition: item_cmpfunc.h:1770
Item_func_ifnull(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:1063
const char * func_name() const override
Definition: item_cmpfunc.h:543
COND_EQUAL cond_equal
Definition: item_cmpfunc.h:2185
enum Functype functype() const override
Definition: item_cmpfunc.h:697
const char * func_name() const override
Definition: item_cmpfunc.h:1055
virtual void store_value(Item *item)=0
Item_int_func super
Definition: item_cmpfunc.h:997
table_map not_null_tables() const override
Definition: item_cmpfunc.h:736
Le_creator le_creator
Definition: mysqld.cc:1263
virtual Item_bool_func * combine(List< Item > list) const
Combines a list of conditions exp op exp.
Definition: item_cmpfunc.cc:289
longlong val_int() override
Definition: item_cmpfunc.cc:2203
longlong val_int() override
Definition: item_cmpfunc.cc:2159
bool find_item(Item *item) override
Calls item->val_int() or item->val_str() etc.
Definition: item_cmpfunc.cc:3797
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:284
const char * func_name() const override
Definition: item_cmpfunc.h:1599
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:3245
bool remove_const_conds(THD *thd, Item *item, Item **new_item)
Remove constant conditions over literals.
Definition: item_cmpfunc.cc:4946
It is interface module to fixed precision decimals library.
void set_subquery()
Set the "has subquery" property.
Definition: item.h:2488
double precision
Definition: item_cmpfunc.h:76
virtual ~Le_creator()
Definition: item_cmpfunc.h:434
Definition: item_func.h:827
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:784
Item_func_ge(Item *a, Item *b)
Definition: item_cmpfunc.h:801
Item_func_eq(Item *a, Item *b)
Definition: item_cmpfunc.h:745
Definition: m_ctype.h:358
Item_func_isnotnull(Item *a)
Definition: item_cmpfunc.h:1847
virtual String * val_str(String *str)=0
Definition: item_cmpfunc.h:2172
bool empty_underlying_subquery()
Definition: item_cmpfunc.cc:394
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:2979
Item_func_case(const POS &pos, List< Item > &list, Item *first_expr_arg, Item *else_expr_arg)
Definition: item_cmpfunc.h:1565
int sortcmp(const String *a, const String *b, const CHARSET_INFO *cs)
Definition: sql_string.cc:743
bool fix_fields(THD *thd, Item **ref) override
Definition: item_cmpfunc.h:650
int compare_datetime()
Compare item values as dates.
Definition: item_cmpfunc.cc:1368
in_string(MEM_ROOT *mem_root, uint elements, const CHARSET_INFO *cs)
Definition: item_cmpfunc.cc:3834
void update_used_tables() override
Definition: item_cmpfunc.h:664
Item ** args
Definition: item_func.h:85
Item_basic_constant * create_item(MEM_ROOT *) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1773
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:1603
String * val_str(String *str) override
Definition: item_cmpfunc.cc:3081
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:100
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:3952
longlong int_op() override
Performs the operation that this functions implements when the result type is INT.
Definition: item_cmpfunc.cc:2937
Definition: item_cmpfunc.h:392
Common header for many mysys elements.
longlong val_int() override
The implementation of optimized <outer expression> [NOT] IN <subquery> predicates.
Definition: item_cmpfunc.cc:1999
#define OUTER_REF_TABLE_BIT
Definition: sql_const.h:114
virtual bool l_op() const
Definition: item_cmpfunc.h:418
bool show
Definition: item_cmpfunc.h:685
Item * transform(Item_transformer transformer, uchar *arg) override
Transform an Item_in_optimizer and its arguments with a callback function.
Definition: item_cmpfunc.cc:2108
Arg_comparator cmp
Definition: item_cmpfunc.h:2085
longlong val_int() override
Definition: item_cmpfunc.cc:2294
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:1151
void cleanup() override
Definition: item_cmpfunc.h:485
Item * copy_andor_structure(THD *thd) override
Definition: item_cmpfunc.h:2225
void sort(Node_cmp_func compare)
Order field items in multiple equality according to a sorting criteria.
Definition: item_cmpfunc.h:2134
longlong val_int() override
Definition: item_cmpfunc.cc:6228
table_map not_null_tables_cache
Value used in calculation of result of not_null_tables()
Definition: item_func.h:106
enum Functype functype() const override
Definition: item_cmpfunc.h:843
Definition: item_cmpfunc.h:1158
Definition: item_func.h:677
Item_func_coalesce(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:1028
enum Functype functype() const override
Definition: item_cmpfunc.h:1118
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:5243
virtual bool eqne_op() const
Definition: item_cmpfunc.h:407
virtual const char * symbol(bool invert) const
This interface is only used by Item_allany_subselect.
Definition: item_cmpfunc.h:416
void top_level_item() override
Definition: item_cmpfunc.h:694
CASE ...
Definition: item_cmpfunc.h:1552
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override
Definition: item_cmpfunc.cc:3123
Item_func_not(const POS &pos, Item *a)
Definition: item_cmpfunc.h:539
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:1838
void top_level_item() override
Definition: item_cmpfunc.h:1993
bool itemize(Parse_context *pc, Item **res) override
The same as contextualize()/contextualize_() but with additional parameter.
Definition: item_cmpfunc.cc:5466
char buff[STRING_BUFFER_USUAL_SIZE]
Definition: item_cmpfunc.h:1230
Item ** cache_converted_constant(THD *thd, Item **value, Item **cache, Item_result type)
Convert and cache a constant.
Definition: item_cmpfunc.cc:1216
Item_func_not(Item *a)
Definition: item_cmpfunc.h:538
Item * neg_transformer(THD *) override
Definition: item_cmpfunc.h:922
static MEM_ROOT mem_root
Definition: client_plugin.cc:107
Definition: item_cmpfunc.h:411
String tmp_value
Definition: item_cmpfunc.h:1557
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:824
cmp_item which stores a scalar (i.e. non-ROW).
Definition: item_cmpfunc.h:1412
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:828
Item * neg_transformer(THD *) override
Apply NOT transformation to the item and return a new one.
Definition: item_cmpfunc.cc:5803
Definition: item_cmpfunc.h:1843
Type type() const override
Definition: item_cmpfunc.h:1984
void cleanup() override
Definition: item_cmpfunc.cc:3573
Item_cache * cache
Definition: item_cmpfunc.h:307
Item_func_xor(const POS &pos, Item *i1, Item *i2)
Definition: item_cmpfunc.h:521
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:1951
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:3274
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1290
bool compare_elems(uint pos1, uint pos2) const override
Compare values number pos1 and pos2 for equality.
Definition: item_cmpfunc.cc:3989
const JOIN * m_join
Optional: JOIN of table which is the source of trig_var.
Definition: item_cmpfunc.h:619
Definition: item_cmpfunc.h:990
Mem_root_array< packed_longlong > base
Definition: item_cmpfunc.h:1261
Item_maxmin_subselect * test_sub_item
Definition: item_cmpfunc.h:679
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:2276
void store_value(Item *item) override
Definition: item_cmpfunc.h:1464
bool fix_fields(THD *, Item **ref) override
Definition: item_cmpfunc.cc:4768
Abstract base class for the comparison operators =, <> and <=>.
Definition: item_cmpfunc.h:352
bool use_decimal_comparison
Definition: item_cmpfunc.h:1000
Item_result_field * owner
Definition: item_cmpfunc.h:73
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:1922
virtual bool eqne_op() const
Definition: item_cmpfunc.h:417
traverse_order
Definition: item.h:735
Definition: item_cmpfunc.h:1286
Item_bool_func(Item *a, Item *b)
Definition: item_cmpfunc.h:185
Definition: item_cmpfunc.h:1316
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:6471
Item_func_isnotnull(const POS &pos, Item *a)
Definition: item_cmpfunc.h:1848
bool save_cache
Definition: item_cmpfunc.h:308
Arg_comparator cmp
Definition: item_cmpfunc.h:447
virtual bool is_null()
Definition: item.h:1879
double val_real() override
Definition: item_cmpfunc.cc:3316
const char * func_name() const override
Definition: item_cmpfunc.h:977
bool itemize(Parse_context *pc, Item **res) override
The same as contextualize()/contextualize_() but with additional parameter.
Definition: item_cmpfunc.cc:2344
ANY_VALUE(expr) is like expr except that it is not checked by aggregate_check logic.
Definition: item_cmpfunc.h:1083
Definition: item_cmpfunc.h:1356
Definition: mysql_time.h:64
enum Functype rev_functype() const override
Definition: item_cmpfunc.h:844
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:6174
int cmp(Item *arg) override
Definition: item_cmpfunc.cc:4179
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:6193
Item_func_istrue(const POS &pos, Item *a)
Definition: item_cmpfunc.h:245
virtual bool eqne_op() const
Definition: item_cmpfunc.h:355
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1302
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:1365
Item ** b
Definition: item_cmpfunc.h:71
bool maybe_null
True if this item may be null.
Definition: item.h:2699
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:2949
Mem_root_array< my_decimal > base
Definition: item_cmpfunc.h:1357
cmp_item * make_same() override
Definition: item_cmpfunc.cc:4197
Definition: item_func.h:208
Item ** a
Definition: item_cmpfunc.h:71
table_map used_tables_cache
Value used in calculation of result of used_tables()
Definition: item_func.h:104
Definition: item_func.h:189
uint decimal_precision() const override
Definition: item_cmpfunc.h:1136
const char * func_name() const override
Definition: item_cmpfunc.h:752
enum Functype functype() const override
Definition: item_cmpfunc.h:1798
int type
Definition: http_common.h:411
Equal_creator equal_creator
Definition: mysqld.cc:1259
enum Functype functype() const override
Definition: item_cmpfunc.h:883
int(Arg_comparator::* arg_cmp_func)()
Definition: item_cmpfunc.h:68
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:3964
void update_used_tables() override
Definition: item_func.cc:447
DTCollation collation
Character set and collation properties assigned for this Item.
Definition: item.h:2617
in_time_as_longlong(MEM_ROOT *mem_root, uint elements)
Definition: item_cmpfunc.h:1300
String * str_op(String *str) override
Coalesce - return first not NULL argument.
Definition: item_cmpfunc.cc:2985
Mem_root_array< cmp_item_row * > base_pointers
Definition: item_cmpfunc.h:1763
Definition: item_cmpfunc.h:1459
uint elements
Definition: sql_list.h:133
bool alloc_comparators(THD *thd, Item *item)
Allocate comparator objects.
Definition: item_cmpfunc.cc:4052
void store_value(Item *item) override
Definition: item_cmpfunc.cc:4167
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:6488
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:1099
table_map not_null_tables() const override
Definition: item_cmpfunc.h:704
my_decimal dec
Definition: item_cmpfunc.h:993
bool is_row_result() const override
Definition: item_cmpfunc.h:1767
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:5025
bool compare_as_temporal_times
Definition: item_cmpfunc.h:939
longlong val
Definition: item_cmpfunc.h:1256
cmp_item_row * tmp
Definition: item_cmpfunc.h:1760
static bool can_compare_as_dates(Item *a, Item *b)
Checks whether compare_datetime() can be used to compare items.
Definition: item_cmpfunc.cc:971
cmp_item * make_same() override
Definition: item_cmpfunc.cc:4024
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:3045
Item * copy_andor_structure(THD *thd) override
Definition: item_cmpfunc.h:2198
Definition: item_cmpfunc.h:2162
Item * and_conds(Item *a, Item *b)
Definition: item_cmpfunc.h:2242
double real_op() override
Performs the operation that this functions implements when the result type is REAL.
Definition: item_cmpfunc.cc:3623
DTCollation cmp_collation
Definition: item_cmpfunc.h:1640
Item * negated_item() override
just fake method, should never be called.
Definition: item_cmpfunc.cc:5813
bool abort_on_null
Definition: item_cmpfunc.h:448
table_map get_inner_tables() const
Get table_map of inner tables spanned by associated outer join operation.
Definition: item_cmpfunc.cc:6267
Definition: sql_list.h:567
uint max_members
Definition: item_cmpfunc.h:2164
longlong val_int() override
Definition: item_cmpfunc.cc:3173
This Item represents a X IS TRUE boolean predicate.
Definition: item_cmpfunc.h:243
void prepend(List< T > *list)
Definition: sql_list.h:457
bool is_top_level_item() const
Definition: item_cmpfunc.h:921
void print_op(const THD *thd, String *str, enum_query_type query_type) const
Definition: item_func.cc:482
uint decimal_precision() const override
Definition: item_cmpfunc.cc:2913
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:4985
Item_bool_func(const POS &pos)
Definition: item_cmpfunc.h:178
enum Functype functype() const override
Definition: item_cmpfunc.h:823
int compare_int_unsigned_signed()
Compare unsigned (*a) with signed (*B)
Definition: item_cmpfunc.cc:1697
Ne_creator ne_creator
Definition: mysqld.cc:1258
void destroy(T *ptr)
Definition: my_alloc.h:373
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1342
cond_result eq_cmp_result() const override
Definition: item_cmpfunc.h:865
Definition: item.h:3793
Definition: item.h:733
Definition: field_types.h:69
Definition: item_func.h:121
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:5079
void set_max_str_length(size_t max_length)
When comparing strings, compare at most max_length bytes.
Definition: item_cmpfunc.h:139
longlong cached_value
Definition: item_cmpfunc.h:1790
Definition: item_cmpfunc.h:1298
bool created_by_in2exists() const override
Whether this Item was created by the IN->EXISTS subquery transformation.
Definition: item_cmpfunc.h:199
virtual Item_bool_func * create(Item *a, Item *b) const
Definition: item_cmpfunc.cc:311
Time declarations shared between the server and client API: you should not add anything to this heade...
Item with result field.
Definition: item.h:4493
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:959
Definition: item_func.h:131
uint allowed_arg_cols
Definition: item_func.h:102
Item * neg_transformer(THD *) override
Apply NOT transformation to the item and return a new one.
Definition: item_cmpfunc.cc:5726
Item_func_equal(Item *a, Item *b)
Definition: item_cmpfunc.h:775
Item * neg_transformer(THD *) override
Definition: item_cmpfunc.h:788
bool fill(Item **items, uint item_count)
Fill the vector by evaluating the items passed as arguments.
Definition: item_cmpfunc.cc:3677
virtual int cmp(Item *item)=0
Mem_root_array< String * > base_pointers
Definition: item_cmpfunc.h:1234
enum Functype functype() const override
Definition: item_cmpfunc.h:524
double dbl
Definition: item_cmpfunc.h:992
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:6246
void set_cmp_context_for_datetime()
Definition: item_cmpfunc.h:168
enum Item_result cached_result_type
Definition: item_cmpfunc.h:1092
void negate()
Definition: item_cmpfunc.h:919
Definition: item_cmpfunc.h:1026
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:2145
cmp_item * make_same() override
Definition: item_cmpfunc.cc:4026
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.cc:4407
Implements the comparison operator less than (<)
Definition: item_cmpfunc.h:859
String * val_str(String *str) override
Definition: item_cmpfunc.cc:3185
enum Functype functype() const override
Definition: item_cmpfunc.h:643
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:599
uint16 comparator_count
Definition: item_cmpfunc.h:75
A better implementation of the UNIX ctype(3) library.
Item_cond(Item *i1, Item *i2)
Definition: item_cmpfunc.h:1952
Item_func_trig_cond(Item *a, bool *f, JOIN *join, plan_idx idx, enum_trig_type trig_type_arg)
Definition: item_cmpfunc.h:635
Definition: item_cmpfunc.h:1788
void set_comparator(uint col, cmp_item *comparator)
Definition: item_cmpfunc.h:1751
Definition: item_cmpfunc.h:1524
Definition: item_subselect.h:316
Definition: item_func.h:129
enum Functype functype() const override
Definition: item_cmpfunc.h:1904
void print(const THD *thd, String *str, enum_query_type query_type) const override
Definition: item_cmpfunc.cc:3551
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:1584
Definition: item_func.h:132
void set_const(Item *c)
Definition: item_cmpfunc.h:2098
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:3993
bool * trig_var
Pointer to trigger variable.
Definition: item_cmpfunc.h:617
bool * get_trig_var()
Definition: item_cmpfunc.h:669
Definition: item_cmpfunc.h:731
cmp_item * make_same()
Definition: item_cmpfunc.cc:4158
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:2925
if(++stacktop > STACKSIZ)
Definition: dbug_analyze.cc:141
~Item_equal() override
Definition: item_cmpfunc.h:2095
virtual enum Functype rev_functype() const
Definition: item_cmpfunc.h:471
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:1141
Definition: item_cmpfunc.h:1729
static STATUS status
Definition: mysql.cc:188
bool fix_fields(THD *thd, Item **ref) override
Definition: item_cmpfunc.cc:5321
Interface for low level time utilities.
Item_func_lt(Item *a, Item *b)
Definition: item_cmpfunc.h:861
Representation of IN subquery predicates of the form "left_expr IN (SELECT ...)". ...
Definition: item_subselect.h:441
const bool affirmative
True for X IS Y, false for X IS NOT Y predicates.
Definition: item_cmpfunc.h:236
const char * func_name() const override
Definition: item_cmpfunc.h:698
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:1631
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:896
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:3817
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:1817
int cmp(Item *arg) override
Definition: item_cmpfunc.h:1513
Definition: item_func.h:137
bool has_date
Distinguish between DATE/DATETIME/TIMESTAMP and TIME.
Definition: item_cmpfunc.h:1495
void cleanup_arrays()
Cleanup data and comparator arrays.
Definition: item_cmpfunc.h:1663
Definition: item_sum.h:1483
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:1684
bool compare_as_dates
Definition: item_cmpfunc.h:2087
longlong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg, const Item *warn_item, bool *is_null)
Definition: item_cmpfunc.cc:1272
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:2258
bool update_const(THD *thd)
Check appearance of new constant items in the multiple equality object.
Definition: item_cmpfunc.cc:5989
Definition: item_func.h:127
Definition: table.h:2439
Item_cond_or(const POS &pos, Item *i1, Item *i2)
Definition: item_cmpfunc.h:2218
#define STRING_BUFFER_USUAL_SIZE
Definition: sql_const.h:131
bool aggregate_check_distinct(uchar *arg) override
Definition: item_cmpfunc.cc:6513
bool push_back(T *a)
Definition: sql_list.h:440
bool aggregate_check_group(uchar *arg) override
Definition: item_cmpfunc.cc:6506
int cmp(Item *arg) override
Definition: item_cmpfunc.h:1468
virtual bool l_op() const =0
void cleanup() override
Definition: item_cmpfunc.h:1673
Definition: item_func.h:133
void cleanup() override
Definition: item_cmpfunc.cc:2082
bool resolve_type(THD *) override
Definition: item_cmpfunc.cc:2877
longlong val_int() override
Definition: item_cmpfunc.cc:6157
uint decimal_precision() const override
Definition: item_cmpfunc.h:198
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:4392
bool fix_fields(THD *, Item **) override
Perform context analysis of an IF item tree.
Definition: item_cmpfunc.cc:3025
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.h:979
Definition: item_cmpfunc.h:401
Item_sum_hybrid * test_sum_item
Definition: item_cmpfunc.h:678
bool have_rev_func() const override
Definition: item_cmpfunc.h:472
cmp_item * eval_item
Definition: item_cmpfunc.h:2084
const char * func_name() const override
Definition: item_cmpfunc.h:951
const char * func_name() const override
Definition: item_cmpfunc.h:1683
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:1637
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1239
Ge_creator()
Definition: item_cmpfunc.h:423
void set_subselect(Item_subselect *item)
Definition: item_cmpfunc.h:703
bool fix_fields(THD *thd, Item **ref) override
Definition: item_cmpfunc.cc:5551
bool abort_on_null
Definition: item_cmpfunc.h:682
void set_sum_test(Item_sum_hybrid *item)
Definition: item_cmpfunc.h:701
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:6212
optimize_type select_optimize() const override
Definition: item_cmpfunc.h:1679
static arg_cmp_func comparator_matrix[5]
Definition: item_cmpfunc.h:163
Definition: item_cmpfunc.h:930
bool abort_on_null
Definition: item_cmpfunc.h:1947
my_decimal value
Definition: item_cmpfunc.h:1525
Definition: item_func.h:122
T * head()
Definition: sql_list.h:448
Item_field * get_subst_item(const Item_field *field)
Get item that can be substituted for the supplied item.
Definition: item_cmpfunc.cc:6349
const bool value
True for X IS [NOT] TRUE, false for X IS [NOT] FALSE predicates.
Definition: item_cmpfunc.h:232
unsigned short uint16
Definition: my_inttypes.h:53
longlong value
Definition: item_cmpfunc.h:1487
uint decimal_precision() const override
Definition: item_cmpfunc.h:1655
bool m_null_value
If stored value is NULL.
Definition: item_cmpfunc.h:1414
Item_func_truth(const POS &pos, Item *a, bool a_value, bool a_affirmative)
Definition: item_cmpfunc.h:224
String tmp
Definition: item_cmpfunc.h:1231
Item * neg_transformer(THD *thd) override
a IS NOT NULL -> a IS NULL.
Definition: item_cmpfunc.cc:5772
#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:436
Lt_creator()
Definition: item_cmpfunc.h:413
int compare(const cmp_item *c) const
Definition: item_cmpfunc.cc:4153
virtual Item * negated_item()
just fake method, should never be called.
Definition: item_cmpfunc.cc:5846
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_cmpfunc.cc:5160
virtual Item_bool_func * create(Item *a, Item *b) const
Definition: item_cmpfunc.cc:319
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size...
Definition: item_cmpfunc.h:194
bool set_null
Definition: item_cmpfunc.h:79
double val_real() override
Definition: item_cmpfunc.cc:3161
enum Functype functype() const override
Definition: item_cmpfunc.h:950
Definition: item_cmpfunc.h:370
bool pred_level
Definition: item_cmpfunc.h:907
Definition: item_cmpfunc.h:1253
bool find_item(Item *item) override
Calls item->val_int() or item->val_str() etc.
Definition: item_cmpfunc.cc:3981
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:6181
void rewind(void)
Definition: item_cmpfunc.h:2180
longlong val_int() override
Definition: item_cmpfunc.cc:2174
void top_level_item() override
Definition: item_cmpfunc.h:920
void add_at_head(List< Item > *nlist)
Definition: item_cmpfunc.h:1973
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:1004
bool compare_as_temporal_dates
Definition: item_cmpfunc.h:938
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:2183
const char * func_name() const override
Definition: item_cmpfunc.h:525
Item_cond_and(THD *thd, Item_cond_and *item)
Definition: item_cmpfunc.h:2193
longlong val_int() override
Definition: item_cmpfunc.cc:5427
Item_func_not_all(Item *a)
Definition: item_cmpfunc.h:687
Definition: item_func.h:124
void cleanup()
Definition: item_cmpfunc.cc:669
Definition: items.h:34
Item_result cmp_type
Definition: item_cmpfunc.h:1559
Item_in_subselect * owner
Definition: item_cmpfunc.h:1824
const char * func_name() const override
Definition: item_cmpfunc.h:1117
Item_basic_constant * create_item(MEM_ROOT *mem_root) const override
Create an instance of Item_{type} (e.g.
Definition: item_cmpfunc.h:1362
Definition: item_cmpfunc.h:971
const CHARSET_INFO * compare_collation() const override
Definition: item_cmpfunc.h:480
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:4201
This trigger type deactivates predicated from WHERE condition when no row satisfying the join conditi...
Definition: item_cmpfunc.h:603
void update_used_tables() override
Definition: item_cmpfunc.cc:6143
Item_func_nullif(const POS &pos, Item *a, Item *b)
Definition: item_cmpfunc.h:1125
Item * a_cache
Definition: item_cmpfunc.h:78
The <=> operator evaluates the same as.
Definition: item_cmpfunc.h:773
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:5650
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:776
Item_bool_func super
Definition: item_cmpfunc.h:1943
int compare_decimal()
Definition: item_cmpfunc.cc:1569
Arg_comparator()
Definition: item_cmpfunc.h:107
enum Functype functype() const override
Definition: item_cmpfunc.h:2222
Item * escape_item
Definition: item_cmpfunc.h:1880
in_datetime_as_longlong(MEM_ROOT *mem_root, uint elements)
Definition: item_cmpfunc.h:1288
bool fix_fields(THD *thd, Item **ref) override
Definition: item_cmpfunc.cc:3385
bool push_front(T *a)
Definition: sql_list.h:444
int compare_int_unsigned()
Compare values as BIGINT UNSIGNED.
Definition: item_cmpfunc.cc:1659
const char * func_name() const override
&#39;<if>&#39;, to distinguish from the if() SQL function
Definition: item_cmpfunc.h:645
Item_cond_and()
Definition: item_cmpfunc.h:2188
enum Functype functype() const override
Definition: item_cmpfunc.h:2195
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:3976
Item_cond_and(List< Item > &list_arg)
Definition: item_cmpfunc.h:2194
Item_bool_func2(Item *a, Item *b)
Definition: item_cmpfunc.h:451
bool gc_subst_analyzer(uchar **) override
Analyzer function for GC substitution.
Definition: item_cmpfunc.h:868
cmp_item ** comparators
Definition: item_cmpfunc.h:1730
bool null_on_null
Affects how to determine that NULL argument implies a NULL function return.
Definition: item_func.h:97
virtual void store_value_by_template(cmp_item *, Item *item)
Definition: item_cmpfunc.h:1406
bool negated
Definition: item_cmpfunc.h:906