CUBRID Engine  latest
tz_support.c File Reference
#include "config.h"
#include <assert.h>
#include "tz_support.h"
#include "db_date.h"
#include "environment_variable.h"
#include "chartype.h"
#include "error_manager.h"
#include <dlfcn.h>
#include <unistd.h>
#include "system_parameter.h"
#include "show_scan.h"
#include "authenticate.h"
#include "db.h"
#include "boot_sr.h"
#include "dbtype.h"
Include dependency graph for tz_support.c:

Go to the source code of this file.

Classes

struct  tz_decode_info
 

Macros

#define strlen(s1)   ((int) strlen(s1))
 
#define FULL_DATE(jul_date, time_sec)
 
#define TIME_OFFSET(is_utc, offset)   ((is_utc) ? (-offset) : (offset))
 
#define ABS(i)   ((i) >= 0 ? (i) : -(i))
 
#define TZ_INVALID_OFFSET   ((((23 * 60) + 59) * 60) + 59)
 
#define TZ_MIN_OFFSET   -12 * 3600
 
#define TZ_MAX_OFFSET   14 * 3600
 
#define MILLIS_IN_A_DAY   (long)(86400000) /* 24L * 60L * 60L * 1000 */
 
#define TZ_MASK_TZ_ID_FLAG   0xc0000000
 
#define TZ_BIT_SHIFT_TZ_ID_FLAG   30
 
#define TZ_OFFSET_MASK   0x3fffffff
 
#define SECONDS_IN_A_DAY   24 * 3600
 
#define TZ_GET_SYM_ADDR(lib, sym)   dlsym(lib, sym)
 
#define TZLIB_GET_ADDR(v, SYM_NAME, SYM_TYPE, lh)
 
#define TZLIB_GET_VAL(v, SYM_NAME, SYM_TYPE, lh)
 
#define APPLY_NEXT_OFF_RULE()
 
#define LEN_MIN_HOUR   6
 
#define LEN_MIN_HOUR_SEC   9
 

Typedefs

typedef struct tz_decode_info TZ_DECODE_INFO
 
typedef enum ds_search_direction DS_SEARCH_DIRECTION
 

Enumerations

enum  ds_search_direction { FORWARD = 0, BACKWARD = 1 }
 

Functions

static int tz_load_library (const char *lib_file, void **handle)
 
static int tz_load_data_from_lib (TZ_DATA *tzd, void *lib_handle)
 
static bool tz_get_leapsec_support (void)
 
static const TZ_REGIONtz_get_invalid_tz_region (void)
 
static DB_DATE tz_get_current_date (void)
 
static int tz_str_timezone_decode (const char *tz_str, const int tz_str_size, TZ_DECODE_INFO *tz_info, const char **tz_end)
 
static int tz_zone_info_to_str (const TZ_DECODE_INFO *tz_info, char *tz_str, const int tz_str_size)
 
static void tz_encode_tz_id (const TZ_DECODE_INFO *tz_info, TZ_ID *tz_id)
 
static void tz_encode_tz_region (const TZ_DECODE_INFO *tz_info, TZ_REGION *tz_region)
 
static void tz_decode_tz_id (const TZ_ID *tz_id, const bool is_full_decode, TZ_DECODE_INFO *tz_info)
 
static void tz_decode_tz_region (const TZ_REGION *tz_region, TZ_DECODE_INFO *tz_info)
 
static int tz_fast_find_ds_rule (const TZ_DATA *tzd, const TZ_DS_RULESET *ds_ruleset, const int src_julian_date, const int src_year, const int src_month, int *ds_rule_id)
 
static bool tz_check_ds_match_string (const TZ_OFFSET_RULE *off_rule, const TZ_DS_RULE *ds_rule, const char *ds_string, const char *default_abrev)
 
static int tz_datetime_utc_conv (const DB_DATETIME *src_dt, TZ_DECODE_INFO *tz_info, bool src_is_utc, bool only_tz_adjust, DB_DATETIME *dest_dt)
 
static int tz_conv_tz_datetime_w_zone_info (const DB_DATETIME *src_dt, const TZ_DECODE_INFO *src_zone_info_in, const TZ_DECODE_INFO *dest_zone_info_in, DB_DATETIME *dest_dt, TZ_DECODE_INFO *src_zone_info_out, TZ_DECODE_INFO *dest_zone_info_out)
 
static int tz_print_tz_offset (char *result, int tz_offset)
 
static int starts_with (const char *prefix, const char *str)
 
static int tz_get_zone_id_by_name (const char *name, const int name_size)
 
static void tz_timestamp_decode_leap_sec_adj (int timestamp, int *yearp, int *monthsp, int *dayp, int *hoursp, int *minutesp, int *secondsp)
 
static int tz_offset (const bool src_is_utc, const TZ_TIME_TYPE until_time_type, const int gmt_offset_sec, const int ds_save_time)
 
static int get_date_diff_from_ds_rule (const int src_julian_date, const int src_time_sec, const TZ_DS_RULE *ds_rule, const DS_SEARCH_DIRECTION direction, full_date_t *date_diff)
 
static int get_closest_ds_rule (const int src_julian_date, const int src_time_sec, const TZ_DS_RULESET *ds_ruleset, const TZ_DATA *tzd, const DS_SEARCH_DIRECTION direction)
 
