mirror of
https://github.com/postgres/postgres.git
synced 2025-11-15 03:41:20 +03:00
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.
This commit is contained in:
@@ -2494,12 +2494,12 @@ _copySelectStmt(const SelectStmt *from)
|
||||
COPY_NODE_FIELD(groupClause);
|
||||
COPY_NODE_FIELD(havingClause);
|
||||
COPY_NODE_FIELD(windowClause);
|
||||
COPY_NODE_FIELD(withClause);
|
||||
COPY_NODE_FIELD(valuesLists);
|
||||
COPY_NODE_FIELD(sortClause);
|
||||
COPY_NODE_FIELD(limitOffset);
|
||||
COPY_NODE_FIELD(limitCount);
|
||||
COPY_NODE_FIELD(lockingClause);
|
||||
COPY_NODE_FIELD(withClause);
|
||||
COPY_SCALAR_FIELD(op);
|
||||
COPY_SCALAR_FIELD(all);
|
||||
COPY_NODE_FIELD(larg);
|
||||
|
||||
@@ -976,12 +976,12 @@ _equalSelectStmt(const SelectStmt *a, const SelectStmt *b)
|
||||
COMPARE_NODE_FIELD(groupClause);
|
||||
COMPARE_NODE_FIELD(havingClause);
|
||||
COMPARE_NODE_FIELD(windowClause);
|
||||
COMPARE_NODE_FIELD(withClause);
|
||||
COMPARE_NODE_FIELD(valuesLists);
|
||||
COMPARE_NODE_FIELD(sortClause);
|
||||
COMPARE_NODE_FIELD(limitOffset);
|
||||
COMPARE_NODE_FIELD(limitCount);
|
||||
COMPARE_NODE_FIELD(lockingClause);
|
||||
COMPARE_NODE_FIELD(withClause);
|
||||
COMPARE_SCALAR_FIELD(op);
|
||||
COMPARE_SCALAR_FIELD(all);
|
||||
COMPARE_NODE_FIELD(larg);
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -2037,12 +2037,12 @@ _outSelectStmt(StringInfo str, const SelectStmt *node)
|
||||
WRITE_NODE_FIELD(groupClause);
|
||||
WRITE_NODE_FIELD(havingClause);
|
||||
WRITE_NODE_FIELD(windowClause);
|
||||
WRITE_NODE_FIELD(withClause);
|
||||
WRITE_NODE_FIELD(valuesLists);
|
||||
WRITE_NODE_FIELD(sortClause);
|
||||
WRITE_NODE_FIELD(limitOffset);
|
||||
WRITE_NODE_FIELD(limitCount);
|
||||
WRITE_NODE_FIELD(lockingClause);
|
||||
WRITE_NODE_FIELD(withClause);
|
||||
WRITE_ENUM_FIELD(op, SetOperation);
|
||||
WRITE_BOOL_FIELD(all);
|
||||
WRITE_NODE_FIELD(larg);
|
||||
|
||||
Reference in New Issue
Block a user