1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

MDEV-25202: JSON_TABLE: Early table reference leads to unexpected result set

Followup part#2: allocate the List object on the right mem-root, too.
This commit is contained in:
Sergei Petrunia
2021-04-17 18:23:15 +03:00
committed by Alexey Botchkov
parent e4665f417b
commit 0a09525625
3 changed files with 76 additions and 3 deletions

View File

@@ -623,7 +623,44 @@ insert into t1 values ('Jeans', '{"color": ["gray"], "price": 60}');
insert into t1 values ('Laptop', '{"color": ["black"], "price": 1000}');
insert into t1 values ('Shirt', '{"color": ["black"], "price": 20}');
select t.item_name, jt.* from (select t1.item_name, concat(concat(concat("{\"color\": ",concat(concat("[\"",group_concat(jt.color separator "\", \"")),"\"]")),','),concat(concat("\"price\": ",jt.price),'}')) as item_props from t1, json_table(t1.item_props, '$' columns (nested path '$.color[*]' columns (color varchar(32) path '$'), price int path '$.price')) as jt group by t1.item_name, jt.price) as t, json_table(t.item_props, '$' columns (nested path '$.color[*]' columns (color varchar(32) path '$'), price int path '$.price')) as jt order by t.item_name, jt.price, jt.color;
select
t.item_name,
jt.*
from
(select
t1.item_name,
concat(
concat(
concat(
"{\"color\": ",
concat(
concat("[\"",
group_concat( jt.color separator "\", \"")
),
"\"]")
),','
),
concat(concat("\"price\": ",jt.price),'}')
) as item_props
from
t1,
json_table(
t1.item_props,
'$' columns (
nested path '$.color[*]' columns (color varchar(32) path '$'),
price int path '$.price')
) as jt
group by
t1.item_name, jt.price
) as t,
json_table(t.item_props,
'$' columns (
nested path '$.color[*]' columns (color varchar(32) path '$'),
price int path '$.price')
) as jt
order by
t.item_name, jt.price, jt.color;
drop table t1;