-
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
types,expression: Fix parse time from string #7654
Conversation
types/time.go
Outdated
_, err = fmt.Sscanf(fracStr, "%1d", &second) | ||
default: | ||
_, err = fmt.Sscanf(fracStr[:2], "%2d", &second) | ||
} |
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.
should we raise warning as MySQL does for the case below?
mysql> select cast("170102037.1122" as datetime);
+------------------------------------+
| cast("170102037.1122" as datetime) |
+------------------------------------+
| 2017-01-02 03:07:11 |
+------------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+------------------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------------------+
| Warning | 1292 | Truncated incorrect datetime value: '170102037.1122' |
+---------+------+------------------------------------------------------+
1 row in set (0.00 sec)
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.
Yes, indeed. I'll fix here
@spongedu We use go 1.11 now, maybe you can update |
@zz-jason ok |
@zz-jason done here. PTAL |
/run-all-tests |
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
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
What problem does this PR solve?
What is changed and how it works?
Currently TiDB fail to deal with some cases when parse
string
todatetime
, This pr fixes these cases. For example, in MySQL:While in TiDB:
Check List
Tests