static int get_saving_time_from_offset_rule (const TZ_OFFSET_RULE *offset_rule, const TZ_DATA *tzd, int *save_time)
 
static bool is_in_overlap_interval (const TZ_TIME_TYPE time_type, const full_date_t offset_rule_diff, const full_date_t gmt_diff, const int save_time_diff)
 
static int get_year_to_apply_rule (const int src_year, const TZ_DS_RULE *ds_rule)
 
static int set_new_zone_id (TZ_DECODE_INFO *tz_info)
 
int tz_load (void)
 
void tz_unload (void)
 
DB_BIGINT tz_timestamp_encode_leap_sec_adj (const int year_century, const int year, const int mon, const int day)
 
void tz_timestamp_decode_sec (int timestamp, int *yearp, int *monthsp, int *dayp, int *hoursp, int *minutesp, int *secondsp)
 
void tz_timestamp_decode_no_leap_sec (int timestamp, int *yearp, int *monthsp, int *dayp, int *hoursp, int *minutesp, int *secondsp)
 
const TZ_DATAtz_get_data (void)
 
void tz_set_data (const TZ_DATA *data)
 
const TZ_DATAtz_get_new_timezone_data (void)
 
void tz_set_new_timezone_data (const TZ_DATA *data)
 
const char * tz_get_session_local_timezone (void)
 
const char * tz_get_system_timezone (void)
 
void tz_get_system_tz_region (TZ_REGION *tz_region)
 
void tz_get_session_tz_region (TZ_REGION *tz_region)
 
void tz_id_to_region (const TZ_ID *tz_id, TZ_REGION *tz_region)
 
const TZ_IDtz_get_utc_tz_id (void)
 
const TZ_REGIONtz_get_utc_tz_region (void)
 
int tz_get_timezone_offset (const char *tz_str, int tz_size, char *result, DB_DATETIME *utc_datetime)
 
int tz_create_session_tzid_for_datetime (const DB_DATETIME *src_dt, bool src_is_utc, TZ_ID *tz_id)
 
int tz_create_session_tzid_for_timestamp (const DB_UTIME *src_ts, TZ_ID *tz_id)
 
int tz_create_session_tzid_for_time (const DB_TIME *src_time, bool src_is_utc, TZ_ID *tz_id)
 
int tz_str_to_region (const char *tz_str, const int tz_str_size, TZ_REGION *tz_region)
 
int tz_create_datetimetz (const DB_DATETIME *dt, const char *tz_str, const int tz_size, const TZ_REGION *default_tz_region, DB_DATETIMETZ *dt_tz, const char **end_tz_str)
 
int tz_create_timestamptz (const DB_DATE *date, const DB_TIME *time, const char *tz_str, const int tz_size, const TZ_REGION *default_tz_region, DB_TIMESTAMPTZ *ts_tz, const char **end_tz_str)
 
int tz_create_datetimetz_from_ses (const DB_DATETIME *dt, DB_DATETIMETZ *dt_tz)
 
int tz_conv_tz_time_w_zone_name (const DB_TIME *time_source, const char *source_zone, int len_source, const char *dest_zone, int len_dest, DB_TIME *time_dest)
 
int tz_utc_datetimetz_to_local (const DB_DATETIME *dt_utc, const TZ_ID *tz_id, DB_DATETIME *dt_local)
 
int tz_datetimeltz_to_local (const DB_DATETIME *dt_ltz, DB_DATETIME *dt_local)
 
int tz_id_to_str (const TZ_ID *tz_id, char *tz_str, const int tz_str_size)
 
int tz_datetimetz_fix_zone (const DB_DATETIMETZ *src_dt_tz, DB_DATETIMETZ *dest_dt_tz)
 
int tz_timestamptz_fix_zone (const DB_TIMESTAMPTZ *src_ts_tz, DB_TIMESTAMPTZ *dest_ts_tz)
 
int tz_get_first_weekday_around_date (const int year, const int month, const int weekday, const int ref_day, const bool before)
 
int tz_str_read_number (const char *str, const char *str_end, const bool strict, const bool read_sign, int *val, const char **str_next)
 
int tz_str_read_time (const char *str, const char *str_end, bool need_minutes, bool allow_sec60, int *hour, int *min, int *sec, const char **str_next)
 
int tz_str_to_seconds (const char *str, const char *str_end, int *seconds, const char **str_next, const bool is_offset)
 
int tz_get_ds_change_julian_date_diff (const int src_julian_date, const TZ_DS_RULE *ds_rule, const int year, int *ds_rule_julian_date, full_date_t *date_diff)
 
int tz_conv_tz_datetime_w_region (const DB_DATETIME *src_dt, const TZ_REGION *src_tz_region, const TZ_REGION *dest_tz_region, DB_DATETIME *dest_dt, TZ_ID *src_tz_id_out, TZ_ID *dest_tz_id_out)
 
int tz_conv_tz_datetime_w_zone_name (const DB_DATETIME *src_dt, const char *source_zone, int len_source, const char *dest_zone, int len_dest, DB_DATETIME *dest_dt)
 
int tz_explain_tz_id (const TZ_ID *tz_id, char *tzr, const int tzr_size, char *tzdst, const int tzdst_size, int *tzh, int *tzm)
 
