Re: Wrong results from a parameterized Append

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Richard Guo <guofenglinux(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Wrong results from a parameterized Append
Date: 2026-10-18 03:47:37
Message-ID: CAGRkXqRh=RZAdN06qS5okiDK_ffvBoGYacMr4Fc96q3UwOghzw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Tom,

v2 looks right to me. Here is a case that fails on v16 too, using
plain LATERAL. With Richard's tables it gives 18 rows on 16 to
master, and 6 with v2:

set from_collapse_limit = 1;
set enable_hashjoin = off;
set enable_mergejoin = off;
select t1.*, ss.a from t1, lateral
(select s.a from t1 t3,
(select a from t2 where t2.b > t1.b
union all
select a from t2 where t2.b > t1.b) s) ss
where t1.a = ss.a + t1.b

The original SQL not work for 16 because v16 keeps a correlated I
N sublink as a SubPlan and never makes the semijoin. So we can
use Plain LATERAL to repro it.

Thanks,
Shihao

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shihao zhong 2026-10-18 03:52:33 [PG19] ILIKE index scan misses rows with a libc UTF-8 collation on macOS
Previous Message shihao zhong 2026-10-18 03:33:54 Re: json/jsonb cleanup + FmgrInfo caching