Bug #103298 Potentially wrong results

Submitted: 13 Apr 2021 9:19 Modified: 13 Apr 2021 9:26
Reporter: Tigger Beat Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0.22, 5.7.33, 8.0.23 OS:Any
Assigned to: CPU Architecture:Any

[13 Apr 2021 9:19] Tigger Beat
Description:
The following two queries may produce inconsistent result. 

The first query: 
mysql> SELECT (NOT ((COALESCE('x')) != (t1.c1))) from t1;
+------------------------------------+
| (NOT ((COALESCE('x')) != (t1.c1))) |
+------------------------------------+
|                                  1 |
+------------------------------------+

The second query: 
mysql> SELECT t1.c1 from t1 Where (NOT ((COALESCE('x')) != (t1.c1)));
Empty set, 1 warning (0.17 sec)

Because the result of the expresssion, '(NOT ((COALESCE('x')) != (t1.c1)))',is true(please check the first query),the second query will produce one row.But the  result of the second query is empty.

How to repeat:
CREATE TABLE t1 (
  c0 int,
  c1 decimal(10,0),
  UNIQUE KEY c1 (c1)
);
insert into t1 select 0,0;

SELECT (NOT ((COALESCE('x')) != (t1.c1))) from t1;
SELECT t1.c1 from t1 Where (NOT ((COALESCE('x')) != (t1.c1)));
[13 Apr 2021 9:26] MySQL Verification Team
Hello!

Thank you for the report and test case.

regards,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.