int tz_create_datetimetz_from_offset (const DB_DATETIME *dt, const int tzh, const int tzm, DB_DATETIMETZ *dt_tz)
 
int tz_create_timestamptz_from_offset (const DB_DATE *date, const DB_TIME *time, const int tzh, const int tzm, DB_TIMESTAMPTZ *timestamp_tz)
 
int tz_get_best_match_zone (const char *name, int *size)
 
int tz_create_datetimetz_from_zoneid_and_tzd (const DB_DATETIME *dt, TZ_REGION *default_tz_region, const int zone_id, const char *tzd, const int tzd_len, bool is_time_tz, DB_DATETIMETZ *dt_tz)
 
int tz_create_timestamptz_from_zoneid_and_tzd (const DB_DATE *date, const DB_TIME *time, TZ_REGION *default_tz_region, const int zone_id, const char *tzd, const int tzd_len, DB_TIMESTAMPTZ *timestamp_tz)
 
int tz_resolve_os_timezone (char *timezone, int buf_len)
 
void tz_set_tz_region_system (const TZ_REGION *tz_region)
 
TZ_REGIONtz_get_client_tz_region_session (void)
 
int tz_timezones_start_scan (THREAD_ENTRY *thread_p, int show_type, DB_VALUE **arg_values, int arg_cnt, void **ptr)
 
int tz_full_timezones_start_scan (THREAD_ENTRY *thread_p, int show_type, DB_VALUE **arg_values, int arg_cnt, void **ptr)
 
int tz_load_with_library_path (TZ_DATA *tzd, const char *timezone_library_path)
 
int tz_check_geographic_tz (const TZ_ID *tz_id)
 
int tz_check_session_has_geographic_tz (void)
 
int put_timezone_checksum (char *checksum)
 
int check_timezone_compat (const char *client_checksum, const char *server_checksum, const char *client_text, const char *server_text)
 
void tz_tzid_convert_region_to_offset (TZ_ID *tz_id)
 
int tz_create_datetimetz_from_utc (const DB_DATETIME *src_dt, const TZ_REGION *dest_region, DB_DATETIMETZ *dest_dt_tz)
 
int tz_create_datetimetz_from_parts (const int m, const int d, const int y, const int h, const int mi, const int s, const int ms, const TZ_ID *tz_id, DB_DATETIMETZ *dt_tz)
 
int conv_tz (void *p_out, const void *p_in, DB_TYPE type)
 
int tz_get_offset_in_mins ()
 

Variables

static int tz_Initialized = 0
 
static TZ_REGION tz_Region_system
 
static TZ_REGION tz_Region_session
 
static void * tz_Lib_handle = NULL
 
static TZ_DATA tz_Timezone_data = { 0, NULL, 0, NULL, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, {'0'} }
 
static TZ_DATA tz_New_timezone_data = { 0, NULL, 0, NULL, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, {'0'} }
 
static const int tz_Days_of_month [] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
 
static const int tz_Days_up_to_month [] = { 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }
 

Macro Definition Documentation

#define ABS (   i)    ((i) >= 0 ? (i) : -(i))

Definition at line 90 of file tz_support.c.

Referenced by is_in_overlap_interval(), and tz_datetime_utc_conv().

#define APPLY_NEXT_OFF_RULE ( )
Value:
do { \
prev_off_rule = curr_off_rule; \
curr_off_rule = next_off_rule; \
next_off_rule = offset_rules[offset_rule_counter++]; \
curr_offset_id++; \
} while (0)

Definition at line 204 of file tz_support.c.

Referenced by tz_datetime_utc_conv().

#define FULL_DATE (   jul_date,
  time_sec 
)
Value:
((full_date_t) jul_date * 86400ll \
+ (full_date_t) time_sec)
DB_BIGINT full_date_t
Definition: tz_support.h:125

Definition at line 86 of file tz_support.c.

Referenced by get_date_diff_from_ds_rule(), tz_datetime_utc_conv(), tz_fast_find_ds_rule(), and tz_get_ds_change_julian_date_diff().

#define LEN_MIN_HOUR   6

Referenced by tz_explain_tz_id().

#define LEN_MIN_HOUR_SEC   9

Referenced by tz_explain_tz_id().

#define MILLIS_IN_A_DAY   (long)(86400000) /* 24L * 60L * 60L * 1000 */

Definition at line 95 of file tz_support.c.

Referenced by tz_datetime_utc_conv().

#define SECONDS_IN_A_DAY   24 * 3600

Definition at line 99 of file tz_support.c.

Referenced by tz_datetime_utc_conv().

#define strlen (   s1)    ((int) strlen(s1))
#define TIME_OFFSET (   is_utc,
  offset 
)    ((is_utc) ? (-offset) : (offset))

Definition at line 88 of file tz_support.c.

Referenced by tz_datetime_utc_conv().

#define TZ_BIT_SHIFT_TZ_ID_FLAG   30

Definition at line 97 of file tz_support.c.

Referenced by tz_decode_tz_id(), and tz_tzid_convert_region_to_offset().

#define TZ_GET_SYM_ADDR (   lib,
  sym 
)    dlsym(lib, sym)

Definition at line 183 of file tz_support.c.

#define TZ_INVALID_OFFSET   ((((23 * 60) + 59) * 60) + 59)
#define TZ_MASK_TZ_ID_FLAG   0xc0000000

