1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-28 11:44:57 +03:00

Repair bug in 8.2's new logic for planning outer joins: we have to allow joins

that overlap an outer join's min_righthand but aren't fully contained in it,
to support joining within the RHS after having performed an outer join that
can commute with this one.  Aside from the direct fix in make_join_rel(),
fix has_join_restriction() and GEQO's desirable_join() to consider this
possibility.  Per report from Ian Harding.
This commit is contained in:
Tom Lane
2007-02-13 02:31:03 +00:00
parent 849b070707
commit c17117649b
4 changed files with 55 additions and 23 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.129 2007/02/01 19:10:26 momjian Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.130 2007/02/13 02:31:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -370,7 +370,9 @@ deconstruct_recurse(PlannerInfo *root, Node *jtnode, bool below_outer_join,
/*
* For an OJ, form the OuterJoinInfo now, because we need the OJ's
* semantic scope (ojscope) to pass to distribute_qual_to_rels.
* semantic scope (ojscope) to pass to distribute_qual_to_rels. But
* we mustn't add it to oj_info_list just yet, because we don't want
* distribute_qual_to_rels to think it is an outer join below us.
*/
if (j->jointype != JOIN_INNER)
{
@@ -451,8 +453,13 @@ deconstruct_recurse(PlannerInfo *root, Node *jtnode, bool below_outer_join,
* the caller, so that left_rels is always the nonnullable side. Hence
* we need only distinguish the LEFT and FULL cases.
*
* The node should eventually be put into root->oj_info_list, but we
* The node should eventually be appended to root->oj_info_list, but we
* do not do that here.
*
* Note: we assume that this function is invoked bottom-up, so that
* root->oj_info_list already contains entries for all outer joins that are
* syntactically below this one; and indeed that oj_info_list is ordered
* with syntactically lower joins listed first.
*/
static OuterJoinInfo *
make_outerjoininfo(PlannerInfo *root,