diff options
author | Vladislav Vaintroub <wlad@montyprogram.com> | 2012-06-15 17:21:06 +0200 |
---|---|---|
committer | Vladislav Vaintroub <wlad@montyprogram.com> | 2012-06-15 17:21:06 +0200 |
commit | 99edca97f453cb88f80a62be1bc8c38b05c9ec79 (patch) | |
tree | b73f3ba00e55d11d8118144ffeefd036d692d642 | |
parent | b14d3adad9d10a8575bebca7e7af0ff7ef9f71b1 (diff) | |
download | mariadb-git-99edca97f453cb88f80a62be1bc8c38b05c9ec79.tar.gz |
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.
-rw-r--r-- | sql/mysqld.cc | 23 | ||||
-rw-r--r-- | sql/sys_vars.cc | 2 |
2 files changed, 17 insertions, 8 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c001991effc..c01aebf99f9 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -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); + struct tm tm_tmp; + localtime_r(&server_start_time,&tm_tmp); + 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. diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index c8af1422388..bbe6d45b533 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -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", |