Bug #106267 | wrong result with COALESCE function | ||
---|---|---|---|
Submitted: | 24 Jan 2022 18:39 | Modified: | 26 Jan 2022 17:17 |
Reporter: | Morgan Tocker | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.7 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[24 Jan 2022 18:39]
Morgan Tocker
[25 Jan 2022 14:17]
MySQL Verification Team
Hi Mr. Tocker, Thank you for your bug report. BTW, how are you ??? Unfortunately, you are quite correct. Both queries should return the same result, but they don't: pk col_time_not_null col_time_6_not_null_key col_datetime_key 2011-09-08 05:08:19.8362 05:10:32 23:09:37.056340 NULL 2011-09-08 05:08:21.8362 00:20:00 09:44:10.025082 2022-01-24 11:35:37 2011-09-08 05:08:22.8362 00:20:06 00:20:06.000000 2004-08-23 21:05:10 2011-09-08 05:08:23.8362 00:20:06 23:02:50.013380 2003-11-18 04:32:18 pk col_time_not_null col_time_6_not_null_key col_datetime_key 2011-09-08 05:08:20.8362 13:56:51 03:07:29.013169 2000-06-10 19:41:30 2011-09-08 05:08:24.8362 01:04:48 00:20:03.000000 2022-01-24 11:35:37 2011-09-08 05:08:25.8362 14:48:29 00:20:01.000000 2022-01-24 11:35:37 2011-09-08 05:08:26.8362 21:43:24 19:48:23.009935 NULL 2011-09-08 05:08:27.8362 23:29:59 06:00:36.034953 NULL 2011-09-08 05:08:28.8362 00:20:09 00:20:01.000000 2003-01-23 14:57:31 Verified as an Optimiser bug. Thank you very much !
[26 Jan 2022 17:17]
Jon Stephens
Documented fix as follows in the MySQL 8.0.29 changelog: A query having a WHERE condition of the form c NOT BETWEEN NULL AND COALESCE(a, b), having DATETIME columns a, b, and c, with columns a and c created as NOT NULL, did not return correct results. Further investigation showed that, in such cases, when the second or third argument to BETWEEN was NULL, the comparison results were inverted, causing it to evaluate as NULL for FALSE, and FALSE for NULL. Closed.
[27 Jan 2022 13:46]
MySQL Verification Team
Thank you , Jon .....