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: wrong result of timestampadd(month,1,date '2024-01-31') #53101

Merged
merged 5 commits into from
May 11, 2024

Conversation

xzhangxian1008
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #41052

Problem Summary:

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 8, 2024
@xzhangxian1008
Copy link
Contributor Author

/cc @XuHuaiyu @yibin87 @SeaRise

@ti-chi-bot ti-chi-bot bot requested review from SeaRise, XuHuaiyu and yibin87 May 8, 2024 06:19
Copy link

tiprow bot commented May 8, 2024

Hi @xzhangxian1008. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

codecov bot commented May 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.0256%. Comparing base (2b754c7) to head (4e080f5).
Report is 29 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #53101        +/-   ##
================================================
+ Coverage   72.4215%   75.0256%   +2.6040%     
================================================
  Files          1490       1493         +3     
  Lines        428984     438057      +9073     
================================================
+ Hits         310677     328655     +17978     
+ Misses        99041      89396      -9645     
- Partials      19266      20006       +740     
Flag Coverage Δ
integration 49.4659% <0.0000%> (?)
unit 71.6518% <100.0000%> (+0.3504%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 50.3521% <ø> (+9.0100%) ⬆️

@@ -6232,6 +6232,11 @@ func addUnitToTime(unit string, t time.Time, v float64) (time.Time, bool, error)
return tb, true, nil
}
tb = t.AddDate(0, int(v), 0)

// For corner case: timestampadd(month,1,date '2024-01-31') = "2024-02-29", timestampadd(month,1,date '2024-01-30') = "2024-02-29"
for tb.Month() != t.Month()+1 {
Copy link
Contributor

@yibin87 yibin87 May 8, 2024

Choose a reason for hiding this comment

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

What happen if adding more than 1 month?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What happen if adding more than 1 month?

This is mysql: timestampadd(month,1,date '2024-01-31') = "2024-02-29"

This is tidb: timestampadd(month,1,date '2024-01-31') = "2024-03-02"

The month field of the result of timestampadd(month,1,date '2024-01-31') is always 1 more than the month field of input. Adding more than 1 month is unexpected.

@xzhangxian1008 xzhangxian1008 requested a review from yibin87 May 9, 2024 01:07
@xzhangxian1008
Copy link
Contributor Author

/cc @SeaRise

Copy link
Contributor

@yibin87 yibin87 left a comment

Choose a reason for hiding this comment

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

Others LGTM

Copy link

ti-chi-bot bot commented May 9, 2024

@yibin87: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

Others LGTM

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@SeaRise
Copy link
Contributor

SeaRise commented May 9, 2024

/cc @XuHuaiyu @windtalker
Need a LGTM from the expression owners.

@ti-chi-bot ti-chi-bot bot requested a review from windtalker May 9, 2024 10:11
Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 10, 2024
Copy link

ti-chi-bot bot commented May 10, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: windtalker, XuHuaiyu, yibin87

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 10, 2024
@xzhangxian1008 xzhangxian1008 deleted the fix-41052 branch May 11, 2024 05:47
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. label May 11, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #53194.

@ti-chi-bot ti-chi-bot added needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. labels May 21, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #53419.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #53420.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #53421.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.1: #53422.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request May 21, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-5.4: #53423.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request May 21, 2024
@@ -2580,6 +2580,18 @@ func TestTimestampAdd(t *testing.T) {
{"MINUTE", 1.5, "1995-05-01 00:00:00", "1995-05-01 00:02:00"},
{"MINUTE", 1.5, "1995-05-01 00:00:00.000000", "1995-05-01 00:02:00"},
{"MICROSECOND", -100, "1995-05-01 00:00:00.0001", "1995-05-01 00:00:00"},

// issue41052
{"MONTH", 1, "2024-01-31", "2024-02-29 00:00:00"},
Copy link
Contributor

Choose a reason for hiding this comment

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

We should've at least had one case for negative month.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should've at least had one case for negative month.

fixed in #54916

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wrong result of timestampadd(month,1,date '2024-01-31')
7 participants