Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor, expression: calculating the default value for datetime should consider the time zone #7655

Merged
merged 3 commits into from
Sep 10, 2018

Conversation

zz-jason
Copy link
Member

What problem does this PR solve?

The default value calculated for datetime column has not consider the timezone. This PR fixes it.

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test

Related changes

  • Need to cherry-pick to the release branch

@zz-jason
Copy link
Member Author

@XuHuaiyu @tiancaiamao @eurekaka @lysu PTAL.

@zz-jason
Copy link
Member Author

/run-common-test tidb-test=pr/620

@zz-jason zz-jason added priority/P1 The issue has P1 priority. type/bugfix This PR fixes a bug. sig/execution SIG execution component/expression labels Sep 10, 2018
@zz-jason
Copy link
Member Author

@coocood Why?

@coocood
Copy link
Member

coocood commented Sep 10, 2018

@zz-jason never mind

CI failed, due to no database selected

@XuHuaiyu
Copy link
Contributor

I think what @coocood mean is that:
When insert using current_timestamp, timezone should be take into consideration.
But when selecting we should not convert it using timezone, because that we do not know in which timezone the DATETIME value is inserted since DATETIME does not maintain the info of timezone.

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zz-jason
Copy link
Member Author

Got it. After investigating, mysql document says:

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.)

And the behavior seems like MySQL converts DATETIME values from the current time zone to UTC for storage, but for retrieval, MySQL doesn't convert back from UTC to the current time zone.

@zz-jason zz-jason added the status/LGT2 Indicates that a PR has LGTM 2. label Sep 10, 2018
@zz-jason
Copy link
Member Author

/run-all-tests tidb-test=pr/620

@coocood coocood merged commit 96e44a8 into pingcap:master Sep 10, 2018
@zz-jason zz-jason deleted the dev/fix-datetime-default branch September 10, 2018 08:11
zz-jason added a commit to zz-jason/tidb that referenced this pull request Sep 11, 2018
coocood pushed a commit that referenced this pull request Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression priority/P1 The issue has P1 priority. sig/execution SIG execution status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants