Skip to content
/ server Public

Conversation

@mariadb-RexJohnston
Copy link
Member

…incorrectly evaluated as constant

Subselects with outer references to derived tables may be incorrectly evaluated as having no table references. This can lead to these subselects being marked as constant, leading to an incorrect result.

During the calculation of the tables used in a subselect, we construct a table map of outer references in our (not necessarily new) "new_parent" select. This is currently done purely by finding Item_fields in our tree and using the attached table to update our bitmap. It can be that a reference to a derived table also needs to have it's table added to this map. If the derived table can be null, this is the case.

We add a new processor to our item walk system,
enumerate_table_refs_processor which is defined at this stage only for Item_direct_view_ref items.
This called alongside enumerate_field_refs_processor in Item_subselect::recalc_used_tables().

…incorrectly evaluated as constant

Subselects with outer references to derived tables may be incorrectly
evaluated as having no table references.  This can lead to these
subselects being marked as constant, leading to an incorrect
result.

During the calculation of the tables used in a subselect, we construct a
table map of outer references in our (not necessarily new) "new_parent"
select.  This is currently done purely by finding Item_fields in our tree
and using the attached table to update our bitmap.  It can be that a
reference to a derived table also needs to have it's table added to this
map.  If the derived table can be null, this is the case.

We add a new processor to our item walk system,
enumerate_table_refs_processor which is defined at this stage only
for Item_direct_view_ref items.
This called alongside enumerate_field_refs_processor in
Item_subselect::recalc_used_tables().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants