-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: Truncate FSP instead of rounding for utc_timestamp() | tidb-test=pr/2405 #56431
base: master
Are you sure you want to change the base?
Conversation
Hi @mjonss. 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. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #56431 +/- ##
================================================
+ Coverage 73.3645% 75.3508% +1.9862%
================================================
Files 1624 1624
Lines 448069 448161 +92
================================================
+ Hits 328724 337693 +8969
+ Misses 99207 89904 -9303
- Partials 20138 20564 +426
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Also
vs MySQL 8.0.32:
|
/test build |
[LGTM Timeline notifier]Timeline:
|
@dveeden: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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. |
/check-issue-triage-complete |
/ok-to-test |
I think this does need a release note |
/retest |
tz = gotime.Local | ||
} | ||
|
||
func (d Duration) RoundFrac(fsp int) (Duration, error) { |
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.
Duration
should not use gotime.Time
for rounding or truncating. There is simply no need or benefit to convert back and forth.
/retest |
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.
So this is not yet fixing SYSDATE()
right?
sql> select utc_timestamp(6), utc_timestamp(), now(), now(6), utc_timestamp(6), utc_timestamp(), now(1), now(3), utc_timestamp(1), utc_timestamp(3), now(1), now(3), utc_timestamp(6)+0, now(6)+0, sysdate(6), current_timestamp(6), unix_timestamp(now(6)), unix_timestamp(sysdate(6)), from_unixtime(unix_timestamp(now(6))), microsecond(now(6))\G
*************************** 1. row ***************************
utc_timestamp(6): 2024-10-04 08:31:43.397413
utc_timestamp(): 2024-10-04 08:31:43
now(): 2024-10-04 10:31:43
now(6): 2024-10-04 10:31:43.397413
utc_timestamp(6): 2024-10-04 08:31:43.397413
utc_timestamp(): 2024-10-04 08:31:43
now(1): 2024-10-04 10:31:43.3
now(3): 2024-10-04 10:31:43.397
utc_timestamp(1): 2024-10-04 08:31:43.3
utc_timestamp(3): 2024-10-04 08:31:43.397
now(1): 2024-10-04 10:31:43.3
now(3): 2024-10-04 10:31:43.397
utc_timestamp(6)+0: 20241004083143.397413
now(6)+0: 20241004103143.397413
sysdate(6): 2024-10-04 10:31:43.397786
current_timestamp(6): 2024-10-04 10:31:43.397413
unix_timestamp(now(6)): 1728030703.397413
unix_timestamp(sysdate(6)): 1728030703.397790
from_unixtime(unix_timestamp(now(6))): 2024-10-04 10:31:43.397413
microsecond(now(6)): 397413
1 row in set (0.0009 sec)
Maybe add some tests in tests/integrationtest
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dveeden The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@dveeden: Your lgtm message is repeated, so it is ignored. In response to this:
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. |
It should fix
Here you see that both fsp == 0 and fsp == 3 is truncating instead of rounding.
It is tested here, doing it in an integration test is harder, since SYSDATE() is evaluated every time, using the current wall clock time, not the start of the statement as NOW(), CURRENT_TIMESTAMP() etc. |
Please ignore my earlier comment. |
https://github.com/mysql/mysql-server/blob/trunk/mysql-test/t/func_time.test seems to use |
TiDB also supports |
I guess I must have made a typo. I tried again with TiDB and it indeed works. |
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.
Please improve the description and title of the PR. This commit not only modifies the behavior of the utc_timestamp method.
// fractional seconds part, returns the duration type Time value and bool to indicate | ||
// whether the result is null. It also truncates FSP part instead of rounding it as | ||
// ParseDuration above does. | ||
func ParseDurationTruncateFsp(ctx Context, str string, fsp int) (Duration, bool, error) { |
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.
Do we need to add a test for this?
What problem does this PR solve?
Issue Number: close #56430 , close #31938
Problem Summary:
utc_timestamp() was rounding instead of truncating.
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.