Commit 99edca97 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-339, LP1001340 - system_time_zone is wrong on Windows

On localized Windows versions, Windows uses localized time zone names and contain non-ASCII characters.  non-ASCII characters appear broken when displayed by clients
The fix is to declare system_time_zone variable to have UTF8 encoding and to convert tzname to UTF8.
parent b14d3ada
......@@ -3418,14 +3418,23 @@ static int init_common_variables()
return 1;
#ifdef HAVE_TZNAME
{
struct tm tm_tmp;
localtime_r(&server_start_time,&tm_tmp);
strmake(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0],
sizeof(system_time_zone)-1);
const char *tz_name= tzname[tm_tmp.tm_isdst != 0 ? 1 : 0];
#ifdef _WIN32
/*
Time zone name may be localized and contain non-ASCII characters,
Convert from ANSI encoding to UTF8.
*/
wchar_t wtz_name[sizeof(system_time_zone)];
mbstowcs(wtz_name, tz_name, sizeof(system_time_zone)-1);
WideCharToMultiByte(CP_UTF8,0, wtz_name, -1, system_time_zone,
sizeof(system_time_zone) - 1, NULL, NULL);
#else
strmake(system_time_zone, tz_name, sizeof(system_time_zone)-1);
#endif /* _WIN32 */
#endif /* HAVE_TZNAME */
}
#endif
/*
We set SYSTEM time zone as reasonable default and
also for failure of my_tz_init() and bootstrap mode.
......
......@@ -2246,7 +2246,7 @@ static char *system_time_zone_ptr;
static Sys_var_charptr Sys_system_time_zone(
"system_time_zone", "The server system time zone",
READ_ONLY GLOBAL_VAR(system_time_zone_ptr), NO_CMD_LINE,
IN_FS_CHARSET, DEFAULT(system_time_zone));
IN_SYSTEM_CHARSET, DEFAULT(system_time_zone));
static Sys_var_ulong Sys_table_def_size(
"table_definition_cache",
......
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