Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rRwTq-00AJ7T-1S for pgsql-bugs@arkaria.postgresql.org; Mon, 22 Jan 2024 15:44:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rRwTp-004gxB-3R for pgsql-bugs@arkaria.postgresql.org; Mon, 22 Jan 2024 15:44:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rRwTo-004gx3-Rp for pgsql-bugs@lists.postgresql.org; Mon, 22 Jan 2024 15:44:56 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rRwTk-002oND-Mf for pgsql-bugs@lists.postgresql.org; Mon, 22 Jan 2024 15:44:55 +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 40MFikas3738976; Mon, 22 Jan 2024 10:44:47 -0500 From: Tom Lane To: zuming.jiang@inf.ethz.ch cc: David Rowley , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18305: Unexpected error: "WindowFunc not found in subplan target lists" triggered by subqueries In-reply-to: <18305-33c49b4c830b37b3@postgresql.org> References: <18305-33c49b4c830b37b3@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Mon, 22 Jan 2024 12:15:00 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3738974.1705938286.1@sss.pgh.pa.us> Date: Mon, 22 Jan 2024 10:44:46 -0500 Message-ID: <3738975.1705938286@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > My fuzzer finds a bug in Postgres 17devel, which triggers an unexpected > error "ERROR: WindowFunc not found in subplan target lists". > create table exeet_t3 (pkey int4); > create view exeet_t8 as > select > ntile(exeet_subq_0.c_0) over () as c_0 > from > (select (select pkey from exeet_t3 order by pkey limit 1 offset 6) as > c_0) as exeet_subq_0; > select > 1 as c_1 > from > exeet_t8 as exeet_ref_17 > where exeet_ref_17.c_0 < 0; > ERROR: WindowFunc not found in subplan target lists Thanks for the report! Bisecting shows that this broke at 456fa635a909ee36f73ca84d340521bd730f265f is the first bad commit commit 456fa635a909ee36f73ca84d340521bd730f265f Author: David Rowley Date: Fri Jan 27 16:08:41 2023 +1300 Teach planner about more monotonic window functions 9d9c02ccd introduced runConditions for window functions to allow monotonic window function evaluation to be made more efficient when the window function value went beyond some value that it would never go back from due to its monotonic nature. That commit added prosupport functions to inform the planner that row_number(), rank(), dense_rank() and some forms of count(*) were monotonic. Here we add support for ntile(), cume_dist() and percent_rank(). So I'm betting there's something wrong with the ntile support function, but I've not dug deeper. regards, tom lane