diff options
Diffstat (limited to 'src/backend/optimizer/util')
| -rw-r--r-- | src/backend/optimizer/util/clauses.c | 49 | ||||
| -rw-r--r-- | src/backend/optimizer/util/pathnode.c | 5 | ||||
| -rw-r--r-- | src/backend/optimizer/util/restrictinfo.c | 10 |
3 files changed, 23 insertions, 41 deletions
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index 84db3df008..5c9e4175ad 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.40 1999/07/16 04:59:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.41 1999/07/24 23:21:13 tgl Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -290,6 +290,21 @@ make_andclause(List *andclauses) return expr; } +/* + * Sometimes (such as in the result of cnfify), we use lists of expression + * nodes with implicit AND semantics. This function converts back to an + * explicit-AND representation. + */ +Expr * +make_ands_explicit(List *andclauses) +{ + if (andclauses == NIL) + return NULL; + else if (length(andclauses) == 1) + return (Expr *) lfirst(andclauses); + else + return make_andclause(andclauses); +} /***************************************************************************** * CASE clause functions @@ -411,38 +426,6 @@ NumRelids(Node *clause) } /* - * contains_not - * - * Returns t iff the clause is a 'not' clause or if any of the - * subclauses within an 'or' clause contain 'not's. - * - * NOTE that only the top-level AND/OR structure is searched for NOTs; - * we are not interested in buried substructure. - */ -bool -contains_not(Node *clause) -{ - if (single_node(clause)) - return false; - - if (not_clause(clause)) - return true; - - if (or_clause(clause) || and_clause(clause)) - { - List *a; - - foreach(a, ((Expr *) clause)->args) - { - if (contains_not(lfirst(a))) - return true; - } - } - - return false; -} - -/* * is_joinable * * Returns t iff 'clause' is a valid join clause. diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index 3c9e0a4dc8..52689d96a4 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.46 1999/07/16 04:59:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.47 1999/07/24 23:21:14 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -426,7 +426,8 @@ create_index_path(Query *root, /* each clause gets an equal selectivity */ clausesel = pow(selec, 1.0 / (double) length(restriction_clauses)); - pathnode->indexqual = restriction_clauses; + pathnode->indexqual = lcons(get_actual_clauses(restriction_clauses), + NIL); pathnode->path.path_cost = cost_index(lfirsti(index->relids), (int) npages, selec, diff --git a/src/backend/optimizer/util/restrictinfo.c b/src/backend/optimizer/util/restrictinfo.c index 12b95a61af..4dfdf66fcb 100644 --- a/src/backend/optimizer/util/restrictinfo.c +++ b/src/backend/optimizer/util/restrictinfo.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.6 1999/07/16 04:59:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.7 1999/07/24 23:21:14 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -20,17 +20,15 @@ #include "optimizer/restrictinfo.h" /* - * valid_or_clause + * restriction_is_or_clause * - * Returns t iff the restrictinfo node contains a 'normal' 'or' clause. + * Returns t iff the restrictinfo node contains an 'or' clause. * */ bool -valid_or_clause(RestrictInfo *restrictinfo) +restriction_is_or_clause(RestrictInfo *restrictinfo) { if (restrictinfo != NULL && - !single_node((Node *) restrictinfo->clause) && - !restrictinfo->notclause && or_clause((Node *) restrictinfo->clause)) return true; else |
