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