Bug #120535 Incorrect Query Result: IN and NOT IN return the same row simultaneously (boolean logic violation)

Submitted: 24 May 5:29 Modified: 26 May 12:42
Reporter: Jason Tang Email Updates:
Status: Patch pending Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0.45 OS:Any
Assigned to: CPU Architecture:Any

[24 May 5:29] Jason Tang
Description:
When using IN / NOT IN with a COALESCE() expression that returns a FLOAT/DOUBLE value, MySQL returns the same row for both conditions:
WHERE (col) IN ( ... ) → returns row
WHERE (col) NOT IN ( ... ) → also returns the same row

How to repeat:
DROP DATABASE IF EXISTS database0;
CREATE DATABASE database0;
USE database0;

CREATE TABLE `t0` (
  `c0` smallint STORAGE DISK DEFAULT NULL COMMENT 'asdf',
  KEY `i0` (`c0`) USING BTREE
);

INSERT INTO t0(c0) VALUES (1);

-- Query 1: returns row
SELECT ALL t0.c0 AS ref0
FROM t0
WHERE (t0.c0) IN (COALESCE(0.5995035972593574, "yo?x&I", '', NULL));

-- Query 2: returns THE SAME row (WRONG)
SELECT ALL t0.c0 AS ref0
FROM t0
WHERE (t0.c0) NOT IN (COALESCE(0.5995035972593574, "yo?x&I", '', NULL));
[26 May 12:42] Roy Lyseng
Thank you for the bug report.
Verified as described.
[26 Oct 15:44] OCA Admin
Contribution submitted via Github - Bug#120535: Preserve equality filters after lossy integer key conversion 
(*) Contribution by PR specific confirm no longer needed

Contribution: git_patch_4659942971.txt (text/plain), 238.59 KiB.

[30 Oct 15:47] MySQL Admin
Posted by developer: Bug status updated to 'Patch pending'

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

Page generated in 0.071 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.