-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: fix infinity loop in timestampadd
#54916
Conversation
Hi @xzhangxian1008. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with 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. |
/cc @windtalker @XuHuaiyu |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #54916 +/- ##
================================================
+ Coverage 72.6924% 74.5632% +1.8707%
================================================
Files 1557 1561 +4
Lines 438381 443201 +4820
================================================
+ Hits 318670 330465 +11795
+ Misses 100054 92977 -7077
- Partials 19657 19759 +102
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case "MONTH":
if !validAddMonth(v, t.Year(), int(t.Month())) {
return tb, true, nil
}
year, month := t.Year(), int(t.Month())
targetMonth := month + int(v)
// Adjust the year and month based on the total months calculated
targetYear := year + (targetMonth-1)/12
targetMonth = (targetMonth-1)%12 + 1
// Handle cases where month might become negative or zero
if targetMonth <= 0 {
targetYear -= 1
targetMonth += 12
}
targetDay := t.Day()
// Try to create the target date
tb = time.Date(targetYear, time.Month(targetMonth), targetDay, t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), t.Location())
if tb.Month() != time.Month(targetMonth) {
// If the day overflows (like trying to get Feb 30), adjust to the last day of the target month
tb = time.Date(targetYear, time.Month(targetMonth+1), 0, t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), t.Location())
}
release note needed |
/cc @windtalker @XuHuaiyu |
{"MONTH", -3, "2023-03-20", "2022-12-20 00:00:00"}, | ||
{"MONTH", -3, "2023-03-31", "2022-12-31 00:00:00"}, | ||
{"MONTH", -15, "2023-03-20", "2021-12-20 00:00:00"}, | ||
{"MONTH", -15, "2023-03-31", "2021-12-31 00:00:00"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tests to test from 2020-02-29
to 2021-02-28
and from 2020-02-29
to 2019-02-28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And add some invalid input test cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And add some invalid input test cases
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-check-issue-triage-complete |
In response to a cherrypick label: new pull request created to branch |
In response to a cherrypick label: new pull request created to branch |
In response to a cherrypick label: new pull request created to branch |
In response to a cherrypick label: new pull request created to branch |
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
* upstream/master: (93 commits) disjoinset: add generic impl (pingcap#54917) planner: derive index filters for mv index paths (pingcap#54877) br: cli refactor backup error handling logic (pingcap#54697) expression: fix infinity loop in `timestampadd` (pingcap#54916) planner: import more expand test. (pingcap#54962) planner: use code-gen to generate CloneForPlanCache method for some operators (pingcap#54957) test: fix flaky test TestFailSchemaSyncer (pingcap#54958) planner: move logical show into logicalop pkg. (pingcap#54928) privilege: Remove TestAbnormalMySQLTable (pingcap#54925) resource_control: support unlimited keyword when setting the resource group (pingcap#54704) ddl: fix a data race on localRowCntListener Written() (pingcap#54484) lightning: fix SET SESSION on connection pool (pingcap#54927) planner: move logical mem-table to logicalop pkg. (pingcap#54903) table: Add `CachedTableSupport` and `TemporaryTableSupport` for `MutateContext` (pingcap#54900) executor: fix index_hash_join hang when context canceled (pingcap#54855) statistics: add metrics for unneeded analyze table (pingcap#54822) *: refine pipelined dml benchmarks (pingcap#54844) ddl: assign table IDs for jobs submitted to queue (pingcap#54880) *: avoid using Tables field of model.DBInfo, use API instead (pingcap#52302) planner: remove useless check (pingcap#54907) ...
What problem does this PR solve?
Issue Number: close #54908
Problem Summary:
What changed and how does it work?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.