Definition at line 96 of file tz_support.c.

Referenced by tz_decode_tz_id(), and tz_tzid_convert_region_to_offset().

#define TZ_MAX_OFFSET   14 * 3600
#define TZ_MIN_OFFSET   -12 * 3600
#define TZ_OFFSET_MASK   0x3fffffff

Definition at line 98 of file tz_support.c.

Referenced by tz_decode_tz_id(), and tz_encode_tz_id().

#define TZLIB_GET_ADDR (   v,
  SYM_NAME,
  SYM_TYPE,
  lh 
)
Value:
do { \
v = (SYM_TYPE) TZ_GET_SYM_ADDR (lh, SYM_NAME); \
if (v == NULL) \
{ \
strncpy (sym_name, (SYM_NAME), sizeof (sym_name) - 1); \
sym_name[sizeof (sym_name) - 1] = '\0'; \
goto error_loading_symbol; \
} \
} while (0)
#define TZ_GET_SYM_ADDR(lib, sym)
Definition: tz_support.c:183
#define NULL
Definition: freelistheap.h:34
if(extra_options)
Definition: dynamic_load.c:958

Definition at line 186 of file tz_support.c.

Referenced by tz_load_data_from_lib().

#define TZLIB_GET_VAL (   v,
  SYM_NAME,
  SYM_TYPE,
  lh 
)
Value:
do { \
SYM_TYPE* aux; \
TZLIB_GET_ADDR(aux, SYM_NAME, SYM_TYPE*, lh); \
v = *aux; \
} while (0)
#define TZLIB_GET_ADDR(v, SYM_NAME, SYM_TYPE, lh)
Definition: tz_support.c:186

Definition at line 197 of file tz_support.c.

Referenced by tz_load_data_from_lib().

Typedef Documentation

Definition at line 83 of file tz_support.c.

Definition at line 56 of file tz_support.c.

Enumeration Type Documentation

Enumerator
FORWARD 
BACKWARD 

Definition at line 78 of file tz_support.c.

Function Documentation

int check_timezone_compat ( const char *  client_checksum,
const char *  server_checksum,
const char *  client_text,
const char *  server_text 
)

Definition at line 5043 of file tz_support.c.

References ARG_FILE_LINE, assert, ER_ERROR_SEVERITY, er_set(), ER_TZ_INCOMPATIBLE_TIMEZONE_LIBRARIES, NO_ERROR, and NULL.

Referenced by boot_restart_server(), and boot_set_server_session_key().

Here is the caller graph for this function:

static int get_closest_ds_rule ( const int  src_julian_date,
const int  src_time_sec,
const TZ_DS_RULESET ds_ruleset,
const TZ_DATA tzd,
const DS_SEARCH_DIRECTION  direction 
)
static

Definition at line 2648 of file tz_support.c.

References tz_ds_ruleset::count, tz_data::ds_rules, FORWARD, get_date_diff_from_ds_rule(), tz_ds_ruleset::index_start, NO_ERROR, and tz_ds_rule::save_time.

Referenced by tz_datetime_utc_conv().

Here is the caller graph for this function:

static int get_date_diff_from_ds_rule ( const int  src_julian_date,
const int  src_time_sec,
const TZ_DS_RULE ds_rule,
const DS_SEARCH_DIRECTION  direction,
full_date_t date_diff 
)
static

Definition at line 2601 of file tz_support.c.

References tz_ds_rule::at_time, FORWARD, tz_ds_rule::from_year, FULL_DATE, NO_ERROR, NULL, tz_ds_rule::to_year, and tz_get_ds_change_julian_date_diff().

Referenced by get_closest_ds_rule().

Here is the caller graph for this function:

static int get_saving_time_from_offset_rule ( const TZ_OFFSET_RULE offset_rule,
const TZ_DATA tzd,
int *  save_time 
)
static
static int get_year_to_apply_rule ( const int  src_year,
const TZ_DS_RULE ds_rule 
)
static

Definition at line 2777 of file tz_support.c.

References tz_ds_rule::from_year.

Referenced by tz_datetime_utc_conv(), and tz_fast_find_ds_rule().

Here is the caller graph for this function:

static bool is_in_overlap_interval ( const TZ_TIME_TYPE  time_type,
const full_date_t  offset_rule_diff,
const full_date_t  gmt_diff,
const int  save_time_diff 
)
static

Definition at line 2744 of file tz_support.c.

References ABS, TZ_TIME_TYPE_LOCAL_STD, and TZ_TIME_TYPE_UTC.

Referenced by tz_datetime_utc_conv().

Here is the caller graph for this function:

int put_timezone_checksum ( char *  checksum)

Definition at line 5017 of file tz_support.c.

References AU_DISABLE, AU_ENABLE, Au_root, db_make_string(), db_put_internal(), and NO_ERROR.

Referenced by createdb(), and gen_tz().

Here is the caller graph for this function:

static int set_new_zone_id ( TZ_DECODE_INFO tz_info)
static

Definition at line 5177 of file tz_support.c.

References ER_TZ_INVALID_TIMEZONE, tz_name::name, tz_data::names, NO_ERROR, NULL, strlen, tz_get_new_timezone_data(), tz_get_zone_id_by_name(), tz_set_data(), and tz_decode_info::zone.

