1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

Merge branch '10.3' into 10.4

This commit is contained in:
Sergei Golubchik
2023-01-10 21:04:17 +01:00
38 changed files with 524 additions and 116 deletions

View File

@ -2287,11 +2287,7 @@ enum_nested_loop_state JOIN_CACHE::join_matching_records(bool skip_last)
int error;
enum_nested_loop_state rc= NESTED_LOOP_OK;
join_tab->table->null_row= 0;
bool check_only_first_match=
join_tab->check_only_first_match() &&
(!join_tab->first_inner || // semi-join case
join_tab->first_inner == join_tab->first_unmatched); // outer join case
bool outer_join_first_inner= join_tab->is_first_inner_for_outer_join();
bool check_only_first_match= join_tab->check_only_first_match();
DBUG_ENTER("JOIN_CACHE::join_matching_records");
/* Return at once if there are no records in the join buffer */
@ -2357,7 +2353,34 @@ enum_nested_loop_state JOIN_CACHE::join_matching_records(bool skip_last)
Also those records that must be null complemented are not considered
as candidates for matches.
*/
if ((!check_only_first_match && !outer_join_first_inner) ||
bool not_exists_opt_is_applicable= true;
if (check_only_first_match && join_tab->first_inner)
{
/*
This is the case with not_exists optimization for nested outer join
when join_tab is the last inner table for one or more embedding outer
joins. To safely use 'not_exists' optimization in this case we have
to check that the match flags for all these embedding outer joins are
in the 'on' state.
(See also a similar check in evaluate_join_record() for the case when
join buffer are not used.)
*/
for (JOIN_TAB *tab= join_tab->first_inner;
tab && tab->first_inner && tab->last_inner == join_tab;
tab= tab->first_inner->first_upper)
{
if (get_match_flag_by_pos_from_join_buffer(rec_ptr, tab) !=
MATCH_FOUND)
{
not_exists_opt_is_applicable= false;
break;
}
}
}
if (!check_only_first_match ||
(join_tab->first_inner && !not_exists_opt_is_applicable) ||
!skip_next_candidate_for_match(rec_ptr))
{
read_next_candidate_for_match(rec_ptr);