Bug #45342 | Server sends timezoned timestamps over the wire | ||
---|---|---|---|
Submitted: | 4 Jun 2009 20:57 | Modified: | 8 Jun 2009 17:56 |
Reporter: | Roberto Jimeno | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server | Severity: | S4 (Feature request) |
Version: | 5.1.30 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | GMT, timestamp, timezone, UTC |
[4 Jun 2009 20:57]
Roberto Jimeno
[4 Jun 2009 21:33]
Sveta Smirnova
Thank you for the report. According to http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html: ----<Q>---- The current session time zone setting affects display and storage of time values that are zone-sensitive. This includes the values displayed by functions such as NOW() or CURTIME(), and values stored in and retrieved from TIMESTAMP columns. Values for TIMESTAMP columns are converted from the current time zone to UTC for storage, and from UTC to the current time zone for retrieval. ----</Q>---- This means TIMESTAMP values stored in UTC already and server sends them in client timezone. Please confirm if you want TIMESTAMP values to be not converted to session time zone, but sent as they stored == UTC.
[4 Jun 2009 22:03]
Roberto Jimeno
My client is in UTC but I am getting timestamps with the timezone of the server and even without a timezone specification (like +0200) I just want my Java code (at bug #45340) to work correctly. I suggest various ways on how to fix this bug: -If the client does not specify what timezone he is in, always send timestamps in UTC. (This will bother people using old clients that cannot display timestamps in local timezone) -In MySQL Connector/J always start the connection telling the server to send UTC timestamps. (This would fix the bug but all correctly written clients need UTC timestamps) -Document that MySQL server should be always run on a UTC configured server and prevent it from running on a timezoned server. (This will bother people that want to have the server user interface in their timezone) So, yes timestamps should always be stored UTC on the server and sent in UTC to the client.
[5 Jun 2009 6:07]
Sveta Smirnova
Thank you for the feedback. Combination of stmt.executeUpdate("set time_zone='+00:00'"); and configuration property useJDBCCompliantTimezoneShift=true fixes this problem for your test. So everything works correctly if client settings are correct too. Although I consult with Mark before make this report "Verified" or "Not a Bug"
[8 Jun 2009 12:47]
Roberto Jimeno
I do not want to modify my code to add stmt.executeUpdate("set time_zone='+00:00'"); everywhere. How do you recommend configuring a standard Web Application Server like Tomcat to fix this bug? Will you consider fixing this bug so neither stmt.executeUpdate("set time_zone='+00:00'"); and useJDBCCompliantTimezoneShift is needed?
[8 Jun 2009 17:56]
Sveta Smirnova
Thank you for the feedback. Verified as feature request. Thought you can use UTC as server TZ, or use DATETIME. > How do you recommend configuring a standard Web Application Server like Tomcat to fix this bug? Try to use init_connect (http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_init_connect) or init-file (http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_init-file) Regarding Web Application Server like Tomcat consult its documentation.
[22 Jun 2010 10:40]
Steve Thomson
I agree that having the timestamp returned to the client in UTC is the only logical way that this can work. > [8 Jun 2009 19:56] Sveta Smirnova > Verified as feature request. Thought you can use UTC as server TZ, > or use DATETIME. DATETIME doesn't allow `DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP` so I suggest either removing that restriction or this one. I need an auto-updating timestamp that is stored in UTC and returns as UTC. Changing the server time or adding triggers are not acceptable solutions.