MySQL 9.0.0
Source Code Documentation
sql_time.h File Reference

Interface for server time utilities. More...

#include "my_config.h"
#include <stddef.h>
#include <sys/time.h>
#include <sys/types.h>
#include "field_types.h"
#include "lex_string.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_time.h"
#include "mysql/strings/m_ctype.h"
#include "mysql_time.h"
#include "sql/sql_error.h"
#include "sql_string.h"

Go to the source code of this file.

Classes

struct  Date_time_format
 Representation of time formats. More...
 
struct  Known_date_time_format
 Collection of strings describing date/time formats. More...
 
const LEX_CSTRING interval_type_to_name []
 Name description of interval names used in statements. More...
 
my_time_t TIME_to_timestamp (const MYSQL_TIME *t, const Time_zone &tz, bool *not_exist)
 
bool datetime_with_no_zero_in_date_to_timeval (const MYSQL_TIME *t, const Time_zone &tz, my_timeval *tm, int *warnings)
 Converts a datetime in MYSQL_TIME representation to corresponding struct timeval value. More...
 
bool datetime_to_timeval (const MYSQL_TIME *t, const Time_zone &tz, my_timeval *tm, int *warnings)
 Convert a datetime MYSQL_TIME representation to corresponding "struct timeval" value. More...
 
bool str_to_datetime_with_warn (String *str, MYSQL_TIME *l_time, my_time_flags_t flags)
 Convert a timestamp string to a MYSQL_TIME value and produce a warning if string was truncated during conversion. More...
 
bool decimal_to_datetime (const my_decimal *decimal, MYSQL_TIME *ltime, my_time_flags_t flags)
 Convert decimal value to datetime. More...
 
bool decimal_to_time (const my_decimal *decimal, MYSQL_TIME *ltime)
 Convert decimal number to TIME. More...
 
bool double_to_datetime (double nr, MYSQL_TIME *ltime, my_time_flags_t flags)
 Convert double value to datetime. More...
 
bool double_to_time (double nr, MYSQL_TIME *ltime)
 Convert double number to TIME. More...
 
bool my_decimal_to_datetime_with_warn (const my_decimal *decimal, MYSQL_TIME *ltime, my_time_flags_t flags)
 Convert decimal value to datetime value with a warning. More...
 
bool my_double_to_datetime_with_warn (double nr, MYSQL_TIME *ltime, my_time_flags_t flags)
 Convert double value to datetime value with a warning. More...
 
bool my_longlong_to_datetime_with_warn (longlong nr, MYSQL_TIME *ltime, my_time_flags_t flags)
 Convert longlong value to datetime value with a warning. More...
 
bool my_decimal_to_time_with_warn (const my_decimal *decimal, MYSQL_TIME *ltime)
 Convert decimal number to TIME. More...
 
bool my_double_to_time_with_warn (double nr, MYSQL_TIME *ltime)
 Convert double number to TIME. More...
 
bool my_longlong_to_time_with_warn (longlong nr, MYSQL_TIME *ltime)
 Convert longlong number to TIME. More...
 
bool str_to_time_with_warn (String *str, MYSQL_TIME *l_time)
 Convert a time string to a MYSQL_TIME struct and produce a warning if string was cut during conversion. More...
 
void time_to_datetime (THD *thd, const MYSQL_TIME *tm, const Time_zone &tz, MYSQL_TIME *dt)
 
void time_to_datetime (THD *thd, const MYSQL_TIME *in, MYSQL_TIME *out)
 Convert time to datetime. More...
 
bool make_truncated_value_warning (THD *thd, Sql_condition::enum_severity_level level, const ErrConvString &val, enum_mysql_timestamp_type time_type, const char *field_name)
 Create and add a truncated value warning to the THD. More...
 
const char * get_date_time_format_str (const Known_date_time_format *format, enum_mysql_timestamp_type type)
 Return format string according format name. More...
 
void make_date (const Date_time_format *format, const MYSQL_TIME *l_time, String *str)
 Convert DATE value to String. More...
 
void make_time (const Date_time_format *format, const MYSQL_TIME *l_time, String *str, uint dec)
 Convert TIME value to String. More...
 
void make_datetime (const Date_time_format *format, const MYSQL_TIME *l_time, String *str, uint dec)
 Convert DATETIME value to String. More...
 
bool my_TIME_to_str (const MYSQL_TIME *ltime, String *str, uint dec)
 Convert TIME/DATE/DATETIME value to String. More...
 
my_time_flags_t DatetimeConversionFlags (const THD *thd)
 Generate flags to use when converting a string to a date or datetime value. More...
 
void propagate_datetime_overflow_helper (THD *thd, int *warnings)
 Propagates a DATETIME_OVERFLOW warning from warnings bitfield to DA in thd. More...
 
template<class T >
propagate_datetime_overflow (THD *thd, int *warnings, T t)
 Wrapper function which will propagate any DATETIME_OVERFLOW warnings to the THD. More...
 
template<class CLOS >
auto propagate_datetime_overflow (THD *thd, CLOS &&clos)
 Wrapper function which will propagate any DATETIME_OVERFLOW warnings to the THD. More...
 
bool date_add_interval_with_warn (THD *, MYSQL_TIME *ltime, interval_type int_type, Interval interval)
 Uses propagate_datetime_overflow() to handle and propagate any warnings from date_add_interval() to the THD. More...
 
bool str_to_time (const CHARSET_INFO *cs, const char *str, size_t length, MYSQL_TIME *l_time, my_time_flags_t flags, MYSQL_TIME_STATUS *status)
 Character set-aware version of str_to_time(). More...
 
bool str_to_time (const String *str, MYSQL_TIME *ltime, my_time_flags_t flags, MYSQL_TIME_STATUS *status)
 Converts a time String value to MYSQL_TIME. More...
 
bool str_to_datetime (const CHARSET_INFO *cs, const char *str, size_t length, MYSQL_TIME *l_time, my_time_flags_t flags, MYSQL_TIME_STATUS *status)
 Character set-aware version of str_to_datetime(). More...
 
bool str_to_datetime (const String *str, MYSQL_TIME *ltime, my_time_flags_t flags, MYSQL_TIME_STATUS *status)
 Converts a datetime String value to MYSQL_TIME. More...
 
my_decimalmy_decimal_from_datetime_packed (my_decimal *dec, enum enum_field_types type, longlong packed_value)
 Unpack packed numeric temporal value to date/time value and then convert to decimal representation. More...
 
enum_mysql_timestamp_type field_type_to_timestamp_type (enum enum_field_types type)
 Return the timstamp value corresponding the field type passed as argument. More...
 
ulonglong gmt_time_to_local_time (ulonglong time)
 This function gets GMT time and adds value of time_zone to get the local time. More...
 
MYSQL_TIME my_time_set (uint y, uint m, uint d, uint h, uint mi, uint s, unsigned long ms, bool negative, enum_mysql_timestamp_type type)
 In lieu of a proper constructor for the C struct MYSQL_TIME, this method initializes the struct. More...
 
uint actual_decimals (const MYSQL_TIME *ts)
 Return the number of significant second fraction decimals in ts, e.g. More...
 
size_t max_fraction (uint decimals)
 For a time fraction with a given number of decimals, return maximum fraction, if any, can be are present in a time value. More...
 

Detailed Description

Interface for server time utilities.