diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-03-28 00:58:26 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-03-28 00:58:26 +0000 |
| commit | 5db2e83852cc3f25fdea48c4aa0da8696c88a826 (patch) | |
| tree | 1b6db39b1a6af12052bb93f1a7892a46a0a504d7 /src/backend/optimizer/util | |
| parent | bf3dbb5881e9b886ee9fe84bca2153c698eea885 (diff) | |
| download | postgresql-5db2e83852cc3f25fdea48c4aa0da8696c88a826.tar.gz | |
Rethink the order of expression preprocessing: eval_const_expressions
really ought to run before canonicalize_qual, because it can now produce
forms that canonicalize_qual knows how to improve (eg, NOT clauses).
Also, because eval_const_expressions already knows about flattening
nested ANDs and ORs into N-argument form, the initial flatten_andors
pass in canonicalize_qual is now completely redundant and can be
removed. This doesn't save a whole lot of code, but the time and
palloc traffic eliminated is a useful gain on large expression trees.
Diffstat (limited to 'src/backend/optimizer/util')
| -rw-r--r-- | src/backend/optimizer/util/clauses.c | 9 | ||||
| -rw-r--r-- | src/backend/optimizer/util/restrictinfo.c | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index cf585cccbc..15418d4e95 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.189 2005/03/27 19:18:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.190 2005/03/28 00:58:24 tgl Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -1190,6 +1190,9 @@ rowtype_field_matches(Oid rowtypeid, int fieldnum, * * We assume that the tree has already been type-checked and contains * only operators and functions that are reasonable to try to execute. + * + * NOTE: the planner assumes that this will always flatten nested AND and + * OR clauses into N-argument form. See comments in prepqual.c. *-------------------- */ Node * @@ -1871,7 +1874,7 @@ eval_const_expressions_mutator(Node *node, * is TRUE and at least one is NULL. * * This is split out as a subroutine so that we can recurse to fold sub-ORs - * into the upper OR clause, thereby preserving AND/OR flatness. + * into the upper OR clause, thereby ensuring that nested ORs are flattened. * * The output arguments *haveNull and *forceTrue must be initialized FALSE * by the caller. They will be set TRUE if a null constant or true constant, @@ -1931,7 +1934,7 @@ simplify_or_arguments(List *args, bool *haveNull, bool *forceTrue) * is FALSE and at least one is NULL. * * This is split out as a subroutine so that we can recurse to fold sub-ANDs - * into the upper AND clause, thereby preserving AND/OR flatness. + * into the upper AND clause, thereby ensuring that nested ANDs are flattened. * * The output arguments *haveNull and *forceFalse must be initialized FALSE * by the caller. They will be set TRUE if a null constant or false constant, diff --git a/src/backend/optimizer/util/restrictinfo.c b/src/backend/optimizer/util/restrictinfo.c index 20590a98e0..3dad1a1607 100644 --- a/src/backend/optimizer/util/restrictinfo.c +++ b/src/backend/optimizer/util/restrictinfo.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.31 2004/12/31 22:00:23 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.32 2005/03/28 00:58:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -63,7 +63,7 @@ make_restrictinfo(Expr *clause, bool is_pushed_down, bool valid_everywhere) } else { - /* Shouldn't be an AND clause, else flatten_andors messed up */ + /* Shouldn't be an AND clause, else AND/OR flattening messed up */ Assert(!and_clause((Node *) clause)); orclause = NULL; |
