diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-11-14 23:54:23 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-11-14 23:54:23 +0000 |
commit | 1bdf124b94af3c24d3c3083c820804274df8262b (patch) | |
tree | 580185c38a9903dd1bb390d099719e781044d2de /src/backend/optimizer/util/restrictinfo.c | |
parent | e93fb885ebbf4ecbafe3e16813dc47397eda84ea (diff) | |
download | postgresql-1bdf124b94af3c24d3c3083c820804274df8262b.tar.gz postgresql-1bdf124b94af3c24d3c3083c820804274df8262b.zip |
Restore the former RestrictInfo field valid_everywhere (but invert the flag
sense and rename to "outerjoin_delayed" to more clearly reflect what it
means). I had decided that it was redundant in 8.1, but the folly of this
is exposed by a bug report from Sebastian Böck. The place where it's
needed is to prevent orindxpath.c from cherry-picking arms of an outer-join
OR clause to form a relation restriction that isn't actually legal to push
down to the relation scan level. There may be some legal cases that this
forbids optimizing, but we'd need much closer analysis to determine it.
Diffstat (limited to 'src/backend/optimizer/util/restrictinfo.c')
-rw-r--r-- | src/backend/optimizer/util/restrictinfo.c | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/src/backend/optimizer/util/restrictinfo.c b/src/backend/optimizer/util/restrictinfo.c index d277cac7351..96c207c9350 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.41 2005/10/15 02:49:21 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.42 2005/11/14 23:54:22 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -25,9 +25,11 @@ static RestrictInfo *make_restrictinfo_internal(Expr *clause, Expr *orclause, bool is_pushed_down, + bool outerjoin_delayed, Relids required_relids); static Expr *make_sub_restrictinfos(Expr *clause, - bool is_pushed_down); + bool is_pushed_down, + bool outerjoin_delayed); static RestrictInfo *join_clause_is_redundant(PlannerInfo *root, RestrictInfo *rinfo, List *reference_list, @@ -39,8 +41,8 @@ static RestrictInfo *join_clause_is_redundant(PlannerInfo *root, * * Build a RestrictInfo node containing the given subexpression. * - * The is_pushed_down flag must be supplied by the caller. - * required_relids can be NULL, in which case it defaults to the + * The is_pushed_down and outerjoin_delayed flags must be supplied by the + * caller. required_relids can be NULL, in which case it defaults to the * actual clause contents (i.e., clause_relids). * * We initialize fields that depend only on the given subexpression, leaving @@ -48,19 +50,25 @@ static RestrictInfo *join_clause_is_redundant(PlannerInfo *root, * later. */ RestrictInfo * -make_restrictinfo(Expr *clause, bool is_pushed_down, Relids required_relids) +make_restrictinfo(Expr *clause, + bool is_pushed_down, + bool outerjoin_delayed, + Relids required_relids) { /* * If it's an OR clause, build a modified copy with RestrictInfos inserted * above each subclause of the top-level AND/OR structure. */ if (or_clause((Node *) clause)) - return (RestrictInfo *) make_sub_restrictinfos(clause, is_pushed_down); + return (RestrictInfo *) make_sub_restrictinfos(clause, + is_pushed_down, + outerjoin_delayed); /* Shouldn't be an AND clause, else AND/OR flattening messed up */ Assert(!and_clause((Node *) clause)); - return make_restrictinfo_internal(clause, NULL, is_pushed_down, + return make_restrictinfo_internal(clause, NULL, + is_pushed_down, outerjoin_delayed, required_relids); } @@ -74,6 +82,9 @@ make_restrictinfo(Expr *clause, bool is_pushed_down, Relids required_relids) * The result is a List (effectively, implicit-AND representation) of * RestrictInfos. * + * The caller must pass is_pushed_down, but we assume outerjoin_delayed + * is false (no such qual should ever get into a bitmapqual). + * * If include_predicates is true, we add any partial index predicates to * the explicit index quals. When this is not true, we return a condition * that might be weaker than the actual scan represents. @@ -169,6 +180,7 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual, list_make1(make_restrictinfo_internal(make_orclause(withoutris), make_orclause(withris), is_pushed_down, + false, NULL)); } } @@ -193,6 +205,7 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual, result = lappend(result, make_restrictinfo(pred, is_pushed_down, + false, NULL)); } } @@ -213,13 +226,15 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual, */ static RestrictInfo * make_restrictinfo_internal(Expr *clause, Expr *orclause, - bool is_pushed_down, Relids required_relids) + bool is_pushed_down, bool outerjoin_delayed, + Relids required_relids) { RestrictInfo *restrictinfo = makeNode(RestrictInfo); restrictinfo->clause = clause; restrictinfo->orclause = orclause; restrictinfo->is_pushed_down = is_pushed_down; + restrictinfo->outerjoin_delayed = outerjoin_delayed; restrictinfo->can_join = false; /* may get set below */ /* @@ -299,7 +314,8 @@ make_restrictinfo_internal(Expr *clause, Expr *orclause, * simple clauses are valid RestrictInfos. */ static Expr * -make_sub_restrictinfos(Expr *clause, bool is_pushed_down) +make_sub_restrictinfos(Expr *clause, + bool is_pushed_down, bool outerjoin_delayed) { if (or_clause((Node *) clause)) { @@ -309,10 +325,12 @@ make_sub_restrictinfos(Expr *clause, bool is_pushed_down) foreach(temp, ((BoolExpr *) clause)->args) orlist = lappend(orlist, make_sub_restrictinfos(lfirst(temp), - is_pushed_down)); + is_pushed_down, + outerjoin_delayed)); return (Expr *) make_restrictinfo_internal(clause, make_orclause(orlist), is_pushed_down, + outerjoin_delayed, NULL); } else if (and_clause((Node *) clause)) @@ -323,13 +341,15 @@ make_sub_restrictinfos(Expr *clause, bool is_pushed_down) foreach(temp, ((BoolExpr *) clause)->args) andlist = lappend(andlist, make_sub_restrictinfos(lfirst(temp), - is_pushed_down)); + is_pushed_down, + outerjoin_delayed)); return make_andclause(andlist); } else return (Expr *) make_restrictinfo_internal(clause, NULL, is_pushed_down, + outerjoin_delayed, NULL); } |