-
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
Wrong results and nonoptimal plan when datetime column comparing number constant #38361
Comments
MySQL conversion behavior for Datetime with constant, convert constant to Datetime; while tidb changed the behavior after PR #20961 : |
I suggest to revert PR #20961, due to following reasons:
|
And MySQL's behavior of implicit converting constant integer to Date/DateTime is different from TiDB's ParseTimeFromNum. TiDB's ParseTimeFromNum produces either correct Time value or Zero value, while MySQL's not: mysql> select a > 888888888 from t0; mysql> show warnings; mysql> select a > 20241331 from t0; Personally, I think it doesn't make much sense to align TiDB's behavior with MySQL in such cases. |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
Result of MySQL 8.0.30:
3. What did you see instead (Required)
Result of tidb master (v6.4.0-alpha-nightly-20221009):
Result of tidb v4.0.16:
The difference between tidb v4.0.x and tidb v5.0+ is caused by #20961.
We expect that (1) the results are correct (maybe we also need to make clear the behavior of MySQL) and (2) if possible, both queries could use range scan instead of full scan.
The key problem here is how to handle the type incompatibility between a datetime column and a number.
The simplest but not complete solution I can think of is to revert #20961 directly.
4. What is your TiDB version? (Required)
current master
The text was updated successfully, but these errors were encountered: