mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-30623 JSON_TABLE in subquery not correctly marked as correlated
st_select_lex::update_correlated_cache() fails to take JSON_TABLE functions in subqueries into account. Reviewed by Sergei Petrunia (sergey@mariadb.com)
This commit is contained in:
@ -7559,5 +7559,31 @@ Warning 1292 Truncated incorrect DECIMAL value: 'e'
|
|||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1, t2, t3;
|
drop table t1, t2, t3;
|
||||||
#
|
#
|
||||||
|
# MDEV-30623 JSON_TABLE in subquery not correctly marked as correlated
|
||||||
|
# update_correlated_cache() fails to take JSON_TABLE functions in
|
||||||
|
# subqueries into account.
|
||||||
|
#
|
||||||
|
create table t1(c json);
|
||||||
|
insert into t1 values ('[{"x":"1"},{"x":"2"}]'),
|
||||||
|
('[{"x":"10"},{"x":"20"}]'),
|
||||||
|
('[{"x":"100"},{"x":"200"}]');
|
||||||
|
select c,
|
||||||
|
(SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
from t1;
|
||||||
|
c (SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
[{"x":"1"},{"x":"2"}] 3
|
||||||
|
[{"x":"10"},{"x":"20"}] 30
|
||||||
|
[{"x":"100"},{"x":"200"}] 300
|
||||||
|
explain select c,
|
||||||
|
(SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
from t1;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||||
|
2 DEPENDENT SUBQUERY jt ALL NULL NULL NULL NULL 40 Table function: json_table
|
||||||
|
drop table t1;
|
||||||
|
#
|
||||||
# End of 10.6 tests
|
# End of 10.6 tests
|
||||||
#
|
#
|
||||||
|
@ -6434,6 +6434,28 @@ insert into t2 select (('e','e') IN (SELECT v1.id, v1.id FROM v1 JOIN t3));
|
|||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1, t2, t3;
|
drop table t1, t2, t3;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-30623 JSON_TABLE in subquery not correctly marked as correlated
|
||||||
|
--echo # update_correlated_cache() fails to take JSON_TABLE functions in
|
||||||
|
--echo # subqueries into account.
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
create table t1(c json);
|
||||||
|
insert into t1 values ('[{"x":"1"},{"x":"2"}]'),
|
||||||
|
('[{"x":"10"},{"x":"20"}]'),
|
||||||
|
('[{"x":"100"},{"x":"200"}]');
|
||||||
|
select c,
|
||||||
|
(SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
from t1;
|
||||||
|
|
||||||
|
explain select c,
|
||||||
|
(SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
from t1;
|
||||||
|
|
||||||
|
drop table t1;
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
--echo # End of 10.6 tests
|
--echo # End of 10.6 tests
|
||||||
--echo #
|
--echo #
|
||||||
|
@ -7559,6 +7559,32 @@ Warning 1292 Truncated incorrect DECIMAL value: 'e'
|
|||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1, t2, t3;
|
drop table t1, t2, t3;
|
||||||
#
|
#
|
||||||
|
# MDEV-30623 JSON_TABLE in subquery not correctly marked as correlated
|
||||||
|
# update_correlated_cache() fails to take JSON_TABLE functions in
|
||||||
|
# subqueries into account.
|
||||||
|
#
|
||||||
|
create table t1(c json);
|
||||||
|
insert into t1 values ('[{"x":"1"},{"x":"2"}]'),
|
||||||
|
('[{"x":"10"},{"x":"20"}]'),
|
||||||
|
('[{"x":"100"},{"x":"200"}]');
|
||||||
|
select c,
|
||||||
|
(SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
from t1;
|
||||||
|
c (SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
[{"x":"1"},{"x":"2"}] 3
|
||||||
|
[{"x":"10"},{"x":"20"}] 30
|
||||||
|
[{"x":"100"},{"x":"200"}] 300
|
||||||
|
explain select c,
|
||||||
|
(SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
from t1;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||||
|
2 DEPENDENT SUBQUERY jt ALL NULL NULL NULL NULL 40 Table function: json_table
|
||||||
|
drop table t1;
|
||||||
|
#
|
||||||
# End of 10.6 tests
|
# End of 10.6 tests
|
||||||
#
|
#
|
||||||
set optimizer_switch=default;
|
set optimizer_switch=default;
|
||||||
|
@ -7552,6 +7552,32 @@ Warning 1292 Truncated incorrect DECIMAL value: 'e'
|
|||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1, t2, t3;
|
drop table t1, t2, t3;
|
||||||
#
|
#
|
||||||
|
# MDEV-30623 JSON_TABLE in subquery not correctly marked as correlated
|
||||||
|
# update_correlated_cache() fails to take JSON_TABLE functions in
|
||||||
|
# subqueries into account.
|
||||||
|
#
|
||||||
|
create table t1(c json);
|
||||||
|
insert into t1 values ('[{"x":"1"},{"x":"2"}]'),
|
||||||
|
('[{"x":"10"},{"x":"20"}]'),
|
||||||
|
('[{"x":"100"},{"x":"200"}]');
|
||||||
|
select c,
|
||||||
|
(SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
from t1;
|
||||||
|
c (SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
[{"x":"1"},{"x":"2"}] 3
|
||||||
|
[{"x":"10"},{"x":"20"}] 30
|
||||||
|
[{"x":"100"},{"x":"200"}] 300
|
||||||
|
explain select c,
|
||||||
|
(SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
from t1;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||||
|
2 DEPENDENT SUBQUERY jt ALL NULL NULL NULL NULL 40 Table function: json_table
|
||||||
|
drop table t1;
|
||||||
|
#
|
||||||
# End of 10.6 tests
|
# End of 10.6 tests
|
||||||
#
|
#
|
||||||
set optimizer_switch=default;
|
set optimizer_switch=default;
|
||||||
|
@ -7550,6 +7550,32 @@ Warning 1292 Truncated incorrect DECIMAL value: 'e'
|
|||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1, t2, t3;
|
drop table t1, t2, t3;
|
||||||
#
|
#
|
||||||
|
# MDEV-30623 JSON_TABLE in subquery not correctly marked as correlated
|
||||||
|
# update_correlated_cache() fails to take JSON_TABLE functions in
|
||||||
|
# subqueries into account.
|
||||||
|
#
|
||||||
|
create table t1(c json);
|
||||||
|
insert into t1 values ('[{"x":"1"},{"x":"2"}]'),
|
||||||
|
('[{"x":"10"},{"x":"20"}]'),
|
||||||
|
('[{"x":"100"},{"x":"200"}]');
|
||||||
|
select c,
|
||||||
|
(SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
from t1;
|
||||||
|
c (SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
[{"x":"1"},{"x":"2"}] 3
|
||||||
|
[{"x":"10"},{"x":"20"}] 30
|
||||||
|
[{"x":"100"},{"x":"200"}] 300
|
||||||
|
explain select c,
|
||||||
|
(SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
from t1;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||||
|
2 DEPENDENT SUBQUERY jt ALL NULL NULL NULL NULL 40 Table function: json_table
|
||||||
|
drop table t1;
|
||||||
|
#
|
||||||
# End of 10.6 tests
|
# End of 10.6 tests
|
||||||
#
|
#
|
||||||
set @optimizer_switch_for_subselect_test=null;
|
set @optimizer_switch_for_subselect_test=null;
|
||||||
|
@ -7565,6 +7565,32 @@ Warning 1292 Truncated incorrect DECIMAL value: 'e'
|
|||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1, t2, t3;
|
drop table t1, t2, t3;
|
||||||
#
|
#
|
||||||
|
# MDEV-30623 JSON_TABLE in subquery not correctly marked as correlated
|
||||||
|
# update_correlated_cache() fails to take JSON_TABLE functions in
|
||||||
|
# subqueries into account.
|
||||||
|
#
|
||||||
|
create table t1(c json);
|
||||||
|
insert into t1 values ('[{"x":"1"},{"x":"2"}]'),
|
||||||
|
('[{"x":"10"},{"x":"20"}]'),
|
||||||
|
('[{"x":"100"},{"x":"200"}]');
|
||||||
|
select c,
|
||||||
|
(SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
from t1;
|
||||||
|
c (SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
[{"x":"1"},{"x":"2"}] 3
|
||||||
|
[{"x":"10"},{"x":"20"}] 30
|
||||||
|
[{"x":"100"},{"x":"200"}] 300
|
||||||
|
explain select c,
|
||||||
|
(SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
from t1;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||||
|
2 DEPENDENT SUBQUERY jt ALL NULL NULL NULL NULL 40 Table function: json_table
|
||||||
|
drop table t1;
|
||||||
|
#
|
||||||
# End of 10.6 tests
|
# End of 10.6 tests
|
||||||
#
|
#
|
||||||
set optimizer_switch=default;
|
set optimizer_switch=default;
|
||||||
|
@ -7550,6 +7550,32 @@ Warning 1292 Truncated incorrect DECIMAL value: 'e'
|
|||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1, t2, t3;
|
drop table t1, t2, t3;
|
||||||
#
|
#
|
||||||
|
# MDEV-30623 JSON_TABLE in subquery not correctly marked as correlated
|
||||||
|
# update_correlated_cache() fails to take JSON_TABLE functions in
|
||||||
|
# subqueries into account.
|
||||||
|
#
|
||||||
|
create table t1(c json);
|
||||||
|
insert into t1 values ('[{"x":"1"},{"x":"2"}]'),
|
||||||
|
('[{"x":"10"},{"x":"20"}]'),
|
||||||
|
('[{"x":"100"},{"x":"200"}]');
|
||||||
|
select c,
|
||||||
|
(SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
from t1;
|
||||||
|
c (SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
[{"x":"1"},{"x":"2"}] 3
|
||||||
|
[{"x":"10"},{"x":"20"}] 30
|
||||||
|
[{"x":"100"},{"x":"200"}] 300
|
||||||
|
explain select c,
|
||||||
|
(SELECT sum(x) FROM json_table(c, "$[*]" columns( x int path "$.x"))
|
||||||
|
AS jt)
|
||||||
|
from t1;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||||
|
2 DEPENDENT SUBQUERY jt ALL NULL NULL NULL NULL 40 Table function: json_table
|
||||||
|
drop table t1;
|
||||||
|
#
|
||||||
# End of 10.6 tests
|
# End of 10.6 tests
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
@ -5501,6 +5501,9 @@ void st_select_lex::update_correlated_cache()
|
|||||||
|
|
||||||
while ((tl= ti++))
|
while ((tl= ti++))
|
||||||
{
|
{
|
||||||
|
if (tl->table_function)
|
||||||
|
is_correlated|= MY_TEST(tl->table_function->used_tables() &
|
||||||
|
OUTER_REF_TABLE_BIT);
|
||||||
// is_correlated|= tl->is_with_table_recursive_reference();
|
// is_correlated|= tl->is_with_table_recursive_reference();
|
||||||
if (tl->on_expr)
|
if (tl->on_expr)
|
||||||
is_correlated|= MY_TEST(tl->on_expr->used_tables() & OUTER_REF_TABLE_BIT);
|
is_correlated|= MY_TEST(tl->on_expr->used_tables() & OUTER_REF_TABLE_BIT);
|
||||||
|
Reference in New Issue
Block a user