![]() |
MySQL 9.5.0
Source Code Documentation
|
This file defines all time functions. More...
#include "sql/item_timefunc.h"#include <cstdint>#include "my_config.h"#include "sql/hash.h"#include <sys/time.h>#include <algorithm>#include <climits>#include <cstdio>#include <cstdlib>#include <cstring>#include "decimal.h"#include "lex_string.h"#include "my_compiler.h"#include "my_dbug.h"#include "my_sys.h"#include "my_systime.h"#include "mysql/strings/int2str.h"#include "mysql/strings/m_ctype.h"#include "mysql/strings/my_strtoll10.h"#include "mysql_com.h"#include "mysqld_error.h"#include "nulls.h"#include "sql-common/my_decimal.h"#include "sql/current_thd.h"#include "sql/dd/info_schema/table_stats.h"#include "sql/dd/object_id.h"#include "sql/derror.h"#include "sql/parse_tree_node_base.h"#include "sql/sql_class.h"#include "sql/sql_error.h"#include "sql/sql_lex.h"#include "sql/sql_locale.h"#include "sql/sql_time.h"#include "sql/strfunc.h"#include "sql/system_variables.h"#include "sql/table.h"#include "sql/tztime.h"#include "sql_string.h"#include "string_with_len.h"#include "strmake.h"#include "template_utils.h"#include "typelib.h"Classes | |
| struct | Temporal_val |
Enumerations | |
| enum class | Temporal_type { INVALID_VALUE = 0 , TIME_VALUE = 1 , DATE_VALUE = 2 , DATETIME_VALUE = 4 } |
| INVALID_VALUE - Temporal value could not be evaluated TIME_VALUE - Temporal value of type TIME was evaluated DATE_VALUE - Temporal value of type DATE was evaluated (UNUSED) DATETIME_VALUE - Temporal value of type DATE or DATETIME was evaluated. More... | |
Functions | |
| static bool | adjust_time_range_with_warn (MYSQL_TIME *ltime, uint8 decimals) |
| Check and adjust a time value with a warning. More... | |
| static bool | sec_to_time (lldiv_t seconds, Time_val *time) |
| Convert seconds to time value with overflow checking. More... | |
| static bool | extract_date_time (const Date_time_format *format, const char *val, size_t length, MYSQL_TIME *l_time, enum_mysql_timestamp_type cached_timestamp_type, const char **sub_pattern_end, const char *date_time_type, enum_field_types data_type, my_time_flags_t flags) |
| Extract datetime value to MYSQL_TIME struct from string value according to format string. More... | |
| 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. More... | |
| static bool | get_interval_info (Item *args, String *str_value, bool *is_negative, uint count, ulonglong *values, bool transform_msec) |
| static bool | eval_temporal (Item *item, my_time_flags_t flags, Temporal_val *val) |
| Get a "best fit" temporal value from an item, using data type of the item and possibly its value. More... | |
| static uint | week_mode (uint mode) |
| bool | get_interval_value (Item *args, interval_type int_type, String *str_value, Interval *interval) |
| Convert a string to a interval value. More... | |
| static bool | date_should_be_null (enum_field_types target_type, const MYSQL_TIME &time, my_time_flags_t fuzzy_date) |
| Determines whether this date should be NULL (and a warning raised) under the given sql_mode. More... | |
Variables | |
| static constexpr const Known_date_time_format | known_date_time_formats [6] |
| Array of known date_time formats. More... | |
| static const Date_time_format | time_ampm_format = {{0}, {"%I:%i:%S %p", 11}} |
| static const Date_time_format | time_24hrs_format = {{0}, {"%H:%i:%S", 8}} |
| const char * | interval_names [] |
This file defines all time functions.
|
strong |
INVALID_VALUE - Temporal value could not be evaluated TIME_VALUE - Temporal value of type TIME was evaluated DATE_VALUE - Temporal value of type DATE was evaluated (UNUSED) DATETIME_VALUE - Temporal value of type DATE or DATETIME was evaluated.
| Enumerator | |
|---|---|
| INVALID_VALUE | |
| TIME_VALUE | |
| DATE_VALUE | |
| DATETIME_VALUE | |
|
static |
Check and adjust a time value with a warning.
| ltime | Time variable. |
| decimals | Precision. |
| True | on error, false of success. |
|
static |
Determines whether this date should be NULL (and a warning raised) under the given sql_mode.
Zeroes are allowed in the date if the data type is TIME.
| target_type | The data type of the time/date. |
| time | Date and time data |
| fuzzy_date | What sql_mode dictates. |
|
static |
Get a "best fit" temporal value from an item, using data type of the item and possibly its value.
| [in] | item | An item to extract a temporal value from. |
| [in] | flags | Date flags. |
| [out] | val | Returned temporal value |
|
static |
Extract datetime value to MYSQL_TIME struct from string value according to format string.
| format | date/time format specification |
| val | String to decode |
| length | Length of string |
| l_time | Store result here |
| cached_timestamp_type | It uses to get an appropriate warning in the case when the value is truncated. |
| sub_pattern_end | if non-zero then we are parsing string which should correspond compound specifier (like T or r) and this parameter is pointer to place where pointer to end of string matching this specifier should be stored. |
| date_time_type | "time" or "datetime", used for the error/warning msg |
| data_type | Type of data |
| flags | flags used by check_date() |
| 0 | ok |
| 1 | error |
|
static |
Get a array of positive numbers from a string object. Each number is separated by 1 non digit character Return error if there is too many numbers. If there is too few numbers, assume that the numbers are left out from the high end. This allows one to give: DAY_TO_SECOND as "D MM:HH:SS", "MM:HH:SS" "HH:SS" or as seconds.
| args | item expression which we convert to an ASCII string |
| str_value | string buffer |
| is_negative | set to true if interval is prefixed by '-' |
| count | count of elements in result array |
| values | array of results |
| transform_msec | if value is true we suppose that the last part of string value is microseconds and we should transform value to six digit value. For example, '1.1' -> '1.100000' |
| bool get_interval_value | ( | Item * | args, |
| interval_type | int_type, | ||
| String * | str_value, | ||
| Interval * | interval | ||
| ) |
Convert a string to a interval value.
To make code easy, allow interval objects without separators.
| 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.
|
static |
Convert seconds to time value with overflow checking.
| seconds | number of seconds | |
| [out] | time | output time value |
If the 'seconds' argument is inside MYSQL_TIME data range, convert it to a corresponding value. Otherwise, truncate the resulting value to the nearest endpoint. Note: Truncation in this context means setting the result to the MAX/MIN value of TIME type if value is outside the allowed range. If the number of decimals exceeds what is supported, the value is rounded to the supported number of decimals.
|
static |
| const char* interval_names[] |
|
staticconstexpr |
Array of known date_time formats.
|
static |
|
static |