[MDEV-29102] system_time_zone is incorrect on Windows when TZ is set Created: 2022-07-14  Updated: 2022-10-11  Resolved: 2022-10-11

Status: Closed
Project: MariaDB Server
Component/s: Variables
Affects Version/s: 10.6.8
Fix Version/s: 10.6.11, 10.7.7, 10.8.6, 10.9.4, 10.10.2

Type: Bug Priority: Minor
Reporter: Sebastian Weiser Assignee: Vladislav Vaintroub
Resolution: Fixed Votes: 0
Labels: None
Environment:

Microsoft Windows [Version 10.0.18363.2274]
official MSI build


Issue Links:
Problem/Incident
is caused by MDEV-19243 Fix timezone handling on Windows to r... Closed

 Description   

On Windows, the global variable system_time_zone doesn't properly reflect the used time zone when the environment variable TZ is set.

For example, on my system configured for region Germany, but TZ is set as "CST-8":
SELECT @@time_zone, @@system_time_zone, TIMEDIFF(NOW(), UTC_TIMESTAMP());
SYSTEM Europe/Berlin 08:00:00
Whereas in Linux it returns
SYSTEM CST 08:00:00



 Comments   
Comment by Vladislav Vaintroub [ 2022-07-24 ]

sweiser a question

From documentation (emphasis mine)

If you are using a Unix-like operating system, then you can set the system time zone by setting the TZ environment variable in your shell before starting the server. For example:
$ export TZ='America/New_York'
$ service mysql start

You are not using Unix-like operating system, why would you expect that to work?

Comment by Sebastian Weiser [ 2022-07-25 ]

I didn't expect anything, not even that this part of the documentation (which I did read in advance) is up-to-date, so I just tried it. And what I see is that it works in parts (MariaDB does apply the time zone, it just doesn't reflect it in the variable system_time_zone), so I assumed that it is a bug.

If I understand your comment correctly, the fact that is somewhat working right now is "an accident" and not intended. So maybe this should be better as a "task": "make TZ variable work properly on Windows too".

I would still point out that the current behavior is somewhat inconsistent, especially because the TZ variable might be deliberately or accidentally set to something even on Windows systems (for example, some old versions of Cygwin did set it during installation). That being said, if the solution to it being inconsistent would be to remove the current behavior entirely, that would make me sad.

Generated at Thu Feb 08 10:05:55 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.