Re: BUG #17768: Assert triggered on initsplan.c

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Guo <guofenglinux@gmail.com>
Cc: tharakan@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2023-02-03T00:47:25Z
Lists: pgsql-bugs
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



Commits

  1. Rethink treatment of "postponed" quals in deconstruct_jointree().