Referenced by conv_tz().

Here is the caller graph for this function:

static int starts_with ( const char *  prefix,
const char *  str 
)
static

Definition at line 4349 of file tz_support.c.

References assert, error(), NULL, p, tz_get_data(), and tz_decode_info::zone.

Referenced by tz_get_best_match_zone().

Here is the caller graph for this function:

static bool tz_check_ds_match_string ( const TZ_OFFSET_RULE off_rule,
const TZ_DS_RULE ds_rule,
const char *  ds_string,
const char *  default_abrev 
)
static
int tz_check_geographic_tz ( const TZ_ID tz_id)
int tz_check_session_has_geographic_tz ( void  )
int tz_conv_tz_datetime_w_region ( const DB_DATETIME src_dt,
const TZ_REGION src_tz_region,
const TZ_REGION dest_tz_region,
DB_DATETIME dest_dt,
TZ_ID src_tz_id_out,
TZ_ID dest_tz_id_out 
)
static int tz_conv_tz_datetime_w_zone_info ( const DB_DATETIME src_dt,
const TZ_DECODE_INFO src_zone_info_in,
const TZ_DECODE_INFO dest_zone_info_in,
DB_DATETIME dest_dt,
TZ_DECODE_INFO src_zone_info_out,
TZ_DECODE_INFO dest_zone_info_out 
)
static
int tz_conv_tz_datetime_w_zone_name ( const DB_DATETIME src_dt,
const char *  source_zone,
int  len_source,
const char *  dest_zone,
int  len_dest,
DB_DATETIME dest_dt 
)

Definition at line 3858 of file tz_support.c.

References NO_ERROR, NULL, tz_conv_tz_datetime_w_region(), and tz_str_to_region().

Referenced by db_new_time().

Here is the caller graph for this function:

int tz_conv_tz_time_w_zone_name ( const DB_TIME time_source,
const char *  source_zone,
int  len_source,
const char *  dest_zone,
int  len_dest,
DB_TIME time_dest 
)
int tz_create_datetimetz ( const DB_DATETIME dt,
const char *  tz_str,
const int  tz_size,
const TZ_REGION default_tz_region,
DB_DATETIMETZ dt_tz,
const char **  end_tz_str 
)
int tz_create_datetimetz_from_offset ( const DB_DATETIME dt,
const int  tzh,
const int  tzm,
DB_DATETIMETZ dt_tz 
)
int tz_create_datetimetz_from_parts ( const int  m,
const int  d,
const int  y,
const int  h,
const int  mi,
const int  s,
const int  ms,
const TZ_ID tz_id,
DB_DATETIMETZ dt_tz 
)
int tz_create_datetimetz_from_utc ( const DB_DATETIME src_dt,
const TZ_REGION dest_region,
DB_DATETIMETZ dest_dt_tz 
)

Definition at line 5104 of file tz_support.c.

References db_datetimetz::datetime, NO_ERROR, tz_datetime_utc_conv(), tz_decode_tz_region(), tz_encode_tz_id(), and db_datetimetz::tz_id.

Referenced by tz_create_datetimetz_from_parts().

Here is the caller graph for this function:

int tz_create_datetimetz_from_zoneid_and_tzd ( const DB_DATETIME dt,
TZ_REGION default_tz_region,
const int  zone_id,
const char *  tzd,
const int  tzd_len,
bool  is_time_tz,
DB_DATETIMETZ dt_tz 
)
int tz_create_session_tzid_for_time ( const DB_TIME src_time,
bool  src_is_utc,
TZ_ID tz_id 
)

Definition at line 1091 of file tz_support.c.

References db_datetime::date, db_datetime::time, tz_create_session_tzid_for_datetime(), and tz_get_current_date().

Referenced by date_to_char(), and db_time_format().

Here is the caller graph for this function:

int tz_create_timestamptz ( const DB_DATE date,
const DB_TIME time,
const char *  tz_str,
const int  tz_size,
const TZ_REGION default_tz_region,
DB_TIMESTAMPTZ ts_tz,
const char **  end_tz_str 
)
int tz_create_timestamptz_from_offset ( const DB_DATE date,
const DB_TIME time,
const int  tzh,
const int  tzm,
DB_TIMESTAMPTZ timestamp_tz 
)
int tz_create_timestamptz_from_zoneid_and_tzd ( const DB_DATE date,
const DB_TIME time,
TZ_REGION default_tz_region,
const int  zone_id,
const char *  tzd,
const int  tzd_len,
DB_TIMESTAMPTZ timestamp_tz 
)
static int tz_datetime_utc_conv ( const DB_DATETIME src_dt,
TZ_DECODE_INFO tz_info,
bool  src_is_utc,
bool  only_tz_adjust,
DB_DATETIME dest_dt 
)
static

Definition at line 2815 of file tz_support.c.

