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 1pb2wu-0005E7-Sl for pgsql-bugs@arkaria.postgresql.org; Sat, 11 Mar 2023 17:24:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pb2wt-0005cY-Ln for pgsql-bugs@arkaria.postgresql.org; Sat, 11 Mar 2023 17:24:03 +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 1pb2wt-0005cF-DN for pgsql-bugs@lists.postgresql.org; Sat, 11 Mar 2023 17:24:03 +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 1pb2wr-0007Tg-3p for pgsql-bugs@lists.postgresql.org; Sat, 11 Mar 2023 17:24:02 +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 32BHNuMp1229468; Sat, 11 Mar 2023 12:23:56 -0500 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> Comments: In-reply-to David Rowley message dated "Sat, 11 Mar 2023 19:35:07 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1229466.1678555436.1@sss.pgh.pa.us> Date: Sat, 11 Mar 2023 12:23:56 -0500 Message-ID: <1229467.1678555436@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > On Fri, 10 Mar 2023 at 05:09, Tom Lane wrote: >> How is this even a little bit sane? > I don't think it is. I've not looked in detail yet, but I think we > might be able to do something in check_output_expressions() so that we > track the targetIsInAllPartitionLists() separately. Maybe > unsafeColumns[] needs to become an enum type that has UNSAFE, SAFE, > WINDOW_RUNCONDITION_ONLY and then change things so we never make a > runCondition when the qual is UNSAFE. > Anyway, I'll give it more thought and aim to come up with a patch > early next week. Why can't we simply *remove* all this logic from subquery pushdown? I would expect that what happens in useful cases is that we push down the (safe) qual and then during planning of the subquery we see a WHERE clause matching the window run condition and work with that. So this all seems redundant, quite aside from being faulty. regards, tom lane