-
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
UTC_TIMESTAMP() rounds fraction part instead of truncating it #56430
Comments
Related to #9710 but for |
Thank you very much. I noticed that e.g. https://github.com/pingcap/tidb/blob/master/pkg/expression/builtin_time.go#L1736 |
So there are several things that are tricky. SQL Standard and MySQL are using rounding for time in general (INSERT/UPDATE) but this specific PR if for now() type of functions, that generates a new current time, where it should not round, but truncate instead. The use you link to is for I am working on a proof-of-concept for introducing @dulao5 what do you think about introducing MySQL's sql_mode |
Similar with curtime(), but only for the fsp, not if fsp == 0: tidb> select now(), now(3), now(6), curtime(), curtime(6), curtime(3);
+---------------------+-------------------------+----------------------------+-----------+-----------------+--------------+
| now() | now(3) | now(6) | curtime() | curtime(6) | curtime(3) |
+---------------------+-------------------------+----------------------------+-----------+-----------------+--------------+
| 2024-10-03 09:16:33 | 2024-10-03 09:16:33.743 | 2024-10-03 09:16:33.743866 | 09:16:33 | 09:16:33.743866 | 09:16:33.744 |
+---------------------+-------------------------+----------------------------+-----------+-----------------+--------------+
1 row in set (0.00 sec) |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
UTC_TIMESTAMP()
should never round up, it is very confusing if time is rounding up, since it will be earlier than what the clock on the wall shows.3. What did you see instead (Required)
Truncating (or always rounding down).
4. What is your TiDB version? (Required)
The text was updated successfully, but these errors were encountered: