Bug #108630 json query bug
Submitted: 28 Sep 2022 10:46 Modified: 28 Sep 2022 11:32
Reporter: yu wei Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: JSON Severity:S3 (Non-critical)
Version:5.7 OS:Linux (centos 7.5)
Assigned to: CPU Architecture:x86

[28 Sep 2022 10:46] yu wei
Description:
Table structure:
CREATE TABLE `test_json` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `info` json DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT DEFAULT CHARSET=gb2312;

Table rows:
id       info
1        {"age": 10, "name": "foo"}
2        {"age": 15, "name": "boo"}

WHEN execute query:
select * from test_json where info -> '$.name' in ('foo');
then return row 1;

WHEN execute query:
select * from test_json where info -> '$.name' in ('foo', 'boo');
then return empty;

How to repeat:
table structure:
CREATE TABLE `test_json` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `info` json DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT DEFAULT CHARSET=gb2312;

table data:
INSERT INTO `test`.`test_json` (`id`, `info`) VALUES (1, '{\"age\": 10, \"name\": \"foo\"}');
INSERT INTO `test`.`test_json` (`id`, `info`) VALUES (2, '{\"age\": 15, \"name\": \"boo\"}');

WHEN execute query:
select * from test_json where info -> '$.name' in ('foo');
then return row 1;

WHEN execute query:
select * from test_json where info -> '$.name' in ('foo', 'boo');
then return empty;

Suggested fix:
WHEN execute query:
select * from test_json where info -> '$.name' in ('foo', 'boo');
should return row 2;
[28 Sep 2022 11:32] MySQL Verification Team
Hello delv delv,

Thank you for the report and test case.
Observed that 5.7.39 is affected.

regards,
Umesh