From e349eb6e2c9084fe4baff4eacac3ea274aec1e6e Mon Sep 17 00:00:00 2001
From: "Vadim B. Mikheev" <vadim4o@yahoo.com>
Date: Thu, 24 Apr 1997 15:59:58 +0000
Subject: [PATCH] Bug (yet unfixed but not fatal) found: Re-moving index
 clauses from the nestloop's join clauses doesn't work in some cases:         
 *    1. fix_indxqual_references may change varattno-s in          *      
 inner_indxqual;          *    2. clauses may be commuted

---
 src/backend/optimizer/plan/createplan.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index c56cc61c805..7637d15f200 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.10 1997/04/22 03:30:36 vadim Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.11 1997/04/24 15:59:58 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -432,7 +432,7 @@ create_nestloop_node(JoinPath *best_path,
 
 	foreach (inner_qual, inner_indxqual)
 	{
-	    if ( !(qual_clause_p ((Node*)inner_qual)) )
+	    if ( !qual_clause_p ((Node*)lfirst(inner_qual)) )
 	    {
 	    	found = true;
 	    	break;
@@ -443,12 +443,18 @@ create_nestloop_node(JoinPath *best_path,
 	 * index clauses from the nestloop's join clauses and reset the 
 	 * inner(index) scan's qualification so that the var nodes refer to
 	 * the proper outer join relation attributes.
+	 *
+	 * XXX Re-moving index clauses doesn't work properly: 
+	 *    1. fix_indxqual_references may change varattno-s in 
+	 *       inner_indxqual;
+	 *    2. clauses may be commuted
+	 * I havn't time to fix it at the moment.   - vadim 04/24/97
 	 */
 	if  ( found )
 	{
 	    List *new_inner_qual = NIL;
 	    
-	    clauses = set_difference(clauses,inner_indxqual);
+	    clauses = set_difference(clauses,inner_indxqual);	/* XXX */
 	    new_inner_qual =
 		index_outerjoin_references(inner_indxqual,
 					   outer_node->targetlist,
-- 
GitLab