Skip to content

Commit b62672a

Browse files
committed
MDEV-26054 Server crashes in Item_func_json_arrayagg::get_str_from_field
Revert "fix JSON_ARRAYAGG not to over-quote json in joins" This removes 8711adb but keeps the test case. A different fix is coming up. Because args can be Item_field's that are later replaced by Item_direct_view_ref to the actual field. While Item_field preserved in orig_args will stay unfixed with item->field==NULL and no metadata
1 parent 83684fc commit b62672a

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

mysql-test/main/func_json.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,5 +1382,16 @@ id materials
13821382
DROP TABLE t1;
13831383
DROP TABLE t2;
13841384
#
1385+
# MDEV-26054 Server crashes in Item_func_json_arrayagg::get_str_from_field
1386+
#
1387+
CREATE TABLE t (a VARCHAR(8));
1388+
CREATE VIEW v AS SELECT * FROM t;
1389+
INSERT INTO t VALUES ('foo'),('bar');
1390+
SELECT JSON_ARRAYAGG(a) AS f FROM v;
1391+
f
1392+
["foo","bar"]
1393+
DROP VIEW v;
1394+
DROP TABLE t;
1395+
#
13851396
# End of 10.5 tests
13861397
#

mysql-test/main/func_json.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,17 @@ SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id) ORDER BY t2.id) as materials
873873
DROP TABLE t1;
874874
DROP TABLE t2;
875875

876+
--echo #
877+
--echo # MDEV-26054 Server crashes in Item_func_json_arrayagg::get_str_from_field
878+
--echo #
879+
880+
CREATE TABLE t (a VARCHAR(8));
881+
CREATE VIEW v AS SELECT * FROM t;
882+
INSERT INTO t VALUES ('foo'),('bar');
883+
SELECT JSON_ARRAYAGG(a) AS f FROM v;
884+
DROP VIEW v;
885+
DROP TABLE t;
886+
876887
--echo #
877888
--echo # End of 10.5 tests
878889
--echo #

sql/item_jsonfunc.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3723,12 +3723,12 @@ String *Item_func_json_arrayagg::get_str_from_item(Item *i, String *tmp)
37233723
}
37243724

37253725

3726-
String *Item_func_json_arrayagg::get_str_from_field(Item *, Field *f,
3726+
String *Item_func_json_arrayagg::get_str_from_field(Item *i,Field *f,
37273727
String *tmp, const uchar *key, size_t offset)
37283728
{
37293729
m_tmp_json.length(0);
37303730

3731-
if (append_json_value_from_field(&m_tmp_json, *orig_args, f, key, offset, tmp))
3731+
if (append_json_value_from_field(&m_tmp_json, i, f, key, offset, tmp))
37323732
return NULL;
37333733

37343734
return &m_tmp_json;

0 commit comments

Comments
 (0)