Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNkEk-0003jY-VJ for pgsql-bugs@arkaria.postgresql.org; Fri, 03 Feb 2023 00:47:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pNkEj-0006qE-Qp for pgsql-bugs@arkaria.postgresql.org; Fri, 03 Feb 2023 00:47:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNkEj-0006py-IW for pgsql-bugs@lists.postgresql.org; Fri, 03 Feb 2023 00:47:29 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pNkEh-0004x4-1Y for pgsql-bugs@lists.postgresql.org; Fri, 03 Feb 2023 00:47:28 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3130lPbw1600596; Thu, 2 Feb 2023 19:47:25 -0500 From: Tom Lane To: Richard Guo cc: tharakan@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17768: Assert triggered on initsplan.c In-reply-to: References: <17768-5ac8730ece54478f@postgresql.org> Comments: In-reply-to Richard Guo message dated "Thu, 02 Feb 2023 20:02:44 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1600594.1675385245.1@sss.pgh.pa.us> Date: Thu, 02 Feb 2023 19:47:25 -0500 Message-ID: <1600595.1675385245@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo 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