@@ -2773,7 +2773,7 @@ JOIN::optimize_inner()
27732773 mature enough to correctly execute the queries. But for now
27742774 this allows for some EXPLAIN EXTENDED support.
27752775 */
2776- else if (!thd->lex->has_full_outer_join )
2776+ else if (!thd->lex->full_join_count )
27772777 {
27782778 if (optimize_stage2())
27792779 DBUG_RETURN(1);
@@ -5627,7 +5627,16 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
56275627 TABLE **table_vector;
56285628 JOIN_TAB *stat,*stat_end,*s,**stat_ref, **stat_vector;
56295629 KEYUSE *keyuse,*start_keyuse;
5630+
5631+ /*
5632+ outer_join here does not have the same meaning as TABLE_LIST::outer_join.
5633+ Here, outer_join is the union of all table numbers representing tables
5634+ that participate in this join. TABLE_LIST::outer_join marks how a
5635+ TABLE_LIST participates in a particular JOIN (as a right table, left table,
5636+ as part of a FULL JOIN, etc).
5637+ */
56305638 table_map outer_join=0;
5639+
56315640 table_map no_rows_const_tables= 0;
56325641 SARGABLE_PARAM *sargables= 0;
56335642 List_iterator<TABLE_LIST> ti(tables_list);
@@ -5841,6 +5850,19 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
58415850 join->const_table_map= no_rows_const_tables;
58425851 join->const_tables= const_count;
58435852 eliminate_tables(join);
5853+
5854+ /*
5855+ Temporary gate. As the FULL JOIN implementation matures, this keeps moving
5856+ deeper into the server until it's eventually eliminated.
5857+ */
5858+ if (thd->lex->full_join_count && !thd->lex->describe)
5859+ {
5860+ my_error(ER_NOT_SUPPORTED_YET, MYF(0),
5861+ "FULL JOINs that cannot be converted to LEFT, RIGHT, or "
5862+ "INNER JOINs");
5863+ goto error;
5864+ }
5865+
58445866 join->const_table_map &= ~no_rows_const_tables;
58455867 const_count= join->const_tables;
58465868 found_const_table_map= join->const_table_map;
@@ -20353,23 +20375,10 @@ static COND *rewrite_full_outer_joins(JOIN *join,
2035320375 see the right table first. If, on this call to rewrite_full_outer_joins,
2035420376 the current table is left member of the JOIN (e.g., left_member FULL JOIN
2035520377 ...) it means we couldn't rewrite the FULL JOIN as a LEFT, RIGHT, or
20356- INNER JOIN, so emit an error (unless we're in an EXPLAIN EXTENDED, permit
20357- that).
20378+ INNER JOIN, so pass along the unmodified FULL JOIN.
2035820379 */
2035920380 if (right_table->outer_join & JOIN_TYPE_LEFT)
20360- {
20361- if (join->thd->lex->describe)
20362- return conds;
20363-
20364- /*
20365- We always see the RIGHT table before the LEFT table, so nothing to
20366- do here for JOIN_TYPE_LEFT.
20367- */
20368- my_error(ER_NOT_SUPPORTED_YET, MYF(0),
20369- "FULL JOINs that cannot be converted to LEFT, RIGHT, or "
20370- "INNER JOINs");
20371- return nullptr;
20372- }
20381+ return conds;
2037320382
2037420383 /*
2037520384 Must always see the right table before the left. Down below, we deal
@@ -20420,7 +20429,7 @@ static COND *rewrite_full_outer_joins(JOIN *join,
2042020429 RIGHT JOINs don't actually exist in MariaDB!
2042120430 */
2042220431 *table_ptr= li.swap_next();
20423- join->thd->lex->has_full_outer_join= false ;
20432+ -- join->thd->lex->full_join_count ;
2042420433 }
2042520434 else
2042620435 {
@@ -20457,7 +20466,7 @@ static COND *rewrite_full_outer_joins(JOIN *join,
2045720466 if (peeked_map & not_null_tables)
2045820467 {
2045920468 rewrite_full_to_left(left_table, right_table);
20460- join->thd->lex->has_full_outer_join= false ;
20469+ -- join->thd->lex->full_join_count ;
2046120470 }
2046220471 // else the FULL JOIN cannot be rewritten, pass it along.
2046320472 }
0 commit comments