1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-11 20:28:21 +03:00

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!
This commit is contained in:
Tom Lane
2000-10-05 19:11:39 +00:00
parent 5292637f52
commit 05e3d0ee86
51 changed files with 2621 additions and 1935 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.35 2000/07/12 02:37:03 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.36 2000/10/05 19:11:26 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -80,11 +80,9 @@ exec_append_initialize_next(Append *node)
AppendState *appendstate;
TupleTableSlot *result_slot;
List *rangeTable;
int whichplan;
int nplans;
List *rtables;
List *rtable;
List *inheritrtable;
RangeTblEntry *rtentry;
/* ----------------
@ -98,8 +96,7 @@ exec_append_initialize_next(Append *node)
whichplan = appendstate->as_whichplan;
nplans = appendstate->as_nplans;
rtables = node->unionrtables;
rtable = node->inheritrtable;
inheritrtable = node->inheritrtable;
if (whichplan < 0)
{
@ -131,19 +128,17 @@ exec_append_initialize_next(Append *node)
/* ----------------
* initialize the scan
* (and update the range table appropriately)
* (doesn't this leave the range table hosed for anybody upstream
* of the Append node??? - jolly )
*
* (doesn't this leave the range table hosed for anybody upstream
* of the Append node??? - jolly )
* ----------------
*/
if (node->inheritrelid > 0)
{
rtentry = nth(whichplan, rtable);
rtentry = nth(whichplan, inheritrtable);
Assert(rtentry != NULL);
rt_store(node->inheritrelid, rangeTable, rtentry);
}
else
estate->es_range_table = nth(whichplan, rtables);
if (appendstate->as_junkFilter_list)
{
@ -181,7 +176,7 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
{
AppendState *appendstate;
int nplans;
List *rtable;
List *inheritrtable;
List *appendplans;
bool *initialized;
int i;
@ -201,7 +196,7 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
appendplans = node->appendplans;
nplans = length(appendplans);
rtable = node->inheritrtable;
inheritrtable = node->inheritrtable;
initialized = (bool *) palloc(nplans * sizeof(bool));
MemSet(initialized, 0, nplans * sizeof(bool));
@ -214,7 +209,6 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
appendstate->as_whichplan = 0;
appendstate->as_nplans = nplans;
appendstate->as_initialized = initialized;
appendstate->as_rtentries = rtable;
node->appendstate = appendstate;
@ -250,7 +244,7 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
inherited_result_rel = true;
foreach(rtentryP, rtable)
foreach(rtentryP, inheritrtable)
{
RangeTblEntry *rtentry = lfirst(rtentryP);
Oid reloid = rtentry->relid;
@ -522,8 +516,7 @@ ExecEndAppend(Append *node)
estate->es_result_relation_info = NULL;
/*
* XXX should free appendstate->as_rtentries and
* appendstate->as_junkfilter_list here
* XXX should free appendstate->as_junkfilter_list here
*/
}
void