-
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 with NOT BETWEEN + EXTRACT #31937
Labels
Comments
It looks like there might be a bug in MySQL: mysql [localhost:8028] {msandbox} (test) > SELECT pk, col_time_not_null, col_time_6_not_null_key, col_datetime_key FROM t1 WHERE col_time_not_null NOT BETWEEN NULL AND col_time_6_not_null_key;
+--------------------------+-------------------+-------------------------+---------------------+
| pk | col_time_not_null | col_time_6_not_null_key | col_datetime_key |
+--------------------------+-------------------+-------------------------+---------------------+
| 2011-09-07 23:08:20.8362 | 13:56:51 | 03:07:29.013169 | 2000-06-10 19:41:30 |
| 2011-09-07 23:08:24.8362 | 01:04:48 | 00:20:03.000000 | 0000-00-00 00:00:00 |
| 2011-09-07 23:08:25.8362 | 14:48:29 | 00:20:01.000000 | 0000-00-00 00:00:00 |
| 2011-09-07 23:08:26.8362 | 21:43:24 | 19:48:23.009935 | NULL |
| 2011-09-07 23:08:27.8362 | 23:29:59 | 06:00:36.034953 | NULL |
| 2011-09-07 23:08:28.8362 | 00:20:09 | 00:20:01.000000 | 2003-01-23 14:57:31 |
+--------------------------+-------------------+-------------------------+---------------------+
6 rows in set (0.00 sec)
mysql [localhost:8028] {msandbox} (test) > SELECT pk, col_time_not_null, col_time_6_not_null_key, col_datetime_key FROM t1 WHERE col_time_not_null NOT BETWEEN NULL AND COALESCE (col_time_6_not_null_key, col_datetime_key);
+--------------------------+-------------------+-------------------------+---------------------+
| pk | col_time_not_null | col_time_6_not_null_key | col_datetime_key |
+--------------------------+-------------------+-------------------------+---------------------+
| 2011-09-07 23:08:19.8362 | 05:10:32 | 23:09:37.056340 | NULL |
| 2011-09-07 23:08:21.8362 | 00:20:00 | 09:44:10.025082 | 0000-00-00 00:00:00 |
| 2011-09-07 23:08:22.8362 | 00:20:06 | 00:20:06.000000 | 2004-08-23 21:05:10 |
| 2011-09-07 23:08:23.8362 | 00:20:06 | 23:02:50.013380 | 2003-11-18 04:32:18 |
+--------------------------+-------------------+-------------------------+---------------------+
4 rows in set (0.00 sec) Because the first column in the Edit: Filed as https://bugs.mysql.com/bug.php?id=106267 |
There is both a bug in MySQL and a bug in TiDB. This is what I think is a bug in TiDB; the tidb> SELECT pk, EXTRACT(YEAR_MONTH FROM '0000-00-00 00:00:00') as expr1, COALESCE (col_time_6_not_null_key, col_datetime_key) as expr2 FROM t1 WHERE col_time_not_null NOT BETWEEN NULL AND COALESCE (col_time_6_not_null_key, col_datetime_key);
+--------------------------+-------+----------------------------+
| pk | expr1 | expr2 |
+--------------------------+-------+----------------------------+
| 2011-09-07 23:08:20.8362 | NULL | 2022-01-24 03:07:29.013169 |
| 2011-09-07 23:08:24.8362 | NULL | 2022-01-24 00:20:03.000000 |
| 2011-09-07 23:08:26.8362 | NULL | 2022-01-24 19:48:23.009935 |
| 2011-09-07 23:08:28.8362 | NULL | 2022-01-24 00:20:01.000000 |
| 2011-09-07 23:08:25.8362 | NULL | 2022-01-24 00:20:01.000000 |
| 2011-09-07 23:08:27.8362 | NULL | 2022-01-24 06:00:36.034953 |
+--------------------------+-------+----------------------------+
6 rows in set, 1 warning (0.00 sec)
tidb> SELECT pk, EXTRACT(YEAR_MONTH FROM '0000-00-00 00:00:00') as expr1, COALESCE (col_time_6_not_null_key, col_datetime_key) as expr2 FROM t1 WHERE col_time_not_null NOT BETWEEN EXTRACT(YEAR_MONTH FROM '0000-00-00 00:00:00') AND COALESCE (col_time_6_not_null_key, col_datetime_key);
Empty set, 2 warnings (0.03 sec)
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug Report
This issues is related to tidb/issues/30359 and tidb/issues/31600.
1. Minimal reproduce step
2. What did you expect to see?
In MySQL8.0
3. What did you see instead
4. What is your TiDB version?
The text was updated successfully, but these errors were encountered: