Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 13.0
-
None
-
None
Description
An object argument merged onto SQL NULL is dropped, which is the right
answer - nothing of it reaches the result whether it is a document or
not. What is missing is any diagnostic: in this one argument position a
malformed document draws nothing, while the same function refuses the
same characters everywhere else.
SELECT JSON_MERGE_PATCH(NULL,'{"a":1 "b":2}','[1,2]') AS v; |
v
|
[1, 2]
|
No warning. The same broken object in any other position is refused
with Warning 4038 naming its position.
How to repeat
SELECT JSON_MERGE_PATCH(NULL,'{"a":1 "b":2}','[1,2]') AS v; |
SELECT JSON_MERGE_PATCH(NULL,'{"a":1,','[1,2]') AS v; |
SELECT JSON_MERGE_PATCH(NULL,'{','[1,2]') AS v; |
SELECT JSON_MERGE_PATCH(NULL,'{"a":1 "b":2}','[1,2]','{"c":3}') AS v; |
-- [1, 2] / [1, 2] / [1, 2] / {"c": 3}, all silent
|
The answers themselves are not in dispute: the two-argument forms are
NULL, and no partial content ever reaches the result.
Root cause
The arm that merges onto SQL NULL returns before the point where a
refusal would be reported, on the reasoning - stated in the code - that
an object merged onto NULL contributes nothing either way. That much is
true; the sentence that follows it is not, since the same characters are
in fact refused in every other argument position rather than spoken for.
Affected versions
JSON_MERGE_PATCH was added in 10.2.25.
Verified on 10.11 only (10.11.19-MariaDB-debug, commit 1dab253482d).
Other branches were not tested.
Note
Found while auditing the JSON functions against their documented
contracts. Pinned as correct:
func_json_merge_broken.result:113-116 records
JSON_MERGE_PATCH(NULL, '
', '[3,4]') -> [3, 4] with no
Warnings block at all.
Attachments
Issue Links
- split from
-
MDEV-40642 Project "JSON Phoenix" (placeholder)
-
- Open
-