Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 13.1, 12.3.3
-
Linux/amd64
Description
JSON_CONTAINS and JSON_OVERLAPS return 0 when comparing valid JSON strings that represent the same Unicode character but are supplied as independently encoded latin1 and utf8mb4 SQL arguments. SQL comparison and JSON_EQUALS recognize the decoded values as equal, but both other functions report inequality in either argument direction. This was reproduced with MariaDB 12.3.3-MariaDB-ubu2404 on Linux/amd64.
Cross-character-set comparison
Run the following SQL in one session:
SET @latin1_doc = |
CONVERT(0x22E922 USING latin1); |
SET @utf8_doc = |
CONVERT(0x22C3A922 USING utf8mb4); |
|
|
SELECT JSON_VALID(@latin1_doc) AS latin1_valid, |
JSON_VALID(@utf8_doc) AS utf8_valid, |
CONVERT(JSON_UNQUOTE(@latin1_doc) USING utf8mb4) = |
JSON_UNQUOTE(@utf8_doc) AS decoded_equal, |
JSON_EQUALS(@latin1_doc,
|
@utf8_doc) AS json_equals, |
JSON_CONTAINS(@latin1_doc,
|
@utf8_doc) AS contains_latin1_utf8, |
JSON_CONTAINS(@utf8_doc,
|
@latin1_doc) AS contains_utf8_latin1, |
JSON_OVERLAPS(@latin1_doc,
|
@utf8_doc) AS overlaps_latin1_utf8, |
JSON_OVERLAPS(@utf8_doc,
|
@latin1_doc) AS overlaps_utf8_latin1; |
|
|
SET @latin1_doc = NULL; |
SET @utf8_doc = NULL; |
The query returns:
latin1_valid utf8_valid decoded_equal json_equals contains_latin1_utf8 contains_utf8_latin1 overlaps_latin1_utf8 overlaps_utf8_latin1
|
1 1 1 1 0 0 0 0
|
Both inputs are valid, their decoded SQL values compare equal, and JSON_EQUALS returns 1. All result columns should return 1 because the two JSON strings represent U+00E9 and differ only in their SQL argument encodings. Semantic JSON comparison should compare the decoded characters independently of those encodings and produce the same result in either argument direction.
This occurs when JSON_CONTAINS or JSON_OVERLAPS compares equivalent JSON string values supplied through SQL arguments with different character sets.
Attachments
Issue Links
- relates to
-
MDEV-14301 JSON_UNQUOTE returns incorrect results depending on the collation
-
- Closed
-