pred_test() logic was being too narrow-minded about where it might find

RestrictInfo nodes in the query expression.  Per example from James Robinson.
This commit is contained in:
Tom Lane 2004-11-05 20:45:10 +00:00
parent 98e8b48053
commit 3d6e538edf
1 changed files with 12 additions and 8 deletions

View File

@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.165 2004/10/11 22:56:56 tgl Exp $ * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.166 2004/11/05 20:45:10 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -848,13 +848,9 @@ pred_test_restrict_list(Expr *predicate, List *restrictinfo_list)
foreach(item, restrictinfo_list) foreach(item, restrictinfo_list)
{ {
RestrictInfo *restrictinfo = (RestrictInfo *) lfirst(item);
Assert(IsA(restrictinfo, RestrictInfo));
/* if any clause implies the predicate, return true */ /* if any clause implies the predicate, return true */
if (pred_test_recurse_restrict(predicate, if (pred_test_recurse_restrict(predicate,
(Node *) restrictinfo->clause)) (Node *) lfirst(item)))
return true; return true;
} }
return false; return false;
@ -865,7 +861,8 @@ pred_test_restrict_list(Expr *predicate, List *restrictinfo_list)
* pred_test_recurse_restrict * pred_test_recurse_restrict
* Does the "predicate inclusion test" for one element of a predicate * Does the "predicate inclusion test" for one element of a predicate
* expression. Here we recursively deal with the possibility that the * expression. Here we recursively deal with the possibility that the
* restriction-list element is itself an AND or OR structure. * restriction-list element is itself an AND or OR structure; also,
* we strip off RestrictInfo nodes to find bare predicate expressions.
*/ */
static bool static bool
pred_test_recurse_restrict(Expr *predicate, Node *clause) pred_test_recurse_restrict(Expr *predicate, Node *clause)
@ -874,7 +871,14 @@ pred_test_recurse_restrict(Expr *predicate, Node *clause)
ListCell *item; ListCell *item;
Assert(clause != NULL); Assert(clause != NULL);
if (or_clause(clause)) if (IsA(clause, RestrictInfo))
{
RestrictInfo *restrictinfo = (RestrictInfo *) clause;
return pred_test_recurse_restrict(predicate,
(Node *) restrictinfo->clause);
}
else if (or_clause(clause))
{ {
items = ((BoolExpr *) clause)->args; items = ((BoolExpr *) clause)->args;
foreach(item, items) foreach(item, items)