References ABS, APPLY_NEXT_OFF_RULE, ARG_FILE_LINE, assert, tz_ds_rule::at_time, tz_ds_rule::at_time_type, BACKWARD, BO_IS_SERVER_RESTARTED, tz_ds_ruleset::count, db_datetime::date, DATE_DIFF_MATCH_SAFE_THRESHOLD_DAYS, DATE_DIFF_MATCH_SAFE_THRESHOLD_SEC, db_add_int_to_datetime(), tz_ds_ruleset::default_abrev, diff, tz_data::ds_rule_count, tz_data::ds_rules, tz_offset_rule::ds_ruleset, tz_data::ds_ruleset_count, tz_data::ds_rulesets, tz_offset_rule::ds_type, DS_TYPE_FIXED, DS_TYPE_RULESET_ID, ER_ERROR_SEVERITY, er_set(), ER_TIME_CONVERSION, ER_TZ_DURING_DS_LEAP, ER_TZ_DURING_OFFSET_RULE_LEAP, ER_TZ_INTERNAL_ERROR, ER_TZ_INVALID_COMBINATION, ER_TZ_INVALID_DST, FORWARD, tz_ds_rule::from_year, FULL_DATE, get_closest_ds_rule(), get_saving_time_from_offset_rule(), get_year_to_apply_rule(), tz_offset_rule::gmt_off, tz_timezone::gmt_off_rule_count, tz_timezone::gmt_off_rule_start, tz_ds_rule::in_month, tz_ds_ruleset::index_start, is_in_overlap_interval(), tz_offset_rule::julian_date, julian_decode(), MILLIS_IN_A_DAY, tz_data::name_count, tz_data::names, NO_ERROR, NULL, tz_decode_info::offset, tz_data::offset_rule_count, tz_data::offset_rules, tz_offset_rule::save_format, tz_ds_rule::save_time, SECONDS_IN_A_DAY, tz_offset_rule::std_format, db_datetime::time, TIME_OFFSET, tz_data::timezones, tz_ds_rule::to_year, tz_ds_ruleset::to_year_max, tz_decode_info::type, tz_check_ds_match_string(), tz_fast_find_ds_rule(), tz_get_data(), tz_get_ds_change_julian_date_diff(), TZ_INVALID_OFFSET, TZ_MAX_JULIAN_DATE, TZ_MON_DEC, TZ_MON_JAN, tz_offset(), TZ_REGION_OFFSET, TZ_REGION_ZONE, TZ_TIME_TYPE_LOCAL_STD, TZ_TIME_TYPE_LOCAL_WALL, TZ_TIME_TYPE_UTC, UNTIL_EXPLICIT, tz_offset_rule::until_flag, tz_offset_rule::until_hour, UNTIL_INFINITE, tz_offset_rule::until_min, tz_offset_rule::until_sec, tz_offset_rule::until_time_type, tz_offset_rule::var_format, tz_decode_info::zone, and tz_name::zone_id.

Referenced by conv_tz(), tz_conv_tz_datetime_w_zone_info(), tz_create_datetimetz(), tz_create_datetimetz_from_offset(), tz_create_datetimetz_from_ses(), tz_create_datetimetz_from_utc(), tz_create_datetimetz_from_zoneid_and_tzd(), tz_create_session_tzid_for_datetime(), tz_create_timestamptz(), tz_create_timestamptz_from_offset(), tz_create_timestamptz_from_zoneid_and_tzd(), tz_datetimetz_fix_zone(), tz_full_timezones_start_scan(), and tz_get_timezone_offset().

Here is the caller graph for this function:

static void tz_encode_tz_region ( const TZ_DECODE_INFO tz_info,
TZ_REGION tz_region 
)
static

Definition at line 1932 of file tz_support.c.

References assert, tz_decode_info::offset, tz_region::offset, tz_decode_info::type, tz_region::type, TZ_REGION_OFFSET, TZ_ZONE_ID_MAX, tz_decode_info::zone, and tz_region::zone_id.

Referenced by tz_id_to_region().

Here is the caller graph for this function:

static int tz_fast_find_ds_rule ( const TZ_DATA tzd,
const TZ_DS_RULESET ds_ruleset,
const int  src_julian_date,
const int  src_year,
const int  src_month,
int *  ds_rule_id 
)
static
int tz_get_best_match_zone ( const char *  name,
int *  size 
)

Definition at line 4157 of file tz_support.c.

References assert, tz_name::name, tz_data::name_count, tz_data::names, NULL, starts_with(), strlen, and tz_get_data().

Referenced by db_str_to_date(), db_to_datetime(), db_to_time(), and db_to_timestamp().

Here is the caller graph for this function:

TZ_REGION* tz_get_client_tz_region_session ( void  )
static DB_DATE tz_get_current_date ( void  )
static

Definition at line 852 of file tz_support.c.

References db_datetime::date, db_datetime_encode(), and NULL.

Referenced by tz_conv_tz_time_w_zone_name(), and tz_create_session_tzid_for_time().

Here is the caller graph for this function:

int tz_get_first_weekday_around_date ( const int  year,
const int  month,
const int  weekday,
const int  ref_day,
const bool  before 
)
static const TZ_REGION * tz_get_invalid_tz_region ( void  )
static

Definition at line 840 of file tz_support.c.

References TZ_INVALID_OFFSET, and TZ_REGION_OFFSET.

Referenced by tz_get_session_tz_region().

Here is the caller graph for this function:

static bool tz_get_leapsec_support ( void  )
static

Definition at line 402 of file tz_support.c.

References prm_get_bool_value(), and PRM_ID_TZ_LEAP_SECOND_SUPPORT.

Referenced by tz_timestamp_decode_sec(), and tz_timestamp_encode_leap_sec_adj().

