Details
-
Bug
-
Status: In Review (View Workflow)
-
Major
-
Resolution: Unresolved
-
12.3, 12.3.1, 12.3.2
-
ubuntu22.04
Description
Summary
Single-level `JSON_ARRAY_INTERSECT(c1, c2)` returns correct JSON arrays.
Nesting the function:
SELECT JSON_ARRAY_INTERSECT(JSON_ARRAY_INTERSECT(c1, c2), c2) FROM t1; |
produces NULL for every row, although the inner intersect is non-empty.
The outer intersect with `c2` should return the same result as the single-level call (`[2,3]` and `[4]` for sample data).
Version
MariaDB 12.3.1-MariaDB-asan
|
Minimal reproducer
DROP TABLE IF EXISTS t1; |
CREATE TABLE t1 ( |
c1 longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin |
DEFAULT NULL CHECK (json_valid(c1)), |
c2 longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin |
DEFAULT NULL CHECK (json_valid(c2)) |
) ENGINE=InnoDB;
|
|
|
INSERT INTO t1 VALUES |
('[1,2,3]', '[2,3,4]'), |
('[2,3,4]', '[4,5,6]'); |
|
|
-- single-level
|
SELECT JSON_ARRAY_INTERSECT(c1, c2) AS r FROM t1; |
|
|
-- nested (produces bug)
|
SELECT JSON_ARRAY_INTERSECT(JSON_ARRAY_INTERSECT(c1, c2), c2) AS r FROM t1; |
Actual Result
-- single-level
|
r
|
[2, 3]
|
[4]
|
|
|
-- nested
|
r
|
NULL
|
NULL
|
Expected Result
Nested output should match single-level intersect:
[2, 3]
|
[4]
|
Type / Priority / Component
| Field | Value |
| --------- | ---------------------------------------------------------- |
| Type | Bug |
| Priority | Major (wrong result) |
| Component | Server / SQL — JSON functions |
| Labels | json, json_array_intersect, wrong-result |
| Link | relates to |
Notes
- No SQL error is produced; the wrong result is silent NULLs.
- Only the nested expression triggers the bug; single-level usage works as expected.
- Not related to filtering with `WHERE JSON_ARRAY_INTERSECT(...)`.
Discovery
- Tool: crdb_mutate n200 MariaDB batch (`--oracle --oracle-psi`)
- PSI:
MDEV-31411(`JSON_ARRAY_INTERSECT(c1,c2)`) - Nested candidate confirmed manually.
Environment
- MariaDB tested: 12.3.1-MariaDB-asan
- Reproduced: 2026-06-06