Richard Guo <guofenglinux@gmail.com> writes:
>> There is something wrong about postponing quals. We are supposed to
>> postpone quals only from children to their parent nodes. But here in
>> deconstruct_distribute we scan all the jointree nodes in depth-first
>> traversal order and any quals postponed by left children may be checked
>> against right children. If the right subtree is an outer join as in
>> this example, the assertion would be triggered.
> To fix this issue, I'm considering that we can add two types of info in
> JoinTreeItem for each jointree node, one is the jointree's children, and
> one is the list of quals that need to be postponed at this join level.
> Thus in deconstruct_distribute we can process the quals postponed by
> children.
I've not looked closely at this, but ... I remember thinking while
revising deconstruct_jointree that the whole PostponedQual mechanism
was a wart we should try to get rid of. I didn't touch it since
I saw no obvious bugs and the patch was too large already, but maybe
now is the time to try harder. In any case I suspect you are right
that the core of this issue is that we're dealing with PostponedQuals
in the wrong order now.
regards, tom lane