Fix WITH attached to a nested set operation (UNION/INTERSECT/EXCEPT).
Tom Lane <tgl@sss.pgh.pa.us>
Fix WITH attached to a nested set operation (UNION/INTERSECT/EXCEPT). Parse analysis neglected to cover the case of a WITH clause attached to an intermediate-level set operation; it only handled WITH at the top level or WITH attached to a leaf-level SELECT. Per report from Adam Mackler. In HEAD, I rearranged the order of SelectStmt's fields to put withClause with the other fields that can appear on non-leaf SelectStmts. In back branches, leave it alone to avoid a possible ABI break for third-party code. Back-patch to 8.4 where WITH support was added.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/nodes/copyfuncs.c | modified | +1 −1 |
| src/backend/nodes/equalfuncs.c | modified | +1 −1 |
| src/backend/nodes/nodeFuncs.c | modified | +2 −2 |
| src/backend/nodes/outfuncs.c | modified | +1 −1 |
| src/backend/parser/analyze.c | modified | +16 −13 |
| src/backend/parser/parse_cte.c | modified | +14 −1 |
| src/backend/parser/parse_type.c | modified | +1 −1 |
| src/include/nodes/parsenodes.h | modified | +1 −1 |
| src/test/regress/expected/with.out | modified | +51 −0 |
| src/test/regress/sql/with.sql | modified | +35 −0 |