| From: | Tender Wang <tndrwang(at)gmail(dot)com> |
|---|---|
| To: | Richard Guo <guofenglinux(at)gmail(dot)com> |
| Cc: | Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Subject: | Re: Assert failure in try_nestloop_path() |
| Date: | 2026-09-03 09:39:30 |
| Message-ID: | CAHewXNkAMV63VHCLmZnsH1_rWVZedAHTAzht5F2E7BzXefYECg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Richard Guo <guofenglinux(at)gmail(dot)com> 于2026年9月1日周二 15:43写道:
>
> I was studying the PHV bug caused by join-removal and ran into an
> assertion failure with the query below, which is not related to
> join-removal. So start a new thread for it.
>
> create table ta (id int primary key, x int);
> create table tb (id int primary key, a_id int, x int);
> create table tc (id int, x int);
>
> explain (costs off)
> select 1 from ta t1 left join
> (select tb.x as bx, 1 as one from ta a2 left join tb on a2.id =
> tb.a_id) t2 on true
> left join lateral (select tc.x as cnt from tc where tc.id = t2.one
> offset 0) t3
> on t2.bx = t3.cnt;
>
> TRAP: failed Assert("!have_unsafe_outer_join_ref(root, outerrelids,
> inner_paramrels)")
>
I tested v1 and it fixes the reported assertion failure.
I also noticed that the resulting plan contains a duplicated filter:
QUERY PLAN
-------------------------------------------------------------------
Nested Loop Left Join
-> Seq Scan on ta t1
-> Materialize
-> Nested Loop Left Join
-> Hash Right Join
Hash Cond: (tb.a_id = a2.id)
-> Seq Scan on tb
-> Hash
-> Seq Scan on ta a2
-> Subquery Scan on t3
Filter: ((tb.x = t3.cnt) AND (tb.x = t3.cnt))
-> Seq Scan on tc
Filter: (id = (1))
```
Filter: ((tb.x = t3.cnt) AND (tb.x = t3.cnt))
```
This is not introduced by v1; I can reproduce the same duplicate qual on
pg16.14 as well, so it seems to be a pre-existing issue.
It is probably unrelated to this fix, but I thought it was worth mentioning
since the test case exposes it.
--
Thanks,
Tender Wang
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chee Wooson | 2026-09-03 09:56:25 | Re: [PATCH v1 1/1] Avoid carrying self lock-only xmax to updated tuple |
| Previous Message | Etsuro Fujita | 2026-09-03 09:35:13 | Re: Remove fcinfo from statistics update internal functions |