-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Driver should not round time #1121
Comments
Direct link to the code that must be fixed: https://github.com/go-sql-driver/mysql/blob/master/utils.go#L282 Instead of rounding to micro-second in the driver, the driver should just pass digits down to nanoseconds and let the server handle them. The only optimization should be to drop zeroes at the end. This issue doesn't matter just for sub-seconds data types as the rounding will affect |
Here are some SQL expression that could be used as test cases: SELECT(?, TIME);
SELECT(?, TIME(2));
SELECT(?, TIME(6)); |
I quote some comments in #1172 for aggregating information about this issue. shogo82148 commented #1172 (comment)
methane commented #1172 (comment)
methane commented #1172 (comment)
|
Options: a. Truncate at microseconds. |
a. Truncate interacts with server truncate, so will lead to incorrect value in SOME cases (which means hard to debug for users not aware of the issue), so no Correctness first, performance second. |
Check also how basic TIME/DATETIME values are affected by server rounding (and so is corrupted by client-side truncation):
|
* stop rounding times fixes #1121 * trim trailing zeros
After upgrading from v1.5.0, queries with nanoseconds in params does not use index for datetime fields on MariaDB 10.4.7 (( |
I didn't expect such a side effect. |
use |
Issue
See this comment:
https://github.com/go-sql-driver/mysql/pull/1118/files#r433293822
MySQL rounds the received datetime. (ref). So the time may be rounded twice.
Example:
Proposal
I just want to drop the rounding behavior in the driver.
The text was updated successfully, but these errors were encountered: