Re: Wrong results with right-semi-joins

2024-12-12 Thread Melanie Plageman
On Wed, Dec 11, 2024 at 9:44 PM Richard Guo wrote: > > On Wed, Dec 11, 2024 at 11:27 AM Richard Guo wrote: > > > Maybe I should update the test case introduced in 5668a857d to this > > one. > > Done. Great, thanks. I think the new example is more clear. - Melanie

Re: Wrong results with right-semi-joins

2024-12-11 Thread Richard Guo
On Wed, Dec 11, 2024 at 11:27 AM Richard Guo 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 t

Re: Wrong results with right-semi-joins

2024-12-10 Thread Richard Guo
On Mon, Dec 9, 2024 at 11:01 PM Melanie Plageman wrote: > Thanks for finding and fixing this. Just for my own benefit, could you > explain more about the minimal repro? Specifically, if you just need a > subplan in the hash side of a right semi-join, why do you also need > the outer part of the qu

Re: Wrong results with right-semi-joins

2024-12-09 Thread Melanie Plageman
On Tue, Dec 3, 2024 at 3:56 AM Richard Guo wrote: > > I ran into $subject and it can be reproduced with the query below. > > create temp table tbl_rs(a int, b int); > insert into tbl_rs select i, i from generate_series(1,10)i; > analyze tbl_rs; > > set enable_nestloop to off; > set enable_hashagg

Re: Wrong results with right-semi-joins

2024-12-09 Thread Richard Guo
On Tue, Dec 3, 2024 at 5:56 PM Richard Guo wrote: > I've traced the root cause to ExecReScanHashJoin, where we neglect to > reset the inner-tuple match flags in the hash table for right-semi > joins when reusing the hash table. It was my oversight in commit > aa86129e1. Attached is patch to fix

Wrong results with right-semi-joins

2024-12-03 Thread Richard Guo
I ran into $subject and it can be reproduced with the query below. create temp table tbl_rs(a int, b int); insert into tbl_rs select i, i from generate_series(1,10)i; analyze tbl_rs; set enable_nestloop to off; set enable_hashagg to off; select * from tbl_rs t1 where (select a from tbl_rs t2