Commit 397f5cf7 authored by Sergei Petrunia's avatar Sergei Petrunia

MDEV-27238: Assertion `got_name == named_item_expected()' failed in Json_writer

make_join_select() calls const_cond->val_int(). There are edge cases
where const_cond may have a not-yet optimized subquery.

(The subquery will have used_tables() covered by join->const_tables. It
will still have const_item()==false, so other parts of the optimizer
will not try to evaluate it.  We should probably mark such subqueries
as constant but that is outside the scope of this MDEV)
parent 0165a063
...@@ -2393,7 +2393,8 @@ select t1.a from t1 left join t2 on t1.a=t2.a { ...@@ -2393,7 +2393,8 @@ select t1.a from t1 left join t2 on t1.a=t2.a {
"best_join_order": ["t2", "t1"] "best_join_order": ["t2", "t1"]
}, },
{ {
"condition_on_constant_tables": "1" "condition_on_constant_tables": "1",
"computing_condition": []
}, },
{ {
"attaching_conditions_to_tables": { "attaching_conditions_to_tables": {
...@@ -2550,7 +2551,8 @@ explain select * from t1 left join t2 on t2.a=t1.a { ...@@ -2550,7 +2551,8 @@ explain select * from t1 left join t2 on t2.a=t1.a {
"best_join_order": ["t1", "t2"] "best_join_order": ["t1", "t2"]
}, },
{ {
"condition_on_constant_tables": "1" "condition_on_constant_tables": "1",
"computing_condition": []
}, },
{ {
"attaching_conditions_to_tables": { "attaching_conditions_to_tables": {
...@@ -2708,7 +2710,8 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and ...@@ -2708,7 +2710,8 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and
"best_join_order": ["t3", "t2", "t1"] "best_join_order": ["t3", "t2", "t1"]
}, },
{ {
"condition_on_constant_tables": "1" "condition_on_constant_tables": "1",
"computing_condition": []
}, },
{ {
"attaching_conditions_to_tables": { "attaching_conditions_to_tables": {
...@@ -3021,7 +3024,8 @@ explain extended select * from t1 where a in (select pk from t10) { ...@@ -3021,7 +3024,8 @@ explain extended select * from t1 where a in (select pk from t10) {
"best_join_order": ["t1", "<subquery2>"] "best_join_order": ["t1", "<subquery2>"]
}, },
{ {
"condition_on_constant_tables": "1" "condition_on_constant_tables": "1",
"computing_condition": []
}, },
{ {
"attaching_conditions_to_tables": { "attaching_conditions_to_tables": {
...@@ -4719,7 +4723,8 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ ...@@ -4719,7 +4723,8 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
"best_join_order": ["t1", "<subquery2>"] "best_join_order": ["t1", "<subquery2>"]
}, },
{ {
"condition_on_constant_tables": "1" "condition_on_constant_tables": "1",
"computing_condition": []
}, },
{ {
"attaching_conditions_to_tables": { "attaching_conditions_to_tables": {
...@@ -7365,7 +7370,8 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { ...@@ -7365,7 +7370,8 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
] ]
}, },
{ {
"condition_on_constant_tables": "1" "condition_on_constant_tables": "1",
"computing_condition": []
}, },
{ {
"attaching_conditions_to_tables": { "attaching_conditions_to_tables": {
...@@ -8632,5 +8638,14 @@ SELECT 'a\0' LIMIT 0 { ...@@ -8632,5 +8638,14 @@ SELECT 'a\0' LIMIT 0 {
} }
SET optimizer_trace=DEFAULT; SET optimizer_trace=DEFAULT;
# #
# MDEV-27238: Assertion `got_name == named_item_expected()' failed in Json_writer::on_start_object
#
CREATE TABLE t1 (a INT KEY,b INT,KEY(b)) ENGINE=MEMORY;
SET optimizer_trace=1;
INSERT INTO t1 VALUES (0,0);
SELECT a FROM t1 WHERE (a,b) in (SELECT @c,@d);
a
DROP TABLE t1;
#
# End of 10.4 tests # End of 10.4 tests
# #
...@@ -643,6 +643,16 @@ SELECT 'a\0' LIMIT 0; ...@@ -643,6 +643,16 @@ SELECT 'a\0' LIMIT 0;
SELECT query, trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; SELECT query, trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
SET optimizer_trace=DEFAULT; SET optimizer_trace=DEFAULT;
--echo #
--echo # MDEV-27238: Assertion `got_name == named_item_expected()' failed in Json_writer::on_start_object
--echo #
CREATE TABLE t1 (a INT KEY,b INT,KEY(b)) ENGINE=MEMORY;
SET optimizer_trace=1;
INSERT INTO t1 VALUES (0,0);
SELECT a FROM t1 WHERE (a,b) in (SELECT @c,@d);
DROP TABLE t1;
--echo # --echo #
--echo # End of 10.4 tests --echo # End of 10.4 tests
--echo # --echo #
...@@ -11409,7 +11409,11 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) ...@@ -11409,7 +11409,11 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
} }
else else
{ {
const bool const_cond_result = const_cond->val_int() != 0; bool const_cond_result;
{
Json_writer_array a(thd, "computing_condition");
const_cond_result= const_cond->val_int() != 0;
}
if (!const_cond_result) if (!const_cond_result)
{ {
DBUG_PRINT("info",("Found impossible WHERE condition")); DBUG_PRINT("info",("Found impossible WHERE condition"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment