From f6ce81f55a3c6932d5f88bc89374f404688f054e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 31 Jul 2012 17:56:21 -0400 Subject: 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. --- src/backend/nodes/nodeFuncs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/backend/nodes/nodeFuncs.c') diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c index 813d1da1a28..b130902dcf2 100644 --- a/src/backend/nodes/nodeFuncs.c +++ b/src/backend/nodes/nodeFuncs.c @@ -2909,8 +2909,6 @@ raw_expression_tree_walker(Node *node, return true; if (walker(stmt->windowClause, context)) return true; - if (walker(stmt->withClause, context)) - return true; if (walker(stmt->valuesLists, context)) return true; if (walker(stmt->sortClause, context)) @@ -2921,6 +2919,8 @@ raw_expression_tree_walker(Node *node, return true; if (walker(stmt->lockingClause, context)) return true; + if (walker(stmt->withClause, context)) + return true; if (walker(stmt->larg, context)) return true; if (walker(stmt->rarg, context)) -- cgit v1.2.3