Commit 4fec99a2 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-29102 system_time_zone is incorrect on Windows when TZ is set

MDEV-19243 introduced a regression on Windows.

In (supposedly rare) case, where environment variable TZ was set,
@@system_time_zone no longer derives from TZ. Instead, it incorrecty
refers to system default time zone, eventhough UTC time conversion
takes TZ into account.

The fix is to restore TZ-aware handling (timezone name derives from
tzname), if TZ is set.
parent e8101a4d
......@@ -4303,14 +4303,24 @@ static int init_common_variables()
if (ignore_db_dirs_init())
exit(1);
struct tm tm_tmp;
localtime_r(&server_start_time, &tm_tmp);
#ifdef HAVE_TZNAME
#ifdef _WIN32
/*
If env.variable TZ is set, derive timezone name from it.
Otherwise, use IANA tz name from get_win_tzname.
*/
if (!getenv("TZ"))
get_win_tzname(system_time_zone, sizeof(system_time_zone));
#elif defined(HAVE_TZNAME)
struct tm tm_tmp;
localtime_r(&server_start_time,&tm_tmp);
else
#endif
{
const char *tz_name= tzname[tm_tmp.tm_isdst != 0 ? 1 : 0];
strmake_buf(system_time_zone, tz_name);
#endif /* HAVE_TZNAME */
}
#endif
/*
We set SYSTEM time zone as reasonable default and
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment