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:
parent
e4665f417b
commit
0a09525625
@ -722,7 +722,43 @@ insert into t1 values ('Jeans', '{"color": ["black"], "price": 60}');
|
|||||||
insert into t1 values ('Jeans', '{"color": ["gray"], "price": 60}');
|
insert into t1 values ('Jeans', '{"color": ["gray"], "price": 60}');
|
||||||
insert into t1 values ('Laptop', '{"color": ["black"], "price": 1000}');
|
insert into t1 values ('Laptop', '{"color": ["black"], "price": 1000}');
|
||||||
insert into t1 values ('Shirt', '{"color": ["black"], "price": 20}');
|
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;
|
||||||
item_name color price
|
item_name color price
|
||||||
Jeans brown 50
|
Jeans brown 50
|
||||||
Jeans green 50
|
Jeans green 50
|
||||||
|
@ -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 ('Laptop', '{"color": ["black"], "price": 1000}');
|
||||||
insert into t1 values ('Shirt', '{"color": ["black"], "price": 20}');
|
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;
|
drop table t1;
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ List<TABLE_LIST>* get_disallowed_table_deps(MEM_ROOT *mem_root,
|
|||||||
{
|
{
|
||||||
List<TABLE_LIST> *disallowed_tables;
|
List<TABLE_LIST> *disallowed_tables;
|
||||||
|
|
||||||
if (!(disallowed_tables = new List<TABLE_LIST>))
|
if (!(disallowed_tables = new (mem_root) List<TABLE_LIST>))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
int res= get_disallowed_table_deps_for_list(mem_root, table_func,
|
int res= get_disallowed_table_deps_for_list(mem_root, table_func,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user