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