Re: BUG #18305: Unexpected error: "WindowFunc not found in subplan target lists" triggered by subqueries

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: zuming(dot)jiang(at)inf(dot)ethz(dot)ch
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18305: Unexpected error: "WindowFunc not found in subplan target lists" triggered by subqueries
Date: 2024-01-22 15:44:46
Message-ID: 3738975.1705938286@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> 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 <drowley(at)postgresql(dot)org>
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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2024-01-22 16:01:03 Re: MarkBufferDirty Assert held LW_EXCLUSIVE lock fail when ginFinishSplit
Previous Message feichanghong 2024-01-22 15:27:11 Re: MarkBufferDirty Assert held LW_EXCLUSIVE lock fail when ginFinishSplit