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