Re: Wrong results with right-semi-joins

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Wrong results with right-semi-joins
Date: 2024-12-12 02:44:42
Message-ID: CAMbWs48dcaBS1zHMG3j4oMGsQtjTidmbB2nkZZJwFv7aj8jNCw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Dec 11, 2024 at 11:27 AM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> I spent some time on this and came up with a simpler query to
> reproduce the issue.
>
> explain (costs off)
> select * from tbl_rs t1 join
> lateral (select * from tbl_rs t2 where t2.a in
> (select t1.a+t3.a from tbl_rs t3) and t2.a < 5)
> on true;
> QUERY PLAN
> -------------------------------------------
> Nested Loop
> -> Seq Scan on tbl_rs t1
> -> Hash Right Semi Join
> Hash Cond: ((t1.a + t3.a) = t2.a)
> -> Seq Scan on tbl_rs t3
> -> Hash
> -> Seq Scan on tbl_rs t2
> Filter: (a < 5)
> (8 rows)
>
> Without the fix, this query returns 3 rows rather than the expected 6.
>
> Maybe I should update the test case introduced in 5668a857d to this
> one.

Done.

Thanks
Richard

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-12-12 02:46:26 Re: pg_createsubscriber TAP test wrapping makes command options hard to read.
Previous Message Hayato Kuroda (Fujitsu) 2024-12-12 02:43:50 RE: Adding a '--two-phase' option to 'pg_createsubscriber' utility.