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

zz-jason commented Sep 10, 2018

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
…ld consider the time zone
@zz-jason

This comment has been minimized.

Copy link
Member Author

zz-jason commented Sep 10, 2018

@zz-jason

This comment has been minimized.

Copy link
Member Author

zz-jason commented Sep 10, 2018

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

@zz-jason

This comment has been minimized.

Copy link
Member Author

zz-jason commented Sep 10, 2018

@coocood Why?

@coocood

This comment has been minimized.

Copy link
Member

coocood commented Sep 10, 2018

@zz-jason never mind

CI failed, due to no database selected

@XuHuaiyu

This comment has been minimized.

Copy link
Contributor

XuHuaiyu commented Sep 10, 2018

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 left a comment

LGTM

@lysu
lysu approved these changes Sep 10, 2018
Copy link
Member

lysu left a comment

LGTM

Copy link
Contributor

eurekaka left a comment

LGTM

@zz-jason

This comment has been minimized.

Copy link
Member Author

zz-jason commented Sep 10, 2018

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

This comment has been minimized.

Copy link
Member Author

zz-jason commented Sep 10, 2018

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

@coocood coocood merged commit 96e44a8 into pingcap:master Sep 10, 2018
3 of 4 checks passed
3 of 4 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
ci/circleci Your tests passed on CircleCI!
Details
jenkins-ci-tidb/build Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details
@zz-jason zz-jason deleted the zz-jason:dev/fix-datetime-default branch Sep 10, 2018
zz-jason added a commit to zz-jason/tidb that referenced this pull request Sep 11, 2018
…ld consider the time zone (pingcap#7655)
coocood added 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
Projects
None yet
5 participants
You can’t perform that action at this time.