MySQL 9.5.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, 2025, 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
140/**
141 TS-TODO: This should probably have Item_int_func as parent class.
142*/
143class Item_func_month final : public Item_func {
144 public:
145 Item_func_month(const POS &pos, Item *a) : Item_func(pos, a) {
148 }
149 longlong val_int() override;
150 double val_real() override {
151 assert(fixed);
152 return (double)Item_func_month::val_int();
153 }
154 String *val_str(String *str) override {
155 const longlong nr = val_int();
156 if (null_value) return nullptr;
157 str->set(nr, collation.collation);
158 return str;
159 }
160 bool val_date(Date_val *date, my_time_flags_t flags) override {
161 return get_date_from_int(date, flags);
162 }
163 bool val_time(Time_val *time) override { return get_time_from_int(time); }
165 return get_datetime_from_int(dt, flags);
166 }
167 const char *func_name() const override { return "month"; }
168 enum Functype functype() const override { return MONTH_FUNC; }
169 enum Item_result result_type() const override { return INT_RESULT; }
170 bool resolve_type(THD *thd) override;
171 bool check_partition_func_processor(uchar *) override { return false; }
173 return !has_date_args();
174 }
175};
176
177class Item_func_monthname final : public Item_str_func {
179
180 public:
181 Item_func_monthname(const POS &pos, Item *a) : Item_str_func(pos, a) {}
182 const char *func_name() const override { return "monthname"; }
183 enum Functype functype() const override { return MONTHNAME_FUNC; }
184 String *val_str(String *str) override;
185 bool resolve_type(THD *thd) override;
186 bool check_partition_func_processor(uchar *) override { return true; }
188 return !has_date_args();
189 }
190};
191
192class Item_func_dayofyear final : public Item_int_func {
193 public:
194 Item_func_dayofyear(const POS &pos, Item *a) : Item_int_func(pos, a) {}
195 longlong val_int() override;
196 const char *func_name() const override { return "dayofyear"; }
197 enum Functype functype() const override { return DAYOFYEAR_FUNC; }
198 bool resolve_type(THD *thd) override;
199 bool check_partition_func_processor(uchar *) override { return false; }
201 return !has_date_args();
202 }
203};
204
205class Item_func_hour final : public Item_int_func {
206 public:
207 Item_func_hour(const POS &pos, Item *a) : Item_int_func(pos, a) {}
208 longlong val_int() override;
209 const char *func_name() const override { return "hour"; }
210 enum Functype functype() const override { return HOUR_FUNC; }
211 bool resolve_type(THD *thd) override;
212 bool check_partition_func_processor(uchar *) override { return false; }
214 return !has_time_args();
215 }
216};
217
218class Item_func_minute final : public Item_int_func {
219 public:
220 Item_func_minute(const POS &pos, Item *a) : Item_int_func(pos, a) {}
221 longlong val_int() override;
222 const char *func_name() const override { return "minute"; }
223 enum Functype functype() const override { return MINUTE_FUNC; }
224 bool resolve_type(THD *thd) override;
225 bool check_partition_func_processor(uchar *) override { return false; }
227 return !has_time_args();
228 }
229};
230
231class Item_func_quarter final : public Item_int_func {
232 public:
233 Item_func_quarter(const POS &pos, Item *a) : Item_int_func(pos, a) {}
234 longlong val_int() override;
235 const char *func_name() const override { return "quarter"; }
236 enum Functype functype() const override { return QUARTER_FUNC; }
237 bool resolve_type(THD *thd) override;
238 bool check_partition_func_processor(uchar *) override { return false; }
240 return !has_date_args();
241 }
242};
243
244class Item_func_second final : public Item_int_func {
245 public:
246 Item_func_second(const POS &pos, Item *a) : Item_int_func(pos, a) {}
247 longlong val_int() override;
248 const char *func_name() const override { return "second"; }
249 enum Functype functype() const override { return SECOND_FUNC; }
250 bool resolve_type(THD *thd) override;
251 bool check_partition_func_processor(uchar *) override { return false; }
253 return !has_time_args();
254 }
255};
256
257class Item_func_week final : public Item_int_func {
259
260 public:
262 Item_func_week(const POS &pos, Item *a, Item *b) : super(pos, a, b) {}
263
264 bool do_itemize(Parse_context *pc, Item **res) override;
265
266 longlong val_int() override;
267 const char *func_name() const override { return "week"; }
268 enum Functype functype() const override { return WEEK_FUNC; }
269 bool resolve_type(THD *thd) override;
270};
271
272class Item_func_yearweek final : public Item_int_func {
273 public:
274 Item_func_yearweek(const POS &pos, Item *a, Item *b)
275 : Item_int_func(pos, a, b) {}
276 longlong val_int() override;
277 const char *func_name() const override { return "yearweek"; }
278 enum Functype functype() const override { return YEARWEEK_FUNC; }
279 bool resolve_type(THD *thd) override;
280 bool check_partition_func_processor(uchar *) override { return false; }
282 return !has_date_args();
283 }
284};
285
286class Item_func_year final : public Item_int_func {
287 public:
288 Item_func_year(const POS &pos, Item *a) : Item_int_func(pos, a) {}
289 longlong val_int() override;
290 const char *func_name() const override { return "year"; }
291 enum Functype functype() const override { return YEAR_FUNC; }
293 longlong val_int_endpoint(bool left_endp, bool *incl_endp) override;
294 bool resolve_type(THD *thd) override;
295 bool check_partition_func_processor(uchar *) override { return false; }
297 return !has_date_args();
298 }
299};
300
301class Item_typecast_year final : public Item_int_func {
302 public:
303 Item_typecast_year(const POS &pos, Item *a) : Item_int_func(pos, a) {
305 }
306 longlong val_int() override;
307 const char *func_name() const override { return "cast_as_year"; }
308 enum Functype functype() const override { return TYPECAST_FUNC; }
309 bool resolve_type(THD *thd) override;
310 void print(const THD *thd, String *str,
311 enum_query_type query_type) const override;
312};
313
314/**
315 TS-TODO: This should probably have Item_int_func as parent class.
316*/
319
320 public:
321 Item_func_weekday(const POS &pos, Item *a, bool type_arg)
322 : Item_func(pos, a), odbc_type(type_arg) {
325 }
326 longlong val_int() override;
327 double val_real() override {
328 assert(fixed);
329 return static_cast<double>(val_int());
330 }
331 String *val_str(String *str) override {
332 assert(fixed);
333 str->set(val_int(), &my_charset_bin);
334 return null_value ? nullptr : str;
335 }
336 bool val_date(Date_val *date, my_time_flags_t flags) override {
337 return get_date_from_int(date, flags);
338 }
339 bool val_time(Time_val *time) override { return get_time_from_int(time); }
341 return get_datetime_from_int(dt, flags);
342 }
343 const char *func_name() const override {
344 return (odbc_type ? "dayofweek" : "weekday");
345 }
346 enum Functype functype() const override { return WEEKDAY_FUNC; }
347 enum Item_result result_type() const override { return INT_RESULT; }
348 bool resolve_type(THD *thd) override;
349 bool check_partition_func_processor(uchar *) override { return false; }
351 return !has_date_args();
352 }
353};
354
355/**
356 TS-TODO: Item_func_dayname should be derived from Item_str_func.
357 In the current implementation funny things can happen:
358 select dayname(now())+1 -> 4
359*/
362
363 public:
364 Item_func_dayname(const POS &pos, Item *a)
365 : Item_func_weekday(pos, a, false) {}
366 const char *func_name() const override { return "dayname"; }
367 enum Functype functype() const override { return DAYNAME_FUNC; }
368 String *val_str(String *str) override;
369 bool val_date(Date_val *date, my_time_flags_t flags) override {
370 return get_date_from_string(date, flags);
371 }
372 bool val_time(Time_val *time) override { return get_time_from_string(time); }
375 }
376 enum Item_result result_type() const override { return STRING_RESULT; }
377 bool resolve_type(THD *thd) override;
378 bool check_partition_func_processor(uchar *) override { return true; }
379};
380
381/*
382 Abstract class for functions returning "struct timeval".
383*/
385 public:
386 explicit Item_timeval_func(const POS &pos) : Item_func(pos) {}
387
389 Item_timeval_func(const POS &pos, Item *a) : Item_func(pos, a) {}
390 /**
391 Return timestamp in "struct timeval" format.
392 @param[out] tm The value is store here.
393 @retval false On success
394 @retval true On error
395 */
396 virtual bool val_timeval(my_timeval *tm) = 0;
397 longlong val_int() override;
398 double val_real() override;
399 String *val_str(String *str) override;
400 my_decimal *val_decimal(my_decimal *decimal_value) override;
401 bool val_date(Date_val *date, my_time_flags_t flags) override {
402 return get_date_from_numeric(date, flags);
403 }
404 bool val_time(Time_val *time) override { return get_time_from_numeric(time); }
407 }
408 enum Item_result result_type() const override {
410 }
411};
412
415
416 public:
417 explicit Item_func_unix_timestamp(const POS &pos) : Item_timeval_func(pos) {}
418
420
422 : Item_timeval_func(pos, a) {}
423
424 const char *func_name() const override { return "unix_timestamp"; }
425 enum Functype functype() const override { return UNIX_TIMESTAMP_FUNC; }
426
427 bool do_itemize(Parse_context *pc, Item **res) override;
429 longlong val_int_endpoint(bool left_endp, bool *incl_endp) override;
430 bool check_partition_func_processor(uchar *) override { return false; }
431 /*
432 UNIX_TIMESTAMP() depends on the current timezone
433 (and thus may not be used as a partitioning function)
434 when its argument is NOT of the TIMESTAMP type.
435 */
437 return !has_timestamp_args();
438 }
439
441 if (arg_count == 0) return INNER_TABLE_BIT;
442 return 0;
443 }
444
445 bool resolve_type(THD *thd) override {
446 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_DATETIME)) return true;
447 if (reject_vector_args()) return true;
449 const uint8 dec = arg_count == 0 ? 0 : args[0]->datetime_precision();
450 if (dec > 0) {
452 } else {
454 }
455 return false;
456 }
457 bool val_timeval(my_timeval *tm) override;
458
460 /*
461 TODO: Allow UNIX_TIMESTAMP called with an argument to be a part
462 of the expression for a generated column too.
463 */
465 pointer_cast<Check_function_as_value_generator_parameters *>(p_arg);
466 func_arg->banned_function_name = func_name();
467 return ((func_arg->source == VGS_GENERATED_COLUMN) ||
468 (func_arg->source == VGS_CHECK_CONSTRAINT));
469 }
470};
471
473 public:
474 Item_func_time_to_sec(const POS &pos, Item *item)
475 : Item_int_func(pos, item) {}
476 longlong val_int() override;
477 const char *func_name() const override { return "time_to_sec"; }
478 enum Functype functype() const override { return TIME_TO_SEC_FUNC; }
479 bool resolve_type(THD *thd) override;
480 bool check_partition_func_processor(uchar *) override { return false; }
482 return !has_time_args();
483 }
484};
485
486/**
487 Abstract class for functions returning TIME, DATE, DATETIME types
488 whose data type is known at constructor time.
489*/
491 protected:
492 bool check_precision();
493
494 protected:
495 void add_json_info(Json_object *obj) override {
496 if (decimals > 0)
497 obj->add_alias("precision", create_dom_ptr<Json_uint>(decimals));
498 }
499
500 public:
502 explicit Item_temporal_func(const POS &pos) : Item_func(pos) {}
503
505 Item_temporal_func(const POS &pos, Item *a) : Item_func(pos, a) {}
506
507 Item_temporal_func(const POS &pos, Item *a, Item *b) : Item_func(pos, a, b) {}
508
509 Item_temporal_func(Item *a, Item *b, Item *c) : Item_func(a, b, c) {}
510 Item_temporal_func(const POS &pos, Item *a, Item *b, Item *c)
511 : Item_func(pos, a, b, c) {}
512 Item_temporal_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
513 : Item_func(pos, a, b, c, d) {}
515 : Item_func(pos, list) {}
516
517 Item_result result_type() const override { return STRING_RESULT; }
519 return &my_charset_bin;
520 }
523 }
524 uint time_precision() override {
525 assert(fixed);
526 return decimals;
527 }
528 uint datetime_precision() override {
529 assert(fixed);
530 return decimals;
531 }
532 void print(const THD *thd, String *str,
533 enum_query_type query_type) const override;
534};
535
536/**
537 Abstract class for functions returning TIME, DATE, DATETIME or string values,
538 whose data type depends on parameters and is set at fix_field time.
539*/
541 protected:
542 sql_mode_t sql_mode; // sql_mode value is cached here in resolve_type()
543 String ascii_buf; // Conversion buffer
544 /**
545 Evaluate temporal expression as datetime value
546 @param[out] dt The value is stored here.
547 @param flags Date flags.
548
549 @returns false on success, true on error or if NULL value
550 */
552 /**
553 Evaluate temporal expression as date value
554 @param[out] date The value is stored here.
555 @param flags Date flags.
556
557 @returns false on success, true on error or if NULL value
558 */
560 return eval_datetime(date, flags);
561 }
562 /**
563 Evaluate temporal expression as time value
564 @param[out] time The value is stored here.
565
566 @returns false on success, true on error or if NULL value
567 */
568 virtual bool eval_time(Time_val *time) = 0;
570 bool no_conversions) override;
571 void add_json_info(Json_object *obj) override {
573 }
574
575 public:
577 : Item_str_func(a, b), sql_mode(0) {}
579 : Item_str_func(pos, a, b), sql_mode(0) {}
580
581 Item_result result_type() const override { return STRING_RESULT; }
583 /*
584 Can return TIME, DATE, DATETIME or VARCHAR depending on arguments.
585 Send using "binary" when TIME, DATE or DATETIME,
586 or using collation.collation when VARCHAR
587 (which is fixed from @collation_connection in resolve_type()).
588 */
589 assert(fixed);
592 }
595 }
596 longlong val_int() override { return val_int_from_decimal(); }
597 double val_real() override { return val_real_from_decimal(); }
598 my_decimal *val_decimal(my_decimal *decimal_value) override;
599 /**
600 Return string value in ASCII character set.
601 */
602 String *val_str_ascii(String *str) override;
603 /**
604 Return string value in @@character_set_connection.
605 */
606 String *val_str(String *str) override {
608 }
609 bool val_date(Date_val *date, my_time_flags_t flags) override;
610 bool val_time(Time_val *time) override;
612};
613
614/*
615 This can't be a Item_str_func, because the val_real() functions are special
616*/
617
618/**
619 Abstract class for functions returning DATE values.
620*/
622 protected:
624 return save_date_in_field(field);
625 }
626
627 public:
629 explicit Item_date_func(const POS &pos) : Item_temporal_func(pos) {
631 }
633 Item_date_func(const POS &pos, Item *a) : Item_temporal_func(pos, a) {
635 }
636 Item_date_func(const POS &pos, Item *a, Item *b)
637 : Item_temporal_func(pos, a, b) {
639 }
640 bool val_time(Time_val *time) override { return get_time_from_date(time); }
642 longlong val_int() override { return val_int_from_date(); }
643 longlong val_date_temporal() override;
644 double val_real() override { return static_cast<double>(val_int()); }
645 const char *func_name() const override { return "date"; }
646 enum Functype functype() const override { return DATE_FUNC; }
647 bool resolve_type(THD *) override { return false; }
648 my_decimal *val_decimal(my_decimal *decimal_value) override {
649 assert(fixed);
650 return val_decimal_from_date(decimal_value);
651 }
652 // All date functions must implement val_date()
653 // to avoid use of generic Item::val_date()
654 // which converts to string and then parses the string as DATE.
655 bool val_date(Date_val *date, my_time_flags_t flags) override = 0;
656};
657
658/**
659 Abstract class for functions returning DATETIME values.
660*/
662 protected:
664 return save_date_in_field(field);
665 }
666
667 public:
670 }
673 }
676 }
677 Item_datetime_func(const POS &pos, Item *a) : Item_temporal_func(pos, a) {
679 }
680 Item_datetime_func(const POS &pos, Item *a, Item *b)
681 : Item_temporal_func(pos, a, b) {
683 }
686 }
687 Item_datetime_func(const POS &pos, Item *a, Item *b, Item *c)
688 : Item_temporal_func(pos, a, b, c) {
690 }
691 Item_datetime_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
692 : Item_temporal_func(pos, a, b, c, d) {
694 }
696 : Item_temporal_func(pos, list) {
698 }
699
700 double val_real() override { return val_real_from_decimal(); }
701 String *val_str(String *str) override {
703 }
704 longlong val_int() override { return val_int_from_datetime(); }
705 longlong val_date_temporal() override;
706 my_decimal *val_decimal(my_decimal *decimal_value) override {
707 assert(fixed);
708 return val_decimal_from_date(decimal_value);
709 }
710 bool val_time(Time_val *time) override {
711 return get_time_from_datetime(time);
712 }
713 // All datetime functions must implement val_datetime()
714 // to avoid use of generic Item::val_datetime()
715 // which converts to string and then parses the string as DATETIME.
716 bool val_date(Date_val *date, my_time_flags_t flags) override {
717 return val_datetime(date, flags);
718 }
720};
721
722/**
723 Abstract class for functions returning TIME values.
724*/
726 protected:
728 return save_time_in_field(field);
729 }
730
731 public:
733 explicit Item_time_func(const POS &pos) : Item_temporal_func(pos) {
735 }
738 }
739 Item_time_func(const POS &pos, Item *a) : Item_temporal_func(pos, a) {
741 }
742 Item_time_func(const POS &pos, Item *a, Item *b)
743 : Item_temporal_func(pos, a, b) {
745 }
746 Item_time_func(const POS &pos, Item *a, Item *b, Item *c)
747 : Item_temporal_func(pos, a, b, c) {
749 }
750 double val_real() override { return val_real_from_decimal(); }
751 my_decimal *val_decimal(my_decimal *decimal_value) override {
752 assert(fixed);
753 return val_decimal_from_time(decimal_value);
754 }
755 longlong val_int() override { return val_int_from_time(); }
756 bool val_date(Date_val *date, my_time_flags_t) override {
757 return get_date_from_time(date);
758 }
760 return get_datetime_from_time(dt);
761 }
763 // All time functions must implement val_time()
764 // to avoid use of generic Item::val_time()
765 // which converts to string and then parses the string as TIME.
766 bool val_time(Time_val *time) override = 0;
767};
768
769/**
770 Cache for MYSQL_TIME value with various representations.
771
772 - MYSQL_TIME representation (time) is initialized during set_XXX().
773 - Packed representation (time_packed) is also initialized during set_XXX().
774 - String representation (string_buff) is also initialized during set_XXX();
775*/
777 MYSQL_TIME time; ///< MYSQL_TIME representation
778 longlong time_packed; ///< packed representation
779 char string_buff[MAX_DATE_STRING_REP_LENGTH]; ///< string representation
780 uint string_length; ///< length of string
781 uint8 dec; ///< Number of decimals
782
783 /**
784 Store MYSQL_TIME representation into the given MYSQL_TIME variable.
785 */
786 void get_TIME(MYSQL_TIME *ltime) const {
788 *ltime = time;
789 }
790
791 public:
794 string_buff[0] = '\0';
795 }
796 /**
797 Set time and time_packed from a DATE value.
798 */
799 void set_date(MYSQL_TIME *ltime);
800 /**
801 Set time and time_packed from a DATETIME value.
802 */
803 void set_datetime(MYSQL_TIME *ltime, uint8 dec_arg,
804 const Time_zone *tz = nullptr);
805 /**
806 Set time and time_packed according to DATE value
807 in "struct timeval" representation and its time zone.
808 */
809 void set_date(my_timeval tv, Time_zone *tz);
810 /**
811 Set time and time_packed according to DATETIME value
812 in "struct timeval" representation and its time zone.
813 */
814 void set_datetime(my_timeval tv, uint8 dec_arg, Time_zone *tz);
815 /**
816 Test if cached value is equal to another MYSQL_TIME_cache value.
817 */
818 bool eq(const MYSQL_TIME_cache &tm) const {
819 return val_packed() == tm.val_packed();
820 }
821
822 /**
823 Return number of decimal digits.
824 */
825 uint8 decimals() const {
827 return dec;
828 }
829
830 /**
831 Return packed representation.
832 */
835 return time_packed;
836 }
837 /**
838 Store MYSQL_TIME representation into the given date/datetime variable
839 checking date flags.
840 */
841 bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) const;
842 bool get_date(MYSQL_TIME *ltime) const {
843 get_TIME(ltime);
844 return false;
845 }
846
847 /**
848 Return pointer to MYSQL_TIME representation.
849 */
852 return &time;
853 }
854
855 /**
856 Store string representation into String.
857 */
859 /**
860 Return C string representation.
861 */
862 const char *cptr() const { return string_buff; }
863};
864
865/**
866 DATE'2010-01-01'
867*/
868class Item_date_literal final : public Item_date_func {
870
871 public:
872 /**
873 Constructor for Item_date_literal.
874 @param ltime DATE value.
875 */
877 cached_time.set_date(ltime);
879 fixed = true;
880 }
881 const char *func_name() const override { return "date_literal"; }
882 void print(const THD *thd, String *str,
883 enum_query_type query_type) const override;
884 uint64_t hash() override;
886 assert(fixed);
887 return cached_time.val_packed();
888 }
889 bool val_date(Date_val *date, my_time_flags_t flags) override {
890 assert(fixed);
891 return cached_time.get_date(date, flags);
892 }
894 assert(fixed);
895 return cached_time.get_date(dt, flags);
896 }
897 String *val_str(String *str) override {
898 assert(fixed);
899 return cached_time.val_str(str);
900 }
901 bool resolve_type(THD *) override { return false; }
902 bool check_partition_func_processor(uchar *) override { return false; }
903 bool basic_const_item() const override { return true; }
904 table_map used_tables() const override { return 0; }
905 table_map not_null_tables() const override { return used_tables(); }
906 void cleanup() override { assert(marker == MARKER_NONE); }
907 bool eq_specific(const Item *item) const override;
908};
909
910/**
911 TIME'10:10:10'
912*/
913class Item_time_literal final : public Item_time_func {
914 public:
915 /**
916 Constructor for Item_time_literal.
917
918 @param time TIME value, must have fraction according to dec_arg.
919 @param dec_arg number of fractional digits in time.
920 */
921 Item_time_literal(Time_val *time, uint dec_arg) : m_time(*time) {
922 set_data_type_time(std::min(dec_arg, uint(DATETIME_MAX_DECIMALS)));
923 assert(m_time.is_adjusted(decimals));
924 fixed = true;
925 }
926 const char *func_name() const override { return "time_literal"; }
927 void print(const THD *thd, String *str,
928 enum_query_type query_type) const override;
929 bool val_time(Time_val *time) override {
930 assert(fixed);
931 *time = m_time;
932 return false;
933 }
934 bool resolve_type(THD *) override { return false; }
935 bool check_partition_func_processor(uchar *) override { return false; }
936 bool basic_const_item() const override { return true; }
937 table_map used_tables() const override { return 0; }
938 table_map not_null_tables() const override { return used_tables(); }
939 void cleanup() override { assert(marker == MARKER_NONE); }
940 bool eq_specific(const Item *item) const override;
941
942 private:
944 uint64_t m_hash{0};
945 uint64_t hash() override;
946};
947
948/**
949 TIMESTAMP'2001-01-01 10:20:30'
950*/
953
954 public:
955 /**
956 Constructor for Item_datetime_literal.
957 @param dt DATETIME value.
958 @param dec_arg Number of fractional digits in ltime.
959 @param tz The current time zone, used for converting literals with
960 time zone upon storage.
961 */
962 Item_datetime_literal(Datetime_val *dt, uint dec_arg, const Time_zone *tz) {
963 set_data_type_datetime(std::min(dec_arg, uint{DATETIME_MAX_DECIMALS}));
965 fixed = true;
966 }
967 const char *func_name() const override { return "datetime_literal"; }
968 enum Functype functype() const override { return DATETIME_LITERAL; }
969 void print(const THD *thd, String *str,
970 enum_query_type query_type) const override;
972 assert(fixed);
973 return cached_time.val_packed();
974 }
975 bool val_date(Date_val *date, my_time_flags_t flags) override {
976 assert(fixed);
977 return cached_time.get_date(date, flags);
978 }
980 assert(fixed);
981 return cached_time.get_date(dt, flags);
982 }
983 String *val_str(String *str) override {
984 assert(fixed);
985 return cached_time.val_str(str);
986 }
987 bool resolve_type(THD *) override { return false; }
988 bool check_partition_func_processor(uchar *) override { return false; }
989 bool basic_const_item() const override { return true; }
990 table_map used_tables() const override { return 0; }
991 table_map not_null_tables() const override { return used_tables(); }
992 void cleanup() override { assert(marker == MARKER_NONE); }
993 bool eq_specific(const Item *item) const override;
994 uint64_t hash() override;
995};
996
997/**
998 This function implements the `AT TIME ZONE` operator, which casts a temporal
999 value to a temporal with time zone.
1000
1001 This function is hidden from the user except when used in a cast() operation,
1002 the reason being that it adds time zone information to a temporal value, and
1003 we don't currently have a type that corresponds to such a value. Hence the
1004 only way to evaluate this function is by a concomitant cast to a temporal
1005 without time zone designation. However, the value is not converted according
1006 to the current time zone as is normally the case. For `TIMESTAMP`, this means
1007 that the value is converted to the time zone given as argument to this
1008 function rather than the session's time zone. And as we currently only support
1009 the UTC time zone or the equivalent `INTERVAL '+00:00'`, so in practice the
1010 value is not converted at all. This is a bit similar to the unix_timestamp()
1011 function, but that one converts any argument (DATETIME, TIME) to UTC from the
1012 session's time zone. This operator only accepts `TIMESTAMP` values.
1013*/
1015 public:
1016 Item_func_at_time_zone(const POS &pos, Item *datetime,
1017 const char *specifier_string, bool is_interval)
1018 : Item_datetime_func(pos, datetime),
1020 m_is_interval(is_interval) {}
1021
1022 bool resolve_type(THD *) override;
1023
1024 const char *func_name() const override { return "time_zone"; }
1025
1026 void print(const THD *thd, String *str,
1027 enum_query_type query_type) const override;
1028
1029 bool set_time_zone(THD *thd);
1030
1031 bool val_date(Date_val *date, my_time_flags_t flags) override;
1032 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1033
1034 const char *specifier_string() const { return m_specifier_string; }
1035
1036 protected:
1037 bool check_type() const;
1038
1039 private:
1040 /// The time zone that the specifier string argument resolves to.
1041 const Time_zone *m_tz{nullptr};
1042
1043 /// The specifier string argument, not used after resolution.
1045
1046 /**
1047 Whether the syntax used the `INTERVAL` construction. We have no interval
1048 type.
1049 */
1051};
1052
1053/// Abstract CURTIME function. Children should define what time zone is used.
1056
1057 protected:
1058 // Abstract method that defines which time zone is used for conversion.
1059 virtual Time_zone *time_zone() = 0;
1060
1061 void add_json_info(Json_object *obj) override {
1062 obj->add_alias("precision", create_dom_ptr<Json_uint>(decimals));
1063 }
1064
1065 public:
1066 /**
1067 Constructor for Item_func_curtime.
1068 @param pos Position of token in the parser.
1069 @param dec_arg Number of fractional digits.
1070 */
1071 Item_func_curtime(const POS &pos, uint8 dec_arg) : Item_time_func(pos) {
1072 decimals = dec_arg;
1073 }
1074
1075 bool do_itemize(Parse_context *pc, Item **res) override;
1076
1077 /// This function must assign a new value for each execution
1079 return INNER_TABLE_BIT;
1080 }
1081
1082 bool resolve_type(THD *thd) override;
1083 bool val_time(Time_val *time) override;
1084 bool check_function_as_value_generator(uchar *checker_args) override {
1086 pointer_cast<Check_function_as_value_generator_parameters *>(
1087 checker_args);
1088 func_arg->banned_function_name = func_name();
1089 return ((func_arg->source == VGS_GENERATED_COLUMN) ||
1090 (func_arg->source == VGS_CHECK_CONSTRAINT));
1091 }
1092};
1093
1095 protected:
1096 Time_zone *time_zone() override;
1097
1098 public:
1099 Item_func_curtime_local(const POS &pos, uint8 dec_arg)
1100 : Item_func_curtime(pos, dec_arg) {}
1101 const char *func_name() const override { return "curtime"; }
1102};
1103
1105 protected:
1106 Time_zone *time_zone() override;
1107
1108 public:
1109 Item_func_curtime_utc(const POS &pos, uint8 dec_arg)
1110 : Item_func_curtime(pos, dec_arg) {}
1111 const char *func_name() const override { return "utc_time"; }
1112};
1113
1114/**
1115 Abstract CURDATE function.
1116
1117 @sa Item_func_curtime
1118 */
1121
1122 protected:
1123 virtual Time_zone *time_zone() = 0;
1124
1125 public:
1126 explicit Item_func_curdate(const POS &pos) : Item_date_func(pos) {}
1127
1128 bool do_itemize(Parse_context *pc, Item **res) override;
1129
1130 /// This function must assign a new value for each execution
1132 return INNER_TABLE_BIT;
1133 }
1134
1135 bool resolve_type(THD *) override;
1136 longlong val_date_temporal() override;
1137 bool val_date(Date_val *date, my_time_flags_t flags) override;
1138 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1139 String *val_str(String *) override;
1140 bool check_function_as_value_generator(uchar *checker_args) override {
1142 pointer_cast<Check_function_as_value_generator_parameters *>(
1143 checker_args);
1144 func_arg->banned_function_name = func_name();
1145 return ((func_arg->source == VGS_GENERATED_COLUMN) ||
1146 (func_arg->source == VGS_CHECK_CONSTRAINT));
1147 }
1148};
1149
1151 protected:
1152 Time_zone *time_zone() override;
1153
1154 public:
1155 explicit Item_func_curdate_local(const POS &pos) : Item_func_curdate(pos) {}
1156 const char *func_name() const override { return "curdate"; }
1157};
1158
1160 protected:
1161 Time_zone *time_zone() override;
1162
1163 public:
1165 const char *func_name() const override { return "utc_date"; }
1166};
1167
1168/**
1169 Abstract CURRENT_TIMESTAMP function.
1170
1171 @sa Item_func_curtime
1172*/
1174 protected:
1175 virtual Time_zone *time_zone() = 0;
1177 bool no_conversions) override;
1178
1179 void add_json_info(Json_object *obj) override {
1180 if (decimals > 0)
1181 obj->add_alias("precision", create_dom_ptr<Json_uint>(decimals));
1182 }
1183
1184 public:
1185 /**
1186 Constructor for Item_func_now.
1187 @param dec_arg Number of fractional digits.
1188 */
1190 Item_func_now(const POS &pos, uint8 dec_arg) : Item_datetime_func(pos) {
1191 decimals = dec_arg;
1192 }
1193
1194 /// This function must assign a new value for each execution
1196 return INNER_TABLE_BIT;
1197 }
1198
1199 bool resolve_type(THD *) override;
1200 longlong val_date_temporal() override;
1201 bool val_date(Date_val *date, my_time_flags_t flags) override;
1202 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1203 String *val_str(String *) override;
1204 bool check_function_as_value_generator(uchar *checker_args) override {
1206 pointer_cast<Check_function_as_value_generator_parameters *>(
1207 checker_args);
1208 func_arg->banned_function_name = func_name();
1209 return ((func_arg->source == VGS_GENERATED_COLUMN) ||
1210 (func_arg->source == VGS_CHECK_CONSTRAINT));
1211 }
1212};
1213
1215 protected:
1216 Time_zone *time_zone() override;
1217
1218 public:
1219 /**
1220 Stores the query start time in a field, truncating to the field's number
1221 of fractional second digits.
1222
1223 @param field The field to store in.
1224 */
1225 static void store_in(Field *field);
1226
1228 Item_func_now_local(const POS &pos, uint8 dec_arg)
1229 : Item_func_now(pos, dec_arg) {}
1230
1231 const char *func_name() const override { return "now"; }
1232 enum Functype functype() const override { return NOW_FUNC; }
1233};
1234
1235class Item_func_now_utc final : public Item_func_now {
1237
1238 protected:
1239 Time_zone *time_zone() override;
1240
1241 public:
1242 Item_func_now_utc(const POS &pos, uint8 dec_arg)
1243 : Item_func_now(pos, dec_arg) {}
1244
1245 bool do_itemize(Parse_context *pc, Item **res) override;
1246
1247 const char *func_name() const override { return "utc_timestamp"; }
1248};
1249
1250/**
1251 SYSDATE() is like NOW(), but always uses the real current time, not the
1252 query_start(). This matches the Oracle behavior.
1253*/
1255 public:
1257 decimals = dec_arg;
1258 }
1259 const char *func_name() const override { return "sysdate"; }
1260 bool resolve_type(THD *) override;
1261 enum Functype functype() const override { return SYSDATE_FUNC; }
1262 bool val_date(Date_val *date, my_time_flags_t flags) override;
1263 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1264 /**
1265 This function is non-deterministic and hence depends on the 'RAND'
1266 pseudo-table.
1267
1268 @retval Always RAND_TABLE_BIT
1269 */
1271 return RAND_TABLE_BIT;
1272 }
1273};
1274
1276 public:
1277 Item_func_from_days(const POS &pos, Item *a) : Item_date_func(pos, a) {}
1278 const char *func_name() const override { return "from_days"; }
1279 bool val_date(Date_val *date, my_time_flags_t flags) override;
1280 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1281 bool check_partition_func_processor(uchar *) override { return false; }
1282 enum Functype functype() const override { return FROM_DAYS_FUNC; }
1284 return has_date_args() || has_time_args();
1285 }
1286 bool resolve_type(THD *thd) override {
1287 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_LONGLONG)) return true;
1288 if (reject_vector_args()) return true;
1289 return Item_date_func::resolve_type(thd);
1290 }
1291};
1292
1295 const bool is_time_format;
1297
1298 public:
1300 bool is_time_format_arg = false)
1301 : Item_str_func(pos, a, b), is_time_format(is_time_format_arg) {}
1302 String *val_str(String *str) override;
1303 const char *func_name() const override {
1304 return is_time_format ? "time_format" : "date_format";
1305 }
1306 bool resolve_type(THD *thd) override;
1307 uint format_length(const String *format);
1308 bool eq_specific(const Item *item) const override;
1309};
1310
1312 public:
1314 : Item_datetime_func(pos, a) {}
1315 const char *func_name() const override { return "from_unixtime"; }
1316 enum Functype functype() const override { return FROM_UNIXTIME_FUNC; }
1317 bool resolve_type(THD *thd) override;
1318 bool val_date(Date_val *date, my_time_flags_t flags) override;
1319 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1320};
1321
1322/*
1323 This class represents CONVERT_TZ() function.
1324 The important fact about this function that it is handled in special way.
1325 When such function is met in expression time_zone system tables are added
1326 to global list of tables to open, so later those already opened and locked
1327 tables can be used during this function calculation for loading time zone
1328 descriptions.
1329*/
1331 /*
1332 If time zone parameters are constants we are caching objects that
1333 represent them (we use separate from_tz_cached/to_tz_cached members
1334 to indicate this fact, since NULL is legal value for from_tz/to_tz
1335 members.
1336 */
1339
1340 public:
1341 Item_func_convert_tz(const POS &pos, Item *a, Item *b, Item *c)
1342 : Item_datetime_func(pos, a, b, c),
1343 from_tz_cached(false),
1344 to_tz_cached(false) {}
1345 const char *func_name() const override { return "convert_tz"; }
1346 enum Functype functype() const override { return CONVERT_TZ_FUNC; }
1347 bool resolve_type(THD *) override;
1348 bool val_date(Date_val *date, my_time_flags_t flags) override;
1349 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1350 void cleanup() override;
1351};
1352
1354 public:
1355 Item_func_sec_to_time(const POS &pos, Item *item)
1356 : Item_time_func(pos, item) {}
1357 bool resolve_type(THD *thd) override {
1358 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_NEWDECIMAL)) return true;
1359 if (reject_vector_args()) return true;
1361 std::min(args[0]->decimals, uint8{DATETIME_MAX_DECIMALS}));
1362 set_nullable(true);
1363 return false;
1364 }
1365 const char *func_name() const override { return "sec_to_time"; }
1366 enum Functype functype() const override { return SEC_TO_TIME_FUNC; }
1367 bool val_time(Time_val *time) override;
1368};
1369
1370extern const char *interval_names[];
1371
1372/**
1373 Implementation class for the DATE_ADD and DATE_SUB functions.
1374 Also used for the synonym functions ADDDATE and SUBDATE.
1375*/
1378
1379 public:
1381 bool subtract)
1382 : Item_temporal_hybrid_func(pos, a, b),
1384 m_subtract(subtract) {}
1385 /**
1386 POS-less ctor for post-parse construction with implicit addition to THD's
1387 free_list (see Item::Item() no-argument ctor).
1388 */
1392 m_subtract(subtract) {}
1393 const char *func_name() const override { return "date_add_interval"; }
1394 enum Functype functype() const override { return DATEADD_FUNC; }
1395 bool resolve_type(THD *) override;
1396 bool eq_specific(const Item *item) const override;
1397 void print(const THD *thd, String *str,
1398 enum_query_type query_type) const override;
1400 bool is_subtract() const { return m_subtract; }
1401
1402 protected:
1403 void add_json_info(Json_object *obj) override;
1404
1405 private:
1406 bool eval_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1407 bool eval_time(Time_val *time) override;
1409
1410 /// The type of the interval argument
1412 /// False if function is DATE_ADD, true if function is DATE_SUB
1413 const bool m_subtract;
1415};
1416
1417class Item_extract final : public Item_int_func {
1419
1420 public:
1421 const interval_type int_type; // keep it public
1422 Item_extract(const POS &pos, interval_type type_arg, Item *a)
1423 : Item_int_func(pos, a), int_type(type_arg) {}
1424 longlong val_int() override;
1425 enum Functype functype() const override { return EXTRACT_FUNC; }
1426 const char *func_name() const override { return "extract"; }
1427 bool resolve_type(THD *) override;
1428 bool eq_specific(const Item *item) const override;
1429 void print(const THD *thd, String *str,
1430 enum_query_type query_type) const override;
1431 bool check_partition_func_processor(uchar *) override { return false; }
1433 switch (int_type) {
1434 case INTERVAL_YEAR:
1436 case INTERVAL_QUARTER:
1437 case INTERVAL_MONTH:
1438 /* case INTERVAL_WEEK: Not allowed as partitioning function, bug#57071 */
1439 case INTERVAL_DAY:
1440 return !has_date_args();
1441 case INTERVAL_DAY_HOUR:
1445 return !has_datetime_args();
1446 case INTERVAL_HOUR:
1449 case INTERVAL_MINUTE:
1451 case INTERVAL_SECOND:
1456 return !has_time_args();
1457 default:
1458 /*
1459 INTERVAL_LAST is only an end marker,
1460 INTERVAL_WEEK depends on default_week_format which is a session
1461 variable and cannot be used for partitioning. See bug#57071.
1462 */
1463 break;
1464 }
1465 return true;
1466 }
1467};
1468
1471
1472 public:
1473 Item_typecast_date(Item *a, bool explicit_cast)
1474 : Item_date_func(a), m_explicit_cast(explicit_cast) {
1475 set_nullable(true);
1476 }
1477 Item_typecast_date(const POS &pos, Item *a) : Item_date_func(pos, a) {
1478 set_nullable(true);
1479 }
1480
1481 bool resolve_type(THD *thd) override {
1482 if (args[0]->propagate_type(thd, MYSQL_TYPE_DATE, false, true)) return true;
1483 if (reject_vector_args()) return true;
1484 return Item_date_func::resolve_type(thd);
1485 }
1486 void print(const THD *thd, String *str,
1487 enum_query_type query_type) const override;
1488 const char *func_name() const override { return "cast_as_date"; }
1489 enum Functype functype() const override { return TYPECAST_FUNC; }
1490 bool is_explicit_cast() const { return m_explicit_cast; }
1491 bool val_date(Date_val *date, my_time_flags_t flags) override;
1492 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1493 const char *cast_type() const { return "date"; }
1494};
1495
1499
1500 public:
1503 }
1504 Item_typecast_time(const POS &pos, Item *a) : Item_time_func(pos, a) {
1506 }
1507 Item_typecast_time(const POS &pos, Item *a, uint8 dec_arg)
1508 : Item_time_func(pos, a) {
1510 decimals = dec_arg;
1511 }
1514 decimals = dec_arg;
1515 }
1516 void print(const THD *thd, String *str,
1517 enum_query_type query_type) const override;
1518 const char *func_name() const override { return "cast_as_time"; }
1519 enum Functype functype() const override { return TYPECAST_FUNC; }
1520 bool is_explicit_cast() const { return m_explicit_cast; }
1521 bool val_time(Time_val *time) override;
1522 const char *cast_type() const { return "time"; }
1523 bool resolve_type(THD *thd) override {
1524 if (reject_vector_args()) return true;
1525 if (args[0]->propagate_type(thd, MYSQL_TYPE_DATETIME, false, true))
1526 return true;
1528 : decimals);
1529 set_nullable(true);
1530 return false;
1531 }
1532};
1533
1537
1538 public:
1539 Item_typecast_datetime(Item *a, bool explicit_cast)
1540 : Item_datetime_func(a), m_explicit_cast(explicit_cast) {
1542 }
1545 }
1546 Item_typecast_datetime(const POS &pos, Item *a, uint8 dec_arg)
1547 : Item_datetime_func(pos, a) {
1549 decimals = dec_arg;
1550 }
1553 decimals = dec_arg;
1554 }
1555 void print(const THD *thd, String *str,
1556 enum_query_type query_type) const override;
1557 const char *func_name() const override { return "cast_as_datetime"; }
1558 enum Functype functype() const override { return TYPECAST_FUNC; }
1559 const char *cast_type() const { return "datetime"; }
1560 bool is_explicit_cast() const { return m_explicit_cast; }
1561 bool resolve_type(THD *thd) override {
1562 if (reject_vector_args()) return true;
1563 if (args[0]->propagate_type(thd, MYSQL_TYPE_DATETIME, false, true))
1564 return true;
1567 set_nullable(true);
1568 return false;
1569 }
1570 bool val_date(Date_val *date, my_time_flags_t flags) override;
1571 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1572};
1573
1575 public:
1576 Item_func_makedate(const POS &pos, Item *a, Item *b)
1577 : Item_date_func(pos, a, b) {
1578 set_nullable(true);
1579 }
1580 const char *func_name() const override { return "makedate"; }
1581 bool val_date(Date_val *date, my_time_flags_t flags) override;
1582 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1583 enum Functype functype() const override { return MAKEDATE_FUNC; }
1584 bool resolve_type(THD *thd) override {
1585 if (reject_vector_args()) return true;
1586 if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_LONGLONG)) return true;
1587 return Item_date_func::resolve_type(thd);
1588 }
1589};
1590
1591/**
1592 Add a time expression to a temporal expression, or
1593 subtract a time expression from a temporal expression.
1594 Used to implement the functions ADDTIME and SUBTIME, and the
1595 two-argument version of TIMESTAMP (which sets m_datetime = true).
1596*/
1598 const bool m_datetime; ///< True if first argument expected to be datetime
1599 bool m_subtract; ///< FALSE for ADD, TRUE for SUBTRACT
1600
1601 bool eval_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1602 bool eval_time(Time_val *time) override;
1603
1604 public:
1605 Item_func_add_time(Item *a, Item *b, bool datetime, bool subtract)
1607 m_datetime(datetime),
1608 m_subtract(subtract) {}
1609 Item_func_add_time(const POS &pos, Item *a, Item *b, bool datetime,
1610 bool subtract)
1611 : Item_temporal_hybrid_func(pos, a, b),
1612 m_datetime(datetime),
1613 m_subtract(subtract) {}
1614
1615 Item_func_add_time(const POS &pos, Item *a, Item *b)
1616 : Item_func_add_time(pos, a, b, false, false) {}
1617
1618 bool resolve_type(THD *) override;
1619 void print(const THD *thd, String *str,
1620 enum_query_type query_type) const override;
1621 const char *func_name() const override { return "add_time"; }
1622 enum Functype functype() const override { return ADDTIME_FUNC; }
1623 bool is_subtract() const { return m_subtract; }
1624};
1625
1627 public:
1628 Item_func_timediff(const POS &pos, Item *a, Item *b)
1629 : Item_time_func(pos, a, b) {}
1630 const char *func_name() const override { return "timediff"; }
1631 enum Functype functype() const override { return TIMEDIFF_FUNC; }
1632 bool resolve_type(THD *thd) override {
1633 if (reject_vector_args()) return true;
1634 /*
1635 This function can operate on two TIME, or on two DATETIME (no mix).
1636 We infer the type from the other argument. If both arguments are '?', we
1637 choose VARCHAR; indeed, if we chose TIME and get DATETIME, we risk
1638 cutting the date part, and if we chose DATETIME and get TIME, we risk
1639 interpreting "01:01:01" as "2001:01:01 00:00:00".
1640 */
1641 if (param_type_uses_non_param(thd)) return true;
1644 set_nullable(true);
1645 return false;
1646 }
1647 bool val_time(Time_val *time) override;
1648};
1649
1651 public:
1652 Item_func_maketime(const POS &pos, Item *a, Item *b, Item *c)
1653 : Item_time_func(pos, a, b, c) {
1654 set_nullable(true);
1655 }
1656 bool resolve_type(THD *thd) override {
1657 if (reject_vector_args()) return true;
1658 if (param_type_is_default(thd, 0, 2, MYSQL_TYPE_LONGLONG)) return true;
1659 if (param_type_is_default(thd, 2, 3, MYSQL_TYPE_NEWDECIMAL)) return true;
1661 std::min(args[2]->decimals, uint8{DATETIME_MAX_DECIMALS}));
1662 return false;
1663 }
1664 const char *func_name() const override { return "maketime"; }
1665 enum Functype functype() const override { return MAKETIME_FUNC; }
1666 bool val_time(Time_val *time) override;
1667};
1668
1670 public:
1671 Item_func_microsecond(const POS &pos, Item *a) : Item_int_func(pos, a) {}
1672 longlong val_int() override;
1673 const char *func_name() const override { return "microsecond"; }
1674 enum Functype functype() const override { return MICROSECOND_FUNC; }
1675 bool resolve_type(THD *thd) override;
1676 bool check_partition_func_processor(uchar *) override { return false; }
1678 return !has_time_args();
1679 }
1680};
1681
1684
1685 public:
1687 interval_type type_arg)
1688 : Item_int_func(pos, a, b), int_type(type_arg) {}
1689 const char *func_name() const override { return "timestampdiff"; }
1690 enum Functype functype() const override { return TIMESTAMPDIFF_FUNC; }
1692 longlong val_int() override;
1693 bool resolve_type(THD *thd) override {
1694 if (reject_vector_args()) return true;
1695 if (param_type_is_default(thd, 0, -1, MYSQL_TYPE_DATETIME)) return true;
1696 set_nullable(true);
1697 return false;
1698 }
1699 void print(const THD *thd, String *str,
1700 enum_query_type query_type) const override;
1701};
1702
1710
1712 public:
1713 const enum_mysql_timestamp_type type; // keep it public
1715 Item *a)
1716 : Item_str_ascii_func(pos, a), type(type_arg) {}
1717 String *val_str_ascii(String *str) override;
1718 const char *func_name() const override { return "get_format"; }
1719 enum Functype functype() const override { return GET_FORMAT_FUNC; }
1720 bool resolve_type(THD *thd) override {
1721 if (reject_vector_args()) return true;
1722 if (param_type_is_default(thd, 0, -1)) return true;
1723 set_nullable(true);
1725 return false;
1726 }
1727 void print(const THD *thd, String *str,
1728 enum_query_type query_type) const override;
1729
1731};
1732
1735 void fix_from_format(const char *format, size_t length);
1736
1737 protected:
1738 bool eval_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1739 bool eval_time(Time_val *time) override {
1740 Datetime_val dt;
1741 if (eval_datetime(&dt, TIME_FUZZY_DATE)) return true;
1742 if (dt.time_type != MYSQL_TIMESTAMP_TIME) {
1743 datetime_to_time(&dt);
1744 }
1745 *time = Time_val(dt);
1746 return false;
1747 }
1748
1749 public:
1751 : Item_temporal_hybrid_func(pos, a, b) {}
1752 const char *func_name() const override { return "str_to_date"; }
1753 bool resolve_type(THD *) override;
1754};
1755
1757 public:
1758 Item_func_last_day(const POS &pos, Item *a) : Item_date_func(pos, a) {
1759 set_nullable(true);
1760 }
1761 const char *func_name() const override { return "last_day"; }
1762 enum Functype functype() const override { return LAST_DAY_FUNC; }
1763 bool val_date(Date_val *date, my_time_flags_t flags) override;
1764 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1765 bool resolve_type(THD *thd) override {
1766 if (reject_vector_args()) return true;
1767 if (param_type_is_default(thd, 0, 1, MYSQL_TYPE_DATETIME)) return true;
1768 return Item_date_func::resolve_type(thd);
1769 }
1770};
1771
1773 public:
1775 : Item_datetime_func(pos, list) {}
1776 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
1777 const char *func_name() const override { return "internal_update_time"; }
1778 bool resolve_type(THD *thd) override;
1779 bool val_date(Date_val *date, my_time_flags_t flags) override;
1780 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1781};
1782
1784 public:
1786 : Item_datetime_func(pos, list) {}
1787 enum Functype functype() const override { return DD_INTERNAL_FUNC; }
1788 const char *func_name() const override { return "internal_check_time"; }
1789 bool resolve_type(THD *thd) override;
1790 bool val_date(Date_val *date, my_time_flags_t flags) override;
1791 bool val_datetime(Datetime_val *dt, my_time_flags_t flags) override;
1792};
1793
1794/* Function prototypes */
1795
1798
1799#endif /* ITEM_TIMEFUNC_INCLUDED */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
void set_numeric()
Definition: item.h:219
const CHARSET_INFO * collation
Definition: item.h:185
Definition: my_temporal.h:395
Definition: my_temporal.h:339
Definition: field.h:570
Implementation class for the DATE_ADD and DATE_SUB functions.
Definition: item_timefunc.h:1376
enum Functype functype() const override
Definition: item_timefunc.h:1394
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:2948
const bool m_subtract
False if function is DATE_ADD, true if function is DATE_SUB.
Definition: item_timefunc.h:1413
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_timefunc.cc:2915
Item_temporal_hybrid_func super
Definition: item_timefunc.h:1377
const char * func_name() const override
Definition: item_timefunc.h:1393
bool is_subtract() const
Definition: item_timefunc.h:1400
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_timefunc.cc:2959
bool eval_time(Time_val *time) override
Evaluate temporal expression as time value.
Definition: item_timefunc.cc:2891
bool eval_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate temporal expression as datetime value.
Definition: item_timefunc.cc:2909
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2765
const interval_type m_interval_type
The type of the interval argument.
Definition: item_timefunc.h:1411
Item_date_add_interval(Item *a, Item *b, interval_type type, bool subtract)
POS-less ctor for post-parse construction with implicit addition to THD's free_list (see Item::Item()...
Definition: item_timefunc.h:1389
interval_type get_interval_type() const
Definition: item_timefunc.h:1399
String value
Definition: item_timefunc.h:1414
bool get_datetime_internal(Datetime_val *dt, my_time_flags_t flags)
Definition: item_timefunc.cc:2857
Item_date_add_interval(const POS &pos, Item *a, Item *b, interval_type type, bool subtract)
Definition: item_timefunc.h:1380
Abstract class for functions returning DATE values.
Definition: item_timefunc.h:621
double val_real() override
Definition: item_timefunc.h:644
bool val_date(Date_val *date, my_time_flags_t flags) override=0
Evaluate the item and return result as a date value.
const char * func_name() const override
Definition: item_timefunc.h:645
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:647
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.h:640
enum Functype functype() const override
Definition: item_timefunc.h:646
Item_date_func(const POS &pos)
Definition: item_timefunc.h:629
Item_date_func()
Definition: item_timefunc.h:628
Item_date_func(Item *a)
Definition: item_timefunc.h:632
Item_date_func(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:636
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.cc:1030
longlong val_int() override
Definition: item_timefunc.h:642
Item_date_func(const POS &pos, Item *a)
Definition: item_timefunc.h:633
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:623
String * val_str(String *str) override
Definition: item_timefunc.h:641
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_timefunc.h:648
DATE'2010-01-01'.
Definition: item_timefunc.h:868
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:903
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:893
Item_date_literal(MYSQL_TIME *ltime)
Constructor for Item_date_literal.
Definition: item_timefunc.h:876
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:901
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:1050
const char * func_name() const override
Definition: item_timefunc.h:881
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:889
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_timefunc.cc:1045
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.h:885
MYSQL_TIME_cache cached_time
Definition: item_timefunc.h:869
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_timefunc.h:906
table_map used_tables() const override
Definition: item_timefunc.h:904
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:902
String * val_str(String *str) override
Definition: item_timefunc.h:897
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_timefunc.cc:1056
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:905
Abstract class for functions returning DATETIME values.
Definition: item_timefunc.h:661
longlong val_int() override
Definition: item_timefunc.h:704
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:674
Item_datetime_func(const POS &pos)
Definition: item_timefunc.h:671
Item_datetime_func()
Definition: item_timefunc.h:668
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.h:710
String * val_str(String *str) override
Definition: item_timefunc.h:701
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:716
double val_real() override
Definition: item_timefunc.h:700
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.cc:1037
Item_datetime_func(const POS &pos, PT_item_list *list)
Definition: item_timefunc.h:695
Item_datetime_func(Item *a, Item *b, Item *c)
Definition: item_timefunc.h:684
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:663
Item_datetime_func(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_timefunc.h:687
Item_datetime_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_timefunc.h:691
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_timefunc.h:706
Item_datetime_func(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:680
Item_datetime_func(const POS &pos, Item *a)
Definition: item_timefunc.h:677
TIMESTAMP'2001-01-01 10:20:30'.
Definition: item_timefunc.h:951
MYSQL_TIME_cache cached_time
Definition: item_timefunc.h:952
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_timefunc.cc:1073
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:989
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:987
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:991
enum Functype functype() const override
Definition: item_timefunc.h:968
const char * func_name() const override
Definition: item_timefunc.h:967
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_timefunc.h:992
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:979
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:988
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:975
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:1066
Item_datetime_literal(Datetime_val *dt, uint dec_arg, const Time_zone *tz)
Constructor for Item_datetime_literal.
Definition: item_timefunc.h:962
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_timefunc.cc:1061
String * val_str(String *str) override
Definition: item_timefunc.h:983
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.h:971
table_map used_tables() const override
Definition: item_timefunc.h:990
Definition: item_timefunc.h:1417
bool date_value
Definition: item_timefunc.h:1418
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:1432
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:2966
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_timefunc.cc:3170
const char * func_name() const override
Definition: item_timefunc.h:1426
enum Functype functype() const override
Definition: item_timefunc.h:1425
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2975
longlong val_int() override
Definition: item_timefunc.cc:3067
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:1431
const interval_type int_type
Definition: item_timefunc.h:1421
Item_extract(const POS &pos, interval_type type_arg, Item *a)
Definition: item_timefunc.h:1422
Add a time expression to a temporal expression, or subtract a time expression from a temporal express...
Definition: item_timefunc.h:1597
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3316
const char * func_name() const override
Definition: item_timefunc.h:1621
bool is_subtract() const
Definition: item_timefunc.h:1623
bool m_subtract
FALSE for ADD, TRUE for SUBTRACT.
Definition: item_timefunc.h:1599
const bool m_datetime
True if first argument expected to be datetime.
Definition: item_timefunc.h:1598
enum Functype functype() const override
Definition: item_timefunc.h:1622
bool eval_time(Time_val *time) override
Evaluate temporal expression as time value.
Definition: item_timefunc.cc:3465
Item_func_add_time(const POS &pos, Item *a, Item *b, bool datetime, bool subtract)
Definition: item_timefunc.h:1609
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:3361
Item_func_add_time(Item *a, Item *b, bool datetime, bool subtract)
Definition: item_timefunc.h:1605
Item_func_add_time(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:1615
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:3487
This function implements the AT TIME ZONE operator, which casts a temporal value to a temporal with t...
Definition: item_timefunc.h:1014
bool check_type() const
Definition: item_timefunc.cc:1159
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1100
bool set_time_zone(THD *thd)
Definition: item_timefunc.cc:1118
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:1133
const char * func_name() const override
Definition: item_timefunc.h:1024
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:1112
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:1129
bool m_is_interval
Whether the syntax used the INTERVAL construction.
Definition: item_timefunc.h:1050
const char * m_specifier_string
The specifier string argument, not used after resolution.
Definition: item_timefunc.h:1044
const Time_zone * m_tz
The time zone that the specifier string argument resolves to.
Definition: item_timefunc.h:1041
const char * specifier_string() const
Definition: item_timefunc.h:1034
Item_func_at_time_zone(const POS &pos, Item *datetime, const char *specifier_string, bool is_interval)
Definition: item_timefunc.h:1016
Definition: item_timefunc.h:1330
const char * func_name() const override
Definition: item_timefunc.h:1345
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2713
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:2726
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_timefunc.cc:2759
Time_zone * from_tz
Definition: item_timefunc.h:1338
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:2722
Item_func_convert_tz(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_timefunc.h:1341
bool from_tz_cached
Definition: item_timefunc.h:1337
bool to_tz_cached
Definition: item_timefunc.h:1337
enum Functype functype() const override
Definition: item_timefunc.h:1346
Time_zone * to_tz
Definition: item_timefunc.h:1338
Definition: item_timefunc.h:1150
Time_zone * time_zone() override
Definition: item_timefunc.cc:2280
const char * func_name() const override
Definition: item_timefunc.h:1156
Item_func_curdate_local(const POS &pos)
Definition: item_timefunc.h:1155
Definition: item_timefunc.h:1159
Time_zone * time_zone() override
Definition: item_timefunc.cc:2284
Item_func_curdate_utc(const POS &pos)
Definition: item_timefunc.h:1164
const char * func_name() const override
Definition: item_timefunc.h:1165
Abstract CURDATE function.
Definition: item_timefunc.h:1119
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2275
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:2293
Item_date_func super
Definition: item_timefunc.h:1120
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.cc:2286
String * val_str(String *) override
Definition: item_timefunc.cc:2304
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:1140
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:2297
Item_func_curdate(const POS &pos)
Definition: item_timefunc.h:1126
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_timefunc.cc:2268
table_map get_initial_pseudo_tables() const override
This function must assign a new value for each execution.
Definition: item_timefunc.h:1131
Definition: item_timefunc.h:1094
Item_func_curtime_local(const POS &pos, uint8 dec_arg)
Definition: item_timefunc.h:1099
const char * func_name() const override
Definition: item_timefunc.h:1101
Time_zone * time_zone() override
Definition: item_timefunc.cc:2349
Definition: item_timefunc.h:1104
Time_zone * time_zone() override
Definition: item_timefunc.cc:2353
const char * func_name() const override
Definition: item_timefunc.h:1111
Item_func_curtime_utc(const POS &pos, uint8 dec_arg)
Definition: item_timefunc.h:1109
Abstract CURTIME function. Children should define what time zone is used.
Definition: item_timefunc.h:1054
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:1078
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2325
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:1084
Item_func_curtime(const POS &pos, uint8 dec_arg)
Constructor for Item_func_curtime.
Definition: item_timefunc.h:1071
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.cc:2340
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_timefunc.cc:2318
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_timefunc.h:1061
Item_time_func super
Definition: item_timefunc.h:1055
Definition: item_timefunc.h:1293
const bool is_time_format
Definition: item_timefunc.h:1295
int fixed_length
Definition: item_timefunc.h:1294
const char * func_name() const override
Definition: item_timefunc.h:1303
String * val_str(String *str) override
Definition: item_timefunc.cc:2589
Item_func_date_format(const POS &pos, Item *a, Item *b, bool is_time_format_arg=false)
Definition: item_timefunc.h:1299
String value
Definition: item_timefunc.h:1296
uint format_length(const String *format)
Definition: item_timefunc.cc:2519
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2471
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_timefunc.cc:2500
TS-TODO: Item_func_dayname should be derived from Item_str_func.
Definition: item_timefunc.h:360
enum Item_result result_type() const override
Definition: item_timefunc.h:376
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:369
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.h:372
const char * func_name() const override
Definition: item_timefunc.h:366
Item_func_dayname(const POS &pos, Item *a)
Definition: item_timefunc.h:364
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1775
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:378
String * val_str(String *str) override
Definition: item_timefunc.cc:1787
MY_LOCALE * locale
Definition: item_timefunc.h:361
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:373
enum Functype functype() const override
Definition: item_timefunc.h:367
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:1374
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:1385
enum Functype functype() const override
Definition: item_timefunc.h:132
Definition: item_timefunc.h:192
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1355
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:200
longlong val_int() override
Definition: item_timefunc.cc:1366
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:199
Item_func_dayofyear(const POS &pos, Item *a)
Definition: item_timefunc.h:194
const char * func_name() const override
Definition: item_timefunc.h:196
enum Functype functype() const override
Definition: item_timefunc.h:197
Definition: item_timefunc.h:1275
const char * func_name() const override
Definition: item_timefunc.h:1278
Item_func_from_days(const POS &pos, Item *a)
Definition: item_timefunc.h:1277
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:2191
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:1283
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1286
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:1281
enum Functype functype() const override
Definition: item_timefunc.h:1282
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:2187
Definition: item_timefunc.h:1311
const char * func_name() const override
Definition: item_timefunc.h:1315
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:2662
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:2658
Item_func_from_unixtime(const POS &pos, Item *a)
Definition: item_timefunc.h:1313
enum Functype functype() const override
Definition: item_timefunc.h:1316
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2649
Definition: item_timefunc.h:1711
String * val_str_ascii(String *str) override
Definition: item_timefunc.cc:3840
const char * func_name() const override
Definition: item_timefunc.h:1718
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:3867
enum Functype functype() const override
Definition: item_timefunc.h:1719
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1720
enum_mysql_timestamp_type timestamp_type() const
Definition: item_timefunc.h:1730
Item_func_get_format(const POS &pos, enum_mysql_timestamp_type type_arg, Item *a)
Definition: item_timefunc.h:1714
const enum_mysql_timestamp_type type
Definition: item_timefunc.h:1713
Definition: item_timefunc.h:205
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1614
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:213
longlong val_int() override
Definition: item_timefunc.cc:1624
const char * func_name() const override
Definition: item_timefunc.h:209
enum Functype functype() const override
Definition: item_timefunc.h:210
Item_func_hour(const POS &pos, Item *a)
Definition: item_timefunc.h:207
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:212
Definition: item_timefunc.h:1783
enum Functype functype() const override
Definition: item_timefunc.h:1787
const char * func_name() const override
Definition: item_timefunc.h:1788
Item_func_internal_check_time(const POS &pos, PT_item_list *list)
Definition: item_timefunc.h:1785
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:4163
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:4150
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:4158
Definition: item_timefunc.h:1772
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:4079
const char * func_name() const override
Definition: item_timefunc.h:1777
enum Functype functype() const override
Definition: item_timefunc.h:1776
Item_func_internal_update_time(const POS &pos, PT_item_list *list)
Definition: item_timefunc.h:1774
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:4074
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:4066
Definition: item_timefunc.h:1756
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:4043
Item_func_last_day(const POS &pos, Item *a)
Definition: item_timefunc.h:1758
const char * func_name() const override
Definition: item_timefunc.h:1761
enum Functype functype() const override
Definition: item_timefunc.h:1762
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1765
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:4039
Definition: item_timefunc.h:1574
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1584
enum Functype functype() const override
Definition: item_timefunc.h:1583
bool val_date(Date_val *date, my_time_flags_t flags) override
MAKEDATE(a,b) is a date function that creates a date value from a year and day value.
Definition: item_timefunc.cc:3283
Item_func_makedate(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:1576
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:3287
const char * func_name() const override
Definition: item_timefunc.h:1580
Definition: item_timefunc.h:1650
enum Functype functype() const override
Definition: item_timefunc.h:1665
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1656
Item_func_maketime(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_timefunc.h:1652
const char * func_name() const override
Definition: item_timefunc.h:1664
bool val_time(Time_val *time) override
MAKETIME(h,m,s) is a time function that calculates a time value from the total number of hours,...
Definition: item_timefunc.cc:3592
Definition: item_timefunc.h:1669
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:1677
longlong val_int() override
MICROSECOND(a) is a function ( extraction) that extracts the microseconds from a.
Definition: item_timefunc.cc:3687
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3693
enum Functype functype() const override
Definition: item_timefunc.h:1674
Item_func_microsecond(const POS &pos, Item *a)
Definition: item_timefunc.h:1671
const char * func_name() const override
Definition: item_timefunc.h:1673
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:1676
Definition: item_timefunc.h:218
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
const char * func_name() const override
Definition: item_timefunc.h:222
longlong val_int() override
Definition: item_timefunc.cc:1640
Item_func_minute(const POS &pos, Item *a)
Definition: item_timefunc.h:220
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:225
enum Functype functype() const override
Definition: item_timefunc.h:223
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:226
TS-TODO: This should probably have Item_int_func as parent class.
Definition: item_timefunc.h:143
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1549
double val_real() override
Definition: item_timefunc.h:150
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.h:163
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:160
enum Item_result result_type() const override
Definition: item_timefunc.h:169
longlong val_int() override
Definition: item_timefunc.cc:1560
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:164
const char * func_name() const override
Definition: item_timefunc.h:167
String * val_str(String *str) override
Definition: item_timefunc.h:154
Item_func_month(const POS &pos, Item *a)
Definition: item_timefunc.h:145
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:172
enum Functype functype() const override
Definition: item_timefunc.h:168
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:171
Definition: item_timefunc.h:177
Item_func_monthname(const POS &pos, Item *a)
Definition: item_timefunc.h:181
MY_LOCALE * locale
Definition: item_timefunc.h:178
const char * func_name() const override
Definition: item_timefunc.h:182
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:187
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:186
String * val_str(String *str) override
Definition: item_timefunc.cc:1578
enum Functype functype() const override
Definition: item_timefunc.h:183
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1566
Definition: item_timefunc.h:1214
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:2365
Time_zone * time_zone() override
Definition: item_timefunc.cc:2372
const char * func_name() const override
Definition: item_timefunc.h:1231
Item_func_now_local(const POS &pos, uint8 dec_arg)
Definition: item_timefunc.h:1228
enum Functype functype() const override
Definition: item_timefunc.h:1232
Item_func_now_local(uint8 dec_arg)
Definition: item_timefunc.h:1227
Definition: item_timefunc.h:1235
const char * func_name() const override
Definition: item_timefunc.h:1247
Item_func_now_utc(const POS &pos, uint8 dec_arg)
Definition: item_timefunc.h:1242
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_timefunc.cc:2374
Item_func_now super
Definition: item_timefunc.h:1236
Time_zone * time_zone() override
Definition: item_timefunc.cc:2381
Abstract CURRENT_TIMESTAMP function.
Definition: item_timefunc.h:1173
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:2395
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:2383
Item_func_now(uint8 dec_arg)
Constructor for Item_func_now.
Definition: item_timefunc.h:1189
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:2416
longlong val_date_temporal() override
Return date value of item in packed longlong format.
Definition: item_timefunc.cc:2387
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2357
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:1204
String * val_str(String *) override
Definition: item_timefunc.cc:2403
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_timefunc.h:1179
table_map get_initial_pseudo_tables() const override
This function must assign a new value for each execution.
Definition: item_timefunc.h:1195
Item_func_now(const POS &pos, uint8 dec_arg)
Definition: item_timefunc.h:1190
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:1173
longlong val_int() override
Definition: item_timefunc.cc:1178
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:1192
longlong val_int() override
Definition: item_timefunc.cc:1197
Definition: item_timefunc.h:231
const char * func_name() const override
Definition: item_timefunc.h:235
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:238
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:239
enum Functype functype() const override
Definition: item_timefunc.h:236
Item_func_quarter(const POS &pos, Item *a)
Definition: item_timefunc.h:233
longlong val_int() override
Returns the quarter of the year.
Definition: item_timefunc.cc:1607
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1593
Definition: item_timefunc.h:1353
const char * func_name() const override
Definition: item_timefunc.h:1365
Item_func_sec_to_time(const POS &pos, Item *item)
Definition: item_timefunc.h:1355
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1357
enum Functype functype() const override
Definition: item_timefunc.h:1366
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.cc:2450
Definition: item_timefunc.h:244
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:252
const char * func_name() const override
Definition: item_timefunc.h:248
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:251
enum Functype functype() const override
Definition: item_timefunc.h:249
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1646
Item_func_second(const POS &pos, Item *a)
Definition: item_timefunc.h:246
longlong val_int() override
Returns the second in time_exp in the range of 0 - 59.
Definition: item_timefunc.cc:1659
Definition: item_timefunc.h:1733
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:3954
bool eval_time(Time_val *time) override
Evaluate temporal expression as time value.
Definition: item_timefunc.h:1739
Item_func_str_to_date(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:1750
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:3904
bool eval_datetime(Datetime_val *dt, my_time_flags_t flags) override
Evaluate temporal expression as datetime value.
Definition: item_timefunc.cc:3988
const char * func_name() const override
Definition: item_timefunc.h:1752
enum_mysql_timestamp_type cached_timestamp_type
Definition: item_timefunc.h:1734
SYSDATE() is like NOW(), but always uses the real current time, not the query_start().
Definition: item_timefunc.h:1254
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:1270
const char * func_name() const override
Definition: item_timefunc.h:1259
Item_func_sysdate_local(uint8 dec_arg)
Definition: item_timefunc.h:1256
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:2425
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2444
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:2433
enum Functype functype() const override
Definition: item_timefunc.h:1261
Definition: item_timefunc.h:472
enum Functype functype() const override
Definition: item_timefunc.h:478
longlong val_int() override
Definition: item_timefunc.cc:2023
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:480
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:2015
Item_func_time_to_sec(const POS &pos, Item *item)
Definition: item_timefunc.h:474
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:481
const char * func_name() const override
Definition: item_timefunc.h:477
Definition: item_timefunc.h:1626
enum Functype functype() const override
Definition: item_timefunc.h:1631
Item_func_timediff(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:1628
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1632
const char * func_name() const override
Definition: item_timefunc.h:1630
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:3511
Definition: item_timefunc.h:1682
interval_type intervaltype() const
Definition: item_timefunc.h:1691
const char * func_name() const override
Definition: item_timefunc.h:1689
enum Functype functype() const override
Definition: item_timefunc.h:1690
longlong val_int() override
Definition: item_timefunc.cc:3700
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:3796
Item_func_timestamp_diff(const POS &pos, Item *a, Item *b, interval_type type_arg)
Definition: item_timefunc.h:1686
const interval_type int_type
Definition: item_timefunc.h:1683
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1693
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:1212
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:1226
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:1308
enum_monotonicity_info get_monotonicity_info() const override
Definition: item_timefunc.cc:1289
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:1299
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:1256
longlong val_int() override
Definition: item_timefunc.cc:1263
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:1233
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:121
Definition: item_timefunc.h:413
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:430
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:440
longlong val_int_endpoint(bool left_endp, bool *incl_endp) override
Definition: item_timefunc.cc:2006
const char * func_name() const override
Definition: item_timefunc.h:424
Item_func_unix_timestamp(const POS &pos)
Definition: item_timefunc.h:417
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:459
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:445
Item_timeval_func super
Definition: item_timefunc.h:414
enum_monotonicity_info get_monotonicity_info() const override
Definition: item_timefunc.cc:1999
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_timefunc.cc:1976
Item_func_unix_timestamp(Item *a)
Definition: item_timefunc.h:419
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:436
enum Functype functype() const override
Definition: item_timefunc.h:425
Item_func_unix_timestamp(const POS &pos, Item *a)
Definition: item_timefunc.h:421
bool val_timeval(my_timeval *tm) override
Definition: item_timefunc.cc:1987
Definition: item_timefunc.h:257
const char * func_name() const override
Definition: item_timefunc.h:267
longlong val_int() override
Definition: item_timefunc.cc:1725
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_timefunc.cc:1671
Item_func_week(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:262
Item_func_week(Item *a, Item *b)
Definition: item_timefunc.h:261
Item_int_func super
Definition: item_timefunc.h:258
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1682
enum Functype functype() const override
Definition: item_timefunc.h:268
TS-TODO: This should probably have Item_int_func as parent class.
Definition: item_timefunc.h:317
Item_func_weekday(const POS &pos, Item *a, bool type_arg)
Definition: item_timefunc.h:321
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:349
const char * func_name() const override
Definition: item_timefunc.h:343
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.h:339
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:350
double val_real() override
Definition: item_timefunc.h:327
String * val_str(String *str) override
Definition: item_timefunc.h:331
bool odbc_type
Definition: item_timefunc.h:318
enum Item_result result_type() const override
Definition: item_timefunc.h:347
enum Functype functype() const override
Definition: item_timefunc.h:346
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1754
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:340
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:336
longlong val_int() override
Definition: item_timefunc.cc:1764
Definition: item_timefunc.h:286
enum Functype functype() const override
Definition: item_timefunc.h:291
longlong val_int_endpoint(bool left_endp, bool *incl_endp) override
Definition: item_timefunc.cc:1920
enum_monotonicity_info get_monotonicity_info() const override
Definition: item_timefunc.cc:1912
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:295
const char * func_name() const override
Definition: item_timefunc.h:290
longlong val_int() override
Definition: item_timefunc.cc:1809
Item_func_year(const POS &pos, Item *a)
Definition: item_timefunc.h:288
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1801
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:296
Definition: item_timefunc.h:272
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:280
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.cc:1733
enum Functype functype() const override
Definition: item_timefunc.h:278
longlong val_int() override
Definition: item_timefunc.cc:1744
Item_func_yearweek(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:274
bool check_valid_arguments_processor(uchar *) override
Definition: item_timefunc.h:281
const char * func_name() const override
Definition: item_timefunc.h:277
Definition: item_func.h:101
bool param_type_uses_non_param(THD *thd, enum_field_types def=MYSQL_TYPE_VARCHAR)
Definition: item_func.cc:619
Item ** args
Array of pointers to arguments.
Definition: item_func.h:108
bool reject_vector_args()
Definition: item_func.cc:1617
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:668
enum Type type() const override
Definition: item_func.h:373
bool param_type_is_default(THD *thd, uint start, uint end, uint step, enum_field_types def)
For arguments of this Item_func ("args" array), in range [start, start+step, start+2*step,...
Definition: item_func.cc:530
bool propagate_type(THD *thd, const Type_properties &type) override
Default implementation for all functions: Propagate base_item's type into all arguments.
Definition: item_func.cc:506
bool has_date_args()
Definition: item_func.h:678
uint arg_count
How many arguments in 'args'.
Definition: item_func.h:131
bool has_time_args()
Definition: item_func.h:689
bool has_datetime_args()
Definition: item_func.h:700
Definition: item_func.h:1044
Definition: item_strfunc.h:151
Definition: item_strfunc.h:78
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:143
Abstract class for functions returning TIME, DATE, DATETIME types whose data type is known at constru...
Definition: item_timefunc.h:490
Item_temporal_func()
Definition: item_timefunc.h:501
Item_temporal_func(const POS &pos, Item *a)
Definition: item_timefunc.h:505
Item_temporal_func(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:507
Item_temporal_func(const POS &pos)
Definition: item_timefunc.h:502
Item_temporal_func(Item *a)
Definition: item_timefunc.h:504
Item_temporal_func(Item *a, Item *b, Item *c)
Definition: item_timefunc.h:509
Field * tmp_table_field(TABLE *table) override
Definition: item_timefunc.h:521
Item_temporal_func(const POS &pos, PT_item_list *list)
Definition: item_timefunc.h:514
bool check_precision()
Definition: item_timefunc.cc:822
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_timefunc.h:495
Item_temporal_func(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_timefunc.h:510
Item_temporal_func(const POS &pos, Item *a, Item *b, Item *c, Item *d)
Definition: item_timefunc.h:512
uint datetime_precision() override
DATETIME precision of the item: 0..6.
Definition: item_timefunc.h:528
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:842
uint time_precision() override
TIME precision of the item: 0..6.
Definition: item_timefunc.h:524
const CHARSET_INFO * charset_for_protocol() override
Definition: item_timefunc.h:518
Item_result result_type() const override
Definition: item_timefunc.h:517
Abstract class for functions returning TIME, DATE, DATETIME or string values, whose data type depends...
Definition: item_timefunc.h:540
const CHARSET_INFO * charset_for_protocol() override
Definition: item_timefunc.h:582
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:593
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_timefunc.cc:881
sql_mode_t sql_mode
Definition: item_timefunc.h:542
double val_real() override
Definition: item_timefunc.h:597
void add_json_info(Json_object *obj) override
Add all the node-specific json fields.
Definition: item_timefunc.h:571
Item_result result_type() const override
Definition: item_timefunc.h:581
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:578
Item_temporal_hybrid_func(Item *a, Item *b)
Definition: item_timefunc.h:576
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.cc:952
String * val_str(String *str) override
Return string value in @character_set_connection.
Definition: item_timefunc.h:606
String * val_str_ascii(String *str) override
Return string value in ASCII character set.
Definition: item_timefunc.cc:989
longlong val_int() override
Definition: item_timefunc.h:596
String ascii_buf
Definition: item_timefunc.h:543
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:916
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:864
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:911
bool eval_date(Date_val *date, my_time_flags_t flags)
Evaluate temporal expression as date value.
Definition: item_timefunc.h:559
Abstract class for functions returning TIME values.
Definition: item_timefunc.h:725
type_conversion_status save_in_field_inner(Field *field, bool) override
Helper function which does all of the work for save_in_field(Field*, bool), except some error checkin...
Definition: item_timefunc.h:727
longlong val_int() override
Definition: item_timefunc.h:755
String * val_str(String *str) override
Definition: item_timefunc.h:762
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:739
Item_time_func(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_timefunc.h:746
Item_time_func(Item *a)
Definition: item_timefunc.h:736
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_timefunc.h:751
Item_time_func(const POS &pos)
Definition: item_timefunc.h:733
double val_real() override
Definition: item_timefunc.h:750
Item_time_func(const POS &pos, Item *a, Item *b)
Definition: item_timefunc.h:742
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:759
Item_time_func()
Definition: item_timefunc.h:732
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:756
TIME'10:10:10'.
Definition: item_timefunc.h:913
bool resolve_type(THD *) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:934
bool check_partition_func_processor(uchar *) override
Check if a partition function is allowed.
Definition: item_timefunc.h:935
Time_val m_time
Definition: item_timefunc.h:943
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_timefunc.h:939
Item_time_literal(Time_val *time, uint dec_arg)
Constructor for Item_time_literal.
Definition: item_timefunc.h:921
bool eq_specific(const Item *item) const override
Provide a more specific equality check for a function.
Definition: item_timefunc.cc:1078
uint64_t m_hash
Definition: item_timefunc.h:944
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:936
const char * func_name() const override
Definition: item_timefunc.h:926
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:1083
uint64_t hash() override
Generate hash unique to an item depending on its attributes.
Definition: item_timefunc.cc:1092
table_map used_tables() const override
Definition: item_timefunc.h:937
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.h:929
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:938
Definition: item_timefunc.h:384
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:405
virtual bool val_timeval(my_timeval *tm)=0
Return timestamp in "struct timeval" format.
longlong val_int() override
Definition: item_timefunc.cc:1947
String * val_str(String *str) override
Definition: item_timefunc.cc:1967
Item_timeval_func(const POS &pos, Item *a)
Definition: item_timefunc.h:389
my_decimal * val_decimal(my_decimal *decimal_value) override
Definition: item_timefunc.cc:1952
Item_timeval_func(Item *a)
Definition: item_timefunc.h:388
enum Item_result result_type() const override
Definition: item_timefunc.h:408
Item_timeval_func(const POS &pos)
Definition: item_timefunc.h:386
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.h:404
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:401
double val_real() override
Definition: item_timefunc.cc:1960
Definition: item_timefunc.h:1469
bool m_explicit_cast
Definition: item_timefunc.h:1470
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1481
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:3234
const char * cast_type() const
Definition: item_timefunc.h:1493
const char * func_name() const override
Definition: item_timefunc.h:1488
bool is_explicit_cast() const
Definition: item_timefunc.h:1490
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:3243
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:3247
enum Functype functype() const override
Definition: item_timefunc.h:1489
Item_typecast_date(Item *a, bool explicit_cast)
Definition: item_timefunc.h:1473
Item_typecast_date(const POS &pos, Item *a)
Definition: item_timefunc.h:1477
Definition: item_timefunc.h:1534
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:3186
Item_typecast_datetime(Item *a, uint8 dec_arg)
Definition: item_timefunc.h:1551
Item_typecast_datetime(const POS &pos, Item *a)
Definition: item_timefunc.h:1543
Item_typecast_datetime(Item *a, bool explicit_cast)
Definition: item_timefunc.h:1539
enum Functype functype() const override
Definition: item_timefunc.h:1558
bool is_explicit_cast() const
Definition: item_timefunc.h:1560
const char * func_name() const override
Definition: item_timefunc.h:1557
bool m_explicit_cast
Definition: item_timefunc.h:1536
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1561
Item_typecast_datetime(const POS &pos, Item *a, uint8 dec_arg)
Definition: item_timefunc.h:1546
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:3176
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:3190
bool detect_precision_from_arg
Definition: item_timefunc.h:1535
const char * cast_type() const
Definition: item_timefunc.h:1559
Definition: item_timefunc.h:1496
Item_typecast_time(Item *a, uint8 dec_arg)
Definition: item_timefunc.h:1512
Item_typecast_time(const POS &pos, Item *a)
Definition: item_timefunc.h:1504
bool is_explicit_cast() const
Definition: item_timefunc.h:1520
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_timefunc.h:1523
Item_typecast_time(const POS &pos, Item *a, uint8 dec_arg)
Definition: item_timefunc.h:1507
const char * cast_type() const
Definition: item_timefunc.h:1522
bool val_time(Time_val *time) override
Evaluate the item and return result as a time value.
Definition: item_timefunc.cc:3228
enum Functype functype() const override
Definition: item_timefunc.h:1519
bool detect_precision_from_arg
Definition: item_timefunc.h:1497
Item_typecast_time(Item *a)
Definition: item_timefunc.h:1501
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:3218
const char * func_name() const override
Definition: item_timefunc.h:1518
bool m_explicit_cast
Definition: item_timefunc.h:1498
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:1815
Item_typecast_year(const POS &pos, Item *a)
Definition: item_timefunc.h:303
longlong val_int() override
Definition: item_timefunc.cc:1831
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_timefunc.cc:1824
enum Functype functype() const override
Definition: item_timefunc.h:308
const char * func_name() const override
Definition: item_timefunc.h:307
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:928
void set_nullable(bool nullable)
Definition: item.h:3748
bool get_datetime_from_numeric(Datetime_val *dt, my_time_flags_t flags)
Convert a numeric type to datetime.
Definition: item.cc:1643
void set_data_type_date()
Set all type properties for Item of DATE type.
Definition: item.h:1694
DTCollation collation
Character set and collation properties assigned for this Item.
Definition: item.h:3643
longlong val_int_from_decimal()
Definition: item.cc:477
bool get_time_from_datetime(Time_val *time)
Convert datetime to time.
Definition: item.cc:1737
bool get_date_from_int(Date_val *date, my_time_flags_t flags)
Convert val_int() to date.
Definition: item.cc:1599
void set_data_type(enum_field_types data_type)
Set the data type of the current Item.
Definition: item.h:1511
longlong val_int_from_datetime()
Definition: item.cc:502
static const CHARSET_INFO * default_charset()
Definition: item.cc:1806
String * val_string_from_date(String *str)
Definition: item.cc:340
double val_real_from_decimal()
Definition: item.cc:459
String * val_string_from_datetime(String *str)
Definition: item.cc:329
bool get_datetime_from_time(Datetime_val *dt)
Convert val_time() to datetime.
Definition: item.cc:1616
longlong val_int_from_date()
Definition: item.cc:495
void set_data_type_year()
Set the data type of the Item to be YEAR.
Definition: item.h:1772
bool get_time_from_date(Time_val *time)
Convert date to time.
Definition: item.cc:1728
bool get_time_from_numeric(Time_val *time)
Convert a numeric type to time.
Definition: item.cc:1746
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:6835
enum_field_types data_type() const
Retrieve the derived data type of the Item.
Definition: item.h:1479
bool fixed
True if item has been resolved.
Definition: item.h:3736
longlong val_int_from_time()
Definition: item.cc:486
bool null_value
True if item is null.
Definition: item.h:3773
bool get_datetime_from_string(Datetime_val *dt, my_time_flags_t flags)
Convert val_str() to datetime.
Definition: item.cc:1555
void set_data_type_datetime(uint8 fsp)
Set all properties for Item of DATETIME type.
Definition: item.h:1719
virtual uint datetime_precision()
DATETIME precision of the item: 0..6.
Definition: item.cc:837
bool get_datetime_from_int(Datetime_val *dt, my_time_flags_t flags)
Convert val_int() to datetime.
Definition: item.cc:1593
my_decimal * val_decimal_from_date(my_decimal *decimal_value)
Definition: item.cc:396
bool get_time_from_int(Time_val *time)
Convert val_int() to time.
Definition: item.cc:1722
bool get_date_from_string(Date_val *date, my_time_flags_t flags)
Convert val_str() to date.
Definition: item.cc:1563
@ MARKER_NONE
Definition: item.h:3664
type_conversion_status save_time_in_field(Field *field)
Definition: item.cc:526
item_marker marker
This member has several successive meanings, depending on the phase we're in (.
Definition: item.h:3705
uint8 decimals
Number of decimals in result when evaluating this item.
Definition: item.h:3745
void set_data_type_string(uint32 max_l)
Set the Item to be variable length string.
Definition: item.h:1598
bool get_date_from_time(Date_val *date)
Convert val_time() to date.
Definition: item.cc:1605
String * val_string_from_time(String *str)
Definition: item.cc:351
bool get_date_from_numeric(Date_val *date, my_time_flags_t flags)
Convert a numeric type to date.
Definition: item.cc:1627
void set_data_type_longlong()
Set the data type of the Item to be longlong.
Definition: item.h:1553
void set_data_type_time(uint8 fsp)
Set all type properties for Item of TIME type.
Definition: item.h:1706
void set_data_type_decimal(uint8 precision, uint8 scale)
Set the data type of the Item to be decimal.
Definition: item.h:1567
my_decimal * val_decimal_from_time(my_decimal *decimal_value)
Definition: item.cc:405
type_conversion_status save_date_in_field(Field *field)
Definition: item.cc:535
bool get_time_from_string(Time_val *time)
Convert val_str() to time.
Definition: item.cc:1701
Represents a JSON container value of type "object" (ECMA), type J_OBJECT here.
Definition: json_dom.h:373
bool add_alias(std::string_view key, Json_dom *value)
Insert the value into the object.
Definition: json_dom.h:415
Cache for MYSQL_TIME value with various representations.
Definition: item_timefunc.h:776
uint string_length
length of string
Definition: item_timefunc.h:780
MYSQL_TIME * get_TIME_ptr()
Return pointer to MYSQL_TIME representation.
Definition: item_timefunc.h:850
longlong val_packed() const
Return packed representation.
Definition: item_timefunc.h:833
MYSQL_TIME_cache()
Definition: item_timefunc.h:792
uint8 decimals() const
Return number of decimal digits.
Definition: item_timefunc.h:825
uint8 dec
Number of decimals.
Definition: item_timefunc.h:781
bool get_date(MYSQL_TIME *ltime) const
Definition: item_timefunc.h:842
const char * cptr() const
Return C string representation.
Definition: item_timefunc.h:862
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:2254
longlong time_packed
packed representation
Definition: item_timefunc.h:778
void set_date(MYSQL_TIME *ltime)
Set time and time_packed from a DATE value.
Definition: item_timefunc.cc:2214
MYSQL_TIME time
MYSQL_TIME representation.
Definition: item_timefunc.h:777
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:2222
bool eq(const MYSQL_TIME_cache &tm) const
Test if cached value is equal to another MYSQL_TIME_cache value.
Definition: item_timefunc.h:818
String * val_str(String *str)
Store string representation into String.
Definition: item_timefunc.cc:2261
char string_buff[MAX_DATE_STRING_REP_LENGTH]
string representation
Definition: item_timefunc.h:779
void get_TIME(MYSQL_TIME *ltime) const
Store MYSQL_TIME representation into the given MYSQL_TIME variable.
Definition: item_timefunc.h:786
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:55
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
uint64_t sql_mode_t
Definition: dd_event.h:39
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:31
This file contains the field type.
@ MYSQL_TYPE_LONGLONG
Definition: field_types.h:64
@ MYSQL_TYPE_TIME
Definition: field_types.h:67
@ MYSQL_TYPE_STRING
Definition: field_types.h:89
@ MYSQL_TYPE_NEWDECIMAL
Definition: field_types.h:81
@ MYSQL_TYPE_DATE
Definition: field_types.h:66
@ MYSQL_TYPE_DATETIME
Definition: field_types.h:68
static const std::string dec("DECRYPTION")
bool is_adjusted(uint32_t decimals) const
Definition: my_temporal.cc:45
static int flags[50]
Definition: hp_test1.cc:40
enum_mysql_timestamp_type
Definition: mysql_time.h:45
@ MYSQL_TIMESTAMP_TIME
Stores hour, minute, second and microsecond.
Definition: mysql_time.h:60
@ MYSQL_TIMESTAMP_NONE
Definition: mysql_time.h:46
enum monotonicity_info enum_monotonicity_info
const char * interval_names[]
Definition: item_timefunc.cc:2927
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:537
date_time_format
Definition: item_timefunc.h:1703
@ USA_FORMAT
Definition: item_timefunc.h:1704
@ JIS_FORMAT
Definition: item_timefunc.h:1705
@ INTERNAL_FORMAT
Definition: item_timefunc.h:1708
@ EUR_FORMAT
Definition: item_timefunc.h:1707
@ ISO_FORMAT
Definition: item_timefunc.h:1706
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:2036
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 int DATETIME_MAX_DECIMALS
Definition: my_time.h:134
constexpr const my_time_flags_t TIME_FUZZY_DATE
Allow zero day and zero month.
Definition: my_time.h:88
void datetime_to_time(MYSQL_TIME *ltime)
"Casts" MYSQL_TIME datetime to a MYSQL_TIME time.
Definition: my_time.h:563
unsigned int my_time_flags_t
Flags to str_to_datetime and number_to_datetime.
Definition: my_time.h:85
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:414
interval_type
Available interval types used in any statement.
Definition: my_time.h:439
@ INTERVAL_HOUR_SECOND
Definition: my_time.h:454
@ INTERVAL_MONTH
Definition: my_time.h:442
@ INTERVAL_HOUR_MICROSECOND
Definition: my_time.h:457
@ INTERVAL_MINUTE
Definition: my_time.h:446
@ INTERVAL_HOUR_MINUTE
Definition: my_time.h:453
@ INTERVAL_DAY
Definition: my_time.h:444
@ INTERVAL_MINUTE_MICROSECOND
Definition: my_time.h:458
@ INTERVAL_MINUTE_SECOND
Definition: my_time.h:455
@ INTERVAL_QUARTER
Definition: my_time.h:441
@ INTERVAL_YEAR
Definition: my_time.h:440
@ INTERVAL_DAY_MICROSECOND
Definition: my_time.h:456
@ INTERVAL_SECOND_MICROSECOND
Definition: my_time.h:459
@ INTERVAL_SECOND
Definition: my_time.h:447
@ INTERVAL_DAY_HOUR
Definition: my_time.h:450
@ INTERVAL_HOUR
Definition: my_time.h:445
@ INTERVAL_YEAR_MONTH
Definition: my_time.h:449
@ INTERVAL_DAY_SECOND
Definition: my_time.h:452
@ INTERVAL_MICROSECOND
Definition: my_time.h:448
@ INTERVAL_DAY_MINUTE
Definition: my_time.h:451
static int interval
Definition: mysqladmin.cc:72
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1078
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:197
@ VGS_CHECK_CONSTRAINT
Definition: field.h:471
@ VGS_GENERATED_COLUMN
Definition: field.h:469
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:486
const char * banned_function_name
the name of the function which is not allowed
Definition: item.h:500
Value_generator_source source
Definition: item.h:498
Representation of time formats.
Definition: sql_time.h:62
Struct representing a duration.
Definition: my_time.h:219
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:1435
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