Bug #117234 Unexpected results when using JSON_ARRAY(NULL) in query predicates.
Submitted: 18 Jan 6:35 Modified: 20 Jan 5:55
Reporter: wang jack Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: JSON Severity:S2 (Serious)
Version:8.4.1,9.1.0, 8.0.40, 8.4.3 OS:Windows
Assigned to: CPU Architecture:x86

[18 Jan 6:35] wang jack
Description:
From my understanding, the first query below should return empty, but it is actually return one row.

mysql> SELECT ALL TRUE FROM t0 WHERE (0.19839762360107815 IS NULL) NOT IN (JSON_ARRAY(NULL), ( EXISTS (SELECT 1)) AND (t0.c1)); -- 1 row
+------+
| TRUE |
+------+
|    1 |
+------+
1 row in set (0.00 sec)

mysql>
mysql> SELECT (0.19839762360107815 IS NULL) NOT IN (JSON_ARRAY(NULL), ( EXISTS (SELECT 1)) AND (t0.c1)) FROM t0;                -- {0}
+-------------------------------------------------------------------------------------------+
| (0.19839762360107815 IS NULL) NOT IN (JSON_ARRAY(NULL), ( EXISTS (SELECT 1)) AND (t0.c1)) |
+-------------------------------------------------------------------------------------------+
|                                                                                         0 |
+-------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

How to repeat:
DROP TABLE IF EXISTS t0;
CREATE TABLE IF NOT EXISTS t0(c1 LONGTEXT) ;
INSERT INTO t0(c1) VALUES('y3');

SELECT ALL TRUE FROM t0 WHERE (0.19839762360107815 IS NULL) NOT IN (JSON_ARRAY(NULL), ( EXISTS (SELECT 1)) AND (t0.c1)); -- 1 row

SELECT (0.19839762360107815 IS NULL) NOT IN (JSON_ARRAY(NULL), ( EXISTS (SELECT 1)) AND (t0.c1)) FROM t0;                -- {0}
[20 Jan 5:55] MySQL Verification Team
Hello wang jack,

Thank you for the report and test case.
Verified as described.

regards,
Umesh