Here is the caller graph for this function:

const TZ_DATA* tz_get_new_timezone_data ( void  )

Definition at line 713 of file tz_support.c.

References NULL, tz_data::timezone_count, and tz_New_timezone_data.

Referenced by set_new_zone_id().

Here is the caller graph for this function:

int tz_get_offset_in_mins ( )

Definition at line 5480 of file tz_support.c.

Referenced by db_sys_timezone().

Here is the caller graph for this function:

const char* tz_get_session_local_timezone ( void  )

Definition at line 739 of file tz_support.c.

References prm_get_string_value(), and PRM_ID_TIMEZONE.

Referenced by do_evaluate_default_expr(), fetch_peek_arith(), pt_evaluate_db_value_expr(), and qexec_execute_insert().

Here is the caller graph for this function:

const char* tz_get_system_timezone ( void  )

Definition at line 749 of file tz_support.c.

References prm_get_string_value(), and PRM_ID_SERVER_TIMEZONE.

Referenced by do_evaluate_default_expr(), fetch_peek_arith(), pt_evaluate_db_value_expr(), qexec_execute_insert(), and sysprm_make_default_values().

Here is the caller graph for this function:

void tz_get_system_tz_region ( TZ_REGION tz_region)

Definition at line 758 of file tz_support.c.

References tz_Region_system.

Referenced by db_timestamp_encode_sys(), do_evaluate_default_expr(), fetch_peek_arith(), pt_evaluate_db_value_expr(), and qexec_execute_insert().

Here is the caller graph for this function:

int tz_get_timezone_offset ( const char *  tz_str,
int  tz_size,
char *  result,
DB_DATETIME utc_datetime 
)
const TZ_ID* tz_get_utc_tz_id ( void  )

Definition at line 816 of file tz_support.c.

Referenced by db_timestamp_encode_w_reg(), db_value_domain_default(), db_value_domain_max(), db_value_domain_min(), and tp_value_coerce_strict().

Here is the caller graph for this function:

const TZ_REGION* tz_get_utc_tz_region ( void  )

Definition at line 828 of file tz_support.c.

References TZ_REGION_OFFSET.

Referenced by db_timestamp_decode_w_reg(), and db_timestamp_encode_w_reg().

Here is the caller graph for this function:

static int tz_get_zone_id_by_name ( const char *  name,
const int  name_size 
)
static

Definition at line 1109 of file tz_support.c.

References assert, tz_name::name, tz_data::name_count, tz_data::names, NULL, strlen, and tz_get_data().

Referenced by set_new_zone_id(), tz_get_timezone_offset(), tz_resolve_os_timezone(), tz_str_timezone_decode(), and tz_str_to_region().

Here is the caller graph for this function:

void tz_id_to_region ( const TZ_ID tz_id,
TZ_REGION tz_region 
)

Definition at line 803 of file tz_support.c.

References tz_decode_tz_id(), and tz_encode_tz_region().

Referenced by db_date_add_sub_interval_expr().

Here is the caller graph for this function:

int tz_id_to_str ( const TZ_ID tz_id,
char *  tz_str,
const int  tz_str_size 
)

Definition at line 1789 of file tz_support.c.

References tz_decode_tz_id(), and tz_zone_info_to_str().

Referenced by db_datetimetz_to_string(), db_timestamptz_to_string(), and dbval_to_net_buf().

Here is the caller graph for this function:

static int tz_load_library ( const char *  lib_file,
void **  handle 
)
static

Definition at line 220 of file tz_support.c.

References ARG_FILE_LINE, assert, ER_ERROR_SEVERITY, er_set(), ER_TZ_LOAD_ERROR, error(), NO_ERROR, NULL, and snprintf_dots_truncate.

Referenced by tz_load(), and tz_load_with_library_path().

Here is the caller graph for this function:

int tz_load_with_library_path ( TZ_DATA tzd,
const char *  timezone_library_path 
)

Definition at line 4937 of file tz_support.c.

References ARG_FILE_LINE, assert, er_errid(), ER_ERROR_SEVERITY, er_set(), ER_TZ_LOAD_ERROR, NO_ERROR, NULL, tz_Lib_handle, tz_load_data_from_lib(), and tz_load_library().

Referenced by init_tz_name().

Here is the caller graph for this function:

static int tz_offset ( const bool  src_is_utc,
const TZ_TIME_TYPE  until_time_type,
const int  gmt_offset_sec,
const int  ds_save_time 
)
static

Definition at line 2559 of file tz_support.c.

References tz_decode_info::offset, TZ_TIME_TYPE_LOCAL_STD, TZ_TIME_TYPE_LOCAL_WALL, and TZ_TIME_TYPE_UTC.

Referenced by tz_datetime_utc_conv(), and tz_print_tz_offset().

Here is the caller graph for this function:

static int tz_print_tz_offset ( char *  result,
int  tz_offset 
)
static

Definition at line 884 of file tz_support.c.

References assert, ER_FAILED, NO_ERROR, and tz_offset().

Referenced by tz_full_timezones_start_scan(), and tz_get_timezone_offset().

Here is the caller graph for this function:

int tz_resolve_os_timezone ( char *  timezone,
int  buf_len 
)

Definition at line 4588 of file tz_support.c.

