Details
-
Task
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
Under certain circumstances, the table map returned by Item_subselect::recalc_used_tables is incorrect on the second execution of a prepared statement or procedure.
An example from outer_reference.test where the current used_tables_cache is re-calculated incorrectly.
prepare s from 'select * from t1, v2 where t1a<=v2a and t1b in |
(
|
select t3b from t3
|
where
|
(
|
select t3b <= v2b and t3a <= v2a
|
)
|
)'; |
Watching the value of used_tables_cache of the Item_subselect representing "select t3b from...",
Initialized to 0 during parsing.
Set to 0b11 (t5,t7} during mysql_test_select///setup_fields
Set to OUTER_REF_TABLE_BIT + 0b11 during prepare of first execute
calculated as 0b110 in Item_subselect::recalc_used_tables() during optimize phase of first execution.
0b111 when t1 (left expression) is added in.
used_tables_cache is not cleaned up at the end of execution.
During the prepare of the next execution we accumulate the view fields of v2 into this table map and end up with OUTER_REF_TABLE_BIT + 0b111.
It remains this way for the rest of the execution, leading to the wrong result.
Attachments
Issue Links
- is blocked by
-
MDEV-30073 Wrong result on 2nd execution of PS for query with NOT EXISTS
-
- In Review
-
- is part of
-
MDEV-35673 Correlated subquery problems causing wrong results and server crash
-
- In Review
-