Re: Properly pathify the union planner
От | Richard Guo |
---|---|
Тема | Re: Properly pathify the union planner |
Дата | |
Msg-id | CAMbWs49gWbhSVdX0kT2x5XGKmP5OZerp6VhEA-hM4BvLHxKaqQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Properly pathify the union planner (David Rowley <dgrowleyml@gmail.com>) |
Ответы |
Re: Properly pathify the union planner
|
Список | pgsql-hackers |
On Wed, Mar 27, 2024 at 6:23 AM David Rowley <dgrowleyml@gmail.com> wrote:
Because this field is set, it plans the CTE thinking it's a UNION
child and breaks when it can't find a SortGroupClause for the CTE's
target list item.
Right. The problem here is that we mistakenly think that the CTE query
is a subquery for the set operation and thus store the SetOperationStmt
in its qp_extra. Currently the code for the check is:
/*
* Check if we're a subquery for a set operation. If we are, store
* the SetOperationStmt in qp_extra.
*/
if (root->parent_root != NULL &&
root->parent_root->parse->setOperations != NULL &&
IsA(root->parent_root->parse->setOperations, SetOperationStmt))
qp_extra.setop =
(SetOperationStmt *) root->parent_root->parse->setOperations;
else
qp_extra.setop = NULL;
This check cannot tell if the subquery is for a set operation or a CTE,
because its parent might have setOperations set in both cases. Hmm, is
there any way to differentiate between the two?
Thanks
Richard
is a subquery for the set operation and thus store the SetOperationStmt
in its qp_extra. Currently the code for the check is:
/*
* Check if we're a subquery for a set operation. If we are, store
* the SetOperationStmt in qp_extra.
*/
if (root->parent_root != NULL &&
root->parent_root->parse->setOperations != NULL &&
IsA(root->parent_root->parse->setOperations, SetOperationStmt))
qp_extra.setop =
(SetOperationStmt *) root->parent_root->parse->setOperations;
else
qp_extra.setop = NULL;
This check cannot tell if the subquery is for a set operation or a CTE,
because its parent might have setOperations set in both cases. Hmm, is
there any way to differentiate between the two?
Thanks
Richard
В списке pgsql-hackers по дате отправления: