dolthub / dolthub/dolt

Handling timezones for timestamp/datetime types does not match MySQL

Open
#3,119 0 comments 0 reactions 1 assignee Claimed by @zachmu View on GitHub
bug sql
Dominant language
Go
Stars
24.4k
Forks
873
Avg merge
1d 8h
Merged PRs (30d)
120

Description

In MySQL it seems that DATETIME and TIMESTAMP handle timezones a little differently:

> MySQL converts TIMESTAMP values from the current time zone to UTC for storage, and back from UTC to the current time zone for retrieval. (This does not occur for other types such as DATETIME.) By default, the current time zone for each connection is the server's time. The time zone can be set on a per-connection basis. As long as the time zone setting remains constant, you get back the same value you store. If you store a TIMESTAMP value, and then change the time zone and retrieve the value, the retrieved value is different from the value you stored. This occurs because the same time zone was not used for conversion in both directions. The current time zone is available as the value of the [time_zone](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_time_zone) system variable.

Reference: https://dev.mysql.com/doc/refman/8.0/en/datetime.html

It appears that `DATETIME` persists a locality whereas `TIMESTAMP` does not. As things are today for Dolt, we use the same code to read and write both those types.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.