99 *
1010 *
1111 * IDENTIFICATION
12- * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.165 2004/10/11 22:56:56 tgl Exp $
12+ * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.166 2004/11/05 20:45:10 tgl Exp $
1313 *
1414 *-------------------------------------------------------------------------
1515 */
@@ -848,13 +848,9 @@ pred_test_restrict_list(Expr *predicate, List *restrictinfo_list)
848848
849849foreach (item ,restrictinfo_list )
850850{
851- RestrictInfo * restrictinfo = (RestrictInfo * )lfirst (item );
852-
853- Assert (IsA (restrictinfo ,RestrictInfo ));
854-
855851/* if any clause implies the predicate, return true */
856852if (pred_test_recurse_restrict (predicate ,
857- (Node * )restrictinfo -> clause ))
853+ (Node * )lfirst ( item ) ))
858854return true;
859855}
860856return false;
@@ -865,7 +861,8 @@ pred_test_restrict_list(Expr *predicate, List *restrictinfo_list)
865861 * pred_test_recurse_restrict
866862 * Does the "predicate inclusion test" for one element of a predicate
867863 * expression. Here we recursively deal with the possibility that the
868- * restriction-list element is itself an AND or OR structure.
864+ * restriction-list element is itself an AND or OR structure; also,
865+ * we strip off RestrictInfo nodes to find bare predicate expressions.
869866 */
870867static bool
871868pred_test_recurse_restrict (Expr * predicate ,Node * clause )
@@ -874,7 +871,14 @@ pred_test_recurse_restrict(Expr *predicate, Node *clause)
874871ListCell * item ;
875872
876873Assert (clause != NULL );
877- if (or_clause (clause ))
874+ if (IsA (clause ,RestrictInfo ))
875+ {
876+ RestrictInfo * restrictinfo = (RestrictInfo * )clause ;
877+
878+ return pred_test_recurse_restrict (predicate ,
879+ (Node * )restrictinfo -> clause );
880+ }
881+ else if (or_clause (clause ))
878882{
879883items = ((BoolExpr * )clause )-> args ;
880884foreach (item ,items )