From 9e7e29e6c9dd386a56ab23f419bc358f630cf768 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 27 Jul 1999 03:51:11 +0000 Subject: First cut at doing LIKE/regex indexing optimization in optimizer rather than parser. This has many advantages, such as not getting fooled by chance uses of operator names ~ and ~~ (the operators are identified by OID now), and not creating useless comparison operations in contexts where the comparisons will not actually be used as indexquals. The new code also recognizes exact-match LIKE and regex patterns, and produces an = indexqual instead of >= and <=. This change does NOT fix the problem with non-ASCII locales: the code still doesn't know how to generate an upper bound indexqual for non-ASCII collation order. But it's no worse than before, just the same deficiency in a different place... Also, dike out loc_restrictinfo fields in Plan nodes. These were doing nothing useful in the absence of 'expensive functions' optimization, and they took a considerable amount of processing to fill in. --- src/backend/optimizer/util/clauses.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/backend/optimizer/util/clauses.c') diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index 442ebad1e7b..de9ef509382 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.42 1999/07/25 23:07:25 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.43 1999/07/27 03:51:04 tgl Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -293,8 +293,9 @@ make_andclause(List *andclauses) /* * 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. + * nodes with implicit AND semantics. These functions convert between an + * AND-semantics expression list and the ordinary representation of a + * boolean expression. */ Expr * make_ands_explicit(List *andclauses) @@ -307,6 +308,17 @@ make_ands_explicit(List *andclauses) return make_andclause(andclauses); } +List * +make_ands_implicit(Expr *clause) +{ + if (clause == NULL) + return NIL; + else if (and_clause((Node *) clause)) + return clause->args; + else + return lcons(clause, NIL); +} + /***************************************************************************** * CASE clause functions *****************************************************************************/ -- cgit v1.2.3