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 1pbTX7-0007wA-HU for pgsql-bugs@arkaria.postgresql.org; Sun, 12 Mar 2023 21:47:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pbTX5-0006s8-T5 for pgsql-bugs@arkaria.postgresql.org; Sun, 12 Mar 2023 21:47:11 +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 1pbTU0-0000yv-1P for pgsql-bugs@lists.postgresql.org; Sun, 12 Mar 2023 21:44:00 +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 1pbTTx-0004m3-PA for pgsql-bugs@lists.postgresql.org; Sun, 12 Mar 2023 21:43:59 +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 32CLhtMS1616393; Sun, 12 Mar 2023 17:43:55 -0400 From: Tom Lane To: David Rowley cc: xinwen@stu.scu.edu.cn, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17826: An assert failed in /src/backend/optimizer/util/var.c In-reply-to: References: <17826-7d8750952f19a5f5@postgresql.org> <402866.1678378153@sss.pgh.pa.us> <1229467.1678555436@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Mon, 13 Mar 2023 10:19:45 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1616391.1678657435.1@sss.pgh.pa.us> Date: Sun, 12 Mar 2023 17:43:55 -0400 Message-ID: <1616392.1678657435@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > It is only possible to either leave such quals in the outer query in > the WHERE clause or make them run conditions of some WindowClause in > the subquery. They can never be legally in the WHERE clause of the > subquery as window functions cannot be evaluated in the WHERE clause. Ah, got it. So basically, the quals that we want are excluded by check_output_expressions' point 4 (since they reference window function output columns rather than partitioning columns). I think we need them to satisfy every other property that's checked in this code, though. Now I agree that we need to refactor a bit -- we don't want to have to re-check all of these conditions. regards, tom lane