Bug #120263 Inconsistent results for query with JSON_CONTAINS and CAST(... AS SIGNED)

Submitted: 14 Apr 5:30 Modified: 14 Apr 10:55
Reporter: Guo Yuxiao Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: JSON Severity:S2 (Serious)
Version:8.0.45 OS:Any
Assigned to: CPU Architecture:Any

[14 Apr 5:30] Guo Yuxiao
Description:
Hi, I found a logic bug in MySQL 9.6.0.
A query that should have returned an empty set actually returned 1.

This query will return an empty set when executed in other databases, such as MariaDB.

How to repeat:
-- create table
DROP TABLE IF EXISTS `t2`;
CREATE TABLE `t2` ( `c0` longtext   COMMENT 'asdf' ) CHARSET=utf8mb4;
DROP TABLE IF EXISTS `t4`;
CREATE TABLE `t4` ( `c0` longtext   COMMENT 'asdf' ) CHARSET=utf8mb4;
INSERT INTO `t4` VALUES ('0.8937270726098927'),(NULL);

-- query, expect:empty set, actual:{1}
SELECT DISTINCT
    1 AS c0
FROM t2 AS ref_0
RIGHT JOIN t4 AS ref_1
    ON ref_0.c0 = ref_1.c0
WHERE JSON_LENGTH(JSON_ARRAY(ref_0.c0, ref_1.c0))
    MOD NULLIF(-(JSON_CONTAINS(JSON_OBJECT('k', ref_1.c0), JSON_OBJECT('k', ref_0.c0))), 0)
    < -(CAST(-(COALESCE((-53) & (-82), CAST(-27 AS SIGNED))) AS SIGNED))
ORDER BY c0 DESC;
[14 Apr 10:55] Roy Lyseng
Thank you for the bug report.
Verified as described.

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

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