pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dmitry Dolgov <9erthalion6@gmail.com>
To: mtakahar@gmail.com
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18465: Wrong results from SELECT DISTINCT MIN in scalar subquery using HashAggregate
Date: Sat, 18 May 2024 16:18:01 +0200
Message-ID: <20240518141801.cobd5aup2pnogeo2@ddolgov.remote.csb> (raw)
In-Reply-To: <18465-2fae927718976b22@postgresql.org>
References: <18465-2fae927718976b22@postgresql.org>

> On Tue, May 14, 2024 at 09:14:34PM +0000, PG Bug reporting form wrote:
>
> postgres=# SELECT (  SELECT  DISTINCT  MIN( col_int  )  FROM B  AS
> SUBQUERY1_t1  WHERE SUBQUERY1_t1 .col_int  = table1 .col_int  ), table1
> .col_int  FROM CC  AS table1    ;
>   min   | col_int
> --------+---------
>  <null> |  <null>
>  <null> |       1        <------- *** wrong ***
>  <null> |       2
> (3 rows)
>
> postgres=# SELECT (  SELECT  DISTINCT  MIN( col_int  )  FROM B  AS
> SUBQUERY1_t1  WHERE SUBQUERY1_t1 .col_int  = table1 .col_int  ), table1
> .col_int  FROM CC  AS table1    ;
>  min | col_int
> -----+---------
>    1 |       1        <------- *** correct ***
>    1 |       2        <------- *** wrong ***
>    1 |  <null>        <------- *** wrong ***
> (3 rows)

Thanks, I could reproduce this in v15 and v16. Interestingly enough it
was fixed in d0d44049d1, but looks like due to lack of error reports the
fix was applied only on the main branch. I assume this one makes it
necessary to back-patch the fix.





view thread (3+ messages)  latest in thread

Message-ID: <20240518141801.cobd5aup2pnogeo2@ddolgov.remote.csb>
Permalink:  ../20240518141801.cobd5aup2pnogeo2@ddolgov.remote.csb/
Also on:    postgresql.org/message-id/20240518141801.cobd5aup2pnogeo2@ddolgov.remote.csb

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: 9erthalion6@gmail.com, mtakahar@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18465: Wrong results from SELECT DISTINCT MIN in scalar subquery using HashAggregate
  In-Reply-To: <20240518141801.cobd5aup2pnogeo2@ddolgov.remote.csb>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox