aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/planmain.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-10-05 19:11:39 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-10-05 19:11:39 +0000
commit05e3d0ee8666b74f11ffad16f46e372459d6e53e (patch)
treeb273892bfda60f6bad315e84aaa2e9826e226931 /src/backend/optimizer/plan/planmain.c
parent5292637f52c6db8a22f99177f228273cb69fc510 (diff)
downloadpostgresql-05e3d0ee8666b74f11ffad16f46e372459d6e53e.tar.gz
postgresql-05e3d0ee8666b74f11ffad16f46e372459d6e53e.zip
Reimplementation of UNION/INTERSECT/EXCEPT. INTERSECT/EXCEPT now meet the
SQL92 semantics, including support for ALL option. All three can be used in subqueries and views. DISTINCT and ORDER BY work now in views, too. This rewrite fixes many problems with cross-datatype UNIONs and INSERT/SELECT where the SELECT yields different datatypes than the INSERT needs. I did that by making UNION subqueries and SELECT in INSERT be treated like subselects-in-FROM, thereby allowing an extra level of targetlist where the datatype conversions can be inserted safely. INITDB NEEDED!
Diffstat (limited to 'src/backend/optimizer/plan/planmain.c')
-rw-r--r--src/backend/optimizer/plan/planmain.c42
1 files changed, 1 insertions, 41 deletions
diff --git a/src/backend/optimizer/plan/planmain.c b/src/backend/optimizer/plan/planmain.c
index 29cfccfef7b..a9747b32799 100644
--- a/src/backend/optimizer/plan/planmain.c
+++ b/src/backend/optimizer/plan/planmain.c
@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.60 2000/09/29 18:21:33 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.61 2000/10/05 19:11:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -174,8 +174,6 @@ subplanner(Query *root,
List *brel;
RelOptInfo *final_rel;
Plan *resultplan;
- MemoryContext mycontext;
- MemoryContext oldcxt;
Path *cheapestpath;
Path *presortedpath;
@@ -228,24 +226,6 @@ subplanner(Query *root,
root->query_pathkeys = canonicalize_pathkeys(root, root->query_pathkeys);
/*
- * We might allocate quite a lot of storage during planning (due to
- * constructing lots of Paths), but all of it can be reclaimed after
- * we generate the finished Plan tree. Work in a temporary context
- * to let that happen. We make the context a child of
- * TransactionCommandContext so it will be freed if error abort.
- *
- * Note: beware of trying to move this up to the start of this routine.
- * Some of the data structures built above --- notably the pathkey
- * equivalence sets --- will still be needed after this routine exits.
- */
- mycontext = AllocSetContextCreate(TransactionCommandContext,
- "Planner",
- ALLOCSET_DEFAULT_MINSIZE,
- ALLOCSET_DEFAULT_INITSIZE,
- ALLOCSET_DEFAULT_MAXSIZE);
- oldcxt = MemoryContextSwitchTo(mycontext);
-
- /*
* Ready to do the primary planning.
*/
final_rel = make_one_rel(root);
@@ -355,25 +335,5 @@ subplanner(Query *root,
plan_built:
- /*
- * Must copy the completed plan tree and its pathkeys out of temporary
- * context. We also have to copy the rtable in case it contains any
- * subqueries. (If it does, they'll have been modified during the
- * recursive invocation of planner.c, and hence will contain substructure
- * allocated in my temporary context...)
- */
- MemoryContextSwitchTo(oldcxt);
-
- resultplan = copyObject(resultplan);
-
- root->query_pathkeys = copyObject(root->query_pathkeys);
-
- root->rtable = copyObject(root->rtable);
-
- /*
- * Now we can release the Path storage.
- */
- MemoryContextDelete(mycontext);
-
return resultplan;
}