Skip to content

expression: fix date_add func in SECOND INTERVAL#11312

Merged
sre-bot merged 3 commits into
pingcap:masterfrom
yangwenmai:fix_date_add_neg
Aug 5, 2019
Merged

expression: fix date_add func in SECOND INTERVAL#11312
sre-bot merged 3 commits into
pingcap:masterfrom
yangwenmai:fix_date_add_neg

Conversation

@yangwenmai
Copy link
Copy Markdown
Contributor

@yangwenmai yangwenmai commented Jul 18, 2019

What problem does this PR solve?

Fixes #11319

What is changed and how it works?

The results of this PR like MySQL 5.7 has same result.

SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL -2.2 MINUTE_MICROSECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL -2.2 SECOND_MICROSECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL -2.2 HOUR_MICROSECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL -2.2 DAY_MICROSECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL -2.2 SECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL -2.2 HOUR_SECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL -2.2 DAY_SECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL -2.2 MINUTE_SECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL -2.2 MINUTE);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL -2.2 DAY_MINUTE);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL -2.2 HOUR_MINUTE);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL -2.2 DAY_HOUR);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL -2.2 YEAR_MONTH);

SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL 2.2 MINUTE_MICROSECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL 2.2 SECOND_MICROSECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL 2.2 HOUR_MICROSECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL 2.2 DAY_MICROSECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL 2.2 SECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL 2.2 HOUR_SECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL 2.2 DAY_SECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL 2.2 MINUTE_SECOND);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL 2.2 MINUTE);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL 2.2 DAY_MINUTE);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL 2.2 HOUR_MINUTE);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL 2.2 DAY_HOUR);
SELECT DATE_ADD('2007-03-28 22:08:28',INTERVAL 2.2 YEAR_MONTH);

@yangwenmai yangwenmai changed the title Fix date add neg Fix(expression): fix date_add func in neg INTERVAL Jul 18, 2019
@zz-jason zz-jason added the contribution This PR is from a community contributor. label Jul 18, 2019
@zz-jason zz-jason requested review from XuHuaiyu and qw4990 July 18, 2019 10:49
@zz-jason
Copy link
Copy Markdown
Member

@yangwenmai Thanks for your contribution, it would be nice if you can:

  1. follow the rules described in CONTRIBUTING.md to refine your PR title.
  2. follow the rules described in Closing issues using keywords to refine the PR description so that the issue can be automated closed once this PR is merged.

@SunRunAway
Copy link
Copy Markdown
Contributor

Is it duplicate to pr #11297?

@SunRunAway
Copy link
Copy Markdown
Contributor

SunRunAway commented Jul 18, 2019

Consider fixing issue #11319? @yangwenmai

@yangwenmai
Copy link
Copy Markdown
Contributor Author

yangwenmai commented Jul 18, 2019

I fixed the #11286 and #11319 in this PR.

@wshwsh12
Copy link
Copy Markdown
Contributor

I add some test cases in #11319 . You can have a look.

@yangwenmai yangwenmai changed the title Fix(expression): fix date_add func in neg INTERVAL expression: fix date_add func in neg INTERVAL Jul 18, 2019
@SunRunAway
Copy link
Copy Markdown
Contributor

SunRunAway commented Jul 19, 2019

I fixed the #11286 and #11319 in this PR.

@yangwenmai
#11286 is already fixed by another pull request. Will you consider modifying your code and pull request description to fix #11319 only?

@yangwenmai
Copy link
Copy Markdown
Contributor Author

I fixed the #11286 and #11319 in this PR.

@yangwenmai
#11286 is already fixed by another pull request. Will you consider modifying your code and pull request description to fix #11319 only?

OK

@qw4990 qw4990 requested review from SunRunAway and wshwsh12 July 22, 2019 05:24
@yangwenmai yangwenmai force-pushed the fix_date_add_neg branch 2 times, most recently from 8dfbe7d to 1ea8ed1 Compare July 23, 2019 02:26
@qw4990 qw4990 removed their request for review July 23, 2019 07:12
Comment thread expression/integration_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please take a look at the code commented out above and it seems that something is duplicate.

Comment thread types/time.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please remove the redundant brackets.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you prefer to just fix the SECOND unit problem, please change your pull request title more precisely and do not use neg for abbreviation.

Comment thread types/time.go Outdated
Copy link
Copy Markdown
Contributor

@SunRunAway SunRunAway Jul 24, 2019

Choose a reason for hiding this comment

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

After another look, I think the problem occurs because of the incorrectness of dv.
Is it more reasonable to add a line dv *= sign below to solve this problem?

@SunRunAway
Copy link
Copy Markdown
Contributor

@yangwenmai
Hi, please take a look again when you're free.

Comment thread types/time.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we use iv *= -1 here?

@zz-jason
Copy link
Copy Markdown
Member

zz-jason commented Aug 3, 2019

@yangwenmai friendly ping, any update?

@sre-bot
Copy link
Copy Markdown
Contributor

sre-bot commented Aug 3, 2019

Hi contributor, thanks for your PR.

This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically.

@yangwenmai yangwenmai changed the title expression: fix date_add func in neg INTERVAL expression: fix date_add func in SECOND INTERVAL Aug 5, 2019
@yangwenmai
Copy link
Copy Markdown
Contributor Author

yangwenmai commented Aug 5, 2019

@zz-jason @SunRunAway @XuHuaiyu PTAL

Copy link
Copy Markdown
Contributor

@SunRunAway SunRunAway left a comment

Choose a reason for hiding this comment

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

reset LGTM

@SunRunAway SunRunAway requested a review from XuHuaiyu August 5, 2019 04:44
Comment thread types/time.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we put this line into if decimalPointPos < lf { section?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, It's much better.

Copy link
Copy Markdown
Contributor

@SunRunAway SunRunAway left a comment

Choose a reason for hiding this comment

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

LGTM && @XuHuaiyu @wshwsh12 PTAL

@SunRunAway SunRunAway added status/LGT1 Indicates that a PR has LGTM 1. and removed status/ReqChange labels Aug 5, 2019
Copy link
Copy Markdown
Contributor

@wshwsh12 wshwsh12 left a comment

Choose a reason for hiding this comment

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

LGTM

@wshwsh12 wshwsh12 added status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 5, 2019
@wshwsh12
Copy link
Copy Markdown
Contributor

wshwsh12 commented Aug 5, 2019

/run-all-tests

1 similar comment
@sre-bot
Copy link
Copy Markdown
Contributor

sre-bot commented Aug 5, 2019

/run-all-tests

@sre-bot sre-bot merged commit ddafdff into pingcap:master Aug 5, 2019
@wshwsh12
Copy link
Copy Markdown
Contributor

wshwsh12 commented Aug 5, 2019

/run-cherry-picker

@sre-bot
Copy link
Copy Markdown
Contributor

sre-bot commented Aug 5, 2019

cherry pick to release-2.1 failed

@you06
Copy link
Copy Markdown
Contributor

you06 commented Aug 5, 2019

/run-cherry-picker

@sre-bot
Copy link
Copy Markdown
Contributor

sre-bot commented Aug 5, 2019

cherry pick to release-3.0 in PR #11615

zz-jason added a commit to SunRunAway/tidb that referenced this pull request Aug 5, 2019
SunRunAway added a commit to SunRunAway/tidb that referenced this pull request Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/expression contribution This PR is from a community contributor. status/can-merge Indicates a PR has been approved by a committer. 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.

Result of DATE_ADD function is different from mysql.(Second)

7 participants