Skip to content

Commit 67a9b82

Browse files
committed
Bug#26022576: JSON_INSERT DOES NOT HANDLE AUTO-WRAPPING
JSON_INSERT called Json_dom::seek() with auto_wrap=false, so it didn't handle auto-wrapping. Fixed by changing the auto_wrap argument to true in the calls to seek(). Change-Id: I27c94cb790c426e130df34abbbe8c84b128b98d0
1 parent 9bcf287 commit 67a9b82

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

mysql-test/suite/json/r/json_no_table.result

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3803,3 +3803,11 @@ DROP VIEW v;
38033803
SELECT CAST('{"a": [1,2,3], "a": [4,5,6]}' AS JSON);
38043804
CAST('{"a": [1,2,3], "a": [4,5,6]}' AS JSON)
38053805
{"a": [4, 5, 6]}
3806+
#
3807+
# Bug#26022576: JSON_INSERT DOES NOT HANDLE AUTO-WRAPPING
3808+
#
3809+
SELECT JSON_INSERT('{"a":1}', '$.a[1]', 123) AS c1,
3810+
JSON_INSERT('{"a":1}', '$[0].a[1]', 123) AS c2,
3811+
JSON_INSERT('{"a":1}', '$.a[0][1]', 123) AS c3;
3812+
c1 c2 c3
3813+
{"a": [1, 123]} {"a": [1, 123]} {"a": [1, 123]}

mysql-test/suite/json/t/json_no_table.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2548,3 +2548,10 @@ DROP VIEW v;
25482548
--echo # Bug#26238736: ASSERTION `__NULL != DYNAMIC_CAST<TARGET>(ARG)' FAILURE
25492549
--echo #
25502550
SELECT CAST('{"a": [1,2,3], "a": [4,5,6]}' AS JSON);
2551+
2552+
--echo #
2553+
--echo # Bug#26022576: JSON_INSERT DOES NOT HANDLE AUTO-WRAPPING
2554+
--echo #
2555+
SELECT JSON_INSERT('{"a":1}', '$.a[1]', 123) AS c1,
2556+
JSON_INSERT('{"a":1}', '$[0].a[1]', 123) AS c2,
2557+
JSON_INSERT('{"a":1}', '$.a[0][1]', 123) AS c3;

sql/item_json_func.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,7 +2232,7 @@ bool Item_func_json_insert::val_json(Json_wrapper *wr)
22322232

22332233
{
22342234
Json_dom_vector hits(key_memory_JSON);
2235-
if (doc->seek(m_path, &hits, false, true))
2235+
if (doc->seek(m_path, &hits, true, true))
22362236
return error_json(); /* purecov: inspected */
22372237

22382238
if (hits.size() != 0 || // already exists
@@ -2251,7 +2251,7 @@ bool Item_func_json_insert::val_json(Json_wrapper *wr)
22512251
*/
22522252
Json_dom_vector hits(key_memory_JSON);
22532253
const Json_path_leg *leg= m_path.pop();
2254-
if (doc->seek(m_path, &hits, false, true))
2254+
if (doc->seek(m_path, &hits, true, true))
22552255
return error_json(); /* purecov: inspected */
22562256

22572257
if (hits.size() < 1)

0 commit comments

Comments
 (0)