diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-10-05 19:11:39 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-10-05 19:11:39 +0000 |
commit | 05e3d0ee8666b74f11ffad16f46e372459d6e53e (patch) | |
tree | b273892bfda60f6bad315e84aaa2e9826e226931 /src/include/nodes/plannodes.h | |
parent | 5292637f52c6db8a22f99177f228273cb69fc510 (diff) | |
download | postgresql-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/include/nodes/plannodes.h')
-rw-r--r-- | src/include/nodes/plannodes.h | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index ca5727f0152..d8e3df4829a 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: plannodes.h,v 1.43 2000/09/29 18:21:39 tgl Exp $ + * $Id: plannodes.h,v 1.44 2000/10/05 19:11:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -46,6 +46,7 @@ * Material MaterialState matstate; * Sort SortState sortstate; * Unique UniqueState uniquestate; + * SetOp SetOpState setopstate; * Hash HashState hashstate; * * ---------------------------------------------------------------- @@ -145,16 +146,19 @@ typedef struct Result /* ---------------- * append node + * + * Append nodes can modify the query's rtable during execution. + * If inheritrelid > 0, then the RTE with index inheritrelid is replaced + * by the i'th element of inheritrtable to execute the i'th subplan. + * We assume that this RTE is not used in any other part of the + * query plan tree, else confusion may result... * ---------------- */ typedef struct Append { Plan plan; List *appendplans; - List *unionrtables; /* List of range tables, one for each - * union query. */ - Index inheritrelid; /* The range table has to be changed for - * inheritance. */ + Index inheritrelid; List *inheritrtable; AppendState *appendstate; } Append; @@ -349,6 +353,29 @@ typedef struct Unique } Unique; /* ---------------- + * setop node + * ---------------- + */ +typedef enum SetOpCmd +{ + SETOPCMD_INTERSECT, + SETOPCMD_INTERSECT_ALL, + SETOPCMD_EXCEPT, + SETOPCMD_EXCEPT_ALL +} SetOpCmd; + +typedef struct SetOp +{ + Plan plan; + SetOpCmd cmd; /* what to do */ + int numCols; /* number of columns to check for + * duplicate-ness */ + AttrNumber *dupColIdx; /* indexes into the target list */ + AttrNumber flagColIdx; + SetOpState *setopstate; +} SetOp; + +/* ---------------- * hash build node * ---------------- */ |