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

expression,ddl: fix fraction part handle of current_timestamp #7355

Merged
merged 7 commits into from
Aug 14, 2018
Merged

expression,ddl: fix fraction part handle of current_timestamp #7355

merged 7 commits into from
Aug 14, 2018

Conversation

lysu
Copy link
Contributor

@lysu lysu commented Aug 10, 2018

What problem does this PR solve?

In this PR, fix the bug that = retrieves the record that inserted by current_timestamp.

This bug is caused by current_timestamp doesn't take care of the fsp argument.

user often use default fsp of timestamp and it is 0, but current_timestamp generate and insert data with fsp part into storage. so when user selection table with no fsp value(they know nothing about fsp also not care about that..) and got the empty response.

for old data after this PR still cannot retrieve by =, but new data will work.

Still exists question

expect that when creating a table with current_timestamp we should confirm column's fsp == funcation's fsp, but solve this will break compatible, so 83b4e233457a98dd5f52d633a44445d63b351e08 rollbacked.

also see: https://dev.mysql.com/doc/refman/5.7/en/timestamp-initialization.html

What is changed and how it works?

  • when get time from GetTimeValue follow fsp argument.

Check List

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Code changes

  • Has unexported function/method change

Side effects

  • side effects free

Related changes

  • Need to cherry-pick to the release branch
  • Need to be included in the release note

This change is Reviewable

@lysu
Copy link
Contributor Author

lysu commented Aug 10, 2018

/run-all-tests

@lysu lysu added type/bugfix This PR fixes a bug. component/expression release-note Denotes a PR that will be considered when it comes time to generate release notes. component/DDL-need-LGT3 and removed status/WIP labels Aug 10, 2018
@lysu lysu requested a review from coocood August 10, 2018 12:52
@tiancaiamao
Copy link
Contributor

LGTM

@tiancaiamao tiancaiamao added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 13, 2018
@@ -121,10 +121,10 @@ CREATE TABLE `te` (
`device_identy` varchar(36) NOT NULL,
`uuid` varchar(32) NOT NULL,
`status_flag` tinyint(4) NOT NULL,
`client_create_time` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
`client_create_time` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
Copy link
Member

Choose a reason for hiding this comment

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

Can we not adding (3) to CURRENT_TIMESTAMP?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

check fsp in create table is rollbacked in this PR, 83b4e233457a98dd5f52d633a44445d63b351e08.

@@ -1760,7 +1760,7 @@ func (s *testDBSuite) TestTableDDLWithTimeType(c *C) {
s.testErrorCode(c, "alter table t change column a aa time(7)", tmysql.ErrTooBigPrecision)
s.testErrorCode(c, "alter table t change column a aa datetime(7)", tmysql.ErrTooBigPrecision)
s.testErrorCode(c, "alter table t change column a aa timestamp(7)", tmysql.ErrTooBigPrecision)
s.mustExec(c, "alter table t change column a aa timestamp(0)")
s.mustExec(c, "alter table t change column a aa datetime(0)")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this is changed to datetime ?

Copy link
Contributor Author

@lysu lysu Aug 13, 2018

Choose a reason for hiding this comment

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

because previous test is wrong and should be failure with

ERROR 1105 (HY000): unsupported modify column type 7 not match origin 12

- - and it's strange mustExec in ddl_test seems ignore the err and doesn't fail the case.

Copy link
Member

Choose a reason for hiding this comment

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

The test doesn't init the testKit, but reuse the one in the suite, so the test case never fail.

@coocood
Copy link
Member

coocood commented Aug 13, 2018

LGTM

@coocood coocood added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. status/all tests passed labels Aug 13, 2018
@coocood
Copy link
Member

coocood commented Aug 13, 2018

/run-all-tests

@zz-jason
Copy link
Member

@lysu plz resolve conflicts so we can merge this PR 😄

@lysu
Copy link
Contributor Author

lysu commented Aug 14, 2018

@zz-jason done~

@zz-jason zz-jason merged commit fc89a64 into pingcap:master Aug 14, 2018
@lysu lysu deleted the dev/fix_default_current_timestamp branch September 27, 2018 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression release-note Denotes a PR that will be considered when it comes time to generate release notes. 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