References NULL, strlen, tz_data::timezone_names, tz_get_data(), and tz_get_zone_id_by_name().

Referenced by sysprm_final().

Here is the caller graph for this function:

void tz_set_data ( const TZ_DATA data)

Definition at line 702 of file tz_support.c.

Referenced by conv_tz(), and set_new_zone_id().

Here is the caller graph for this function:

void tz_set_new_timezone_data ( const TZ_DATA data)

Definition at line 729 of file tz_support.c.

Referenced by tzc_compute_timezone_checksum().

Here is the caller graph for this function:

void tz_set_tz_region_system ( const TZ_REGION tz_region)

Definition at line 4650 of file tz_support.c.

Referenced by prm_load_by_section(), and sysprm_set_value().

Here is the caller graph for this function:

int tz_str_read_number ( const char *  str,
const char *  str_end,
const bool  strict,
const bool  read_sign,
int *  val,
const char **  str_next 
)

Definition at line 2130 of file tz_support.c.

References assert, char_isdigit(), ER_FAILED, IS_EMPTY_STR, and NO_ERROR.

Referenced by str_read_day_var(), str_to_offset_rule_until(), tz_str_read_time(), tzc_add_ds_rule(), tzc_add_offset_rule(), and tzc_load_leap_secs().

Here is the caller graph for this function:

int tz_str_read_time ( const char *  str,
const char *  str_end,
bool  need_minutes,
bool  allow_sec60,
int *  hour,
int *  min,
int *  sec,
const char **  str_next 
)

Definition at line 2186 of file tz_support.c.

References assert, ER_FAILED, IS_EMPTY_STR, NO_ERROR, and tz_str_read_number().

Referenced by str_to_offset_rule_until(), tz_str_to_seconds(), and tzc_load_leap_secs().

Here is the caller graph for this function:

int tz_str_to_seconds ( const char *  str,
const char *  str_end,
int *  seconds,
const char **  str_next,
const bool  is_offset 
)
static void tz_timestamp_decode_leap_sec_adj ( int  timestamp,
int *  yearp,
int *  monthsp,
int *  dayp,
int *  hoursp,
int *  minutesp,
int *  secondsp 
)
static
void tz_timestamp_decode_no_leap_sec ( int  timestamp,
int *  yearp,
int *  monthsp,
int *  dayp,
int *  hoursp,
int *  minutesp,
int *  secondsp 
)

Definition at line 601 of file tz_support.c.

References IS_LEAP_YEAR, tz_Days_of_month, tz_Days_up_to_month, TZ_MON_FEB, and TZ_MON_JAN.

Referenced by fetch_peek_arith(), pt_evaluate_db_value_expr(), tz_full_timezones_start_scan(), and tz_timestamp_decode_sec().

Here is the caller graph for this function:

void tz_timestamp_decode_sec ( int  timestamp,
int *  yearp,
int *  monthsp,
int *  dayp,
int *  hoursp,
int *  minutesp,
int *  secondsp 
)

Definition at line 458 of file tz_support.c.

References tz_get_leapsec_support(), tz_timestamp_decode_leap_sec_adj(), and tz_timestamp_decode_no_leap_sec().

Referenced by db_timestamp_decode_utc().

Here is the caller graph for this function:

DB_BIGINT tz_timestamp_encode_leap_sec_adj ( const int  year_century,
const int  year,
const int  mon,
const int  day 
)

Definition at line 415 of file tz_support.c.

References tz_leap_sec::day, tz_data::ds_leap_sec, tz_data::ds_leap_sec_count, tz_leap_sec::month, NULL, tz_get_data(), tz_get_leapsec_support(), and tz_leap_sec::year.

Referenced by db_timestamp_encode_utc().

Here is the caller graph for this function:

int tz_timezones_start_scan ( THREAD_ENTRY thread_p,
int  show_type,
DB_VALUE **  arg_values,
int  arg_cnt,
void **  ptr 
)
void tz_unload ( void  )

Definition at line 381 of file tz_support.c.

References NULL, tz_Initialized, and tz_Lib_handle.

Referenced by boot_client_all_finalize(), boot_initialize_client(), boot_restart_client(), boot_server_all_finalize(), and dump_tz().

Here is the caller graph for this function:

Variable Documentation

const int tz_Days_of_month[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
static
const int tz_Days_up_to_month[] = { 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }
static

Definition at line 127 of file tz_support.c.

Referenced by tz_timestamp_decode_no_leap_sec().

int tz_Initialized = 0
static

Definition at line 101 of file tz_support.c.

Referenced by tz_load(), and tz_unload().

void* tz_Lib_handle = NULL
static

Definition at line 110 of file tz_support.c.

Referenced by tz_load(), tz_load_with_library_path(), and tz_unload().

TZ_DATA tz_New_timezone_data = { 0, NULL, 0, NULL, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, {'0'} }
static

Definition at line 123 of file tz_support.c.

Referenced by tz_get_new_timezone_data().

TZ_REGION tz_Region_session
static

Definition at line 104 of file tz_support.c.

Referenced by tz_get_client_tz_region_session().

TZ_REGION tz_Region_system
static
TZ_DATA tz_Timezone_data = { 0, NULL, 0, NULL, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, {'0'} }
static

Definition at line 120 of file tz_support.c.

Referenced by conv_tz(), and tz_get_data().