aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/createplan.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-07-23 21:05:48 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-07-23 21:05:48 +0000
commitd007a95055b9b649b74b5d25aa4d2b46f3eca21c (patch)
treee726c049f96af578181432ae4da176cf3cbcb970 /src/backend/optimizer/plan/createplan.c
parent9af9d674c61ca1c2e26d7a9295d5b1bcc8cabb60 (diff)
downloadpostgresql-d007a95055b9b649b74b5d25aa4d2b46f3eca21c.tar.gz
postgresql-d007a95055b9b649b74b5d25aa4d2b46f3eca21c.zip
Simple constraint exclusion. For now, only child tables of inheritance
scans are candidates for exclusion; this should be fixed eventually. Simon Riggs, with some help from Tom Lane.
Diffstat (limited to 'src/backend/optimizer/plan/createplan.c')
-rw-r--r--src/backend/optimizer/plan/createplan.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index 589bebef697..6c4c345ca8e 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.194 2005/07/15 22:02:51 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.195 2005/07/23 21:05:46 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -40,7 +40,7 @@ static List *build_relation_tlist(RelOptInfo *rel);
static bool use_physical_tlist(RelOptInfo *rel);
static void disuse_physical_tlist(Plan *plan, Path *path);
static Join *create_join_plan(PlannerInfo *root, JoinPath *best_path);
-static Append *create_append_plan(PlannerInfo *root, AppendPath *best_path);
+static Plan *create_append_plan(PlannerInfo *root, AppendPath *best_path);
static Result *create_result_plan(PlannerInfo *root, ResultPath *best_path);
static Material *create_material_plan(PlannerInfo *root, MaterialPath *best_path);
static Plan *create_unique_plan(PlannerInfo *root, UniquePath *best_path);
@@ -435,7 +435,7 @@ create_join_plan(PlannerInfo *root, JoinPath *best_path)
*
* Returns a Plan node.
*/
-static Append *
+static Plan *
create_append_plan(PlannerInfo *root, AppendPath *best_path)
{
Append *plan;
@@ -443,6 +443,25 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path)
List *subplans = NIL;
ListCell *subpaths;
+ /*
+ * It is possible for the subplans list to contain only one entry,
+ * or even no entries. Handle these cases specially.
+ *
+ * XXX ideally, if there's just one entry, we'd not bother to generate
+ * an Append node but just return the single child. At the moment this
+ * does not work because the varno of the child scan plan won't match
+ * the parent-rel Vars it'll be asked to emit.
+ */
+ if (best_path->subpaths == NIL)
+ {
+ /* Generate a Result plan with constant-FALSE gating qual */
+ return (Plan *) make_result(tlist,
+ (Node *) list_make1(makeBoolConst(false,
+ false)),
+ NULL);
+ }
+
+ /* Normal case with multiple subpaths */
foreach(subpaths, best_path->subpaths)
{
Path *subpath = (Path *) lfirst(subpaths);
@@ -452,7 +471,7 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path)
plan = make_append(subplans, false, tlist);
- return plan;
+ return (Plan *) plan;
}
/*