MySQL 9.7.0
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, 2026, 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
37#include "my_inttypes.h"
38#include "my_table_map.h"
39#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 enum Functype functype() const override { return PERIODADD_FUNC; }
73 bool resolve_type(THD *thd) override;
74};
75
77 public:
78 Item_func_period_diff(const POS &pos, Item *a, Item *b)
79 : Item_int_func(pos, a, b) {}
80 longlong val_int() override;
81 const char *func_name() const override { return "period_diff"; }
82 enum Functype functype() const override { return PERIODDIFF_FUNC; }
83 bool resolve_type(THD *thd) override;
84};
85
86class Item_func_to_days final : public Item_int_func {
87 public:
88 Item_func_to_days(const POS &pos, Item *a) : Item_int_func(pos, a) {}
89 longlong val_int() override;
90 const char *func_name() const override { return "to_days"; }
91 enum Functype functype() const override { return TO_DAYS_FUNC; }
92 bool resolve_type(THD *thd) override;
94 longlong val_int_endpoint(bool left_endp, bool *incl_endp) override;
95 bool check_partition_func_processor(uchar *) override { return false; }
97 return !has_date_args();
98 }
99};
100
102 public:
103 Item_func_to_seconds(const POS &pos, Item *a) : Item_int_func(pos, a) {}
104 longlong val_int() override;
105 const char *func_name() const override { return "to_seconds"; }
106 enum Functype functype() const override { return TO_SECONDS_FUNC; }
107 bool resolve_type(THD *thd) override;
109 longlong val_int_endpoint(bool left_endp, bool *incl_endp) override;
110 bool check_partition_func_processor(uchar *) override { return false; }
111
112 bool intro_version(uchar *int_arg) override {
113 int *input_version = (int *)int_arg;
114 /* This function was introduced in 5.5 */
115 int output_version = std::max(*input_version, 50500);
116 *input_version = output_version;
117 return false;
118 }
119
120 /* Only meaningful with date part and optional time part */
122 return !has_date_args();
123 }
124};
125
127 public:
128 Item_func_dayofmonth(const POS &pos, Item *a) : Item_int_func(pos, a) {}
129
130 longlong val_int() override;
131 const char *func_name() const override { return "dayofmonth"; }
132 enum Functype functype() const override { return DAY_FUNC; }
133 bool resolve_type(THD *thd) override;
134 bool check_partition_func_processor(uchar *) override { return false; }
136 return !has_date_args();
137 }
138};
139
140class Item_func_month final : public Item_int_func {
141 public:
142 Item_func_month(const POS &pos, Item *a) : Item_int_func(pos, a) {}
143 longlong val_int() override;
144 const char *func_name() const override { return "month"; }
145 enum Functype functype() const override { return MONTH_FUNC; }
146 enum Item_result result_type() const override { return INT_RESULT; }
147 bool resolve_type(THD *thd) override;
148 bool check_partition_func_processor(uchar *) override { return false; }
150 return !has_date_args();
151 }
152};
153
154class Item_func_monthname final : public Item_str_func {
156
157 public:
158 Item_func_monthname(const POS &pos, Item *a) : Item_str_func(pos, a) {}
159 const char *func_name() const override { return "monthname"; }
160 enum Functype functype() const override { return MONTHNAME_FUNC; }
161 String *val_str(String *str) override;
162 bool resolve_type(THD *thd) override;
163 bool check_partition_func_processor(uchar *) override { return true; }
165 return !has_date_args();
166 }
167};
168
169class Item_func_dayofyear final : public Item_int_func {
170 public:
171 Item_func_dayofyear(const POS &pos, Item *a) : Item_int_func(pos, a) {}
172 longlong val_int() override;
173 const char *func_name() const override { return "dayofyear"; }
174 enum Functype functype() const override { return DAYOFYEAR_FUNC; }
175 bool resolve_type(THD *thd) override;
176 bool check_partition_func_processor(uchar *) override { return false; }
178 return !has_date_args();
179 }
180};
181
182class Item_func_hour final : public Item_int_func {
183 public:
184 Item_func_hour(const POS &pos, Item *a) : Item_int_func(pos, a) {}
185 longlong val_int() override;
186 const char *func_name() const override { return "hour"; }
187 enum Functype functype() const override { return HOUR_FUNC; }
188 bool resolve_type(THD *thd) override;
189 bool check_partition_func_processor(uchar *) override { return false; }
191 return !has_time_args();
192 }
193};
194
195class Item_func_minute final : public Item_int_func {
196 public:
197 Item_func_minute(const POS &pos, Item *a) : Item_int_func(pos, a) {}
198 longlong val_int() override;
199 const char *func_name() const override { return "minute"; }
200 enum Functype functype() const override { return MINUTE_FUNC; }
201 bool resolve_type(THD *thd) override;
202 bool check_partition_func_processor(uchar *) override { return false; }
204 return !has_time_args();
205 }
206};
207
208class Item_func_quarter final : public Item_int_func {
209 public:
210 Item_func_quarter(const POS &pos, Item *a) : Item_int_func(pos, a) {}
211 longlong val_int() override;
212 const char *func_name() const override { return "quarter"; }
213 enum Functype functype() const override { return QUARTER_FUNC; }
214 bool resolve_type(THD *thd) override;
215 bool check_partition_func_processor(uchar *) override { return false; }
217 return !has_date_args();
218 }
219};
220
221class Item_func_second final : public Item_int_func {
222 public:
223 Item_func_second(const POS &pos, Item *a) : Item_int_func(pos, a) {}
224 longlong val_int() override;
225 const char *func_name() const override { return "second"; }
226 enum Functype functype() const override { return SECOND_FUNC; }
227 bool resolve_type(THD *thd) override;
228 bool check_partition_func_processor(uchar *) override { return false; }
230 return !has_time_args();
231 }
232};
233
234class Item_func_week final : public Item_int_func {
236
237 public:
239 Item_func_week(const POS &pos, Item *a, Item *b) : super(pos, a, b) {}
240
241 bool do_itemize(Parse_context *pc, Item **res) override;
242
243 longlong val_int() override;
244 const char *func_name() const override { return "week"; }
245 enum Functype functype() const override { return WEEK_FUNC; }
246 bool resolve_type(THD *thd) override;
247};
248
249class Item_func_yearweek final : public Item_int_func {
250 public:
251 Item_func_yearweek(const POS &pos, Item *a, Item *b)
252 : Item_int_func(pos, a, b) {}
253 longlong val_int() override;
254 const char *func_name() const override { return "yearweek"; }
255 enum Functype functype() const override { return YEARWEEK_FUNC; }
256 bool resolve_type(THD *thd) override;
257 bool check_partition_func_processor(uchar *) override { return false; }
259 return !has_date_args();
260 }
261};
262
263class Item_func_year final : public Item_int_func {
264 public:
265 Item_func_year(const POS &pos, Item *a) : Item_int_func(pos, a) {}
266 longlong val_int() override;
267 const char *func_name() const override { return "year"; }
268 enum Functype functype() const override { return YEAR_FUNC; }
270 longlong val_int_endpoint(bool left_endp, bool *incl_endp) override;
271 bool resolve_type(THD *thd) override;
272 bool check_partition_func_processor(uchar *) override { return false; }
274 return !has_date_args();
275 }
276};
277
278class Item_typecast_year final : public Item_int_func {
279 public:
280 Item_typecast_year(const POS &pos, Item *a) : Item_int_func(pos, a) {
282 }
283 longlong val_int() override;
284 const char *func_name() const override { return "cast_as_year"; }
285 enum Functype functype() const override { return TYPECAST_FUNC; }
286 bool resolve_type(THD *thd) override;
287 void print(const THD *thd, String *str,
288 enum_query_type query_type) const override;
289};
290
293
294 public:
295 Item_func_weekday(const POS &pos, Item *a, bool type_arg)
296 : Item_int_func(pos, a), odbc_type(type_arg) {}
297 longlong val_int() override;
298 const char *func_name() const override {
299 return (odbc_type ? "dayofweek" : "weekday");
300 }
301 enum Functype functype() const override { return WEEKDAY_FUNC; }
302 enum Item_result result_type() const override { return INT_RESULT; }
303 bool resolve_type(THD *thd) override;
304 bool check_partition_func_processor(uchar *) override { return false; }
306 return !has_date_args();
307 }
308};
309
310class Item_func_dayname final : public Item_str_func {
312
313 public:
314 Item_func_dayname(const POS &pos, Item *a) : Item_str_func(pos, a) {}
315 const char *func_name() const override { return "dayname"; }
316 enum Functype functype() const override { return DAYNAME_FUNC; }
317 String *val_str(String *str) override;
318 bool resolve_type(THD *thd) override;
319 bool check_partition_func_processor(uchar *) override { return true; }
320};
321
322/*
323 Abstract class for functions returning "struct timeval".
324*/
326 public:
327 explicit Item_timeval_func(const POS &pos) : Item_func(pos) {}
328
330 Item_timeval_func(const POS &pos, Item *a) : Item_func(pos, a) {}
331 /**
332 Return timestamp in "struct timeval" format.
333 @param[out] tm The value is store here.
334 @retval false On success
335 @retval true On error
336 */
337 virtual bool val_timeval(my_timeval *tm) = 0;
338 longlong val_int() override;
339 double val_real() override;
340 String *val_str(String *str) override;
341 my_decimal *val_decimal(my_decimal *decimal_value) override;
342 bool val_date(Date_val *date, my_time_flags_t flags) override {
343 return get_date_from_numeric(date, flags);
344 }
345 bool val_time(Time_val *time) override { return get_time_from_numeric(time); }
348 }
349 enum Item_result result_type() const override {
351 }
352};
353
356
357 public:
358 explicit Item_func_unix_timestamp(const POS &pos) : Item_timeval_func(pos) {}
359
361
363 : Item_timeval_func(pos, a) {}
364
365 const char *func_name() const override { return "unix_timestamp"; }
366 enum Functype functype() const override { return UNIX_TIMESTAMP_FUNC; }
367
368 bool do_itemize(Parse_context *pc, Item **res) override;
370 longlong val_int_endpoint(bool left_endp, bool *incl_endp) override;
371 bool check_partition_func_processor(uchar *) override { return false; }
372 /*
373 UNIX_TIMESTAMP() depends on the current timezone
374 (and thus may not be used as a partitioning function)
375 when its argument is NOT of the TIMESTAMP type.
376 */
378 return !has_timestamp_args();
379 }
380
382 if (arg_count == 0) return INNER_TABLE_BIT;
383 return 0;
384 }
385
386 bool resolve_type(THD *thd) override;
387
388 bool val_timeval(my_timeval *tm) override;
389
391 /*
392 TODO: Allow UNIX_TIMESTAMP called with an argument to be a part
393 of the expression for a generated column too.
394 */
396 pointer_cast<Check_function_as_value_generator_parameters *>(p_arg);
397 func_arg->banned_function_name = func_name();
398 return ((func_arg->source == VGS_GENERATED_COLUMN) ||
399 (func_arg->source == VGS_CHECK_CONSTRAINT));
400 }
401};
402
404 public:
405 Item_func_time_to_sec(const POS &pos, Item *item)
406 : Item_int_func(pos, item) {}
407 longlong val_int() override;
408 const char *func_name() const override { return "time_to_sec"; }
409 enum Functype functype() const override { return TIME_TO_SEC_FUNC; }
410 bool resolve_type(THD *thd) override;
411 bool check_partition_func_processor(uchar *) override { return false; }
413 return !has_time_args();
414 }
415};
416
417/**
418 Abstract class for functions returning TIME, DATE, DATETIME types
419 whose data type is known at constructor time.
420*/
422 protected:
423 bool check_precision();
424
425 protected:
426 void add_json_info(Json_object *obj) override {
427 if (decimals > 0)
428 obj->add_alias("precision", create_dom_ptr<Json_uint>(decimals));
429 }
430
431 public:
433 explicit Item_temporal_func(const POS &pos) : Item_func(pos) {}
434
436 Item_temporal_func(const POS &pos, Item *a) : Item_func(pos, a) {}
437
438 Item_temporal_func(const POS &pos, Item *a, Item *b) : Item_func(pos, a, b) {}
439
440 Item_temporal_func(Item *a, Item *b, Item *c) : Item_func(a, b, c) {}
441 Item_temporal_func(const POS &pos, Item *a, Item *b, Item *c)
442 : Item_func(pos, a, b, c) {}
443 Item_temporal_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
444 : Item_func(pos, a, b, c, d) {}
446 : Item_func(pos, list) {}
447
448 Item_result result_type() const override { return STRING_RESULT; }
450 return &my_charset_bin;
451 }
454 }
455 uint time_precision() override {
456 assert(fixed);
457 return decimals;
458 }
459 uint datetime_precision() override {
460 assert(fixed);
461 return decimals;
462 }
463 void print(const THD *thd, String *str,
464 enum_query_type query_type) const override;
465};
466
467/**
468 Abstract class for functions returning TIME, DATE, DATETIME or string values,
469 whose data type depends on parameters and is set at fix_field time.
470*/
472 protected:
473 String ascii_buf; // Conversion buffer
474 /**
475 @returns class specific temporal field evaluation flags
476 */
477 virtual my_time_flags_t eval_flags() const = 0;
478 /**
479 Evaluate temporal expression as datetime value
480 @param[out] dt The value is stored here.
481 @param flags Date flags.
482
483 @returns false on success, true on error or if NULL value
484 */
486 /**
487 Evaluate temporal expression as date value
488 @param[out] date The value is stored here.
489 @param flags Date flags.
490
491 @returns false on success, true on error or if NULL value
492 */
493 virtual bool eval_date(Date_val *date, my_time_flags_t flags) = 0;
494 /**
495 Evaluate temporal expression as time value
496 @param[out] time The value is stored here.
497
498 @returns false on success, true on error or if NULL value
499 */
500 virtual bool eval_time(Time_val *time) = 0;
502 bool no_conversions) override;
503 void add_json_info(Json_object *obj) override {
505 }
506
507 public:
510 : Item_str_func(pos, a, b) {}
511
512 Item_result result_type() const override { return STRING_RESULT; }
514 /*
515 Can return TIME, DATE, DATETIME or VARCHAR depending on arguments.
516 Send using "binary" when TIME, DATE or DATETIME,
517 or using collation.collation when VARCHAR
518 (which is fixed from @collation_connection in resolve_type()).
519 */
520 assert(fixed);
523 }
526 }
527 longlong val_int() override { return val_int_from_decimal(); }
528 double val_real() override { return val_real_from_decimal(); }
529 my_decimal *val_decimal(my_decimal *decimal_value) override;
530 /**
531 Return string value in ASCII character set.
532 */
533 String *val_str_ascii(String *str) override;
534 /**
535 Return string value in @@character_set_connection.
536 */
537 String *val_str(String *str) override {
539 }
540 bool val_date(Date_val *date, my_time_flags_t flags) override;
541 bool val_time(Time_val *time) override;
543};
544
545/**
546 Abstract class for functions returning DATE values.
547*/
549 protected:
551 return save_date_in_field(field);
552 }
553
554 public:
556 explicit Item_date_func(const POS &pos) : Item_temporal_func(pos) {
558 }
560 Item_date_func(const POS &pos, Item *a) : Item_temporal_func(pos, a) {
562 }
563 Item_date_func(const POS &pos, Item *a, Item *b)
564 : Item_temporal_func(pos, a, b) {
566 }
567 bool val_time(Time_val *time) override { return get_time_from_date(time); }
569 return get_datetime_from_date(dt, flags);
570 }
572 longlong val_int() override { return val_int_from_date(); }
573 longlong val_date_temporal() override;
574 double val_real() override { return static_cast<double>(val_int()); }
575 const char *func_name() const override { return "date"; }
576 enum Functype functype() const override { return DATE_FUNC; }
577 bool resolve_type(THD *) override { return false; }
578 my_decimal *val_decimal(my_decimal *decimal_value) override {
579 assert(fixed);
580 return val_decimal_from_date(decimal_value);
581 }
582 // All date functions must implement val_date()
583 // to avoid use of generic Item::val_date()
584 // which converts to string and then parses the string as DATE.
585 bool val_date(Date_val *date, my_time_flags_t flags) override = 0;
586};
587
588/**
589 Abstract class for functions returning DATETIME values.
590*/
592 protected:
594 return save_datetime_in_field(field);
595 }
596
597 public:
600 }
603 }
606 }
607 Item_datetime_func(const POS &pos, Item *a) : Item_temporal_func(pos, a) {
609 }
610 Item_datetime_func(const POS &pos, Item *a, Item *b)
611 : Item_temporal_func(pos, a, b) {
613 }
616 }
617 Item_datetime_func(const POS &pos, Item *a, Item *b, Item *c)
618 : Item_temporal_func(pos, a, b, c) {
620 }
621 Item_datetime_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
622 : Item_temporal_func(pos, a, b, c, d) {
624 }
626 : Item_temporal_func(pos, list) {
628 }
629
630 double val_real() override { return val_real_from_decimal(); }
631 String *val_str(String *str) override {
633 }
634 longlong val_int() override { return val_int_from_datetime(); }
635 longlong val_date_temporal() override;
636 my_decimal *val_decimal(my_decimal *decimal_value) override {
637 assert(fixed);
638 return val_decimal_from_datetime(decimal_value);
639 }
640 bool val_time(Time_val *time) override {
641 return get_time_from_datetime(time);
642 }
643 bool val_date(Date_val *date, my_time_flags_t flags) override;
644 // All datetime functions must implement val_datetime()
646};
647
648/**
649 Abstract class for functions returning TIME values.
650*/
652 protected:
654 return save_time_in_field(field);
655 }
656
657 public:
659 explicit Item_time_func(const POS &pos) : Item_temporal_func(pos) {
661 }
664 }
665 Item_time_func(const POS &pos, Item *a) : Item_temporal_func(pos, a) {
667 }
668 Item_time_func(const POS &pos, Item *a, Item *b)
669 : Item_temporal_func(pos, a, b) {
671 }
672 Item_time_func(const POS &pos, Item *a, Item *b, Item *c)
673 : Item_temporal_func(pos, a, b, c) {
675 }
676 double val_real() override { return val_real_from_decimal(); }
677 my_decimal *val_decimal(my_decimal *decimal_value) override {
678 assert(fixed);
679 return val_decimal_from_time(decimal_value);
680 }
681 longlong val_int() override { return val_int_from_time(); }
682 bool val_date(Date_val *date, my_time_flags_t) override {
683 return get_date_from_time(date);
684 }
686 return get_datetime_from_time(dt);
687 }
689 // All time functions must implement val_time()
690 // to avoid use of generic Item::val_time()
691 // which converts to string and then parses the string as TIME.
692 bool val_time(Time_val *time) override = 0;
693};
694
695/**
696 Cache for MYSQL_TIME value with various representations.
697
698 - MYSQL_TIME representation (time) is initialized during set_XXX().
699 - Packed representation (time_packed) is also initialized during set_XXX().
700 - String representation (string_buff) is also initialized during set_XXX();
701*/
703 MYSQL_TIME time; ///< MYSQL_TIME representation
704 longlong time_packed; ///< packed representation
705 char string_buff[MAX_DATE_STRING_REP_LENGTH]; ///< string representation
706 uint string_length; ///< length of string
707 uint8 dec; ///< Number of decimals
708
709 /**
710 Store MYSQL_TIME representation into the given MYSQL_TIME variable.
711 */
712 void get_TIME(MYSQL_TIME *ltime) const {
714 *ltime = time;
715 }
716
717 public:
720 string_buff[0] = '\0';
721 }
722 /**
723 Set time and time_packed from a DATE value.
724 */
725 void set_date(MYSQL_TIME *ltime);
726 /**
727 Set time and time_packed from a DATETIME value.
728 */
729 void set_datetime(MYSQL_TIME *ltime, uint8 dec_arg,
730 const Time_zone *tz = nullptr);
731 /**
732 Set time and time_packed according to DATE value
733 in "struct timeval" representation and its time zone.
734 */
735 void set_date(my_timeval tv, Time_zone *tz);
736 /**
737 Set time and time_packed according to DATETIME value
738 in "struct timeval" representation and its time zone.
739 */
740 void set_datetime(my_timeval tv, uint8 dec_arg, Time_zone *tz);
741 /**
742 Test if cached value is equal to another MYSQL_TIME_cache value.
743 */
744 bool eq(const MYSQL_TIME_cache &tm) const {
745 return val_packed() == tm.val_packed();
746 }
747
748 /**
749 Return number of decimal digits.
750 */
751 uint8 decimals() const {
753 return dec;
754 }
755
756 /**
757 Return packed representation.
758 */
761 return time_packed;
762 }
763 /**
764 Store MYSQL_TIME representation into the given date/datetime variable
765 checking date flags.
766 */
767 bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) const;
768 bool get_date(MYSQL_TIME *ltime) const {
769 get_TIME(ltime);
770 return false;
771 }
772
773 /**
774 Return pointer to MYSQL_TIME representation.
775 */
778 return &time;
779 }
780
781 /**
782 Store string representation into String.
783 */
785 /**
786 Return C string representation.
787 */
788 const char *cptr() const { return string_buff; }
789};
790
791/**
792 DATE'2010-01-01'
793*/
794class Item_date_literal final : public Item_date_func {
795 public:
796 /**
797 Constructor for Item_date_literal.
798 @param date DATE value.
799 */
802 m_date = date;
803 fixed = true;
804 }
805 const char *func_name() const override { return "date_literal"; }
806 void print(const THD *thd, String *str,
807 enum_query_type query_type) const override;
808 uint64_t hash() override;
809 bool val_date(Date_val *date, my_time_flags_t) override;
810 bool resolve_type(THD *) override { return false; }
811 bool check_partition_func_processor(uchar *) override { return false; }
812 bool basic_const_item() const override { return true; }
813 table_map used_tables() const override { return 0; }
814 table_map not_null_tables() const override { return used_tables(); }
815 void cleanup() override { assert(marker == MARKER_NONE); }
816 bool eq_specific(const Item *item) const override;
817
818 private:
820};
821
822/**
823 TIME'10:10:10'
824*/
825class Item_time_literal final : public Item_time_func {
826 public:
827 /**
828 Constructor for Item_time_literal.
829
830 @param time TIME value, must have fraction according to dec_arg.
831 @param dec_arg number of fractional digits in time.
832 */
833 Item_time_literal(Time_val time, uint dec_arg) : m_time(time) {
834 set_data_type_time(std::min(dec_arg, uint(DATETIME_MAX_DECIMALS)));
835 assert(m_time.is_adjusted(decimals));
836 fixed = true;
837 }
838 const char *func_name() const override { return "time_literal"; }
839 void print(const THD *thd, String *str,
840 enum_query_type query_type) const override;
841 bool val_time(Time_val *time) override {
842 assert(fixed);
843 *time = m_time;
844 return false;
845 }
846 bool resolve_type(THD *) override { return false; }
847 bool check_partition_func_processor(uchar *) override { return false; }
848 bool basic_const_item() const override { return true; }
849 table_map used_tables() const override { return 0; }
850 table_map not_null_tables() const override { return used_tables(); }
851 void cleanup() override { assert(marker == MARKER_NONE); }
852 bool eq_specific(const Item *item) const override;
853
854 private:
856 uint64_t m_hash{0};
857 uint64_t hash() override;
858};
859
860/**
861 TIMESTAMP'2001-01-01 10:20:30'
862*/
865
866 public:
867 /**
868 Constructor for Item_datetime_literal.
869 @param dt DATETIME value.
870 @param dec_arg Number of fractional digits in ltime.
871 @param tz The current time zone, used for converting literals with
872 time zone upon storage.
873 */
874 Item_datetime_literal(Datetime_val *dt, uint dec_arg, const Time_zone *tz) {
875 set_data_type_datetime(std::min(dec_arg, uint{DATETIME_MAX_DECIMALS}));
877 fixed = true;
878 }
879 const char *func_name() const override { return "datetime_literal"; }
880 enum Functype functype() const override { return DATETIME_LITERAL; }
881 void print(const THD *thd, String *str,
882 enum_query_type query_type) const override;
884 assert(fixed);
885 return cached_time.val_packed();
886 }
888 assert(fixed);
889 return cached_time.get_date(dt, flags);
890 }
891 String *val_str(String *str) override {
892 assert(fixed);
893 return cached_time.val_str(str);
894 }
895 bool resolve_type(THD *) override { return false; }
896 bool check_partition_func_processor(uchar *) override { return false; }
897 bool basic_const_item() const override { return true; }
898 table_map used_tables() const override { return 0; }
899 table_map not_null_tables() const override { return used_tables(); }
900 void cleanup() override { assert(marker == MARKER_NONE); }
901 bool eq_specific(const Item *item) const override;
902 uint64_t hash() override;
903};
904
905/**
906 This function implements the `AT TIME ZONE` operator, which casts a temporal
907 value to a temporal with time zone.
908
909 This function is hidden from the user except when used in a cast() operation,
910 the reason being that it adds time zone information to a temporal value, and
911 we don't currently have a type that corresponds to such a value. Hence the
912 only way to evaluate this function is by a concomitant cast to a temporal
913 without time zone designation. However, the value is not converted according
914 to the current time zone as is normally the case. For `TIMESTAMP`, this means
915 that the value is converted to the time zone given as argument to this
916 function rather than the session's time zone. And as we currently only support
917 the UTC time zone or the equivalent `INTERVAL '+00:00'`, so in practice the
918 value is not converted at all. This is a bit similar to the unix_timestamp()
919 function, but that one converts any argument (DATETIME, TIME) to UTC from the
920 session's time zone. This operator only accepts `TIMESTAMP` values.
921*/
923 public:
924 Item_func_at_time_zone(const POS &pos, Item *datetime,
925 const char *specifier_string, bool is_interval)
926 : Item_datetime_func(pos, datetime),
928 m_is_interval(is_interval) {}
929
930 bool resolve_type(THD *) override;
931
932 const char *func_name() const override { return "time_zone"; }
933
934 void print(const THD *thd, String *str,
935 enum_query_type query_type) const override;
936
937 bool set_time_zone(THD *thd);
938
940
941 const char *specifier_string() const { return m_specifier_string; }
942
943 protected:
944 bool check_type() const;
945
946 private:
947 /// The time zone that the specifier string argument resolves to.
948 const Time_zone *m_tz{nullptr};
949
950 /// The specifier string argument, not used after resolution.
952
953 /**
954 Whether the syntax used the `INTERVAL` construction. We have no interval
955 type.
956 */
958};
959
960/// Abstract CURTIME function. Children should define what time zone is used.
963
964 protected:
965 // Abstract method that defines which time zone is used for conversion.
966 virtual Time_zone *time_zone() = 0;
967
968 void add_json_info(Json_object *obj) override {
969 obj->add_alias("precision", create_dom_ptr<Json_uint>(decimals));
970 }
971
972 public:
973 /**
974 Constructor for Item_func_curtime.
975 @param pos Position of token in the parser.
976 @param dec_arg Number of fractional digits.
977 */
978 Item_func_curtime(const POS &pos, uint8 dec_arg) : Item_time_func(pos) {
979 decimals = dec_arg;
980 }
981
982 bool do_itemize(Parse_context *pc, Item **res) override;
983
984 /// This function must assign a new value for each execution
986 return INNER_TABLE_BIT;
987 }
988
989 bool resolve_type(THD *thd) override;
990 bool val_time(Time_val *time) override;
991 bool check_function_as_value_generator(uchar *checker_args) override {
993 pointer_cast<Check_function_as_value_generator_parameters *>(
994 checker_args);
995 func_arg->banned_function_name = func_name();
996 return ((func_arg->source == VGS_GENERATED_COLUMN) ||
997 (func_arg->source == VGS_CHECK_CONSTRAINT));
998 }
999};
1000
1002 protected:
1003 Time_zone *time_zone() override;
1004
1005 public:
1006 Item_func_curtime_local(const POS &pos, uint8 dec_arg)
1007 : Item_func_curtime(pos, dec_arg) {}
1008 const char *func_name() const override { return "curtime"; }
1009};
1010
1012 protected:
1013 Time_zone *time_zone() override;
1014
1015 public:
1016 Item_func_curtime_utc(const POS &pos, uint8 dec_arg)
1017 : Item_func_curtime(pos, dec_arg) {}
1018 const char *func_name() const override { return "utc_time"; }
1019};
1020
1021/**
1022 Abstract CURDATE function.
1023
1024 @sa Item_func_curtime
1025 */
1028
1029 protected:
1030 virtual Time_zone *time_zone() = 0;
1031
1032 public:
1033 explicit Item_func_curdate(const POS &pos) : Item_date_func(pos) {}
1034
1035 bool do_itemize(Parse_context *pc, Item **res) override;
1036
1037 /// This function must assign a new value for each execution
1039 return INNER_TABLE_BIT;
1040 }
1041
1042 longlong val_date_temporal() override;
1043 bool val_date(Date_val *date, my_time_flags_t flags) override;
1044 bool check_function_as_value_generator(uchar *checker_args) override {
1046 pointer_cast<Check_function_as_value_generator_parameters *>(
1047 checker_args);
1048 func_arg->banned_function_name = func_name();
1049 return ((func_arg->source == VGS_GENERATED_COLUMN) ||
1050 (func_arg->source == VGS_CHECK_CONSTRAINT));
1051 }
1052};
1053
1055 protected:
1056 Time_zone *time_zone() override;
1057
1058 public:
1059 explicit Item_func_curdate_local(const POS &pos) : Item_func_curdate(pos) {}
1060 const char *func_name() const override { return "curdate"; }
1061};
1062
1064 protected:
1065 Time_zone *time_zone() override;
1066
1067 public:
1069 const char *func_name() const override { return "utc_date"; }
1070};
1071
1072/**
1073 Abstract CURRENT_TIMESTAMP function.
1074
1075 @sa Item_func_curtime
1076*/
1078 protected:
1079 virtual Time_zone *time_zone() = 0;
1081 bool no_conversions) override;
1082
1083 void add_json_info(Json_object *obj) override {
1084 if (decimals > 0)
1085 obj->add_alias("precision", create_dom_ptr<Json_uint>(decimals));
1086 }
1087
1088 public:
1089 /**
1090 Constructor for Item_func_now.
1091 @param dec_arg Number of fractional digits.
1092 */
1094 Item_func_now(const POS &pos, uint8 dec_arg) : Item_datetime_func(pos) {
1095 decimals = dec_arg;
1096 }
1097
1098 /// This function must assign a new value for each execution
1100 return INNER_TABLE_BIT;
1101 }
1102
1103 bool resolve_type(THD *) override;
1104 longlong val_date_temporal() override;
1105 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1106 String *val_str(String *) override;
1107 bool check_function_as_value_generator(uchar *checker_args) override {
1109 pointer_cast<Check_function_as_value_generator_parameters *>(
1110 checker_args);
1111 func_arg->banned_function_name = func_name();
1112 return ((func_arg->source == VGS_GENERATED_COLUMN) ||
1113 (func_arg->source == VGS_CHECK_CONSTRAINT));
1114 }
1115};
1116
1118 protected:
1119 Time_zone *time_zone() override;
1120
1121 public:
1122 /**
1123 Stores the query start time in a field, truncating to the field's number
1124 of fractional second digits.
1125
1126 @param field The field to store in.
1127 */
1128 static void store_in(Field *field);
1129
1131 Item_func_now_local(const POS &pos, uint8 dec_arg)
1132 : Item_func_now(pos, dec_arg) {}
1133
1134 const char *func_name() const override { return "now"; }
1135 enum Functype functype() const override { return NOW_FUNC; }
1136};
1137
1138class Item_func_now_utc final : public Item_func_now {
1140
1141 protected:
1142 Time_zone *time_zone() override;
1143
1144 public:
1145 Item_func_now_utc(const POS &pos, uint8 dec_arg)
1146 : Item_func_now(pos, dec_arg) {}
1147
1148 bool do_itemize(Parse_context *pc, Item **res) override;
1149
1150 const char *func_name() const override { return "utc_timestamp"; }
1151};
1152
1153/**
1154 SYSDATE() is like NOW(), but always uses the real current time, not the
1155 query_start(). This matches the Oracle behavior.
1156*/
1158 public:
1160 decimals = dec_arg;
1161 }
1162 const char *func_name() const override { return "sysdate"; }
1163 bool resolve_type(THD *) override;
1164 enum Functype functype() const override { return SYSDATE_FUNC; }
1165 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1166 /**
1167 This function is non-deterministic and hence depends on the 'RAND'
1168 pseudo-table.
1169
1170 @retval Always RAND_TABLE_BIT
1171 */
1173 return RAND_TABLE_BIT;
1174 }
1175};
1176
1178 public:
1179 Item_func_from_days(const POS &pos, Item *a) : Item_date_func(pos, a) {
1180 set_nullable(true);
1181 }
1182 const char *func_name() const override { return "from_days"; }
1183 bool resolve_type(THD *thd) override;
1184 bool val_date(Date_val *date, my_time_flags_t flags) override;
1185 bool check_partition_func_processor(uchar *) override { return false; }
1186 enum Functype functype() const override { return FROM_DAYS_FUNC; }
1188 return has_date_args() || has_time_args();
1189 }
1190};
1191
1194 const bool is_time_format;
1196
1197 public:
1199 bool is_time_format_arg = false)
1200 : Item_str_func(pos, a, b), is_time_format(is_time_format_arg) {}
1201 String *val_str(String *str) override;
1202 const char *func_name() const override {
1203 return is_time_format ? "time_format" : "date_format";
1204 }
1205 bool resolve_type(THD *thd) override;
1206 uint format_length(const String *format);
1207 bool eq_specific(const Item *item) const override;
1208};
1209
1211 public:
1213 : Item_datetime_func(pos, a) {}
1214 const char *func_name() const override { return "from_unixtime"; }
1215 enum Functype functype() const override { return FROM_UNIXTIME_FUNC; }
1216 bool resolve_type(THD *thd) override;
1217 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1218};
1219
1220/*
1221 This class represents CONVERT_TZ() function.
1222 The important fact about this function that it is handled in special way.
1223 When such function is met in expression time_zone system tables are added
1224 to global list of tables to open, so later those already opened and locked
1225 tables can be used during this function calculation for loading time zone
1226 descriptions.
1227*/
1229 /*
1230 If time zone parameters are constants we are caching objects that
1231 represent them (we use separate from_tz_cached/to_tz_cached members
1232 to indicate this fact, since NULL is legal value for from_tz/to_tz
1233 members.
1234 */
1237
1238 public:
1239 Item_func_convert_tz(const POS &pos, Item *a, Item *b, Item *c)
1240 : Item_datetime_func(pos, a, b, c),
1241 from_tz_cached(false),
1242 to_tz_cached(false) {}
1243 const char *func_name() const override { return "convert_tz"; }
1244 enum Functype functype() const override { return CONVERT_TZ_FUNC; }
1245 bool resolve_type(THD *) override;
1246 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1247 void cleanup() override;
1248};
1249
1251 public:
1252 Item_func_sec_to_time(const POS &pos, Item *item)
1253 : Item_time_func(pos, item) {}
1254 bool resolve_type(THD *thd) override;
1255 const char *func_name() const override { return "sec_to_time"; }
1256 enum Functype functype() const override { return SEC_TO_TIME_FUNC; }
1257 bool val_time(Time_val *time) override;
1258};
1259
1260extern const char *interval_names[];
1261
1262/**
1263 Implementation class for the DATE_ADD and DATE_SUB functions.
1264 Also used for the synonym functions ADDDATE and SUBDATE.
1265 May be used for all temporal types (DATE, TIME, DATETIME)
1266*/
1269
1270 public:
1272 bool subtract)
1273 : Item_temporal_hybrid_func(pos, a, b),
1275 m_subtract(subtract) {}
1276 /**
1277 POS-less ctor for post-parse construction with implicit addition to THD's
1278 free_list (see Item::Item() no-argument ctor).
1279 */
1283 m_subtract(subtract) {}
1284 const char *func_name() const override { return "date_add_interval"; }
1285 enum Functype functype() const override { return DATEADD_FUNC; }
1286 bool resolve_type(THD *) override;
1287 bool eq_specific(const Item *item) const override;
1288 void print(const THD *thd, String *str,
1289 enum_query_type query_type) const override;
1291 bool is_subtract() const { return m_subtract; }
1292
1293 protected:
1294 void add_json_info(Json_object *obj) override;
1296
1297 private:
1298 bool eval_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1299 bool eval_date(Date_val *date, my_time_flags_t flags) override;
1300 bool eval_time(Time_val *time) override;
1301
1302 /// The type of the interval argument
1304 /// False if function is DATE_ADD, true if function is DATE_SUB
1305 const bool m_subtract;
1307};
1308
1309class Item_extract final : public Item_int_func {
1310 public:
1311 const interval_type int_type; // keep it public
1312 Item_extract(const POS &pos, interval_type type_arg, Item *a)
1313 : Item_int_func(pos, a), int_type(type_arg) {}
1314 longlong val_int() override;
1315 enum Functype functype() const override { return EXTRACT_FUNC; }
1316 const char *func_name() const override { return "extract"; }
1317 bool resolve_type(THD *) override;
1318 bool eq_specific(const Item *item) const override;
1319 void print(const THD *thd, String *str,
1320 enum_query_type query_type) const override;
1321 bool check_partition_func_processor(uchar *) override { return false; }
1323 switch (int_type) {
1324 case INTERVAL_YEAR:
1326 case INTERVAL_QUARTER:
1327 case INTERVAL_MONTH:
1328 /* case INTERVAL_WEEK: Not allowed as partitioning function, bug#57071 */
1329 case INTERVAL_DAY:
1330 return !has_date_args();
1331 case INTERVAL_DAY_HOUR:
1335 return !has_datetime_args();
1336 case INTERVAL_HOUR:
1339 case INTERVAL_MINUTE:
1341 case INTERVAL_SECOND:
1346 return !has_time_args();
1347 default:
1348 /*
1349 INTERVAL_LAST is only an end marker,
1350 INTERVAL_WEEK depends on default_week_format which is a session
1351 variable and cannot be used for partitioning. See bug#57071.
1352 */
1353 break;
1354 }
1355 return true;
1356 }
1357
1358 private:
1359 /// True if only date values are extracted
1360 bool m_date_value{false};
1361 /// True if only time values are extracted
1362 bool m_time_value{false};
1363};
1364
1367
1368 public:
1369 Item_typecast_date(Item *a, bool explicit_cast)
1370 : Item_date_func(a), m_explicit_cast(explicit_cast) {
1371 set_nullable(true);
1372 }
1373 Item_typecast_date(const POS &pos, Item *a) : Item_date_func(pos, a) {
1374 set_nullable(true);
1375 }
1376
1377 bool resolve_type(THD *thd) override;
1378 void print(const THD *thd, String *str,
1379 enum_query_type query_type) const override;
1380 const char *func_name() const override { return "cast_as_date"; }
1381 enum Functype functype() const override { return TYPECAST_FUNC; }
1382 bool is_explicit_cast() const { return m_explicit_cast; }
1383 bool val_date(Date_val *date, my_time_flags_t flags) override;
1384 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1385 const char *cast_type() const { return "date"; }
1386};
1387
1391
1392 public:
1395 }
1396 Item_typecast_time(const POS &pos, Item *a) : Item_time_func(pos, a) {
1398 }
1399 Item_typecast_time(const POS &pos, Item *a, uint8 dec_arg)
1400 : Item_time_func(pos, a) {
1402 decimals = dec_arg;
1403 }
1406 decimals = dec_arg;
1407 }
1408 void print(const THD *thd, String *str,
1409 enum_query_type query_type) const override;
1410 const char *func_name() const override { return "cast_as_time"; }
1411 enum Functype functype() const override { return TYPECAST_FUNC; }
1412 bool is_explicit_cast() const { return m_explicit_cast; }
1413 bool val_time(Time_val *time) override;
1414 const char *cast_type() const { return "time"; }
1415 bool resolve_type(THD *thd) override;
1416};
1417
1421
1422 public:
1423 Item_typecast_datetime(Item *a, bool explicit_cast)
1424 : Item_datetime_func(a), m_explicit_cast(explicit_cast) {
1426 }
1429 }
1430 Item_typecast_datetime(const POS &pos, Item *a, uint8 dec_arg)
1431 : Item_datetime_func(pos, a) {
1433 decimals = dec_arg;
1434 }
1437 decimals = dec_arg;
1438 }
1439 void print(const THD *thd, String *str,
1440 enum_query_type query_type) const override;
1441 const char *func_name() const override { return "cast_as_datetime"; }
1442 enum Functype functype() const override { return TYPECAST_FUNC; }
1443 const char *cast_type() const { return "datetime"; }
1444 bool is_explicit_cast() const { return m_explicit_cast; }
1445 bool resolve_type(THD *thd) override;
1446 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1447};
1448
1450 public:
1451 Item_func_makedate(const POS &pos, Item *a, Item *b)
1452 : Item_date_func(pos, a, b) {
1453 set_nullable(true);
1454 }
1455 const char *func_name() const override { return "makedate"; }
1456 bool resolve_type(THD *thd) override;
1457 bool val_date(Date_val *date, my_time_flags_t flags) override;
1458 enum Functype functype() const override { return MAKEDATE_FUNC; }
1459};
1460
1461/**
1462 Add a time expression to a temporal expression, or
1463 subtract a time expression from a temporal expression.
1464 Used to implement the functions ADDTIME and SUBTIME, and the
1465 two-argument version of TIMESTAMP (which sets m_datetime = true).
1466*/
1468 const bool m_datetime; ///< True if first argument expected to be datetime
1469 bool m_subtract; ///< FALSE for ADD, TRUE for SUBTRACT
1470
1471 protected:
1473 bool eval_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1475 // This class cannot return a date natively
1476 assert(false);
1477 return true;
1478 }
1479 bool eval_time(Time_val *time) override;
1480
1481 public:
1482 Item_func_add_time(Item *a, Item *b, bool datetime, bool subtract)
1484 m_datetime(datetime),
1485 m_subtract(subtract) {}
1486 Item_func_add_time(const POS &pos, Item *a, Item *b, bool datetime,
1487 bool subtract)
1488 : Item_temporal_hybrid_func(pos, a, b),
1489 m_datetime(datetime),
1490 m_subtract(subtract) {}
1491
1492 Item_func_add_time(const POS &pos, Item *a, Item *b)
1493 : Item_func_add_time(pos, a, b, false, false) {}
1494
1495 bool resolve_type(THD *) override;
1496 void print(const THD *thd, String *str,
1497 enum_query_type query_type) const override;
1498 const char *func_name() const override { return "add_time"; }
1499 enum Functype functype() const override { return ADDTIME_FUNC; }
1500 bool is_subtract() const { return m_subtract; }
1501};
1502
1504 public:
1505 Item_func_timediff(const POS &pos, Item *a, Item *b)
1506 : Item_time_func(pos, a, b) {}
1507 const char *func_name() const override { return "timediff"; }
1508 enum Functype functype() const override { return TIMEDIFF_FUNC; }
1509 bool resolve_type(THD *thd) override;
1510 bool val_time(Time_val *time) override;
1511};
1512
1514 public:
1515 Item_func_maketime(const POS &pos, Item *a, Item *b, Item *c)
1516 : Item_time_func(pos, a, b, c) {
1517 set_nullable(true);
1518 }
1519 bool resolve_type(THD *thd) override;
1520 const char *func_name() const override { return "maketime"; }
1521 enum Functype functype() const override { return MAKETIME_FUNC; }
1522 bool val_time(Time_val *time) override;
1523};
1524
1526 public:
1527 Item_func_microsecond(const POS &pos, Item *a) : Item_int_func(pos, a) {}
1528 longlong val_int() override;
1529 const char *func_name() const override { return "microsecond"; }
1530 enum Functype functype() const override { return MICROSECOND_FUNC; }
1531 bool resolve_type(THD *thd) override;
1532 bool check_partition_func_processor(uchar *) override { return false; }
1534 return !has_time_args();
1535 }
1536};
1537
1540
1541 public:
1543 interval_type type_arg)
1544 : Item_int_func(pos, a, b), int_type(type_arg) {}
1545 const char *func_name() const override { return "timestampdiff"; }
1546 enum Functype functype() const override { return TIMESTAMPDIFF_FUNC; }
1548 longlong val_int() override;
1549 bool resolve_type(THD *thd) override;
1550 void print(const THD *thd, String *str,
1551 enum_query_type query_type) const override;
1552};
1553
1561
1563 public:
1564 const enum_mysql_timestamp_type type; // keep it public
1566 Item *a)
1567 : Item_str_ascii_func(pos, a), type(type_arg) {}
1568 String *val_str_ascii(String *str) override;
1569 const char *func_name() const override { return "get_format"; }
1570 enum Functype functype() const override { return GET_FORMAT_FUNC; }
1571 bool resolve_type(THD *thd) override;
1572 void print(const THD *thd, String *str,
1573 enum_query_type query_type) const override;
1574
1576};
1577
1580 void fix_from_format(const char *format, size_t length);
1581
1582 protected:
1583 my_time_flags_t eval_flags() const override;
1584 bool eval_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1585 bool eval_date(Date_val *date, my_time_flags_t flags) override;
1586 bool eval_time(Time_val *time) override;
1587
1588 public:
1590 : Item_temporal_hybrid_func(pos, a, b) {}
1591 const char *func_name() const override { return "str_to_date"; }
1592 bool resolve_type(THD *) override;
1593};
1594
1596 public:
1597 Item_func_last_day(const POS &pos, Item *a) : Item_date_func(pos, a) {
1598 set_nullable(true);
1599 }
1600 const char *func_name() const override { return "last_day"; }
1601 enum Functype functype() const override { return LAST_DAY_FUNC; }
1602 bool resolve_type(THD *thd) override;
1603 bool val_date(Date_val *date, my_time_flags_t flags) override;
1604};
1605
1607 public:
1609 : Item_datetime_func(pos, list) {}
1610 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
1611 const char *func_name() const override { return "internal_update_time"; }
1612 bool resolve_type(THD *thd) override;
1613 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1614};
1615
1617 public:
1619 : Item_datetime_func(pos, list) {}
1620 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
1621 const char *func_name() const override { return "internal_check_time"; }
1622 bool resolve_type(THD *thd) override;
1623 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1624};
1625
1626/* Function prototypes */
1627
1630
1631#endif /* ITEM_TIMEFUNC_INCLUDED */
const CHARSET_INFO * collation
Definition: item.h:186
Date_val is a temporal type that represents dates within the range 0000-01-01 and 9999-12-31.
Definition: my_temporal.h:421
Definition: my_temporal.h:341
Definition: field.h:573
Abstract class for functions returning DATE values.
Definition: item_timefunc.h:548
double val_real() override
Definition: item_timefunc.h:574
bool val_date(Date_val *date, my_time_flags_t flags) override=0
Evaluate the item and return result as a date value.
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_timefunc.h:568
const char * func_name() const override
Definition: item_timefunc.h:575
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:577
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.h:567
enum Functype functype() const override
Definition: item_timefunc.h:576
Item_date_func(const POS &pos)
Definition: item_timefunc.h:556
Item_date_func()
Definition: item_timefunc.h:555
Item_date_func(Item *a)
Definition: item_timefunc.h:559
Item_date_func(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:563
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.cc:1086
longlong val_int() override
Definition: item_timefunc.h:572
Item_date_func(const POS &pos, Item *a)
Definition: item_timefunc.h:560
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:550
String * val_str(String *str) override
Definition: item_timefunc.h:571
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_timefunc.h:578
DATE'2010-01-01'.
Definition: item_timefunc.h:794
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:812
Date_val m_date
Definition: item_timefunc.h:819
bool val_date(Date_val *date, my_time_flags_t) override
Evaluate the item and return result as a date value.
Definition: item_timefunc.cc:1120
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:810
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:1111
Item_date_literal(Date_val date)
Constructor for Item_date_literal.
Definition: item_timefunc.h:800
const char * func_name() const override
Definition: item_timefunc.h:805
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_timefunc.cc:1106
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_timefunc.h:815
table_map used_tables() const override
Definition: item_timefunc.h:813
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:811
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_timefunc.cc:1127
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:814
Abstract class for functions returning DATETIME values.
Definition: item_timefunc.h:591
longlong val_int() override
Definition: item_timefunc.h:634
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override=0
Evaluate the item and return result as a datetime value.
Item_datetime_func(Item *a)
Definition: item_timefunc.h:604
Item_datetime_func(const POS &pos)
Definition: item_timefunc.h:601
Item_datetime_func()
Definition: item_timefunc.h:598
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.h:640
String * val_str(String *str) override
Definition: item_timefunc.h:631
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_timefunc.cc:1093
double val_real() override
Definition: item_timefunc.h:630
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.cc:1100
Item_datetime_func(const POS &pos, PT_item_list *list)
Definition: item_timefunc.h:625
Item_datetime_func(Item *a, Item *b, Item *c)
Definition: item_timefunc.h:614
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:593
Item_datetime_func(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_timefunc.h:617
Item_datetime_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_timefunc.h:621
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_timefunc.h:636
Item_datetime_func(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:610
Item_datetime_func(const POS &pos, Item *a)
Definition: item_timefunc.h:607
TIMESTAMP'2001-01-01 10:20:30'.
Definition: item_timefunc.h:863
MYSQL_TIME_cache cached_time
Definition: item_timefunc.h:864
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_timefunc.cc:1144
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:897
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:895
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:899
enum Functype functype() const override
Definition: item_timefunc.h:880
const char * func_name() const override
Definition: item_timefunc.h:879
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_timefunc.h:900
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_timefunc.h:887
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:896
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:1137
Item_datetime_literal(Datetime_val *dt, uint dec_arg, const Time_zone *tz)
Constructor for Item_datetime_literal.
Definition: item_timefunc.h:874
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_timefunc.cc:1132
String * val_str(String *str) override
Definition: item_timefunc.h:891
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.h:883
table_map used_tables() const override
Definition: item_timefunc.h:898
Definition: item_timefunc.h:1309
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:1322
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:3083
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_timefunc.cc:3283
const char * func_name() const override
Definition: item_timefunc.h:1316
enum Functype functype() const override
Definition: item_timefunc.h:1315
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3092
longlong val_int() override
Definition: item_timefunc.cc:3181
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:1321
const interval_type int_type
Definition: item_timefunc.h:1311
Item_extract(const POS &pos, interval_type type_arg, Item *a)
Definition: item_timefunc.h:1312
bool m_date_value
True if only date values are extracted.
Definition: item_timefunc.h:1360
bool m_time_value
True if only time values are extracted.
Definition: item_timefunc.h:1362
Implementation class for the DATE_ADD and DATE_SUB functions.
Definition: item_timefunc.h:1267
const bool m_subtract
False if function is DATE_ADD, true if function is DATE_SUB.
Definition: item_timefunc.h:1305
Item_func_add_interval(const POS &pos, Item *a, Item *b, interval_type type, bool subtract)
Definition: item_timefunc.h:1271
bool is_subtract() const
Definition: item_timefunc.h:1291
Item_func_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:1280
bool eval_date(Date_val *date, my_time_flags_t flags) override
Evaluate temporal expression as date value.
Definition: item_timefunc.cc:3000
const char * func_name() const override
Definition: item_timefunc.h:1284
bool eval_time(Time_val *time) override
Evaluate temporal expression as time value.
Definition: item_timefunc.cc:3017
interval_type get_interval_type() const
Definition: item_timefunc.h:1290
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2862
bool eval_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate temporal expression as datetime value.
Definition: item_timefunc.cc:2954
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:3065
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_timefunc.cc:3076
Item_temporal_hybrid_func super
Definition: item_timefunc.h:1268
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_timefunc.cc:3032
enum Functype functype() const override
Definition: item_timefunc.h:1285
String value
Definition: item_timefunc.h:1306
const interval_type m_interval_type
The type of the interval argument.
Definition: item_timefunc.h:1303
my_time_flags_t eval_flags() const override
Definition: item_timefunc.h:1295
Add a time expression to a temporal expression, or subtract a time expression from a temporal express...
Definition: item_timefunc.h:1467
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3441
const char * func_name() const override
Definition: item_timefunc.h:1498
bool is_subtract() const
Definition: item_timefunc.h:1500
bool m_subtract
FALSE for ADD, TRUE for SUBTRACT.
Definition: item_timefunc.h:1469
const bool m_datetime
True if first argument expected to be datetime.
Definition: item_timefunc.h:1468
enum Functype functype() const override
Definition: item_timefunc.h:1499
bool eval_time(Time_val *time) override
Evaluate temporal expression as time value.
Definition: item_timefunc.cc:3590
bool eval_date(Date_val *, my_time_flags_t) override
Evaluate temporal expression as date value.
Definition: item_timefunc.h:1474
Item_func_add_time(const POS &pos, Item *a, Item *b, bool datetime, bool subtract)
Definition: item_timefunc.h:1486
my_time_flags_t eval_flags() const override
Definition: item_timefunc.h:1472
bool eval_datetime(Datetime_val *dt, my_time_flags_t flags) override
ADDTIME(t,a) and SUBTIME(t,a) are time functions that calculate a time/datetime value.
Definition: item_timefunc.cc:3486
Item_func_add_time(Item *a, Item *b, bool datetime, bool subtract)
Definition: item_timefunc.h:1482
Item_func_add_time(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:1492
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:3609
This function implements the AT TIME ZONE operator, which casts a temporal value to a temporal with t...
Definition: item_timefunc.h:922
bool check_type() const
Definition: item_timefunc.cc:1226
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1171
bool set_time_zone(THD *thd)
Definition: item_timefunc.cc:1189
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_timefunc.cc:1200
const char * func_name() const override
Definition: item_timefunc.h:932
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:1183
bool m_is_interval
Whether the syntax used the INTERVAL construction.
Definition: item_timefunc.h:957
const char * m_specifier_string
The specifier string argument, not used after resolution.
Definition: item_timefunc.h:951
const Time_zone * m_tz
The time zone that the specifier string argument resolves to.
Definition: item_timefunc.h:948
const char * specifier_string() const
Definition: item_timefunc.h:941
Item_func_at_time_zone(const POS &pos, Item *datetime, const char *specifier_string, bool is_interval)
Definition: item_timefunc.h:924
Definition: item_timefunc.h:1228
const char * func_name() const override
Definition: item_timefunc.h:1243
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2808
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_timefunc.cc:2817
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_timefunc.cc:2856
Time_zone * from_tz
Definition: item_timefunc.h:1236
Item_func_convert_tz(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_timefunc.h:1239
bool from_tz_cached
Definition: item_timefunc.h:1235
bool to_tz_cached
Definition: item_timefunc.h:1235
enum Functype functype() const override
Definition: item_timefunc.h:1244
Time_zone * to_tz
Definition: item_timefunc.h:1236
Definition: item_timefunc.h:1054
Time_zone * time_zone() override
Definition: item_timefunc.cc:2383
const char * func_name() const override
Definition: item_timefunc.h:1060
Item_func_curdate_local(const POS &pos)
Definition: item_timefunc.h:1059
Definition: item_timefunc.h:1063
Time_zone * time_zone() override
Definition: item_timefunc.cc:2387
Item_func_curdate_utc(const POS &pos)
Definition: item_timefunc.h:1068
const char * func_name() const override
Definition: item_timefunc.h:1069
Abstract CURDATE function.
Definition: item_timefunc.h:1026
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_timefunc.cc:2396
Item_date_func super
Definition: item_timefunc.h:1027
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.cc:2389
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:1044
Item_func_curdate(const POS &pos)
Definition: item_timefunc.h:1033
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_timefunc.cc:2376
table_map get_initial_pseudo_tables() const override
This function must assign a new value for each execution.
Definition: item_timefunc.h:1038
Definition: item_timefunc.h:1001
Item_func_curtime_local(const POS &pos, uint8 dec_arg)
Definition: item_timefunc.h:1006
const char * func_name() const override
Definition: item_timefunc.h:1008
Time_zone * time_zone() override
Definition: item_timefunc.cc:2439
Definition: item_timefunc.h:1011
Time_zone * time_zone() override
Definition: item_timefunc.cc:2443
const char * func_name() const override
Definition: item_timefunc.h:1018
Item_func_curtime_utc(const POS &pos, uint8 dec_arg)
Definition: item_timefunc.h:1016
Abstract CURTIME function. Children should define what time zone is used.
Definition: item_timefunc.h:961
virtual Time_zone * time_zone()=0
table_map get_initial_pseudo_tables() const override
This function must assign a new value for each execution.
Definition: item_timefunc.h:985
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2415
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:991
Item_func_curtime(const POS &pos, uint8 dec_arg)
Constructor for Item_func_curtime.
Definition: item_timefunc.h:978
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.cc:2430
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_timefunc.cc:2408
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_timefunc.h:968
Item_time_func super
Definition: item_timefunc.h:962
Definition: item_timefunc.h:1192
const bool is_time_format
Definition: item_timefunc.h:1194
int fixed_length
Definition: item_timefunc.h:1193
const char * func_name() const override
Definition: item_timefunc.h:1202
String * val_str(String *str) override
Definition: item_timefunc.cc:2683
Item_func_date_format(const POS &pos, Item *a, Item *b, bool is_time_format_arg=false)
Definition: item_timefunc.h:1198
String value
Definition: item_timefunc.h:1195
uint format_length(const String *format)
Definition: item_timefunc.cc:2613
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2565
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_timefunc.cc:2594
Definition: item_timefunc.h:310
const char * func_name() const override
Definition: item_timefunc.h:315
Item_func_dayname(const POS &pos, Item *a)
Definition: item_timefunc.h:314
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1872
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:319
String * val_str(String *str) override
Definition: item_timefunc.cc:1884
MY_LOCALE * locale
Definition: item_timefunc.h:311
enum Functype functype() const override
Definition: item_timefunc.h:316
Definition: item_timefunc.h:126
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:135
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1442
Item_func_dayofmonth(const POS &pos, Item *a)
Definition: item_timefunc.h:128
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:134
const char * func_name() const override
Definition: item_timefunc.h:131
longlong val_int() override
Definition: item_timefunc.cc:1453
enum Functype functype() const override
Definition: item_timefunc.h:132
Definition: item_timefunc.h:169
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1422
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:177
longlong val_int() override
Definition: item_timefunc.cc:1433
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:176
Item_func_dayofyear(const POS &pos, Item *a)
Definition: item_timefunc.h:171
const char * func_name() const override
Definition: item_timefunc.h:173
enum Functype functype() const override
Definition: item_timefunc.h:174
Definition: item_timefunc.h:1177
const char * func_name() const override
Definition: item_timefunc.h:1182
Item_func_from_days(const POS &pos, Item *a)
Definition: item_timefunc.h:1179
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:1187
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2304
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:1185
enum Functype functype() const override
Definition: item_timefunc.h:1186
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_timefunc.cc:2310
Definition: item_timefunc.h:1210
const char * func_name() const override
Definition: item_timefunc.h:1214
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_timefunc.cc:2751
Item_func_from_unixtime(const POS &pos, Item *a)
Definition: item_timefunc.h:1212
enum Functype functype() const override
Definition: item_timefunc.h:1215
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2742
Definition: item_timefunc.h:1562
String * val_str_ascii(String *str) override
Definition: item_timefunc.cc:4005
const char * func_name() const override
Definition: item_timefunc.h:1569
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:4032
enum Functype functype() const override
Definition: item_timefunc.h:1570
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3997
enum_mysql_timestamp_type timestamp_type() const
Definition: item_timefunc.h:1575
Item_func_get_format(const POS &pos, enum_mysql_timestamp_type type_arg, Item *a)
Definition: item_timefunc.h:1565
const enum_mysql_timestamp_type type
Definition: item_timefunc.h:1564
Definition: item_timefunc.h:182
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1702
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:190
longlong val_int() override
Definition: item_timefunc.cc:1712
const char * func_name() const override
Definition: item_timefunc.h:186
enum Functype functype() const override
Definition: item_timefunc.h:187
Item_func_hour(const POS &pos, Item *a)
Definition: item_timefunc.h:184
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:189
Definition: item_timefunc.h:1616
enum Functype functype() const override
Definition: item_timefunc.h:1620
const char * func_name() const override
Definition: item_timefunc.h:1621
Item_func_internal_check_time(const POS &pos, PT_item_list *list)
Definition: item_timefunc.h:1618
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_timefunc.cc:4344
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:4336
Definition: item_timefunc.h:1606
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_timefunc.cc:4265
const char * func_name() const override
Definition: item_timefunc.h:1611
enum Functype functype() const override
Definition: item_timefunc.h:1610
Item_func_internal_update_time(const POS &pos, PT_item_list *list)
Definition: item_timefunc.h:1608
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:4257
Definition: item_timefunc.h:1595
Item_func_last_day(const POS &pos, Item *a)
Definition: item_timefunc.h:1597
const char * func_name() const override
Definition: item_timefunc.h:1600
enum Functype functype() const override
Definition: item_timefunc.h:1601
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:4232
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_timefunc.cc:4238
Definition: item_timefunc.h:1449
bool resolve_type(THD *thd) override
MAKEDATE(a,b) is a date function that creates a date value from a year and day value.
Definition: item_timefunc.cc:3407
enum Functype functype() const override
Definition: item_timefunc.h:1458
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_timefunc.cc:3413
Item_func_makedate(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:1451
const char * func_name() const override
Definition: item_timefunc.h:1455
Definition: item_timefunc.h:1513
enum Functype functype() const override
Definition: item_timefunc.h:1521
bool resolve_type(THD *thd) override
MAKETIME(h,m,s) is a time function that calculates a time value from the total number of hours,...
Definition: item_timefunc.cc:3735
Item_func_maketime(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_timefunc.h:1515
const char * func_name() const override
Definition: item_timefunc.h:1520
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.cc:3743
Definition: item_timefunc.h:1525
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:1533
longlong val_int() override
MICROSECOND(a) is a function ( extraction) that extracts the microseconds from a.
Definition: item_timefunc.cc:3837
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3843
enum Functype functype() const override
Definition: item_timefunc.h:1530
Item_func_microsecond(const POS &pos, Item *a)
Definition: item_timefunc.h:1527
const char * func_name() const override
Definition: item_timefunc.h:1529
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:1532
Definition: item_timefunc.h:195
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1718
const char * func_name() const override
Definition: item_timefunc.h:199
longlong val_int() override
Definition: item_timefunc.cc:1728
Item_func_minute(const POS &pos, Item *a)
Definition: item_timefunc.h:197
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:202
enum Functype functype() const override
Definition: item_timefunc.h:200
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:203
Definition: item_timefunc.h:140
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1630
enum Item_result result_type() const override
Definition: item_timefunc.h:146
longlong val_int() override
Definition: item_timefunc.cc:1641
const char * func_name() const override
Definition: item_timefunc.h:144
Item_func_month(const POS &pos, Item *a)
Definition: item_timefunc.h:142
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:149
enum Functype functype() const override
Definition: item_timefunc.h:145
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:148
Definition: item_timefunc.h:154
Item_func_monthname(const POS &pos, Item *a)
Definition: item_timefunc.h:158
MY_LOCALE * locale
Definition: item_timefunc.h:155
const char * func_name() const override
Definition: item_timefunc.h:159
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:164
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:163
String * val_str(String *str) override
Definition: item_timefunc.cc:1662
enum Functype functype() const override
Definition: item_timefunc.h:160
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1650
Definition: item_timefunc.h:1117
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:2455
Time_zone * time_zone() override
Definition: item_timefunc.cc:2462
const char * func_name() const override
Definition: item_timefunc.h:1134
Item_func_now_local(const POS &pos, uint8 dec_arg)
Definition: item_timefunc.h:1131
enum Functype functype() const override
Definition: item_timefunc.h:1135
Item_func_now_local(uint8 dec_arg)
Definition: item_timefunc.h:1130
Definition: item_timefunc.h:1138
const char * func_name() const override
Definition: item_timefunc.h:1150
Item_func_now_utc(const POS &pos, uint8 dec_arg)
Definition: item_timefunc.h:1145
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_timefunc.cc:2464
Item_func_now super
Definition: item_timefunc.h:1139
Time_zone * time_zone() override
Definition: item_timefunc.cc:2471
Abstract CURRENT_TIMESTAMP function.
Definition: item_timefunc.h:1077
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_timefunc.cc:2481
Item_func_now(uint8 dec_arg)
Constructor for Item_func_now.
Definition: item_timefunc.h:1093
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:2502
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.cc:2473
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2447
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:1107
String * val_str(String *) override
Definition: item_timefunc.cc:2489
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_timefunc.h:1083
table_map get_initial_pseudo_tables() const override
This function must assign a new value for each execution.
Definition: item_timefunc.h:1099
Item_func_now(const POS &pos, uint8 dec_arg)
Definition: item_timefunc.h:1094
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:1240
longlong val_int() override
Definition: item_timefunc.cc:1245
enum Functype functype() const override
Definition: item_timefunc.h:72
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:76
const char * func_name() const override
Definition: item_timefunc.h:81
enum Functype functype() const override
Definition: item_timefunc.h:82
Item_func_period_diff(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:78
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1259
longlong val_int() override
Definition: item_timefunc.cc:1264
Definition: item_timefunc.h:208
const char * func_name() const override
Definition: item_timefunc.h:212
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:215
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:216
enum Functype functype() const override
Definition: item_timefunc.h:213
Item_func_quarter(const POS &pos, Item *a)
Definition: item_timefunc.h:210
longlong val_int() override
Returns the quarter of the year.
Definition: item_timefunc.cc:1693
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1679
Definition: item_timefunc.h:1250
const char * func_name() const override
Definition: item_timefunc.h:1255
Item_func_sec_to_time(const POS &pos, Item *item)
Definition: item_timefunc.h:1252
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2532
enum Functype functype() const override
Definition: item_timefunc.h:1256
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.cc:2540
Definition: item_timefunc.h:221
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:229
const char * func_name() const override
Definition: item_timefunc.h:225
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:228
enum Functype functype() const override
Definition: item_timefunc.h:226
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1734
Item_func_second(const POS &pos, Item *a)
Definition: item_timefunc.h:223
longlong val_int() override
Returns the second in time_exp in the range of 0 - 59.
Definition: item_timefunc.cc:1747
Definition: item_timefunc.h:1578
my_time_flags_t eval_flags() const override
Definition: item_timefunc.cc:4054
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:4078
bool eval_date(Date_val *date, my_time_flags_t flags) override
Evaluate temporal expression as date value.
Definition: item_timefunc.cc:4145
Item_func_str_to_temporal(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:1589
bool eval_time(Time_val *time) override
Evaluate temporal expression as time value.
Definition: item_timefunc.cc:4157
bool eval_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate temporal expression as datetime value.
Definition: item_timefunc.cc:4182
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:4129
const char * func_name() const override
Definition: item_timefunc.h:1591
enum_mysql_timestamp_type cached_timestamp_type
Definition: item_timefunc.h:1579
SYSDATE() is like NOW(), but always uses the real current time, not the query_start().
Definition: item_timefunc.h:1157
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:1172
const char * func_name() const override
Definition: item_timefunc.h:1162
Item_func_sysdate_local(uint8 dec_arg)
Definition: item_timefunc.h:1159
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2526
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Converts current time in my_time_t to MYSQL_TIME representation for local time zone.
Definition: item_timefunc.cc:2515
enum Functype functype() const override
Definition: item_timefunc.h:1164
Definition: item_timefunc.h:403
enum Functype functype() const override
Definition: item_timefunc.h:409
longlong val_int() override
Definition: item_timefunc.cc:2139
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:411
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2131
Item_func_time_to_sec(const POS &pos, Item *item)
Definition: item_timefunc.h:405
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:412
const char * func_name() const override
Definition: item_timefunc.h:408
Definition: item_timefunc.h:1503
enum Functype functype() const override
Definition: item_timefunc.h:1508
Item_func_timediff(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:1505
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3627
const char * func_name() const override
Definition: item_timefunc.h:1507
bool val_time(Time_val *time) override
TIMEDIFF(t,s) is a time function that calculates the time value between a start and end time.
Definition: item_timefunc.cc:3649
Definition: item_timefunc.h:1538
interval_type intervaltype() const
Definition: item_timefunc.h:1547
const char * func_name() const override
Definition: item_timefunc.h:1545
enum Functype functype() const override
Definition: item_timefunc.h:1546
longlong val_int() override
Definition: item_timefunc.cc:3857
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:3953
Item_func_timestamp_diff(const POS &pos, Item *a, Item *b, interval_type type_arg)
Definition: item_timefunc.h:1542
const interval_type int_type
Definition: item_timefunc.h:1539
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3850
Definition: item_timefunc.h:86
Item_func_to_days(const POS &pos, Item *a)
Definition: item_timefunc.h:88
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1279
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:95
longlong val_int() override
Definition: item_timefunc.cc:1293
enum Functype functype() const override
Definition: item_timefunc.h:91
const char * func_name() const override
Definition: item_timefunc.h:90
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:96
longlong val_int_endpoint(bool left_endp, bool *incl_endp) override
Definition: item_timefunc.cc:1376
enum_monotonicity_info get_monotonicity_info() const override
Definition: item_timefunc.cc:1357
Definition: item_timefunc.h:101
bool intro_version(uchar *int_arg) override
Definition: item_timefunc.h:112
enum_monotonicity_info get_monotonicity_info() const override
Definition: item_timefunc.cc:1367
Item_func_to_seconds(const POS &pos, Item *a)
Definition: item_timefunc.h:103
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1324
longlong val_int() override
Definition: item_timefunc.cc:1331
enum Functype functype() const override
Definition: item_timefunc.h:106
const char * func_name() const override
Definition: item_timefunc.h:105
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:110
longlong val_int_endpoint(bool left_endp, bool *incl_endp) override
Definition: item_timefunc.cc:1302
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:121
Definition: item_timefunc.h:354
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:371
table_map get_initial_pseudo_tables() const override
Returns the pseudo tables depended upon in order to evaluate this function expression.
Definition: item_timefunc.h:381
longlong val_int_endpoint(bool left_endp, bool *incl_endp) override
Definition: item_timefunc.cc:2122
const char * func_name() const override
Definition: item_timefunc.h:365
Item_func_unix_timestamp(const POS &pos)
Definition: item_timefunc.h:358
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:390
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2086
Item_timeval_func super
Definition: item_timefunc.h:355
enum_monotonicity_info get_monotonicity_info() const override
Definition: item_timefunc.cc:2115
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_timefunc.cc:2079
Item_func_unix_timestamp(Item *a)
Definition: item_timefunc.h:360
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:377
enum Functype functype() const override
Definition: item_timefunc.h:366
Item_func_unix_timestamp(const POS &pos, Item *a)
Definition: item_timefunc.h:362
bool val_timeval(my_timeval *tm) override
Definition: item_timefunc.cc:2103
Definition: item_timefunc.h:234
const char * func_name() const override
Definition: item_timefunc.h:244
longlong val_int() override
Definition: item_timefunc.cc:1813
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_timefunc.cc:1759
Item_func_week(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:239
Item_func_week(Item *a, Item *b)
Definition: item_timefunc.h:238
Item_int_func super
Definition: item_timefunc.h:235
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1770
enum Functype functype() const override
Definition: item_timefunc.h:245
Definition: item_timefunc.h:291
Item_func_weekday(const POS &pos, Item *a, bool type_arg)
Definition: item_timefunc.h:295
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:304
const char * func_name() const override
Definition: item_timefunc.h:298
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:305
bool odbc_type
Definition: item_timefunc.h:292
enum Item_result result_type() const override
Definition: item_timefunc.h:302
enum Functype functype() const override
Definition: item_timefunc.h:301
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1853
longlong val_int() override
Definition: item_timefunc.cc:1863
Definition: item_timefunc.h:263
enum Functype functype() const override
Definition: item_timefunc.h:268
longlong val_int_endpoint(bool left_endp, bool *incl_endp) override
Definition: item_timefunc.cc:2023
enum_monotonicity_info get_monotonicity_info() const override
Definition: item_timefunc.cc:2015
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:272
const char * func_name() const override
Definition: item_timefunc.h:267
longlong val_int() override
Definition: item_timefunc.cc:1908
Item_func_year(const POS &pos, Item *a)
Definition: item_timefunc.h:265
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1900
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:273
Definition: item_timefunc.h:249
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:257
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1827
enum Functype functype() const override
Definition: item_timefunc.h:255
longlong val_int() override
Definition: item_timefunc.cc:1838
Item_func_yearweek(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:251
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:258
const char * func_name() const override
Definition: item_timefunc.h:254
Definition: item_func.h:101
Functype
Definition: item_func.h:214
@ DATEADD_FUNC
Definition: item_func.h:322
@ YEAR_FUNC
Definition: item_func.h:302
@ HOUR_FUNC
Definition: item_func.h:313
@ TIME_TO_SEC_FUNC
Definition: item_func.h:327
@ PERIODDIFF_FUNC
Definition: item_func.h:343
@ FROM_UNIXTIME_FUNC
Definition: item_func.h:323
@ MAKETIME_FUNC
Definition: item_func.h:305
@ NOW_FUNC
Definition: item_func.h:256
@ FROM_DAYS_FUNC
Definition: item_func.h:257
@ CONVERT_TZ_FUNC
Definition: item_func.h:324
@ DD_INTERNAL_FUNC
Definition: item_func.h:271
@ DAY_FUNC
Definition: item_func.h:308
@ MAKEDATE_FUNC
Definition: item_func.h:304
@ SEC_TO_TIME_FUNC
Definition: item_func.h:344
@ DATE_FUNC
Definition: item_func.h:312
@ TIMESTAMPDIFF_FUNC
Definition: item_func.h:328
@ SECOND_FUNC
Definition: item_func.h:315
@ PERIODADD_FUNC
Definition: item_func.h:342
@ EXTRACT_FUNC
Definition: item_func.h:262
@ MONTH_FUNC
Definition: item_func.h:306
@ TO_SECONDS_FUNC
Definition: item_func.h:311
@ MICROSECOND_FUNC
Definition: item_func.h:316
@ QUARTER_FUNC
Definition: item_func.h:319
@ TIMEDIFF_FUNC
Definition: item_func.h:341
@ SYSDATE_FUNC
Definition: item_func.h:340
@ MONTHNAME_FUNC
Definition: item_func.h:307
@ TYPECAST_FUNC
Definition: item_func.h:263
@ LAST_DAY_FUNC
Definition: item_func.h:325
@ WEEKDAY_FUNC
Definition: item_func.h:321
@ ADDTIME_FUNC
Definition: item_func.h:318
@ DAYOFYEAR_FUNC
Definition: item_func.h:317
@ GET_FORMAT_FUNC
Definition: item_func.h:345
@ DAYNAME_FUNC
Definition: item_func.h:309
@ DATETIME_LITERAL
Definition: item_func.h:329
@ MINUTE_FUNC
Definition: item_func.h:314
@ TO_DAYS_FUNC
Definition: item_func.h:310
@ WEEK_FUNC
Definition: item_func.h:320
@ YEARWEEK_FUNC
Definition: item_func.h:303
@ UNIX_TIMESTAMP_FUNC
Definition: item_func.h:326
virtual const char * func_name() const =0
bool has_timestamp_args()
Definition: item_func.h:672
enum Type type() const override
Definition: item_func.h:375
bool has_date_args()
Definition: item_func.h:682
uint arg_count
How many arguments in 'args'.
Definition: item_func.h:131
bool has_time_args()
Definition: item_func.h:693
bool has_datetime_args()
Definition: item_func.h:704
Definition: item_func.h:1048
Definition: item_strfunc.h:152
Definition: item_strfunc.h:79
String * val_str_from_val_str_ascii(String *str, String *str2)
Definition: item_strfunc.cc:155
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_strfunc.h:144
Abstract class for functions returning TIME, DATE, DATETIME types whose data type is known at constru...
Definition: item_timefunc.h:421
Item_temporal_func()
Definition: item_timefunc.h:432
Item_temporal_func(const POS &pos, Item *a)
Definition: item_timefunc.h:436
Item_temporal_func(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:438
Item_temporal_func(const POS &pos)
Definition: item_timefunc.h:433
Item_temporal_func(Item *a)
Definition: item_timefunc.h:435
Item_temporal_func(Item *a, Item *b, Item *c)
Definition: item_timefunc.h:440
Field * tmp_table_field(TABLE *table) override
Definition: item_timefunc.h:452
Item_temporal_func(const POS &pos, PT_item_list *list)
Definition: item_timefunc.h:445
bool check_precision()
Definition: item_timefunc.cc:825
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_timefunc.h:426
Item_temporal_func(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_timefunc.h:441
Item_temporal_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_timefunc.h:443
uint datetime_precision() override
DATETIME precision of the item: 0..6.
Definition: item_timefunc.h:459
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:845
uint time_precision() override
TIME precision of the item: 0..6.
Definition: item_timefunc.h:455
const CHARSET_INFO * charset_for_protocol() override
Definition: item_timefunc.h:449
Item_result result_type() const override
Definition: item_timefunc.h:448
Abstract class for functions returning TIME, DATE, DATETIME or string values, whose data type depends...
Definition: item_timefunc.h:471
const CHARSET_INFO * charset_for_protocol() override
Definition: item_timefunc.h:513
virtual bool eval_time(Time_val *time)=0
Evaluate temporal expression as time value.
Field * tmp_table_field(TABLE *table) override
Definition: item_timefunc.h:524
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_timefunc.cc:885
double val_real() override
Definition: item_timefunc.h:528
virtual my_time_flags_t eval_flags() const =0
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_timefunc.h:503
Item_result result_type() const override
Definition: item_timefunc.h:512
virtual bool eval_datetime(Datetime_val *dt, my_time_flags_t flags)=0
Evaluate temporal expression as datetime value.
Item_temporal_hybrid_func(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:509
Item_temporal_hybrid_func(Item *a, Item *b)
Definition: item_timefunc.h:508
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.cc:998
String * val_str(String *str) override
Return string value in @character_set_connection.
Definition: item_timefunc.h:537
String * val_str_ascii(String *str) override
Return string value in ASCII character set.
Definition: item_timefunc.cc:1039
longlong val_int() override
Definition: item_timefunc.h:527
String ascii_buf
Definition: item_timefunc.h:473
virtual bool eval_date(Date_val *date, my_time_flags_t flags)=0
Evaluate temporal expression as date value.
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_timefunc.cc:956
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:867
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_timefunc.cc:915
Abstract class for functions returning TIME values.
Definition: item_timefunc.h:651
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:653
longlong val_int() override
Definition: item_timefunc.h:681
String * val_str(String *str) override
Definition: item_timefunc.h:688
bool val_time(Time_val *time) override=0
Evaluate the item and return result as a time value.
Item_time_func(const POS &pos, Item *a)
Definition: item_timefunc.h:665
Item_time_func(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_timefunc.h:672
Item_time_func(Item *a)
Definition: item_timefunc.h:662
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_timefunc.h:677
Item_time_func(const POS &pos)
Definition: item_timefunc.h:659
double val_real() override
Definition: item_timefunc.h:676
Item_time_func(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:668
bool val_datetime(Datetime_val *dt, my_time_flags_t) override
Evaluate the item and return result as a datetime value.
Definition: item_timefunc.h:685
Item_time_func()
Definition: item_timefunc.h:658
bool val_date(Date_val *date, my_time_flags_t) override
Evaluate the item and return result as a date value.
Definition: item_timefunc.h:682
TIME'10:10:10'.
Definition: item_timefunc.h:825
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:846
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:847
Time_val m_time
Definition: item_timefunc.h:855
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_timefunc.h:851
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_timefunc.cc:1149
uint64_t m_hash
Definition: item_timefunc.h:856
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:848
const char * func_name() const override
Definition: item_timefunc.h:838
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:1154
Item_time_literal(Time_val time, uint dec_arg)
Constructor for Item_time_literal.
Definition: item_timefunc.h:833
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_timefunc.cc:1163
table_map used_tables() const override
Definition: item_timefunc.h:849
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.h:841
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:850
Definition: item_timefunc.h:325
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_timefunc.h:346
virtual bool val_timeval(my_timeval *tm)=0
Return timestamp in "struct timeval" format.
longlong val_int() override
Definition: item_timefunc.cc:2050
String * val_str(String *str) override
Definition: item_timefunc.cc:2070
Item_timeval_func(const POS &pos, Item *a)
Definition: item_timefunc.h:330
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_timefunc.cc:2055
Item_timeval_func(Item *a)
Definition: item_timefunc.h:329
enum Item_result result_type() const override
Definition: item_timefunc.h:349
Item_timeval_func(const POS &pos)
Definition: item_timefunc.h:327
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.h:345
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_timefunc.h:342
double val_real() override
Definition: item_timefunc.cc:2063
Definition: item_timefunc.h:1365
bool m_explicit_cast
Definition: item_timefunc.h:1366
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3359
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:3365
const char * cast_type() const
Definition: item_timefunc.h:1385
const char * func_name() const override
Definition: item_timefunc.h:1380
bool is_explicit_cast() const
Definition: item_timefunc.h:1382
bool val_date(Date_val *date, my_time_flags_t flags) override
Evaluate the item and return result as a date value.
Definition: item_timefunc.cc:3374
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_timefunc.cc:3390
enum Functype functype() const override
Definition: item_timefunc.h:1381
Item_typecast_date(Item *a, bool explicit_cast)
Definition: item_timefunc.h:1369
Item_typecast_date(const POS &pos, Item *a)
Definition: item_timefunc.h:1373
Definition: item_timefunc.h:1418
Item_typecast_datetime(Item *a, uint8 dec_arg)
Definition: item_timefunc.h:1435
Item_typecast_datetime(const POS &pos, Item *a)
Definition: item_timefunc.h:1427
Item_typecast_datetime(Item *a, bool explicit_cast)
Definition: item_timefunc.h:1423
enum Functype functype() const override
Definition: item_timefunc.h:1442
bool is_explicit_cast() const
Definition: item_timefunc.h:1444
const char * func_name() const override
Definition: item_timefunc.h:1441
bool m_explicit_cast
Definition: item_timefunc.h:1420
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3289
Item_typecast_datetime(const POS &pos, Item *a, uint8 dec_arg)
Definition: item_timefunc.h:1430
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:3299
bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate the item and return result as a datetime value.
Definition: item_timefunc.cc:3309
bool detect_precision_from_arg
Definition: item_timefunc.h:1419
const char * cast_type() const
Definition: item_timefunc.h:1443
Definition: item_timefunc.h:1388
Item_typecast_time(Item *a, uint8 dec_arg)
Definition: item_timefunc.h:1404
Item_typecast_time(const POS &pos, Item *a)
Definition: item_timefunc.h:1396
bool is_explicit_cast() const
Definition: item_timefunc.h:1412
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3333
Item_typecast_time(const POS &pos, Item *a, uint8 dec_arg)
Definition: item_timefunc.h:1399
const char * cast_type() const
Definition: item_timefunc.h:1414
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.cc:3353
enum Functype functype() const override
Definition: item_timefunc.h:1411
bool detect_precision_from_arg
Definition: item_timefunc.h:1389
Item_typecast_time(Item *a)
Definition: item_timefunc.h:1393
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:3343
const char * func_name() const override
Definition: item_timefunc.h:1410
bool m_explicit_cast
Definition: item_timefunc.h:1390
Definition: item_timefunc.h:278
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1917
Item_typecast_year(const POS &pos, Item *a)
Definition: item_timefunc.h:280
longlong val_int() override
Definition: item_timefunc.cc:1933
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:1926
enum Functype functype() const override
Definition: item_timefunc.h:285
const char * func_name() const override
Definition: item_timefunc.h:284
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:929
void set_nullable(bool nullable)
Definition: item.h:3781
bool get_datetime_from_numeric(Datetime_val *dt, my_time_flags_t flags)
Convert a numeric type to datetime.
Definition: item.cc:1705
void set_data_type_date()
Set all type properties for Item of DATE type.
Definition: item.h:1696
DTCollation collation
Character set and collation properties assigned for this Item.
Definition: item.h:3676
my_decimal * val_decimal_from_datetime(my_decimal *decimal_value)
Definition: item.cc:429
longlong val_int_from_decimal()
Definition: item.cc:500
bool get_time_from_datetime(Time_val *time)
Convert datetime to time.
Definition: item.cc:1798
void set_data_type(enum_field_types data_type)
Set the data type of the current Item.
Definition: item.h:1513
longlong val_int_from_datetime()
Definition: item.cc:527
String * val_string_from_date(String *str)
Definition: item.cc:346
double val_real_from_decimal()
Definition: item.cc:480
String * val_string_from_datetime(String *str)
Definition: item.cc:333
bool get_datetime_from_time(Datetime_val *dt)
Convert val_time() to datetime.
Definition: item.cc:1669
longlong val_int_from_date()
Definition: item.cc:520
void set_data_type_year()
Set the data type of the Item to be YEAR.
Definition: item.h:1774
bool get_time_from_date(Time_val *time)
Convert date to time.
Definition: item.cc:1790
type_conversion_status save_datetime_in_field(Field *field)
Definition: item.cc:569
bool get_time_from_numeric(Time_val *time)
Convert a numeric type to time.
Definition: item.cc:1807
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:6979
enum_field_types data_type() const
Retrieve the derived data type of the Item.
Definition: item.h:1481
bool fixed
True if item has been resolved.
Definition: item.h:3769
longlong val_int_from_time()
Definition: item.cc:511
void set_data_type_datetime(uint8 fsp)
Set all properties for Item of DATETIME type.
Definition: item.h:1721
my_decimal * val_decimal_from_date(my_decimal *decimal_value)
Definition: item.cc:410
@ MARKER_NONE
Definition: item.h:3697
type_conversion_status save_time_in_field(Field *field)
Definition: item.cc:551
item_marker marker
This member has several successive meanings, depending on the phase we're in (.
Definition: item.h:3738
bool get_datetime_from_date(Datetime_val *dt, my_time_flags_t flags)
Convert val_date() to datetime.
Definition: item.cc:1679
uint8 decimals
Number of decimals in result when evaluating this item.
Definition: item.h:3778
bool get_date_from_time(Date_val *date)
Convert val_time() to date.
Definition: item.cc:1659
String * val_string_from_time(String *str)
Definition: item.cc:360
bool get_date_from_numeric(Date_val *date, my_time_flags_t flags)
Convert a numeric type to date.
Definition: item.cc:1689
void set_data_type_time(uint8 fsp)
Set all type properties for Item of TIME type.
Definition: item.h:1708
my_decimal * val_decimal_from_time(my_decimal *decimal_value)
Definition: item.cc:421
type_conversion_status save_date_in_field(Field *field)
Definition: item.cc:560
Represents a JSON container value of type "object" (ECMA), type J_OBJECT here.
Definition: json_dom.h:374
bool add_alias(std::string_view key, Json_dom *value)
Insert the value into the object.
Definition: json_dom.h:416
Cache for MYSQL_TIME value with various representations.
Definition: item_timefunc.h:702
uint string_length
length of string
Definition: item_timefunc.h:706
MYSQL_TIME * get_TIME_ptr()
Return pointer to MYSQL_TIME representation.
Definition: item_timefunc.h:776
longlong val_packed() const
Return packed representation.
Definition: item_timefunc.h:759
MYSQL_TIME_cache()
Definition: item_timefunc.h:718
uint8 decimals() const
Return number of decimal digits.
Definition: item_timefunc.h:751
uint8 dec
Number of decimals.
Definition: item_timefunc.h:707
bool get_date(MYSQL_TIME *ltime) const
Definition: item_timefunc.h:768
const char * cptr() const
Return C string representation.
Definition: item_timefunc.h:788
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) const
Store MYSQL_TIME representation into the given date/datetime variable checking date flags.
Definition: item_timefunc.cc:2362
longlong time_packed
packed representation
Definition: item_timefunc.h:704
void set_date(MYSQL_TIME *ltime)
Set time and time_packed from a DATE value.
Definition: item_timefunc.cc:2323
MYSQL_TIME time
MYSQL_TIME representation.
Definition: item_timefunc.h:703
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:2331
bool eq(const MYSQL_TIME_cache &tm) const
Test if cached value is equal to another MYSQL_TIME_cache value.
Definition: item_timefunc.h:744
String * val_str(String *str)
Store string representation into String.
Definition: item_timefunc.cc:2369
char string_buff[MAX_DATE_STRING_REP_LENGTH]
string representation
Definition: item_timefunc.h:705
void get_TIME(MYSQL_TIME *ltime) const
Store MYSQL_TIME representation into the given MYSQL_TIME variable.
Definition: item_timefunc.h:712
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:109
Base class for parse tree nodes (excluding the Parse_tree_root hierarchy)
Definition: parse_tree_node_base.h:231
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:169
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Time_val is a temporal type that represents only time.
Definition: my_temporal.h:57
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:97
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:31
This file contains the field type.
@ MYSQL_TYPE_TIME
Definition: field_types.h:67
@ MYSQL_TYPE_STRING
Definition: field_types.h:89
@ MYSQL_TYPE_DATETIME
Definition: field_types.h:68
bool is_adjusted(uint32_t decimals) const
Definition: my_temporal.cc:53
static int flags[50]
Definition: hp_test1.cc:40
enum_mysql_timestamp_type
Definition: mysql_time.h:45
@ MYSQL_TIMESTAMP_NONE
Definition: mysql_time.h:46
enum monotonicity_info enum_monotonicity_info
const char * interval_names[]
Definition: item_timefunc.cc:3044
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:540
date_time_format
Definition: item_timefunc.h:1554
@ USA_FORMAT
Definition: item_timefunc.h:1555
@ JIS_FORMAT
Definition: item_timefunc.h:1556
@ INTERNAL_FORMAT
Definition: item_timefunc.h:1559
@ EUR_FORMAT
Definition: item_timefunc.h:1558
@ ISO_FORMAT
Definition: item_timefunc.h:1557
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:2152
A better implementation of the UNIX ctype(3) library.
MYSQL_STRINGS_EXPORT CHARSET_INFO my_charset_bin
Definition: ctype-bin.cc:499
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 my_time_flags_t TIME_ONLY_VALID_DATES
Allow only valid dates, no zero date, no zero date component.
Definition: my_time.h:111
constexpr const int DATETIME_MAX_DECIMALS
Definition: my_time.h:146
unsigned int my_time_flags_t
Flags to str_to_datetime and int_to_datetime.
Definition: my_time.h:87
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:427
interval_type
Available interval types used in any statement.
Definition: my_time.h:451
@ INTERVAL_HOUR_SECOND
Definition: my_time.h:466
@ INTERVAL_MONTH
Definition: my_time.h:454
@ INTERVAL_HOUR_MICROSECOND
Definition: my_time.h:469
@ INTERVAL_MINUTE
Definition: my_time.h:458
@ INTERVAL_HOUR_MINUTE
Definition: my_time.h:465
@ INTERVAL_DAY
Definition: my_time.h:456
@ INTERVAL_MINUTE_MICROSECOND
Definition: my_time.h:470
@ INTERVAL_MINUTE_SECOND
Definition: my_time.h:467
@ INTERVAL_QUARTER
Definition: my_time.h:453
@ INTERVAL_YEAR
Definition: my_time.h:452
@ INTERVAL_DAY_MICROSECOND
Definition: my_time.h:468
@ INTERVAL_SECOND_MICROSECOND
Definition: my_time.h:471
@ INTERVAL_SECOND
Definition: my_time.h:459
@ INTERVAL_DAY_HOUR
Definition: my_time.h:462
@ INTERVAL_HOUR
Definition: my_time.h:457
@ INTERVAL_YEAR_MONTH
Definition: my_time.h:461
@ INTERVAL_DAY_SECOND
Definition: my_time.h:464
@ INTERVAL_MICROSECOND
Definition: my_time.h:460
@ INTERVAL_DAY_MINUTE
Definition: my_time.h:463
static int interval
Definition: mysqladmin.cc:72
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1077
std::string format(const routing_guidelines::Session_info &session_info, bool extended_session_info)
Definition: dest_metadata_cache.cc:170
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
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
ValueType max(X &&first)
Definition: gtid.h:103
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2884
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:200
@ VGS_CHECK_CONSTRAINT
Definition: field.h:474
@ VGS_GENERATED_COLUMN
Definition: field.h:472
File containing constants that can be used throughout the server.
constexpr const table_map RAND_TABLE_BIT
Definition: sql_const.h:113
constexpr const table_map INNER_TABLE_BIT
Definition: sql_const.h:111
Our own string classes, used pervasively throughout the executor.
Definition: m_ctype.h:421
Struct used to pass around arguments to/from check_function_as_value_generator.
Definition: item.h:487
const char * banned_function_name
the name of the function which is not allowed
Definition: item.h:501
Value_generator_source source
Definition: item.h:499
Representation of time formats.
Definition: sql_time.h:62
Struct representing a duration.
Definition: my_time.h:231
Definition: mysql_time.h:82
enum enum_mysql_timestamp_type time_type
Definition: mysql_time.h:86
Bison "location" class.
Definition: parse_location.h:43
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:422
Definition: table.h:1456
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
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