Re: BUG #19915: Qual over function-wrapped grouping column pushed past DISTINCT ON returns wrong rows

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: 303677365(at)qq(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19915: Qual over function-wrapped grouping column pushed past DISTINCT ON returns wrong rows
Date: 2026-11-18 21:29:27
Message-ID: CAApHDvp4XZGo+QgJAVYYisHVX2vfJPvcV4gJDpbWKZnj-AJ_jw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, 18 Nov 2026 at 21:38, PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
> But in the single query, the qual is pushed below the Unique node (EXPLAIN
> shows the filter on the scan), the grouping only sees row (2, 1.0), and the
> query returns a row the subquery never produces:
>
> ```sql
> EXPLAIN (COSTS OFF)
> SELECT * FROM (SELECT DISTINCT ON (a) id, a FROM m ORDER BY a, id) s
> WHERE scale(s.a) = 1;
> ```

This is effectively a duplicate of bugs #19619, #19697, and #19713.

Can you reply here with the answer to the question in [1]? We'd very
much like to know why you think this is important.

David

[1] https://postgr.es/m/1187008.1790094524@sss.pgh.pa.us

In response to

Browse pgsql-bugs by date

  From Date Subject
Previous Message David Rowley 2026-11-18 20:10:35 Re: BUG #19904: pg_column_is_updatable(): "negative bitmapset member not allowed" for large attnum (int16 overflow)