Skip to content

Conversation

@DaveGosselin-MariaDB
Copy link
Member

This PR covers two commits, one is a small cleanup commit and the other is the feature work.

Cleanup commit:

MDEV-38177: FULL OUTER JOIN Allowed JOIN Orders

This is a small cleanup commit ahead of the feature work for this MDEV:
 - Upgrade JOIN::get_allowed_nj_tables, JOIN::calc_allowed_top_level_tables
   to const methods as they have no side-effects and don't mutate object state
 - Document that JOIN_TAB::tab_list is the same as
   JOIN_TAB::table->pos_in_table_list
 - Direct access to nj_map replaced by functions to clarify expected usage
 - Remove a dead code path not executed by any regression tests
 - Invert and dedent a couple of loops to keep the happy path on the left
 - Cleanup restore_prev_nj_state and build_bitmap_for_nested_joins

Feature commit:

MDEV-38177: FULL OUTER JOIN Allowed JOIN Orders

Check that tables participating in a FULL OUTER JOIN are not separated from
each other when trying new extenions to the query plan.  Some tables t1, t2
participating in FULL OUTER JOIN should remain adjacent in the final JOIN
order, otherwise wrong results will be computed.

In this patch, tables in a FULL OUTER JOIN remember who their JOIN partner
is.  When JOINs are nested, these partners are preserved and checked
when walking the nested JOIN tree during check_interleaving_in_nj.
This code accounts for the case when tables in a FULL OUTER JOIN may
themselves be nested joins, such as (t1, t2) FULL OUTER JOIN t3.

This is a small cleanup commit ahead of the feature work for this MDEV:
 - Upgrade JOIN::get_allowed_nj_tables, JOIN::calc_allowed_top_level_tables
   to const methods as they have no side-effects and don't mutate object state
 - Document that JOIN_TAB::tab_list is the same as
   JOIN_TAB::table->pos_in_table_list
 - Direct access to nj_map replaced by functions to clarify expected usage
 - Remove a dead code path not executed by any regression tests
 - Invert and dedent a couple of loops to keep the happy path on the left
 - Cleanup restore_prev_nj_state and build_bitmap_for_nested_joins
@DaveGosselin-MariaDB DaveGosselin-MariaDB self-assigned this Jan 7, 2026
@DaveGosselin-MariaDB DaveGosselin-MariaDB changed the title 12.3 mdev 38177 allowed join orders MDEV-38177: FULL OUTER JOIN Allowed JOIN Orders Jan 7, 2026
Check that tables participating in a FULL OUTER JOIN are not separated from
each other when trying new extenions to the query plan.  Some tables t1, t2
participating in FULL OUTER JOIN should remain adjacent in the final JOIN
order, otherwise wrong results will be computed.

In this patch, tables in a FULL OUTER JOIN remember who their JOIN partner
is.  When JOINs are nested, these partners are preserved and checked
when walking the nested JOIN tree during check_interleaving_in_nj.
This code accounts for the case when tables in a FULL OUTER JOIN may
themselves be nested joins, such as (t1, t2) FULL OUTER JOIN t3.
@DaveGosselin-MariaDB DaveGosselin-MariaDB force-pushed the 12.3-MDEV-38177-allowed-join-orders branch from d5e0339 to 2d8ad76 Compare January 7, 2026 16:23
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.

2 participants