MySQL  8.0.27
Source Code Documentation
item_timefunc.h
Go to the documentation of this file.
1 #ifndef ITEM_TIMEFUNC_INCLUDED
2 #define ITEM_TIMEFUNC_INCLUDED
3 
4 /* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License, version 2.0,
8  as published by the Free Software Foundation.
9 
10  This program is also distributed with certain software (including
11  but not limited to OpenSSL) that is licensed under separate terms,
12  as designated in a particular file or component or in included license
13  documentation. The authors of MySQL hereby grant you an additional
14  permission to link the program and your derivative works with the
15  separately licensed software that they have included with MySQL.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License, version 2.0, for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25 
26 /* Function items used by mysql */
27 
28 #include <assert.h>
29 #include <sys/types.h>
30 
31 #include <algorithm>
32 #include <cstddef>
33 
34 #include "field_types.h" // MYSQL_TYPE_DATETIME
35 #include "m_ctype.h"
36 
37 #include "my_inttypes.h"
38 #include "my_table_map.h"
39 #include "my_time.h"
41 #include "mysql_time.h"
42 #include "sql/enum_query_type.h"
43 #include "sql/field.h"
44 #include "sql/item.h"
45 #include "sql/item_func.h"
46 #include "sql/item_strfunc.h" // Item_str_func
47 #include "sql/parse_location.h" // POS
48 #include "sql/set_var.h"
49 #include "sql/sql_const.h"
50 #include "sql_string.h"
51 #include "template_utils.h" // pointer_cast
52 
53 class MY_LOCALE;
54 class PT_item_list;
55 class THD;
56 class Time_zone;
57 class my_decimal;
58 struct Date_time_format;
59 struct Parse_context;
60 struct TABLE;
61 
62 bool get_interval_value(Item *args, interval_type int_type, String *str_value,
64 
65 class Item_func_period_add final : public Item_int_func {
66  public:
68  : Item_int_func(pos, a, b) {}
69  longlong val_int() override;
70  const char *func_name() const override { return "period_add"; }
71  bool resolve_type(THD *thd) override;
72 };
73 
74 class Item_func_period_diff final : public Item_int_func {
75  public:
77  : Item_int_func(pos, a, b) {}
78  longlong val_int() override;
79  const char *func_name() const override { return "period_diff"; }
80  bool resolve_type(THD *thd) override;
81 };
82 
83 class Item_func_to_days final : public Item_int_func {
84  public:
86  longlong val_int() override;
87  const char *func_name() const override { return "to_days"; }
88  enum Functype functype() const override { return TO_DAYS_FUNC; }
89  bool resolve_type(THD *thd) override;
91  longlong val_int_endpoint(bool left_endp, bool *incl_endp) override;
92  bool check_partition_func_processor(uchar *) override { return false; }
94  return !has_date_args();
95  }
96 };
97 
98 class Item_func_to_seconds final : public Item_int_func {
99  public:
101  longlong val_int() override;
102  const char *func_name() const override { return "to_seconds"; }
103  enum Functype functype() const override { return TO_SECONDS_FUNC; }
104  bool resolve_type(THD *thd) override;
106  longlong val_int_endpoint(bool left_endp, bool *incl_endp) override;
107  bool check_partition_func_processor(uchar *) override { return false; }
108 
109  bool intro_version(uchar *int_arg) override {
110  int *input_version = (int *)int_arg;
111  /* This function was introduced in 5.5 */
112  int output_version = std::max(*input_version, 50500);
113  *input_version = output_version;
114  return false;
115  }
116 
117  /* Only meaningful with date part and optional time part */
119  return !has_date_args();
120  }
121 };
122 
123 class Item_func_dayofmonth final : public Item_int_func {
124  public:
126 
127  longlong val_int() override;
128  const char *func_name() const override { return "dayofmonth"; }
129  enum Functype functype() const override { return DAY_FUNC; }
130  bool resolve_type(THD *thd) override;
131  bool check_partition_func_processor(uchar *) override { return false; }
133  return !has_date_args();
134  }
135 };
136 
137 /**
138  TS-TODO: This should probably have Item_int_func as parent class.
139 */
140 class Item_func_month final : public Item_func {
141  public:
142  Item_func_month(const POS &pos, Item *a) : Item_func(pos, a) {
145  }
146  longlong val_int() override;
147  double val_real() override {
148  assert(fixed);
149  return (double)Item_func_month::val_int();
150  }
151  String *val_str(String *str) override {
152  longlong nr = val_int();
153  if (null_value) return nullptr;
154  str->set(nr, collation.collation);
155  return str;
156  }
157  bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override {
158  return get_date_from_int(ltime, fuzzydate);
159  }
160  bool get_time(MYSQL_TIME *ltime) override { return get_time_from_int(ltime); }
161  const char *func_name() const override { return "month"; }
162  enum Functype functype() const override { return MONTH_FUNC; }
163  enum Item_result result_type() const override { return INT_RESULT; }
164  bool resolve_type(THD *thd) override;
165  bool check_partition_func_processor(uchar *) override { return false; }
167  return !has_date_args();
168  }
169 };
170 
171 class Item_func_monthname final : public Item_str_func {
173 
174  public:
176  const char *func_name() const override { return "monthname"; }
177  enum Functype functype() const override { return MONTHNAME_FUNC; }
178  String *val_str(String *str) override;
179  bool resolve_type(THD *thd) override;
180  bool check_partition_func_processor(uchar *) override { return true; }
182  return !has_date_args();
183  }
184 };
185 
186 class Item_func_dayofyear final : public Item_int_func {
187  public:
189  longlong val_int() override;
190  const char *func_name() const override { return "dayofyear"; }
191  enum Functype functype() const override { return DAYOFYEAR_FUNC; }
192  bool resolve_type(THD *thd) override;
193  bool check_partition_func_processor(uchar *) override { return false; }
195  return !has_date_args();
196  }
197 };
198 
199 class Item_func_hour final : public Item_int_func {
200  public:
202  longlong val_int() override;
203  const char *func_name() const override { return "hour"; }
204  enum Functype functype() const override { return HOUR_FUNC; }
205  bool resolve_type(THD *thd) override;
206  bool check_partition_func_processor(uchar *) override { return false; }
208  return !has_time_args();
209  }
210 };
211 
212 class Item_func_minute final : public Item_int_func {
213  public:
215  longlong val_int() override;
216  const char *func_name() const override { return "minute"; }
217  enum Functype functype() const override { return MINUTE_FUNC; }
218  bool resolve_type(THD *thd) override;
219  bool check_partition_func_processor(uchar *) override { return false; }
221  return !has_time_args();
222  }
223 };
224 
225 class Item_func_quarter final : public Item_int_func {
226  public:
228  longlong val_int() override;
229  const char *func_name() const override { return "quarter"; }
230  enum Functype functype() const override { return QUARTER_FUNC; }
231  bool resolve_type(THD *thd) override;
232  bool check_partition_func_processor(uchar *) override { return false; }
234  return !has_date_args();
235  }
236 };
237 
238 class Item_func_second final : public Item_int_func {
239  public:
241  longlong val_int() override;
242  const char *func_name() const override { return "second"; }
243  enum Functype functype() const override { return SECOND_FUNC; }
244  bool resolve_type(THD *thd) override;
245  bool check_partition_func_processor(uchar *) override { return false; }
247  return !has_time_args();
248  }
249 };
250 
251 class Item_func_week final : public Item_int_func {
253 
254  public:
256  Item_func_week(const POS &pos, Item *a, Item *b) : super(pos, a, b) {}
257 
258  bool itemize(Parse_context *pc, Item **res) override;
259 
260  longlong val_int() override;
261  const char *func_name() const override { return "week"; }
262  enum Functype functype() const override { return WEEK_FUNC; }
263  bool resolve_type(THD *thd) override;
264 };
265 
266 class Item_func_yearweek final : public Item_int_func {
267  public:
269  : Item_int_func(pos, a, b) {}
270  longlong val_int() override;
271  const char *func_name() const override { return "yearweek"; }
272  enum Functype functype() const override { return YEARWEEK_FUNC; }
273  bool resolve_type(THD *thd) override;
274  bool check_partition_func_processor(uchar *) override { return false; }
276  return !has_date_args();
277  }
278 };
279 
280 class Item_func_year final : public Item_int_func {
281  public:
283  longlong val_int() override;
284  const char *func_name() const override { return "year"; }
285  enum Functype functype() const override { return YEAR_FUNC; }
287  longlong val_int_endpoint(bool left_endp, bool *incl_endp) override;
288  bool resolve_type(THD *thd) override;
289  bool check_partition_func_processor(uchar *) override { return false; }
291  return !has_date_args();
292  }
293 };
294 
295 class Item_typecast_year final : public Item_int_func {
296  public:
299  }
300  longlong val_int() override;
301  const char *func_name() const override { return "cast_as_year"; }
302  enum Functype functype() const override { return TYPECAST_FUNC; }
303  bool resolve_type(THD *thd) override;
304 };
305 
306 /**
307  TS-TODO: This should probably have Item_int_func as parent class.
308 */
309 class Item_func_weekday : public Item_func {
310  bool odbc_type;
311 
312  public:
313  Item_func_weekday(const POS &pos, Item *a, bool type_arg)
314  : Item_func(pos, a), odbc_type(type_arg) {
317  }
318  longlong val_int() override;
319  double val_real() override {
320  assert(fixed);
321  return static_cast<double>(val_int());
322  }
323  String *val_str(String *str) override {
324  assert(fixed == 1);
325  str->set(val_int(), &my_charset_bin);
326  return null_value ? nullptr : str;
327  }
328  bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override {
329  return get_date_from_int(ltime, fuzzydate);
330  }
331  bool get_time(MYSQL_TIME *ltime) override { return get_time_from_int(ltime); }
332  const char *func_name() const override {
333  return (odbc_type ? "dayofweek" : "weekday");
334  }
335  enum Functype functype() const override { return WEEKDAY_FUNC; }
336  enum Item_result result_type() const override { return INT_RESULT; }
337  bool resolve_type(THD *thd) override;
338  bool check_partition_func_processor(uchar *) override { return false; }
340  return !has_date_args();
341  }
342 };
343 
344 /**
345  TS-TODO: Item_func_dayname should be derived from Item_str_func.
346  In the current implementation funny things can happen:
347  select dayname(now())+1 -> 4
348 */
349 class Item_func_dayname final : public Item_func_weekday {
351 
352  public:
354  : Item_func_weekday(pos, a, false) {}
355  const char *func_name() const override { return "dayname"; }
356  enum Functype functype() const override { return DAYNAME_FUNC; }
357  String *val_str(String *str) override;
358  bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override {
359  return get_date_from_string(ltime, fuzzydate);
360  }
361  bool get_time(MYSQL_TIME *ltime) override {
362  return get_time_from_string(ltime);
363  }
364  enum Item_result result_type() const override { return STRING_RESULT; }
365  bool resolve_type(THD *thd) override;
366  bool check_partition_func_processor(uchar *) override { return true; }
367 };
368 
369 /*
370  Abstract class for functions returning "struct timeval".
371 */
372 class Item_timeval_func : public Item_func {
373  public:
374  explicit Item_timeval_func(const POS &pos) : Item_func(pos) {}
375 
377  Item_timeval_func(const POS &pos, Item *a) : Item_func(pos, a) {}
378  /**
379  Return timestamp in "struct timeval" format.
380  @param[out] tm The value is store here.
381  @retval false On success
382  @retval true On error
383  */
384  virtual bool val_timeval(struct timeval *tm) = 0;
385  longlong val_int() override;
386  double val_real() override;
387  String *val_str(String *str) override;
388  my_decimal *val_decimal(my_decimal *decimal_value) override;
389  bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override {
390  return get_date_from_numeric(ltime, fuzzydate);
391  }
392  bool get_time(MYSQL_TIME *ltime) override {
393  return get_time_from_numeric(ltime);
394  }
395  enum Item_result result_type() const override {
397  }
398 };
399 
402 
403  public:
405 
407 
409  : Item_timeval_func(pos, a) {}
410 
411  const char *func_name() const override { return "unix_timestamp"; }
412  enum Functype functype() const override { return UNIX_TIMESTAMP_FUNC; }
413 
414  bool itemize(Parse_context *pc, Item **res) override;
416  longlong val_int_endpoint(bool left_endp, bool *incl_endp) override;
417  bool check_partition_func_processor(uchar *) override { return false; }
418  /*
419  UNIX_TIMESTAMP() depends on the current timezone
420  (and thus may not be used as a partitioning function)
421  when its argument is NOT of the TIMESTAMP type.
422  */
424  return !has_timestamp_args();
425  }
426  bool resolve_type(THD *thd) override {
427  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_DATETIME)) return true;
429  const uint8 dec = arg_count == 0 ? 0 : args[0]->datetime_precision();
430  if (dec > 0) {
432  } else {
434  }
435  return false;
436  }
437  bool val_timeval(struct timeval *tm) override;
438 
439  bool check_function_as_value_generator(uchar *p_arg) override {
440  /*
441  TODO: Allow UNIX_TIMESTAMP called with an argument to be a part
442  of the expression for a generated column too.
443  */
445  pointer_cast<Check_function_as_value_generator_parameters *>(p_arg);
446  func_arg->banned_function_name = func_name();
447  return ((func_arg->source == VGS_GENERATED_COLUMN) ||
448  (func_arg->source == VGS_CHECK_CONSTRAINT));
449  }
450 };
451 
452 class Item_func_time_to_sec final : public Item_int_func {
453  public:
455  : Item_int_func(pos, item) {}
456  longlong val_int() override;
457  const char *func_name() const override { return "time_to_sec"; }
458  enum Functype functype() const override { return TIME_TO_SEC_FUNC; }
459  bool resolve_type(THD *thd) override;
460  bool check_partition_func_processor(uchar *) override { return false; }
462  return !has_time_args();
463  }
464 };
465 
466 /**
467  Abstract class for functions returning TIME, DATE, DATETIME types
468  whose data type is known at constructor time.
469 */
471  protected:
472  bool check_precision();
473 
474  public:
476  explicit Item_temporal_func(const POS &pos) : Item_func(pos) {}
477 
480 
481  Item_temporal_func(const POS &pos, Item *a, Item *b) : Item_func(pos, a, b) {}
482 
483  Item_temporal_func(Item *a, Item *b, Item *c) : Item_func(a, b, c) {}
484  Item_temporal_func(const POS &pos, Item *a, Item *b, Item *c)
485  : Item_func(pos, a, b, c) {}
486  Item_temporal_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
487  : Item_func(pos, a, b, c, d) {}
489  : Item_func(pos, list) {}
490 
491  Item_result result_type() const override { return STRING_RESULT; }
492  const CHARSET_INFO *charset_for_protocol() override {
493  return &my_charset_bin;
494  }
495  Field *tmp_table_field(TABLE *table) override {
496  return tmp_table_field_from_field_type(table, false);
497  }
498  uint time_precision() override {
499  assert(fixed);
500  return decimals;
501  }
503  assert(fixed);
504  return decimals;
505  }
506  void print(const THD *thd, String *str,
507  enum_query_type query_type) const override;
508 };
509 
510 /**
511  Abstract class for functions returning TIME, DATE, DATETIME or string values,
512  whose data type depends on parameters and is set at fix_field time.
513 */
515  protected:
516  sql_mode_t sql_mode; // sql_mode value is cached here in resolve_type()
517  String ascii_buf; // Conversion buffer
518  /**
519  Get "native" temporal value as MYSQL_TIME
520  @param[out] ltime The value is stored here.
521  @param[in] fuzzy_date Date flags.
522  @retval false On success.
523  @retval true On error.
524  */
525  virtual bool val_datetime(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date) = 0;
527  bool no_conversions) override;
528 
529  public:
531  : Item_str_func(a, b), sql_mode(0) {}
533  : Item_str_func(pos, a, b), sql_mode(0) {}
534 
535  Item_result result_type() const override { return STRING_RESULT; }
536  const CHARSET_INFO *charset_for_protocol() override {
537  /*
538  Can return TIME, DATE, DATETIME or VARCHAR depending on arguments.
539  Send using "binary" when TIME, DATE or DATETIME,
540  or using collation.collation when VARCHAR
541  (which is fixed from @collation_connection in resolve_type()).
542  */
543  assert(fixed == 1);
545  : &my_charset_bin;
546  }
547  Field *tmp_table_field(TABLE *table) override {
548  return tmp_table_field_from_field_type(table, false);
549  }
550  longlong val_int() override { return val_int_from_decimal(); }
551  double val_real() override { return val_real_from_decimal(); }
552  my_decimal *val_decimal(my_decimal *decimal_value) override;
553  /**
554  Return string value in ASCII character set.
555  */
556  String *val_str_ascii(String *str) override;
557  /**
558  Return string value in @@character_set_connection.
559  */
560  String *val_str(String *str) override {
562  }
563  bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override;
564  bool get_time(MYSQL_TIME *ltime) override;
565 };
566 
567 /*
568  This can't be a Item_str_func, because the val_real() functions are special
569 */
570 
571 /**
572  Abstract class for functions returning DATE values.
573 */
575  protected:
577  return save_date_in_field(field);
578  }
579 
580  public:
584  }
588  }
589  Item_date_func(const POS &pos, Item *a, Item *b)
590  : Item_temporal_func(pos, a, b) {
592  }
593  bool get_time(MYSQL_TIME *ltime) override {
594  return get_time_from_date(ltime);
595  }
596  String *val_str(String *str) override { return val_string_from_date(str); }
597  longlong val_int() override { return val_int_from_date(); }
598  longlong val_date_temporal() override;
599  double val_real() override { return static_cast<double>(val_int()); }
600  const char *func_name() const override { return "date"; }
601  enum Functype functype() const override { return DATE_FUNC; }
602  bool resolve_type(THD *) override { return false; }
603  my_decimal *val_decimal(my_decimal *decimal_value) override {
604  assert(fixed == 1);
605  return val_decimal_from_date(decimal_value);
606  }
607  // All date functions must implement get_date()
608  // to avoid use of generic Item::get_date()
609  // which converts to string and then parses the string as DATE.
610  bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override = 0;
611 };
612 
613 /**
614  Abstract class for functions returning DATETIME values.
615 */
617  protected:
619  return save_date_in_field(field);
620  }
621 
622  public:
625  }
628  }
631  }
634  }
636  : Item_temporal_func(pos, a, b) {
638  }
641  }
642  Item_datetime_func(const POS &pos, Item *a, Item *b, Item *c)
643  : Item_temporal_func(pos, a, b, c) {
645  }
646  Item_datetime_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
647  : Item_temporal_func(pos, a, b, c, d) {
649  }
651  : Item_temporal_func(pos, list) {
653  }
654 
655  double val_real() override { return val_real_from_decimal(); }
656  String *val_str(String *str) override {
658  }
659  longlong val_int() override { return val_int_from_datetime(); }
660  longlong val_date_temporal() override;
661  my_decimal *val_decimal(my_decimal *decimal_value) override {
662  assert(fixed == 1);
663  return val_decimal_from_date(decimal_value);
664  }
665  bool get_time(MYSQL_TIME *ltime) override {
666  return get_time_from_datetime(ltime);
667  }
668  // All datetime functions must implement get_date()
669  // to avoid use of generic Item::get_date()
670  // which converts to string and then parses the string as DATETIME.
671  bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override = 0;
672 };
673 
674 /**
675  Abstract class for functions returning TIME values.
676 */
678  protected:
680  return save_time_in_field(field);
681  }
682 
683  public:
687  }
690  }
693  }
694  Item_time_func(const POS &pos, Item *a, Item *b)
695  : Item_temporal_func(pos, a, b) {
697  }
698  Item_time_func(const POS &pos, Item *a, Item *b, Item *c)
699  : Item_temporal_func(pos, a, b, c) {
701  }
702  double val_real() override { return val_real_from_decimal(); }
703  my_decimal *val_decimal(my_decimal *decimal_value) override {
704  assert(fixed);
705  return val_decimal_from_time(decimal_value);
706  }
707  longlong val_int() override { return val_int_from_time(); }
708  longlong val_time_temporal() override;
709  bool get_date(MYSQL_TIME *res, my_time_flags_t) override {
710  return get_date_from_time(res);
711  }
712  String *val_str(String *str) override { return val_string_from_time(str); }
713  // All time functions must implement get_time()
714  // to avoid use of generic Item::get_time()
715  // which converts to string and then parses the string as TIME.
716  bool get_time(MYSQL_TIME *res) override = 0;
717 };
718 
719 /**
720  Cache for MYSQL_TIME value with various representations.
721 
722  - MYSQL_TIME representation (time) is initialized during set_XXX().
723  - Packed representation (time_packed) is also initialized during set_XXX().
724  - String representation (string_buff) is also initialized during set_XXX();
725 */
727  MYSQL_TIME time; ///< MYSQL_TIME representation
728  longlong time_packed; ///< packed representation
729  char string_buff[MAX_DATE_STRING_REP_LENGTH]; ///< string representation
730  uint string_length; ///< length of string
731  uint8 dec; ///< Number of decimals
732 
733  /**
734  Store MYSQL_TIME representation into the given MYSQL_TIME variable.
735  */
736  void get_TIME(MYSQL_TIME *ltime) const {
738  *ltime = time;
739  }
740 
741  public:
744  string_buff[0] = '\0';
745  }
746  /**
747  Set time and time_packed from a DATE value.
748  */
749  void set_date(MYSQL_TIME *ltime);
750  /**
751  Set time and time_packed from a TIME value.
752  */
753  void set_time(MYSQL_TIME *ltime, uint8 dec_arg);
754  /**
755  Set time and time_packed from a DATETIME value.
756  */
757  void set_datetime(MYSQL_TIME *ltime, uint8 dec_arg,
758  const Time_zone *tz = nullptr);
759  /**
760  Set time and time_packed according to DATE value
761  in "struct timeval" representation and its time zone.
762  */
763  void set_date(struct timeval tv, Time_zone *tz);
764  /**
765  Set time and time_packed according to TIME value
766  in "struct timeval" representation and its time zone.
767  */
768  void set_time(struct timeval tv, uint8 dec_arg, Time_zone *tz);
769  /**
770  Set time and time_packed according to DATETIME value
771  in "struct timeval" representation and its time zone.
772  */
773  void set_datetime(struct timeval tv, uint8 dec_arg, Time_zone *tz);
774  /**
775  Test if cached value is equal to another MYSQL_TIME_cache value.
776  */
777  bool eq(const MYSQL_TIME_cache &tm) const {
778  return val_packed() == tm.val_packed();
779  }
780 
781  /**
782  Return number of decimal digits.
783  */
784  uint8 decimals() const {
786  return dec;
787  }
788 
789  /**
790  Return packed representation.
791  */
794  return time_packed;
795  }
796  /**
797  Store MYSQL_TIME representation into the given date/datetime variable
798  checking date flags.
799  */
800  bool get_date(MYSQL_TIME *ltime, uint fuzzyflags) const;
801  /**
802  Store MYSQL_TIME representation into the given time variable.
803  */
804  bool get_time(MYSQL_TIME *ltime) const {
805  get_TIME(ltime);
806  return false;
807  }
808  /**
809  Return pointer to MYSQL_TIME representation.
810  */
813  return &time;
814  }
815  /**
816  Store string representation into String.
817  */
819  /**
820  Return C string representation.
821  */
822  const char *cptr() const { return string_buff; }
823 };
824 
825 /**
826  DATE'2010-01-01'
827 */
828 class Item_date_literal final : public Item_date_func {
830 
831  public:
832  /**
833  Constructor for Item_date_literal.
834  @param ltime DATE value.
835  */
837  cached_time.set_date(ltime);
839  fixed = true;
840  }
841  const char *func_name() const override { return "date_literal"; }
842  void print(const THD *thd, String *str,
843  enum_query_type query_type) const override;
845  assert(fixed);
846  return cached_time.val_packed();
847  }
848  bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date) override {
849  assert(fixed);
850  return cached_time.get_date(ltime, fuzzy_date);
851  }
852  String *val_str(String *str) override {
853  assert(fixed);
854  return cached_time.val_str(str);
855  }
856  bool resolve_type(THD *) override { return false; }
857  bool check_partition_func_processor(uchar *) override { return false; }
858  bool basic_const_item() const override { return true; }
859  table_map used_tables() const override { return 0; }
860  table_map not_null_tables() const override { return used_tables(); }
861  void cleanup() override { assert(marker == MARKER_NONE); }
862  bool eq(const Item *item, bool binary_cmp) const override;
863 };
864 
865 /**
866  TIME'10:10:10'
867 */
868 class Item_time_literal final : public Item_time_func {
870 
871  public:
872  /**
873  Constructor for Item_time_literal.
874  @param ltime TIME value.
875  @param dec_arg number of fractional digits in ltime.
876  */
877  Item_time_literal(MYSQL_TIME *ltime, uint dec_arg) {
878  set_data_type_time(std::min(dec_arg, uint(DATETIME_MAX_DECIMALS)));
879  cached_time.set_time(ltime, decimals);
880  fixed = true;
881  }
882  const char *func_name() const override { return "time_literal"; }
883  void print(const THD *thd, String *str,
884  enum_query_type query_type) const override;
886  assert(fixed);
887  return cached_time.val_packed();
888  }
889  bool get_time(MYSQL_TIME *ltime) override {
890  assert(fixed);
891  return cached_time.get_time(ltime);
892  }
893  String *val_str(String *str) override {
894  assert(fixed);
895  return cached_time.val_str(str);
896  }
897  bool resolve_type(THD *) override { return false; }
898  bool check_partition_func_processor(uchar *) override { return false; }
899  bool basic_const_item() const override { return true; }
900  table_map used_tables() const override { return 0; }
901  table_map not_null_tables() const override { return used_tables(); }
902  void cleanup() override { assert(marker == MARKER_NONE); }
903  bool eq(const Item *item, bool binary_cmp) const override;
904 };
905 
906 /**
907  TIMESTAMP'2001-01-01 10:20:30'
908 */
911 
912  public:
913  /**
914  Constructor for Item_datetime_literal.
915  @param ltime DATETIME value.
916  @param dec_arg Number of fractional digits in ltime.
917  @param tz The current time zone, used for converting literals with
918  time zone upon storage.
919  */
920  Item_datetime_literal(MYSQL_TIME *ltime, uint dec_arg, const Time_zone *tz) {
922  cached_time.set_datetime(ltime, decimals, tz);
923  fixed = true;
924  }
925  const char *func_name() const override { return "datetime_literal"; }
926  enum Functype functype() const override { return DATETIME_LITERAL; }
927  void print(const THD *thd, String *str,
928  enum_query_type query_type) const override;
930  assert(fixed);
931  return cached_time.val_packed();
932  }
933  bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date) override {
934  assert(fixed);
935  return cached_time.get_date(ltime, fuzzy_date);
936  }
937  String *val_str(String *str) override {
938  assert(fixed);
939  return cached_time.val_str(str);
940  }
941  bool resolve_type(THD *) override { return false; }
942  bool check_partition_func_processor(uchar *) override { return false; }
943  bool basic_const_item() const override { return true; }
944  table_map used_tables() const override { return 0; }
945  table_map not_null_tables() const override { return used_tables(); }
946  void cleanup() override { assert(marker == MARKER_NONE); }
947  bool eq(const Item *item, bool binary_cmp) const override;
948 };
949 
950 /**
951  This function implements the `AT TIME ZONE` operator, which casts a temporal
952  value to a temporal with time zone.
953 
954  This function is hidden from the user except when used in a cast() operation,
955  the reason being that it adds time zone information to a temporal value, and
956  we don't currently have a type that corresponds to such a value. Hence the
957  only way to evaluate this function is by a concomitant cast to a temporal
958  without time zone designation. However, the value is not converted according
959  to the current time zone as is normally the case. For `TIMESTAMP`, this means
960  that the value is converted to the time zone given as argument to this
961  function rather than the session's time zone. And as we currently only support
962  the UTC time zone or the equivalent `INTERVAL '+00:00'`, so in practice the
963  value is not converted at all. This is a bit similar to the unix_timestamp()
964  function, but that one converts any argument (DATETIME, TIME) to UTC from the
965  session's time zone. This operator only accepts `TIMESTAMP` values.
966 */
968  public:
969  Item_func_at_time_zone(const POS &pos, Item *datetime,
970  const char *specifier_string, bool is_interval)
971  : Item_datetime_func(pos, datetime),
973  m_is_interval(is_interval) {}
974 
975  bool resolve_type(THD *) override;
976 
977  const char *func_name() const override { return "time_zone"; }
978 
979  bool set_time_zone(THD *thd);
980 
981  bool get_date(MYSQL_TIME *res, my_time_flags_t) override;
982 
983  const char *specifier_string() const { return m_specifier_string; }
984 
985  protected:
986  bool check_type() const;
987 
988  private:
989  /// The time zone that the specifier string argument resolves to.
990  const Time_zone *m_tz{nullptr};
991 
992  /// The specifier string argument, not used after resolution.
993  const char *m_specifier_string;
994 
995  /**
996  Whether the syntax used the `INTERVAL` construction. We have no interval
997  type.
998  */
1000 };
1001 
1002 /// Abstract CURTIME function. Children should define what time zone is used.
1005 
1006  protected:
1007  // Abstract method that defines which time zone is used for conversion.
1008  virtual Time_zone *time_zone() = 0;
1009 
1010  public:
1011  /**
1012  Constructor for Item_func_curtime.
1013  @param pos Position of token in the parser.
1014  @param dec_arg Number of fractional digits.
1015  */
1017  decimals = dec_arg;
1018  }
1019 
1020  bool itemize(Parse_context *pc, Item **res) override;
1021 
1022  /// This function must assign a new value for each execution
1024  return INNER_TABLE_BIT;
1025  }
1026 
1027  bool resolve_type(THD *thd) override;
1028  longlong val_time_temporal() override;
1029  bool get_time(MYSQL_TIME *ltime) override;
1030  String *val_str(String *) override;
1031  bool check_function_as_value_generator(uchar *checker_args) override {
1033  pointer_cast<Check_function_as_value_generator_parameters *>(
1034  checker_args);
1035  func_arg->banned_function_name = func_name();
1036  return ((func_arg->source == VGS_GENERATED_COLUMN) ||
1037  (func_arg->source == VGS_CHECK_CONSTRAINT));
1038  }
1039 };
1040 
1042  protected:
1043  Time_zone *time_zone() override;
1044 
1045  public:
1047  : Item_func_curtime(pos, dec_arg) {}
1048  const char *func_name() const override { return "curtime"; }
1049 };
1050 
1052  protected:
1053  Time_zone *time_zone() override;
1054 
1055  public:
1057  : Item_func_curtime(pos, dec_arg) {}
1058  const char *func_name() const override { return "utc_time"; }
1059 };
1060 
1061 /**
1062  Abstract CURDATE function.
1063 
1064  @sa Item_func_curtime
1065  */
1068 
1069  protected:
1070  virtual Time_zone *time_zone() = 0;
1071 
1072  public:
1073  explicit Item_func_curdate(const POS &pos) : Item_date_func(pos) {}
1074 
1075  bool itemize(Parse_context *pc, Item **res) override;
1076 
1077  /// This function must assign a new value for each execution
1079  return INNER_TABLE_BIT;
1080  }
1081 
1082  bool resolve_type(THD *) override;
1083  longlong val_date_temporal() override;
1084  bool get_date(MYSQL_TIME *res, my_time_flags_t) override;
1085  String *val_str(String *) override;
1086  bool check_function_as_value_generator(uchar *checker_args) override {
1088  pointer_cast<Check_function_as_value_generator_parameters *>(
1089  checker_args);
1090  func_arg->banned_function_name = func_name();
1091  return ((func_arg->source == VGS_GENERATED_COLUMN) ||
1092  (func_arg->source == VGS_CHECK_CONSTRAINT));
1093  }
1094 };
1095 
1097  protected:
1098  Time_zone *time_zone() override;
1099 
1100  public:
1102  const char *func_name() const override { return "curdate"; }
1103 };
1104 
1106  protected:
1107  Time_zone *time_zone() override;
1108 
1109  public:
1111  const char *func_name() const override { return "utc_date"; }
1112 };
1113 
1114 /**
1115  Abstract CURRENT_TIMESTAMP function.
1116 
1117  @sa Item_func_curtime
1118 */
1120  protected:
1121  virtual Time_zone *time_zone() = 0;
1123  bool no_conversions) override;
1124 
1125  public:
1126  /**
1127  Constructor for Item_func_now.
1128  @param dec_arg Number of fractional digits.
1129  */
1130  Item_func_now(uint8 dec_arg) : Item_datetime_func() { decimals = dec_arg; }
1132  decimals = dec_arg;
1133  }
1134 
1135  /// This function must assign a new value for each execution
1137  return INNER_TABLE_BIT;
1138  }
1139 
1140  bool resolve_type(THD *) override;
1141  longlong val_date_temporal() override;
1142  bool get_date(MYSQL_TIME *res, my_time_flags_t) override;
1143  String *val_str(String *) override;
1144  bool check_function_as_value_generator(uchar *checker_args) override {
1146  pointer_cast<Check_function_as_value_generator_parameters *>(
1147  checker_args);
1148  func_arg->banned_function_name = func_name();
1149  return ((func_arg->source == VGS_GENERATED_COLUMN) ||
1150  (func_arg->source == VGS_CHECK_CONSTRAINT));
1151  }
1152 };
1153 
1155  protected:
1156  Time_zone *time_zone() override;
1157 
1158  public:
1159  /**
1160  Stores the query start time in a field, truncating to the field's number
1161  of fractional second digits.
1162 
1163  @param field The field to store in.
1164  */
1165  static void store_in(Field *field);
1166 
1167  Item_func_now_local(uint8 dec_arg) : Item_func_now(dec_arg) {}
1169  : Item_func_now(pos, dec_arg) {}
1170 
1171  const char *func_name() const override { return "now"; }
1172  enum Functype functype() const override { return NOW_FUNC; }
1173 };
1174 
1175 class Item_func_now_utc final : public Item_func_now {
1177 
1178  protected:
1179  Time_zone *time_zone() override;
1180 
1181  public:
1182  Item_func_now_utc(const POS &pos, uint8 dec_arg)
1183  : Item_func_now(pos, dec_arg) {}
1184 
1185  bool itemize(Parse_context *pc, Item **res) override;
1186 
1187  const char *func_name() const override { return "utc_timestamp"; }
1188 };
1189 
1190 /**
1191  SYSDATE() is like NOW(), but always uses the real current time, not the
1192  query_start(). This matches the Oracle behavior.
1193 */
1195  public:
1197  decimals = dec_arg;
1198  }
1199  const char *func_name() const override { return "sysdate"; }
1200  bool resolve_type(THD *) override;
1201  bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override;
1202  /**
1203  This function is non-deterministic and hence depends on the 'RAND'
1204  pseudo-table.
1205 
1206  @retval Always RAND_TABLE_BIT
1207  */
1209  return RAND_TABLE_BIT;
1210  }
1211 };
1212 
1213 class Item_func_from_days final : public Item_date_func {
1214  public:
1216  const char *func_name() const override { return "from_days"; }
1217  bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override;
1218  bool check_partition_func_processor(uchar *) override { return false; }
1220  return has_date_args() || has_time_args();
1221  }
1222  bool resolve_type(THD *thd) override {
1223  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_LONGLONG)) return true;
1224  return Item_date_func::resolve_type(thd);
1225  }
1226 };
1227 
1228 class Item_func_date_format final : public Item_str_func {
1230  const bool is_time_format;
1232 
1233  public:
1235  bool is_time_format_arg = false)
1236  : Item_str_func(pos, a, b), is_time_format(is_time_format_arg) {}
1237  String *val_str(String *str) override;
1238  const char *func_name() const override {
1239  return is_time_format ? "time_format" : "date_format";
1240  }
1241  bool resolve_type(THD *thd) override;
1242  uint format_length(const String *format);
1243  bool eq(const Item *item, bool binary_cmp) const override;
1244 };
1245 
1247  public:
1249  : Item_datetime_func(pos, a) {}
1250  const char *func_name() const override { return "from_unixtime"; }
1251  enum Functype functype() const override { return FROM_UNIXTIME_FUNC; }
1252  bool resolve_type(THD *thd) override;
1253  bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override;
1254 };
1255 
1256 /*
1257  This class represents CONVERT_TZ() function.
1258  The important fact about this function that it is handled in special way.
1259  When such function is met in expression time_zone system tables are added
1260  to global list of tables to open, so later those already opened and locked
1261  tables can be used during this function calculation for loading time zone
1262  descriptions.
1263 */
1265  /*
1266  If time zone parameters are constants we are caching objects that
1267  represent them (we use separate from_tz_cached/to_tz_cached members
1268  to indicate this fact, since NULL is legal value for from_tz/to_tz
1269  members.
1270  */
1273 
1274  public:
1276  : Item_datetime_func(pos, a, b, c),
1277  from_tz_cached(false),
1278  to_tz_cached(false) {}
1279  const char *func_name() const override { return "convert_tz"; }
1280  enum Functype functype() const override { return CONVERT_TZ_FUNC; }
1281  bool resolve_type(THD *) override;
1282  bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override;
1283  void cleanup() override;
1284 };
1285 
1287  public:
1289  : Item_time_func(pos, item) {}
1290  bool resolve_type(THD *thd) override {
1291  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_NEWDECIMAL)) return true;
1293  std::min(args[0]->decimals, uint8{DATETIME_MAX_DECIMALS}));
1294  set_nullable(true);
1295  return false;
1296  }
1297  const char *func_name() const override { return "sec_to_time"; }
1298  bool get_time(MYSQL_TIME *ltime) override;
1299 };
1300 
1301 extern const char *interval_names[];
1302 
1305  bool get_date_internal(MYSQL_TIME *res, my_time_flags_t fuzzy_date);
1306  bool get_time_internal(MYSQL_TIME *res);
1307 
1308  protected:
1309  bool val_datetime(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date) override;
1310 
1311  public:
1312  const interval_type int_type; // keep it public
1313  const bool date_sub_interval; // keep it public
1315  interval_type type_arg, bool neg_arg)
1316  : Item_temporal_hybrid_func(pos, a, b),
1317  int_type(type_arg),
1318  date_sub_interval(neg_arg) {}
1319  /**
1320  POS-less ctor for post-parse construction with implicit addition to THD's
1321  free_list (see Item::Item() no-argument ctor).
1322  */
1323  Item_date_add_interval(Item *a, Item *b, interval_type type_arg, bool neg_arg)
1324  : Item_temporal_hybrid_func(a, b),
1325  int_type(type_arg),
1326  date_sub_interval(neg_arg) {}
1327  const char *func_name() const override { return "date_add_interval"; }
1328  enum Functype functype() const override { return DATEADD_FUNC; }
1329  bool resolve_type(THD *) override;
1330  bool eq(const Item *item, bool binary_cmp) const override;
1331  void print(const THD *thd, String *str,
1332  enum_query_type query_type) const override;
1333 };
1334 
1335 class Item_extract final : public Item_int_func {
1337 
1338  public:
1339  const interval_type int_type; // keep it public
1340  Item_extract(const POS &pos, interval_type type_arg, Item *a)
1341  : Item_int_func(pos, a), int_type(type_arg) {}
1342  longlong val_int() override;
1343  enum Functype functype() const override { return EXTRACT_FUNC; }
1344  const char *func_name() const override { return "extract"; }
1345  bool resolve_type(THD *) override;
1346  bool eq(const Item *item, bool binary_cmp) const override;
1347  void print(const THD *thd, String *str,
1348  enum_query_type query_type) const override;
1349  bool check_partition_func_processor(uchar *) override { return false; }
1351  switch (int_type) {
1352  case INTERVAL_YEAR:
1353  case INTERVAL_YEAR_MONTH:
1354  case INTERVAL_QUARTER:
1355  case INTERVAL_MONTH:
1356  /* case INTERVAL_WEEK: Not allowed as partitioning function, bug#57071 */
1357  case INTERVAL_DAY:
1358  return !has_date_args();
1359  case INTERVAL_DAY_HOUR:
1360  case INTERVAL_DAY_MINUTE:
1361  case INTERVAL_DAY_SECOND:
1363  return !has_datetime_args();
1364  case INTERVAL_HOUR:
1365  case INTERVAL_HOUR_MINUTE:
1366  case INTERVAL_HOUR_SECOND:
1367  case INTERVAL_MINUTE:
1369  case INTERVAL_SECOND:
1370  case INTERVAL_MICROSECOND:
1374  return !has_time_args();
1375  default:
1376  /*
1377  INTERVAL_LAST is only an end marker,
1378  INTERVAL_WEEK depends on default_week_format which is a session
1379  variable and cannot be used for partitioning. See bug#57071.
1380  */
1381  break;
1382  }
1383  return true;
1384  }
1385 };
1386 
1387 class Item_typecast_date final : public Item_date_func {
1388  bool m_explicit_cast{true};
1389 
1390  public:
1391  Item_typecast_date(Item *a, bool explicit_cast)
1392  : Item_date_func(a), m_explicit_cast(explicit_cast) {
1393  set_nullable(true);
1394  }
1396  set_nullable(true);
1397  }
1398 
1399  bool resolve_type(THD *thd) override {
1400  if (args[0]->propagate_type(thd, MYSQL_TYPE_DATE, false, true)) return true;
1401  return Item_date_func::resolve_type(thd);
1402  }
1403  void print(const THD *thd, String *str,
1404  enum_query_type query_type) const override;
1405  const char *func_name() const override { return "cast_as_date"; }
1406  enum Functype functype() const override { return TYPECAST_FUNC; }
1407  bool is_explicit_cast() const { return m_explicit_cast; }
1408  bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date) override;
1409  const char *cast_type() const { return "date"; }
1410 };
1411 
1412 class Item_typecast_time final : public Item_time_func {
1414  bool m_explicit_cast{true};
1415 
1416  public:
1419  }
1422  }
1423  Item_typecast_time(const POS &pos, Item *a, uint8 dec_arg)
1424  : Item_time_func(pos, a) {
1425  detect_precision_from_arg = false;
1426  decimals = dec_arg;
1427  }
1429  detect_precision_from_arg = false;
1430  decimals = dec_arg;
1431  }
1432  void print(const THD *thd, String *str,
1433  enum_query_type query_type) const override;
1434  const char *func_name() const override { return "cast_as_time"; }
1435  enum Functype functype() const override { return TYPECAST_FUNC; }
1436  bool is_explicit_cast() const { return m_explicit_cast; }
1437  bool get_time(MYSQL_TIME *ltime) override;
1438  const char *cast_type() const { return "time"; }
1439  bool resolve_type(THD *thd) override {
1440  if (args[0]->propagate_type(thd, MYSQL_TYPE_DATETIME, false, true))
1441  return true;
1443  : decimals);
1444  set_nullable(true);
1445  return false;
1446  }
1447 };
1448 
1451  bool m_explicit_cast{true};
1452 
1453  public:
1454  Item_typecast_datetime(Item *a, bool explicit_cast)
1455  : Item_datetime_func(a), m_explicit_cast(explicit_cast) {
1457  }
1460  }
1461  Item_typecast_datetime(const POS &pos, Item *a, uint8 dec_arg)
1462  : Item_datetime_func(pos, a) {
1463  detect_precision_from_arg = false;
1464  decimals = dec_arg;
1465  }
1467  detect_precision_from_arg = false;
1468  decimals = dec_arg;
1469  }
1470  void print(const THD *thd, String *str,
1471  enum_query_type query_type) const override;
1472  const char *func_name() const override { return "cast_as_datetime"; }
1473  enum Functype functype() const override { return TYPECAST_FUNC; }
1474  const char *cast_type() const { return "datetime"; }
1475  bool is_explicit_cast() const { return m_explicit_cast; }
1476  bool resolve_type(THD *thd) override {
1477  if (args[0]->propagate_type(thd, MYSQL_TYPE_DATETIME, false, true))
1478  return true;
1481  set_nullable(true);
1482  return false;
1483  }
1484  bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override;
1485 };
1486 
1487 class Item_func_makedate final : public Item_date_func {
1488  public:
1490  : Item_date_func(pos, a, b) {
1491  set_nullable(true);
1492  }
1493  const char *func_name() const override { return "makedate"; }
1494  bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date) override;
1495  enum Functype functype() const override { return MAKEDATE_FUNC; }
1496  bool resolve_type(THD *thd) override {
1497  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_LONGLONG)) return true;
1498  return Item_date_func::resolve_type(thd);
1499  }
1500 };
1501 
1503  const bool is_date;
1504  int sign;
1505  bool val_datetime(MYSQL_TIME *time, my_time_flags_t fuzzy_date) override;
1506 
1507  public:
1508  Item_func_add_time(Item *a, Item *b, bool type_arg, bool neg_arg)
1509  : Item_temporal_hybrid_func(a, b), is_date(type_arg) {
1510  sign = neg_arg ? -1 : 1;
1511  }
1512  Item_func_add_time(const POS &pos, Item *a, Item *b, bool type_arg,
1513  bool neg_arg)
1514  : Item_temporal_hybrid_func(pos, a, b), is_date(type_arg) {
1515  sign = neg_arg ? -1 : 1;
1516  }
1517 
1519  : Item_func_add_time(pos, a, b, false, false) {}
1520 
1521  bool resolve_type(THD *) override;
1522  void print(const THD *thd, String *str,
1523  enum_query_type query_type) const override;
1524  const char *func_name() const override { return "add_time"; }
1525  enum Functype functype() const override { return ADDTIME_FUNC; }
1526  int get_sign() const { return sign; }
1527 };
1528 
1529 class Item_func_timediff final : public Item_time_func {
1530  public:
1532  : Item_time_func(pos, a, b) {}
1533  const char *func_name() const override { return "timediff"; }
1534  bool resolve_type(THD *thd) override {
1535  /*
1536  This function can operate on two TIME, or on two DATETIME (no mix).
1537  We infer the type from the other argument. If both arguments are '?', we
1538  choose VARCHAR; indeed, if we chose TIME and get DATETIME, we risk
1539  cutting the date part, and if we chose DATETIME and get TIME, we risk
1540  interpreting "01:01:01" as "2001:01:01 00:00:00".
1541  */
1542  if (param_type_uses_non_param(thd)) return true;
1544  std::max(args[0]->time_precision(), args[1]->time_precision()));
1545  set_nullable(true);
1546  return false;
1547  }
1548  bool get_time(MYSQL_TIME *ltime) override;
1549 };
1550 
1551 class Item_func_maketime final : public Item_time_func {
1552  public:
1553  Item_func_maketime(const POS &pos, Item *a, Item *b, Item *c)
1554  : Item_time_func(pos, a, b, c) {
1555  set_nullable(true);
1556  }
1557  bool resolve_type(THD *thd) override {
1558  if (param_type_is_default(thd, 0, 2, MYSQL_TYPE_LONGLONG)) return true;
1559  if (param_type_is_default(thd, 2, 3, MYSQL_TYPE_NEWDECIMAL)) return true;
1561  std::min(args[2]->decimals, uint8{DATETIME_MAX_DECIMALS}));
1562  return false;
1563  }
1564  const char *func_name() const override { return "maketime"; }
1565  bool get_time(MYSQL_TIME *ltime) override;
1566 };
1567 
1568 class Item_func_microsecond final : public Item_int_func {
1569  public:
1571  longlong val_int() override;
1572  const char *func_name() const override { return "microsecond"; }
1573  enum Functype functype() const override { return MICROSECOND_FUNC; }
1574  bool resolve_type(THD *thd) override;
1575  bool check_partition_func_processor(uchar *) override { return false; }
1577  return !has_time_args();
1578  }
1579 };
1580 
1583 
1584  public:
1586  interval_type type_arg)
1587  : Item_int_func(pos, a, b), int_type(type_arg) {}
1588  const char *func_name() const override { return "timestampdiff"; }
1589  enum Functype functype() const override { return TIMESTAMPDIFF_FUNC; }
1591  longlong val_int() override;
1592  bool resolve_type(THD *thd) override {
1593  if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_DATETIME)) return true;
1594  set_nullable(true);
1595  return false;
1596  }
1597  void print(const THD *thd, String *str,
1598  enum_query_type query_type) const override;
1599 };
1600 
1607 };
1608 
1610  public:
1611  const enum_mysql_timestamp_type type; // keep it public
1613  Item *a)
1614  : Item_str_ascii_func(pos, a), type(type_arg) {}
1615  String *val_str_ascii(String *str) override;
1616  const char *func_name() const override { return "get_format"; }
1617  bool resolve_type(THD *) override {
1618  set_nullable(true);
1620  return false;
1621  }
1622  void print(const THD *thd, String *str,
1623  enum_query_type query_type) const override;
1624 };
1625 
1628  void fix_from_format(const char *format, size_t length);
1629 
1630  protected:
1631  bool val_datetime(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date) override;
1632 
1633  public:
1635  : Item_temporal_hybrid_func(pos, a, b) {}
1636  const char *func_name() const override { return "str_to_date"; }
1637  bool resolve_type(THD *) override;
1638 };
1639 
1640 class Item_func_last_day final : public Item_date_func {
1641  public:
1643  set_nullable(true);
1644  }
1645  const char *func_name() const override { return "last_day"; }
1646  bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override;
1647  bool resolve_type(THD *thd) override {
1648  if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_DATETIME)) return true;
1649  return Item_date_func::resolve_type(thd);
1650  }
1651 };
1652 
1654  public:
1656  : Item_datetime_func(pos, list) {}
1657  enum Functype functype() const override { return DD_INTERNAL_FUNC; }
1658  const char *func_name() const override { return "internal_update_time"; }
1659  bool resolve_type(THD *thd) override;
1660  bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override;
1661 };
1662 
1664  public:
1666  : Item_datetime_func(pos, list) {}
1667  enum Functype functype() const override { return DD_INTERNAL_FUNC; }
1668  const char *func_name() const override { return "internal_check_time"; }
1669  bool resolve_type(THD *thd) override;
1670  bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override;
1671 };
1672 
1673 /* Function prototypes */
1674 
1675 bool make_date_time(Date_time_format *format, MYSQL_TIME *l_time,
1677 
1678 #endif /* ITEM_TIMEFUNC_INCLUDED */
void set_numeric()
Definition: item.h:208
const CHARSET_INFO * collation
Definition: item.h:174
Definition: field.h:590
Definition: item_timefunc.h:1303
bool eq(const Item *item, bool binary_cmp) const override
Definition: item_timefunc.cc:2592
Item_date_add_interval(Item *a, Item *b, interval_type type_arg, bool neg_arg)
POS-less ctor for post-parse construction with implicit addition to THD's free_list (see Item::Item()...
Definition: item_timefunc.h:1323
enum Functype functype() const override
Definition: item_timefunc.h:1328
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:2626
Item_date_add_interval(const POS &pos, Item *a, Item *b, interval_type type_arg, bool neg_arg)
Definition: item_timefunc.h:1314
const char * func_name() const override
Definition: item_timefunc.h:1327
bool val_datetime(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date) override
Get "native" temporal value as MYSQL_TIME.
Definition: item_timefunc.cc:2585
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2433
bool get_date_internal(MYSQL_TIME *res, my_time_flags_t fuzzy_date)
Definition: item_timefunc.cc:2498
const bool date_sub_interval
Definition: item_timefunc.h:1313
String value
Definition: item_timefunc.h:1304
bool get_time_internal(MYSQL_TIME *res)
Definition: item_timefunc.cc:2533
const interval_type int_type
Definition: item_timefunc.h:1312
Abstract class for functions returning DATE values.
Definition: item_timefunc.h:574
double val_real() override
Definition: item_timefunc.h:599
bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override=0
const char * func_name() const override
Definition: item_timefunc.h:600
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_timefunc.h:603
String * val_str(String *str) override
Definition: item_timefunc.h:596
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:602
enum Functype functype() const override
Definition: item_timefunc.h:601
Item_date_func(const POS &pos)
Definition: item_timefunc.h:582
Item_date_func()
Definition: item_timefunc.h:581
Item_date_func(Item *a)
Definition: item_timefunc.h:585
Item_date_func(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:589
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.cc:914
bool get_time(MYSQL_TIME *ltime) override
Definition: item_timefunc.h:593
longlong val_int() override
Definition: item_timefunc.h:597
Item_date_func(const POS &pos, Item *a)
Definition: item_timefunc.h:586
type_conversion_status save_in_field_inner(Field *field, bool) override
Helper function which does all of the work for save_in_field(Field*, bool), except some error checkin...
Definition: item_timefunc.h:576
DATE'2010-01-01'.
Definition: item_timefunc.h:828
bool basic_const_item() const override
Returns true if this is a simple constant item like an integer, not a constant expression.
Definition: item_timefunc.h:858
Item_date_literal(MYSQL_TIME *ltime)
Constructor for Item_date_literal.
Definition: item_timefunc.h:836
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date) override
Definition: item_timefunc.h:848
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:856
void print(const THD *thd, String *str, enum_query_type query_type) const override
Appends function name with argument list or fractional seconds part to the String str.
Definition: item_timefunc.cc:938
bool eq(const Item *item, bool binary_cmp) const override
Definition: item_timefunc.cc:930
const char * func_name() const override
Definition: item_timefunc.h:841
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.h:844
String * val_str(String *str) override
Definition: item_timefunc.h:852
MYSQL_TIME_cache cached_time
Definition: item_timefunc.h:829
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_timefunc.h:861
table_map used_tables() const override
Definition: item_timefunc.h:859
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:857
table_map not_null_tables() const override
Return table map of tables that can't be NULL tables (tables that are used in a context where if they...
Definition: item_timefunc.h:860
Abstract class for functions returning DATETIME values.
Definition: item_timefunc.h:616
longlong val_int() override
Definition: item_timefunc.h:659
Item_datetime_func(Item *a)
Definition: item_timefunc.h:629
Item_datetime_func(const POS &pos)
Definition: item_timefunc.h:626
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_timefunc.h:661
Item_datetime_func()
Definition: item_timefunc.h:623
String * val_str(String *str) override
Definition: item_timefunc.h:656
double val_real() override
Definition: item_timefunc.h:655
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.cc:922
bool get_time(MYSQL_TIME *ltime) override
Definition: item_timefunc.h:665
Item_datetime_func(const POS &pos, PT_item_list *list)
Definition: item_timefunc.h:650
Item_datetime_func(Item *a, Item *b, Item *c)
Definition: item_timefunc.h:639
type_conversion_status save_in_field_inner(Field *field, bool) override
Helper function which does all of the work for save_in_field(Field*, bool), except some error checkin...
Definition: item_timefunc.h:618
Item_datetime_func(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_timefunc.h:642
bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override=0
Item_datetime_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_timefunc.h:646
Item_datetime_func(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:635
Item_datetime_func(const POS &pos, Item *a)
Definition: item_timefunc.h:632
TIMESTAMP'2001-01-01 10:20:30'.
Definition: item_timefunc.h:909
MYSQL_TIME_cache cached_time
Definition: item_timefunc.h:910
bool basic_const_item() const override
Returns true if this is a simple constant item like an integer, not a constant expression.
Definition: item_timefunc.h:943
const char * func_name() const override
Definition: item_timefunc.h:925
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:941
table_map not_null_tables() const override
Return table map of tables that can't be NULL tables (tables that are used in a context where if they...
Definition: item_timefunc.h:945
enum Functype functype() const override
Definition: item_timefunc.h:926
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_timefunc.h:946
Item_datetime_literal(MYSQL_TIME *ltime, uint dec_arg, const Time_zone *tz)
Constructor for Item_datetime_literal.
Definition: item_timefunc.h:920
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:942
void print(const THD *thd, String *str, enum_query_type query_type) const override
Appends function name with argument list or fractional seconds part to the String str.
Definition: item_timefunc.cc:952
bool eq(const Item *item, bool binary_cmp) const override
Definition: item_timefunc.cc:944
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date) override
Definition: item_timefunc.h:933
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.h:929
table_map used_tables() const override
Definition: item_timefunc.h:944
String * val_str(String *str) override
Definition: item_timefunc.h:937
Definition: item_timefunc.h:1335
bool date_value
Definition: item_timefunc.h:1336
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:1350
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:2637
enum Functype functype() const override
Definition: item_timefunc.h:1343
const char * func_name() const override
Definition: item_timefunc.h:1344
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2646
longlong val_int() override
Definition: item_timefunc.cc:2737
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:1349
const interval_type int_type
Definition: item_timefunc.h:1339
bool eq(const Item *item, bool binary_cmp) const override
Definition: item_timefunc.cc:2815
Item_extract(const POS &pos, interval_type type_arg, Item *a)
Definition: item_timefunc.h:1340
Definition: item_timefunc.h:1502
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2962
enum Functype functype() const override
Definition: item_timefunc.h:1525
bool val_datetime(MYSQL_TIME *time, my_time_flags_t fuzzy_date) override
ADDTIME(t,a) and SUBTIME(t,a) are time functions that calculate a time/datetime value.
Definition: item_timefunc.cc:3002
int get_sign() const
Definition: item_timefunc.h:1526
const char * func_name() const override
Definition: item_timefunc.h:1524
Item_func_add_time(const POS &pos, Item *a, Item *b, bool type_arg, bool neg_arg)
Definition: item_timefunc.h:1512
int sign
Definition: item_timefunc.h:1504
Item_func_add_time(Item *a, Item *b, bool type_arg, bool neg_arg)
Definition: item_timefunc.h:1508
const bool is_date
Definition: item_timefunc.h:1503
Item_func_add_time(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:1518
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:3071
This function implements the AT TIME ZONE operator, which casts a temporal value to a temporal with t...
Definition: item_timefunc.h:967
bool check_type() const
Definition: item_timefunc.cc:1021
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:973
bool set_time_zone(THD *thd)
Definition: item_timefunc.cc:985
const char * func_name() const override
Definition: item_timefunc.h:977
const char * specifier_string() const
Definition: item_timefunc.h:983
bool m_is_interval
Whether the syntax used the INTERVAL construction.
Definition: item_timefunc.h:999
bool get_date(MYSQL_TIME *res, my_time_flags_t) override
Definition: item_timefunc.cc:996
const char * m_specifier_string
The specifier string argument, not used after resolution.
Definition: item_timefunc.h:993
const Time_zone * m_tz
The time zone that the specifier string argument resolves to.
Definition: item_timefunc.h:990
Item_func_at_time_zone(const POS &pos, Item *datetime, const char *specifier_string, bool is_interval)
Definition: item_timefunc.h:969
Definition: item_timefunc.h:1264
bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override
Definition: item_timefunc.cc:2389
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2381
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_timefunc.cc:2427
const char * func_name() const override
Definition: item_timefunc.h:1279
Time_zone * from_tz
Definition: item_timefunc.h:1272
Item_func_convert_tz(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_timefunc.h:1275
bool from_tz_cached
Definition: item_timefunc.h:1271
bool to_tz_cached
Definition: item_timefunc.h:1271
enum Functype functype() const override
Definition: item_timefunc.h:1280
Time_zone * to_tz
Definition: item_timefunc.h:1272
Definition: item_timefunc.h:1096
Time_zone * time_zone() override
Definition: item_timefunc.cc:1975
const char * func_name() const override
Definition: item_timefunc.h:1102
Item_func_curdate_local(const POS &pos)
Definition: item_timefunc.h:1101
Definition: item_timefunc.h:1105
Time_zone * time_zone() override
Definition: item_timefunc.cc:1979
const char * func_name() const override
Definition: item_timefunc.h:1111
Item_func_curdate_utc(const POS &pos)
Definition: item_timefunc.h:1110
Abstract CURDATE function.
Definition: item_timefunc.h:1066
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1970
Item_date_func super
Definition: item_timefunc.h:1067
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.cc:1981
String * val_str(String *) override
Definition: item_timefunc.cc:1995
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_timefunc.h:1086
bool itemize(Parse_context *pc, Item **res) override
The same as contextualize() but with additional parameter.
Definition: item_timefunc.cc:1963
virtual Time_zone * time_zone()=0
bool get_date(MYSQL_TIME *res, my_time_flags_t) override
Definition: item_timefunc.cc:1988
Item_func_curdate(const POS &pos)
Definition: item_timefunc.h:1073
table_map get_initial_pseudo_tables() const override
This function must assign a new value for each execution.
Definition: item_timefunc.h:1078
Definition: item_timefunc.h:1041
Item_func_curtime_local(const POS &pos, uint8 dec_arg)
Definition: item_timefunc.h:1046
const char * func_name() const override
Definition: item_timefunc.h:1048
Time_zone * time_zone() override
Definition: item_timefunc.cc:2060
Definition: item_timefunc.h:1051
Time_zone * time_zone() override
Definition: item_timefunc.cc:2064
Item_func_curtime_utc(const POS &pos, uint8 dec_arg)
Definition: item_timefunc.h:1056
const char * func_name() const override
Definition: item_timefunc.h:1058
Abstract CURTIME function. Children should define what time zone is used.
Definition: item_timefunc.h:1003
virtual Time_zone * time_zone()=0
String * val_str(String *) override
Definition: item_timefunc.cc:2047
table_map get_initial_pseudo_tables() const override
This function must assign a new value for each execution.
Definition: item_timefunc.h:1023
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2016
bool get_time(MYSQL_TIME *ltime) override
Definition: item_timefunc.cc:2039
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_timefunc.h:1031
Item_func_curtime(const POS &pos, uint8 dec_arg)
Constructor for Item_func_curtime.
Definition: item_timefunc.h:1016
bool itemize(Parse_context *pc, Item **res) override
The same as contextualize() but with additional parameter.
Definition: item_timefunc.cc:2009
longlong val_time_temporal() override
Return time value of item in packed longlong format.
Definition: item_timefunc.cc:2031
Item_time_func super
Definition: item_timefunc.h:1004
Definition: item_timefunc.h:1228
bool eq(const Item *item, bool binary_cmp) const override
Definition: item_timefunc.cc:2200
const bool is_time_format
Definition: item_timefunc.h:1230
int fixed_length
Definition: item_timefunc.h:1229
String * val_str(String *str) override
Definition: item_timefunc.cc:2288
Item_func_date_format(const POS &pos, Item *a, Item *b, bool is_time_format_arg=false)
Definition: item_timefunc.h:1234
String value
Definition: item_timefunc.h:1231
uint format_length(const String *format)
Definition: item_timefunc.cc:2218
const char * func_name() const override
Definition: item_timefunc.h:1238
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2172
TS-TODO: Item_func_dayname should be derived from Item_str_func.
Definition: item_timefunc.h:349
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override
Definition: item_timefunc.h:358
enum Item_result result_type() const override
Definition: item_timefunc.h:364
bool get_time(MYSQL_TIME *ltime) override
Definition: item_timefunc.h:361
Item_func_dayname(const POS &pos, Item *a)
Definition: item_timefunc.h:353
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1466
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:366
String * val_str(String *str) override
Definition: item_timefunc.cc:1477
MY_LOCALE * locale
Definition: item_timefunc.h:350
const char * func_name() const override
Definition: item_timefunc.h:355
enum Functype functype() const override
Definition: item_timefunc.h:356
Definition: item_timefunc.h:123
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:132
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1233
const char * func_name() const override
Definition: item_timefunc.h:128
Item_func_dayofmonth(const POS &pos, Item *a)
Definition: item_timefunc.h:125
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:131
longlong val_int() override
Definition: item_timefunc.cc:1243
enum Functype functype() const override
Definition: item_timefunc.h:129
Definition: item_timefunc.h:186
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1215
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:194
const char * func_name() const override
Definition: item_timefunc.h:190
longlong val_int() override
Definition: item_timefunc.cc:1225
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:193
Item_func_dayofyear(const POS &pos, Item *a)
Definition: item_timefunc.h:188
enum Functype functype() const override
Definition: item_timefunc.h:191
Definition: item_timefunc.h:1213
Item_func_from_days(const POS &pos, Item *a)
Definition: item_timefunc.h:1215
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:1219
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1222
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:1218
bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override
Definition: item_timefunc.cc:1868
const char * func_name() const override
Definition: item_timefunc.h:1216
Definition: item_timefunc.h:1246
bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override
Definition: item_timefunc.cc:2338
const char * func_name() const override
Definition: item_timefunc.h:1250
Item_func_from_unixtime(const POS &pos, Item *a)
Definition: item_timefunc.h:1248
enum Functype functype() const override
Definition: item_timefunc.h:1251
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2330
Definition: item_timefunc.h:1609
const char * func_name() const override
Definition: item_timefunc.h:1616
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1617
String * val_str_ascii(String *str) override
Definition: item_timefunc.cc:3376
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:3403
Item_func_get_format(const POS &pos, enum_mysql_timestamp_type type_arg, Item *a)
Definition: item_timefunc.h:1612
const enum_mysql_timestamp_type type
Definition: item_timefunc.h:1611
Definition: item_timefunc.h:199
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1311
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:207
longlong val_int() override
Definition: item_timefunc.cc:1320
const char * func_name() const override
Definition: item_timefunc.h:203
enum Functype functype() const override
Definition: item_timefunc.h:204
Item_func_hour(const POS &pos, Item *a)
Definition: item_timefunc.h:201
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:206
Definition: item_timefunc.h:1663
enum Functype functype() const override
Definition: item_timefunc.h:1667
bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override
Definition: item_timefunc.cc:3683
Item_func_internal_check_time(const POS &pos, PT_item_list *list)
Definition: item_timefunc.h:1665
const char * func_name() const override
Definition: item_timefunc.h:1668
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3675
Definition: item_timefunc.h:1653
enum Functype functype() const override
Definition: item_timefunc.h:1657
Item_func_internal_update_time(const POS &pos, PT_item_list *list)
Definition: item_timefunc.h:1655
const char * func_name() const override
Definition: item_timefunc.h:1658
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3596
bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override
Definition: item_timefunc.cc:3604
Definition: item_timefunc.h:1640
Item_func_last_day(const POS &pos, Item *a)
Definition: item_timefunc.h:1642
const char * func_name() const override
Definition: item_timefunc.h:1645
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1647
bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override
Definition: item_timefunc.cc:3572
Definition: item_timefunc.h:1487
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1496
enum Functype functype() const override
Definition: item_timefunc.h:1495
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date) override
MAKEDATE(a,b) is a date function that creates a date value from a year and day value.
Definition: item_timefunc.cc:2934
Item_func_makedate(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:1489
const char * func_name() const override
Definition: item_timefunc.h:1493
Definition: item_timefunc.h:1551
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1557
bool get_time(MYSQL_TIME *ltime) override
MAKETIME(h,m,s) is a time function that calculates a time value from the total number of hours,...
Definition: item_timefunc.cc:3155
const char * func_name() const override
Definition: item_timefunc.h:1564
Item_func_maketime(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_timefunc.h:1553
Definition: item_timefunc.h:1568
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:1576
longlong val_int() override
MICROSECOND(a) is a function ( extraction) that extracts the microseconds from a.
Definition: item_timefunc.cc:3224
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3230
enum Functype functype() const override
Definition: item_timefunc.h:1573
Item_func_microsecond(const POS &pos, Item *a)
Definition: item_timefunc.h:1570
const char * func_name() const override
Definition: item_timefunc.h:1572
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:1575
Definition: item_timefunc.h:212
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1326
longlong val_int() override
Definition: item_timefunc.cc:1335
Item_func_minute(const POS &pos, Item *a)
Definition: item_timefunc.h:214
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:219
enum Functype functype() const override
Definition: item_timefunc.h:217
const char * func_name() const override
Definition: item_timefunc.h:216
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:220
TS-TODO: This should probably have Item_int_func as parent class.
Definition: item_timefunc.h:140
String * val_str(String *str) override
Definition: item_timefunc.h:151
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1249
double val_real() override
Definition: item_timefunc.h:147
enum Item_result result_type() const override
Definition: item_timefunc.h:163
longlong val_int() override
Definition: item_timefunc.cc:1259
bool get_time(MYSQL_TIME *ltime) override
Definition: item_timefunc.h:160
Item_func_month(const POS &pos, Item *a)
Definition: item_timefunc.h:142
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:166
enum Functype functype() const override
Definition: item_timefunc.h:162
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:165
const char * func_name() const override
Definition: item_timefunc.h:161
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override
Definition: item_timefunc.h:157
Definition: item_timefunc.h:171
Item_func_monthname(const POS &pos, Item *a)
Definition: item_timefunc.h:175
MY_LOCALE * locale
Definition: item_timefunc.h:172
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:181
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:180
String * val_str(String *str) override
Definition: item_timefunc.cc:1276
const char * func_name() const override
Definition: item_timefunc.h:176
enum Functype functype() const override
Definition: item_timefunc.h:177
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1265
Definition: item_timefunc.h:1154
static void store_in(Field *field)
Stores the query start time in a field, truncating to the field's number of fractional second digits.
Definition: item_timefunc.cc:2076
Time_zone * time_zone() override
Definition: item_timefunc.cc:2083
Item_func_now_local(const POS &pos, uint8 dec_arg)
Definition: item_timefunc.h:1168
enum Functype functype() const override
Definition: item_timefunc.h:1172
Item_func_now_local(uint8 dec_arg)
Definition: item_timefunc.h:1167
const char * func_name() const override
Definition: item_timefunc.h:1171
Definition: item_timefunc.h:1175
Item_func_now_utc(const POS &pos, uint8 dec_arg)
Definition: item_timefunc.h:1182
const char * func_name() const override
Definition: item_timefunc.h:1187
bool itemize(Parse_context *pc, Item **res) override
The same as contextualize() but with additional parameter.
Definition: item_timefunc.cc:2085
Item_func_now super
Definition: item_timefunc.h:1176
Time_zone * time_zone() override
Definition: item_timefunc.cc:2092
Abstract CURRENT_TIMESTAMP function.
Definition: item_timefunc.h:1119
Item_func_now(uint8 dec_arg)
Constructor for Item_func_now.
Definition: item_timefunc.h:1130
type_conversion_status save_in_field_inner(Field *to, bool no_conversions) override
Helper function which does all of the work for save_in_field(Field*, bool), except some error checkin...
Definition: item_timefunc.cc:2123
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.cc:2094
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2068
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_timefunc.h:1144
virtual Time_zone * time_zone()=0
String * val_str(String *) override
Definition: item_timefunc.cc:2110
table_map get_initial_pseudo_tables() const override
This function must assign a new value for each execution.
Definition: item_timefunc.h:1136
bool get_date(MYSQL_TIME *res, my_time_flags_t) override
Definition: item_timefunc.cc:2102
Item_func_now(const POS &pos, uint8 dec_arg)
Definition: item_timefunc.h:1131
Definition: item_timefunc.h:65
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1035
const char * func_name() const override
Definition: item_timefunc.h:70
longlong val_int() override
Definition: item_timefunc.cc:1039
Item_func_period_add(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:67
Definition: item_timefunc.h:74
Item_func_period_diff(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:76
const char * func_name() const override
Definition: item_timefunc.h:79
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1053
longlong val_int() override
Definition: item_timefunc.cc:1057
Definition: item_timefunc.h:225
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:232
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:233
enum Functype functype() const override
Definition: item_timefunc.h:230
Item_func_quarter(const POS &pos, Item *a)
Definition: item_timefunc.h:227
longlong val_int() override
Returns the quarter of the year.
Definition: item_timefunc.cc:1304
const char * func_name() const override
Definition: item_timefunc.h:229
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1291
Definition: item_timefunc.h:1286
Item_func_sec_to_time(const POS &pos, Item *item)
Definition: item_timefunc.h:1288
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1290
bool get_time(MYSQL_TIME *ltime) override
Definition: item_timefunc.cc:2155
const char * func_name() const override
Definition: item_timefunc.h:1297
Definition: item_timefunc.h:238
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:246
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:245
enum Functype functype() const override
Definition: item_timefunc.h:243
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1341
Item_func_second(const POS &pos, Item *a)
Definition: item_timefunc.h:240
const char * func_name() const override
Definition: item_timefunc.h:242
longlong val_int() override
Returns the second in time_exp in the range of 0 - 59.
Definition: item_timefunc.cc:1353
Definition: item_timefunc.h:1626
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3490
const char * func_name() const override
Definition: item_timefunc.h:1636
Item_func_str_to_date(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:1634
bool val_datetime(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date) override
Get "native" temporal value as MYSQL_TIME.
Definition: item_timefunc.cc:3523
void fix_from_format(const char *format, size_t length)
Set type of datetime value (DATE/TIME/...) which will be produced according to format string.
Definition: item_timefunc.cc:3440
enum_mysql_timestamp_type cached_timestamp_type
Definition: item_timefunc.h:1627
SYSDATE() is like NOW(), but always uses the real current time, not the query_start().
Definition: item_timefunc.h:1194
table_map get_initial_pseudo_tables() const override
This function is non-deterministic and hence depends on the 'RAND' pseudo-table.
Definition: item_timefunc.h:1208
Item_func_sysdate_local(uint8 dec_arg)
Definition: item_timefunc.h:1196
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2149
bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override
Converts current time in my_time_t to MYSQL_TIME represenatation for local time zone.
Definition: item_timefunc.cc:2136
const char * func_name() const override
Definition: item_timefunc.h:1199
Definition: item_timefunc.h:452
enum Functype functype() const override
Definition: item_timefunc.h:458
longlong val_int() override
Definition: item_timefunc.cc:1702
const char * func_name() const override
Definition: item_timefunc.h:457
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:460
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1695
Item_func_time_to_sec(const POS &pos, Item *item)
Definition: item_timefunc.h:454
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:461
Definition: item_timefunc.h:1529
bool get_time(MYSQL_TIME *ltime) override
TIMEDIFF(t,s) is a time function that calculates the time value between a start and end time.
Definition: item_timefunc.cc:3099
Item_func_timediff(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:1531
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1534
const char * func_name() const override
Definition: item_timefunc.h:1533
Definition: item_timefunc.h:1581
const char * func_name() const override
Definition: item_timefunc.h:1588
interval_type intervaltype() const
Definition: item_timefunc.h:1590
enum Functype functype() const override
Definition: item_timefunc.h:1589
longlong val_int() override
Definition: item_timefunc.cc:3236
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:3332
Item_func_timestamp_diff(const POS &pos, Item *a, Item *b, interval_type type_arg)
Definition: item_timefunc.h:1585
const interval_type int_type
Definition: item_timefunc.h:1582
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1592
Definition: item_timefunc.h:83
Item_func_to_days(const POS &pos, Item *a)
Definition: item_timefunc.h:85
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1072
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:92
longlong val_int() override
Definition: item_timefunc.cc:1085
enum Functype functype() const override
Definition: item_timefunc.h:88
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:93
longlong val_int_endpoint(bool left_endp, bool *incl_endp) override
Definition: item_timefunc.cc:1166
const char * func_name() const override
Definition: item_timefunc.h:87
enum_monotonicity_info get_monotonicity_info() const override
Definition: item_timefunc.cc:1147
Definition: item_timefunc.h:98
bool intro_version(uchar *int_arg) override
Definition: item_timefunc.h:109
enum_monotonicity_info get_monotonicity_info() const override
Definition: item_timefunc.cc:1157
Item_func_to_seconds(const POS &pos, Item *a)
Definition: item_timefunc.h:100
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1115
const char * func_name() const override
Definition: item_timefunc.h:102
longlong val_int() override
Definition: item_timefunc.cc:1121
enum Functype functype() const override
Definition: item_timefunc.h:103
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:107
longlong val_int_endpoint(bool left_endp, bool *incl_endp) override
Definition: item_timefunc.cc:1092
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:118
Definition: item_timefunc.h:400
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:417
longlong val_int_endpoint(bool left_endp, bool *incl_endp) override
Definition: item_timefunc.cc:1686
Item_func_unix_timestamp(const POS &pos)
Definition: item_timefunc.h:404
bool check_function_as_value_generator(uchar *p_arg) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_timefunc.h:439
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:426
Item_timeval_func super
Definition: item_timefunc.h:401
const char * func_name() const override
Definition: item_timefunc.h:411
enum_monotonicity_info get_monotonicity_info() const override
Definition: item_timefunc.cc:1679
Item_func_unix_timestamp(Item *a)
Definition: item_timefunc.h:406
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:423
bool itemize(Parse_context *pc, Item **res) override
The same as contextualize() but with additional parameter.
Definition: item_timefunc.cc:1657
enum Functype functype() const override
Definition: item_timefunc.h:412
Item_func_unix_timestamp(const POS &pos, Item *a)
Definition: item_timefunc.h:408
bool val_timeval(struct timeval *tm) override
Definition: item_timefunc.cc:1668
Definition: item_timefunc.h:251
longlong val_int() override
Definition: item_timefunc.cc:1418
const char * func_name() const override
Definition: item_timefunc.h:261
bool itemize(Parse_context *pc, Item **res) override
The same as contextualize() but with additional parameter.
Definition: item_timefunc.cc:1365
Item_func_week(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:256
Item_func_week(Item *a, Item *b)
Definition: item_timefunc.h:255
Item_int_func super
Definition: item_timefunc.h:252
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1376
enum Functype functype() const override
Definition: item_timefunc.h:262
TS-TODO: This should probably have Item_int_func as parent class.
Definition: item_timefunc.h:309
Item_func_weekday(const POS &pos, Item *a, bool type_arg)
Definition: item_timefunc.h:313
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:338
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:339
double val_real() override
Definition: item_timefunc.h:319
const char * func_name() const override
Definition: item_timefunc.h:332
bool odbc_type
Definition: item_timefunc.h:310
enum Item_result result_type() const override
Definition: item_timefunc.h:336
enum Functype functype() const override
Definition: item_timefunc.h:335
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1446
bool get_time(MYSQL_TIME *ltime) override
Definition: item_timefunc.h:331
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override
Definition: item_timefunc.h:328
longlong val_int() override
Definition: item_timefunc.cc:1455
String * val_str(String *str) override
Definition: item_timefunc.h:323
Definition: item_timefunc.h:280
const char * func_name() const override
Definition: item_timefunc.h:284
enum Functype functype() const override
Definition: item_timefunc.h:285
longlong val_int_endpoint(bool left_endp, bool *incl_endp) override
Definition: item_timefunc.cc:1601
enum_monotonicity_info get_monotonicity_info() const override
Definition: item_timefunc.cc:1593
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:289
longlong val_int() override
Definition: item_timefunc.cc:1498
Item_func_year(const POS &pos, Item *a)
Definition: item_timefunc.h:282
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1491
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:290
Definition: item_timefunc.h:266
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:274
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1426
const char * func_name() const override
Definition: item_timefunc.h:271
enum Functype functype() const override
Definition: item_timefunc.h:272
longlong val_int() override
Definition: item_timefunc.cc:1436
Item_func_yearweek(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:268
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:275
Definition: item_func.h:93
bool param_type_uses_non_param(THD *thd, enum_field_types def=MYSQL_TYPE_VARCHAR)
Definition: item_func.cc:596
Item ** args
Array of pointers to arguments.
Definition: item_func.h:100
Functype
Definition: item_func.h:178
@ DATEADD_FUNC
Definition: item_func.h:280
@ YEAR_FUNC
Definition: item_func.h:261
@ HOUR_FUNC
Definition: item_func.h:271
@ TIME_TO_SEC_FUNC
Definition: item_func.h:284
@ FROM_UNIXTIME_FUNC
Definition: item_func.h:281
@ NOW_FUNC
Definition: item_func.h:219
@ CONVERT_TZ_FUNC
Definition: item_func.h:282
@ DD_INTERNAL_FUNC
Definition: item_func.h:233
@ DAY_FUNC
Definition: item_func.h:266
@ MAKEDATE_FUNC
Definition: item_func.h:263
@ DATE_FUNC
Definition: item_func.h:270
@ TIMESTAMPDIFF_FUNC
Definition: item_func.h:285
@ SECOND_FUNC
Definition: item_func.h:273
@ EXTRACT_FUNC
Definition: item_func.h:224
@ MONTH_FUNC
Definition: item_func.h:264
@ TO_SECONDS_FUNC
Definition: item_func.h:269
@ MICROSECOND_FUNC
Definition: item_func.h:274
@ QUARTER_FUNC
Definition: item_func.h:277
@ MONTHNAME_FUNC
Definition: item_func.h:265
@ TYPECAST_FUNC
Definition: item_func.h:225
@ WEEKDAY_FUNC
Definition: item_func.h:279
@ ADDTIME_FUNC
Definition: item_func.h:276
@ DAYOFYEAR_FUNC
Definition: item_func.h:275
@ DAYNAME_FUNC
Definition: item_func.h:267
@ DATETIME_LITERAL
Definition: item_func.h:286
@ MINUTE_FUNC
Definition: item_func.h:272
@ TO_DAYS_FUNC
Definition: item_func.h:268
@ WEEK_FUNC
Definition: item_func.h:278
@ YEARWEEK_FUNC
Definition: item_func.h:262
@ UNIX_TIMESTAMP_FUNC
Definition: item_func.h:283
bool has_timestamp_args()
Definition: item_func.h:534
bool param_type_is_default(THD *thd, uint start, uint end, uint step, enum_field_types def)
For arguments of this Item_func ("args" array), in range [start, start+step, start+2*step,...
Definition: item_func.cc:508
bool propagate_type(THD *thd, const Type_properties &type) override
Default implementation for all functions: Propagate base_item's type into all arguments.
Definition: item_func.cc:484
bool has_date_args()
Definition: item_func.h:544
uint arg_count
How many arguments in 'args'.
Definition: item_func.h:123
bool has_time_args()
Definition: item_func.h:555
bool has_datetime_args()
Definition: item_func.h:566
Definition: item_func.h:896
virtual const char * func_name() const =0
Definition: item_strfunc.h:141
Definition: item_strfunc.h:75
String * val_str_from_val_str_ascii(String *str, String *str2)
Definition: item_strfunc.cc:137
Abstract class for functions returning TIME, DATE, DATETIME types whose data type is known at constru...
Definition: item_timefunc.h:470
Item_temporal_func()
Definition: item_timefunc.h:475
Item_temporal_func(const POS &pos, Item *a)
Definition: item_timefunc.h:479
Item_temporal_func(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:481
Item_temporal_func(const POS &pos)
Definition: item_timefunc.h:476
Item_temporal_func(Item *a)
Definition: item_timefunc.h:478
const CHARSET_INFO * charset_for_protocol() override
Definition: item_timefunc.h:492
Item_temporal_func(Item *a, Item *b, Item *c)
Definition: item_timefunc.h:483
Item_temporal_func(const POS &pos, PT_item_list *list)
Definition: item_timefunc.h:488
bool check_precision()
Definition: item_timefunc.cc:789
Item_temporal_func(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_timefunc.h:484
Item_temporal_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_timefunc.h:486
uint datetime_precision() override
DATETIME precision of the item: 0..6.
Definition: item_timefunc.h:502
void print(const THD *thd, String *str, enum_query_type query_type) const override
Appends function name with argument list or fractional seconds part to the String str.
Definition: item_timefunc.cc:809
uint time_precision() override
TIME precision of the item: 0..6.
Definition: item_timefunc.h:498
Field * tmp_table_field(TABLE *table) override
Definition: item_timefunc.h:495
Item_result result_type() const override
Definition: item_timefunc.h:491
Abstract class for functions returning TIME, DATE, DATETIME or string values, whose data type depends...
Definition: item_timefunc.h:514
String * val_str(String *str) override
Return string value in @character_set_connection.
Definition: item_timefunc.h:560
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_timefunc.cc:838
sql_mode_t sql_mode
Definition: item_timefunc.h:516
double val_real() override
Definition: item_timefunc.h:551
Field * tmp_table_field(TABLE *table) override
Definition: item_timefunc.h:547
Item_result result_type() const override
Definition: item_timefunc.h:535
bool get_time(MYSQL_TIME *ltime) override
Definition: item_timefunc.cc:873
Item_temporal_hybrid_func(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:532
virtual bool val_datetime(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date)=0
Get "native" temporal value as MYSQL_TIME.
Item_temporal_hybrid_func(Item *a, Item *b)
Definition: item_timefunc.h:530
String * val_str_ascii(String *str) override
Return string value in ASCII character set.
Definition: item_timefunc.cc:884
const CHARSET_INFO * charset_for_protocol() override
Definition: item_timefunc.h:536
longlong val_int() override
Definition: item_timefunc.h:550
String ascii_buf
Definition: item_timefunc.h:517
type_conversion_status save_in_field_inner(Field *field, bool no_conversions) override
Helper function which does all of the work for save_in_field(Field*, bool), except some error checkin...
Definition: item_timefunc.cc:831
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override
Definition: item_timefunc.cc:859
Abstract class for functions returning TIME values.
Definition: item_timefunc.h:677
String * val_str(String *str) override
Definition: item_timefunc.h:712
type_conversion_status save_in_field_inner(Field *field, bool) override
Helper function which does all of the work for save_in_field(Field*, bool), except some error checkin...
Definition: item_timefunc.h:679
longlong val_int() override
Definition: item_timefunc.h:707
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_timefunc.h:703
Item_time_func(const POS &pos, Item *a)
Definition: item_timefunc.h:691
Item_time_func(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_timefunc.h:698
Item_time_func(Item *a)
Definition: item_timefunc.h:688
longlong val_time_temporal() override
Return time value of item in packed longlong format.
Definition: item_timefunc.cc:908
Item_time_func(const POS &pos)
Definition: item_timefunc.h:685
bool get_time(MYSQL_TIME *res) override=0
double val_real() override
Definition: item_timefunc.h:702
Item_time_func(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:694
bool get_date(MYSQL_TIME *res, my_time_flags_t) override
Definition: item_timefunc.h:709
Item_time_func()
Definition: item_timefunc.h:684
TIME'10:10:10'.
Definition: item_timefunc.h:868
String * val_str(String *str) override
Definition: item_timefunc.h:893
bool get_time(MYSQL_TIME *ltime) override
Definition: item_timefunc.h:889
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:897
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:898
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_timefunc.h:902
bool basic_const_item() const override
Returns true if this is a simple constant item like an integer, not a constant expression.
Definition: item_timefunc.h:899
Item_time_literal(MYSQL_TIME *ltime, uint dec_arg)
Constructor for Item_time_literal.
Definition: item_timefunc.h:877
void print(const THD *thd, String *str, enum_query_type query_type) const override
Appends function name with argument list or fractional seconds part to the String str.
Definition: item_timefunc.cc:967
longlong val_time_temporal() override
Return time value of item in packed longlong format.
Definition: item_timefunc.h:885
bool eq(const Item *item, bool binary_cmp) const override
Definition: item_timefunc.cc:959
table_map used_tables() const override
Definition: item_timefunc.h:900
const char * func_name() const override
Definition: item_timefunc.h:882
table_map not_null_tables() const override
Return table map of tables that can't be NULL tables (tables that are used in a context where if they...
Definition: item_timefunc.h:901
MYSQL_TIME_cache cached_time
Definition: item_timefunc.h:869
Definition: item_timefunc.h:372
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) override
Definition: item_timefunc.h:389
longlong val_int() override
Definition: item_timefunc.cc:1628
String * val_str(String *str) override
Definition: item_timefunc.cc:1648
Item_timeval_func(const POS &pos, Item *a)
Definition: item_timefunc.h:377
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_timefunc.cc:1633
virtual bool val_timeval(struct timeval *tm)=0
Return timestamp in "struct timeval" format.
Item_timeval_func(Item *a)
Definition: item_timefunc.h:376
enum Item_result result_type() const override
Definition: item_timefunc.h:395
Item_timeval_func(const POS &pos)
Definition: item_timefunc.h:374
double val_real() override
Definition: item_timefunc.cc:1641
bool get_time(MYSQL_TIME *ltime) override
Definition: item_timefunc.h:392
Definition: item_timefunc.h:1387
bool m_explicit_cast
Definition: item_timefunc.h:1388
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1399
void print(const THD *thd, String *str, enum_query_type query_type) const override
Appends function name with argument list or fractional seconds part to the String str.
Definition: item_timefunc.cc:2888
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date) override
Definition: item_timefunc.cc:2897
const char * cast_type() const
Definition: item_timefunc.h:1409
bool is_explicit_cast() const
Definition: item_timefunc.h:1407
const char * func_name() const override
Definition: item_timefunc.h:1405
enum Functype functype() const override
Definition: item_timefunc.h:1406
Item_typecast_date(Item *a, bool explicit_cast)
Definition: item_timefunc.h:1391
Item_typecast_date(const POS &pos, Item *a)
Definition: item_timefunc.h:1395
Definition: item_timefunc.h:1449
Item_typecast_datetime(Item *a, uint8 dec_arg)
Definition: item_timefunc.h:1466
Item_typecast_datetime(const POS &pos, Item *a)
Definition: item_timefunc.h:1458
const char * cast_type() const
Definition: item_timefunc.h:1474
Item_typecast_datetime(Item *a, bool explicit_cast)
Definition: item_timefunc.h:1454
enum Functype functype() const override
Definition: item_timefunc.h:1473
bool is_explicit_cast() const
Definition: item_timefunc.h:1475
bool m_explicit_cast
Definition: item_timefunc.h:1451
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1476
Item_typecast_datetime(const POS &pos, Item *a, uint8 dec_arg)
Definition: item_timefunc.h:1461
void print(const THD *thd, String *str, enum_query_type query_type) const override
Appends function name with argument list or fractional seconds part to the String str.
Definition: item_timefunc.cc:2828
bool detect_precision_from_arg
Definition: item_timefunc.h:1450
bool get_date(MYSQL_TIME *res, my_time_flags_t fuzzy_date) override
Definition: item_timefunc.cc:2838
const char * func_name() const override
Definition: item_timefunc.h:1472
Definition: item_timefunc.h:1412
Item_typecast_time(Item *a, uint8 dec_arg)
Definition: item_timefunc.h:1428
Item_typecast_time(const POS &pos, Item *a)
Definition: item_timefunc.h:1420
bool is_explicit_cast() const
Definition: item_timefunc.h:1436
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1439
Item_typecast_time(const POS &pos, Item *a, uint8 dec_arg)
Definition: item_timefunc.h:1423
bool get_time(MYSQL_TIME *ltime) override
Definition: item_timefunc.cc:2876
enum Functype functype() const override
Definition: item_timefunc.h:1435
bool detect_precision_from_arg
Definition: item_timefunc.h:1413
Item_typecast_time(Item *a)
Definition: item_timefunc.h:1417
const char * func_name() const override
Definition: item_timefunc.h:1434
const char * cast_type() const
Definition: item_timefunc.h:1438
void print(const THD *thd, String *str, enum_query_type query_type) const override
Appends function name with argument list or fractional seconds part to the String str.
Definition: item_timefunc.cc:2866
bool m_explicit_cast
Definition: item_timefunc.h:1414
Definition: item_timefunc.h:295
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1504
Item_typecast_year(const POS &pos, Item *a)
Definition: item_timefunc.h:297
longlong val_int() override
Definition: item_timefunc.cc:1512
enum Functype functype() const override
Definition: item_timefunc.h:302
const char * func_name() const override
Definition: item_timefunc.h:301
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:802
void set_nullable(bool nullable)
Definition: item.h:3328
void set_data_type_date()
Set all type properties for Item of DATE type.
Definition: item.h:1477
DTCollation collation
Character set and collation properties assigned for this Item.
Definition: item.h:3252
longlong val_int_from_decimal()
Definition: item.cc:439
void set_data_type(enum_field_types data_type)
Set the data type of the current Item.
Definition: item.h:1329
longlong val_int_from_datetime()
Definition: item.cc:470
bool get_time_from_string(MYSQL_TIME *ltime)
Convert val_str() to time in MYSQL_TIME.
Definition: item.cc:1456
static const CHARSET_INFO * default_charset()
Definition: item.cc:1568
String * val_string_from_date(String *str)
Definition: item.cc:293
double val_real_from_decimal()
Definition: item.cc:421
String * val_string_from_datetime(String *str)
Definition: item.cc:283
bool get_date_from_time(MYSQL_TIME *ltime)
Convert get_time() from time to date in MYSQL_TIME.
Definition: item.cc:1406
bool get_time_from_datetime(MYSQL_TIME *ltime)
Convert datetime to time.
Definition: item.cc:1501
longlong val_int_from_date()
Definition: item.cc:462
void set_data_type_year()
Set the data type of the Item to be YEAR.
Definition: item.h:1542
Field * tmp_table_field_from_field_type(TABLE *table, bool fixed_length) const
Create a field based on field_type of argument.
Definition: item.cc:5936
bool get_time_from_date(MYSQL_TIME *ltime)
Convert date to time.
Definition: item.cc:1493
enum_field_types data_type() const
Retrieve the derived data type of the Item.
Definition: item.h:1297
bool fixed
True if item has been resolved.
Definition: item.h:3316
longlong val_int_from_time()
Definition: item.cc:448
bool null_value
True if item is null.
Definition: item.h:3353
void set_data_type_datetime(uint8 fsp)
Set all properties for Item of DATETIME type.
Definition: item.h:1501
virtual uint datetime_precision()
DATETIME precision of the item: 0..6.
Definition: item.cc:670
bool get_date_from_numeric(MYSQL_TIME *ltime, my_time_flags_t fuzzydate)
Convert a numeric type to date.
Definition: item.cc:1416
my_decimal * val_decimal_from_date(my_decimal *decimal_value)
Definition: item.cc:346
@ MARKER_NONE
Definition: item.h:3272
bool get_date_from_string(MYSQL_TIME *ltime, my_time_flags_t flags)
Convert val_str() to date in MYSQL_TIME.
Definition: item.cc:1369
type_conversion_status save_time_in_field(Field *field)
Definition: item.cc:494
item_marker marker
This member has several successive meanings, depending on the phase we're in (.
Definition: item.h:3309
bool get_time_from_numeric(MYSQL_TIME *ltime)
Convert a numeric type to time.
Definition: item.cc:1508
uint8 decimals
Number of decimals in result when evaluating this item.
Definition: item.h:3325
void set_data_type_string(uint32 max_l)
Set the Item to be variable length string.
Definition: item.h:1388
bool get_date_from_int(MYSQL_TIME *ltime, my_time_flags_t flags)
Convert val_int() to date in MYSQL_TIME.
Definition: item.cc:1397
String * val_string_from_time(String *str)
Definition: item.cc:303
void set_data_type_longlong()
Set the data type of the Item to be longlong.
Definition: item.h:1345
void set_data_type_time(uint8 fsp)
Set all type properties for Item of TIME type.
Definition: item.h:1489
void set_data_type_decimal(uint8 precision, uint8 scale)
Set the data type of the Item to be decimal.
Definition: item.h:1358
my_decimal * val_decimal_from_time(my_decimal *decimal_value)
Definition: item.cc:355
type_conversion_status save_date_in_field(Field *field)
Definition: item.cc:501
bool get_time_from_int(MYSQL_TIME *ltime)
Convert val_int() to time in MYSQL_TIME.
Definition: item.cc:1484
Cache for MYSQL_TIME value with various representations.
Definition: item_timefunc.h:726
uint string_length
length of string
Definition: item_timefunc.h:730
bool get_date(MYSQL_TIME *ltime, uint fuzzyflags) const
Store MYSQL_TIME representation into the given date/datetime variable checking date flags.
Definition: item_timefunc.cc:1949
void set_time(MYSQL_TIME *ltime, uint8 dec_arg)
Set time and time_packed from a TIME value.
Definition: item_timefunc.cc:1892
bool get_time(MYSQL_TIME *ltime) const
Store MYSQL_TIME representation into the given time variable.
Definition: item_timefunc.h:804
longlong val_packed() const
Return packed representation.
Definition: item_timefunc.h:792
MYSQL_TIME_cache()
Definition: item_timefunc.h:742
uint8 decimals() const
Return number of decimal digits.
Definition: item_timefunc.h:784
uint8 dec
Number of decimals.
Definition: item_timefunc.h:731
longlong time_packed
packed representation
Definition: item_timefunc.h:728
MYSQL_TIME * get_TIME_ptr()
Return pointer to MYSQL_TIME representation.
Definition: item_timefunc.h:811
const char * cptr() const
Return C string representation.
Definition: item_timefunc.h:822
void set_date(MYSQL_TIME *ltime)
Set time and time_packed from a DATE value.
Definition: item_timefunc.cc:1900
MYSQL_TIME time
MYSQL_TIME representation.
Definition: item_timefunc.h:727
void set_datetime(MYSQL_TIME *ltime, uint8 dec_arg, const Time_zone *tz=nullptr)
Set time and time_packed from a DATETIME value.
Definition: item_timefunc.cc:1908
bool eq(const MYSQL_TIME_cache &tm) const
Test if cached value is equal to another MYSQL_TIME_cache value.
Definition: item_timefunc.h:777
String * val_str(String *str)
Store string representation into String.
Definition: item_timefunc.cc:1956
char string_buff[MAX_DATE_STRING_REP_LENGTH]
string representation
Definition: item_timefunc.h:729
void get_TIME(MYSQL_TIME *ltime) const
Store MYSQL_TIME representation into the given MYSQL_TIME variable.
Definition: item_timefunc.h:736
Definition: sql_locale.h:36
Wrapper class for an Item list head, used to allocate Item lists in the parser in a context-independe...
Definition: parse_tree_helpers.h:101
Base class for parse tree nodes (excluding the Parse_tree_root hierarchy)
Definition: parse_tree_node_base.h:102
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:165
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:821
This class represents abstract time zone and provides basic interface for MYSQL_TIME <-> my_time_t co...
Definition: tztime.h:48
my_decimal class limits 'decimal_t' type to what we need in MySQL.
Definition: my_decimal.h:92
ulonglong sql_mode_t
Definition: dd_event.h:36
Dialog Client Authentication nullptr
Definition: dialog.cc:352
char * pos
Definition: do_ctype.cc:76
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:30
This file contains the field type.
@ MYSQL_TYPE_LONGLONG
Definition: field_types.h:65
@ MYSQL_TYPE_TIME
Definition: field_types.h:68
@ MYSQL_TYPE_STRING
Definition: field_types.h:89
@ MYSQL_TYPE_NEWDECIMAL
Definition: field_types.h:81
@ MYSQL_TYPE_DATE
Definition: field_types.h:67
@ MYSQL_TYPE_DATETIME
Definition: field_types.h:69
static const std::string dec("DECRYPTION")
enum monotonicity_info enum_monotonicity_info
const char * interval_names[]
Definition: item_timefunc.cc:2605
bool make_date_time(Date_time_format *format, MYSQL_TIME *l_time, enum_mysql_timestamp_type type, String *str)
Create a formated date/time value in a string.
Definition: item_timefunc.cc:505
date_time_format
Definition: item_timefunc.h:1601
@ USA_FORMAT
Definition: item_timefunc.h:1602
@ JIS_FORMAT
Definition: item_timefunc.h:1603
@ INTERNAL_FORMAT
Definition: item_timefunc.h:1606
@ EUR_FORMAT
Definition: item_timefunc.h:1605
@ ISO_FORMAT
Definition: item_timefunc.h:1604
bool get_interval_value(Item *args, interval_type int_type, String *str_value, Interval *interval)
Convert a string to a interval value.
Definition: item_timefunc.cc:1717
A better implementation of the UNIX ctype(3) library.
MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_bin
Definition: ctype-bin.cc:510
Some integer typedefs for easier portability.
uint8_t uint8
Definition: my_inttypes.h:62
unsigned char uchar
Definition: my_inttypes.h:51
long long int longlong
Definition: my_inttypes.h:54
uint64_t table_map
Definition: my_table_map.h:29
Interface for low level time utilities.
constexpr const int DATETIME_MAX_DECIMALS
Definition: my_time.h:131
unsigned int my_time_flags_t
Flags to str_to_datetime and number_to_datetime.
Definition: my_time.h:82
constexpr const std::size_t MAX_DATE_STRING_REP_LENGTH
Required buffer length for my_time_to_str, my_date_to_str, my_datetime_to_str and TIME_to_string func...
Definition: my_time.h:378
interval_type
Available interval types used in any statement.
Definition: my_time.h:403
@ INTERVAL_HOUR_SECOND
Definition: my_time.h:418
@ INTERVAL_MONTH
Definition: my_time.h:406
@ INTERVAL_HOUR_MICROSECOND
Definition: my_time.h:421
@ INTERVAL_MINUTE
Definition: my_time.h:410
@ INTERVAL_HOUR_MINUTE
Definition: my_time.h:417
@ INTERVAL_DAY
Definition: my_time.h:408
@ INTERVAL_MINUTE_MICROSECOND
Definition: my_time.h:422
@ INTERVAL_MINUTE_SECOND
Definition: my_time.h:419
@ INTERVAL_QUARTER
Definition: my_time.h:405
@ INTERVAL_YEAR
Definition: my_time.h:404
@ INTERVAL_DAY_MICROSECOND
Definition: my_time.h:420
@ INTERVAL_SECOND_MICROSECOND
Definition: my_time.h:423
@ INTERVAL_SECOND
Definition: my_time.h:411
@ INTERVAL_DAY_HOUR
Definition: my_time.h:414
@ INTERVAL_HOUR
Definition: my_time.h:409
@ INTERVAL_YEAR_MONTH
Definition: my_time.h:413
@ INTERVAL_DAY_SECOND
Definition: my_time.h:416
@ INTERVAL_MICROSECOND
Definition: my_time.h:412
@ INTERVAL_DAY_MINUTE
Definition: my_time.h:415
Time declarations shared between the server and client API: you should not add anything to this heade...
enum_mysql_timestamp_type
Definition: mysql_time.h:44
@ MYSQL_TIMESTAMP_NONE
Definition: mysql_time.h:45
static int interval
Definition: mysqladmin.cc:64
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1056
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
required string type
Definition: replication_group_member_actions.proto:33
"public" interface to sys_var - server configuration variables.
type_conversion_status
Status when storing a value in a field or converting from one datatype to another.
Definition: field.h:200
@ VGS_CHECK_CONSTRAINT
Definition: field.h:474
@ VGS_GENERATED_COLUMN
Definition: field.h:472
File containing constants that can be used throughout the server.
#define RAND_TABLE_BIT
Definition: sql_const.h:110
#define INNER_TABLE_BIT
Definition: sql_const.h:108
Our own string classes, used pervasively throughout the executor.
Definition: m_ctype.h:354
Struct used to pass around arguments to/from check_function_as_value_generator.
Definition: item.h:485
const char * banned_function_name
the name of the function which is not allowed
Definition: item.h:499
Value_generator_source source
Definition: item.h:497
Representation of time formats.
Definition: sql_time.h:60
Struct representing a duration.
Definition: my_time.h:168
Definition: mysql_time.h:81
enum enum_mysql_timestamp_type time_type
Definition: mysql_time.h:85
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:90
Definition: table.h:1394
Bison "location" class.
Definition: parse_location.h:42
static task_arg int_arg(int i)
Definition: task.h:164
unsigned int uint
Definition: uca-dump.cc:29
Item_result
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:38
@ STRING_RESULT
not valid for UDFs
Definition: udf_registration_types.h:40
@ DECIMAL_RESULT
not valid for UDFs
Definition: udf_registration_types.h:44
@ INT_RESULT
double
Definition: udf_registration_types.h:42