| From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | Thom Brown <thom(at)linux(dot)com>, Jacob Brazeal <jacob(dot)brazeal(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: remove_useless_joins vs. bug #19560 |
| Date: | 2026-09-17 02:40:57 |
| Message-ID: | CAMbWs484SQSdzWTgZYKvwtuC6J4m7acw0LfBjp3aWPvav7gC_w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, Aug 28, 2026 at 10:43 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Sold. I'll make it so and push. Thanks for reviewing!
Fuzzing with Claude, I ran into an assertion failure that comes from
commit 2ebf25e7d:
create table t1 (a int, b int, c int);
create table t2 (a int primary key, b int, c int);
select j.x from (t1 s(x) left join t2 on s.x = t2.a) j;
server closed the connection unexpectedly
TRAP: failed Assert("context->new_index != INVALID_VAR")
This is because that since the join has an alias, j.x is a Var with
varno pointing to s and varnosyn pointing to the join. When the join
is removed, ChangeVarNodes() notices that varnosyn still references
the join's RT index, so the Assert fires.
I think this varnosyn is fine to keep. The join is only removed from
the jointree; its RTE stays in the rangetable through to the final
plan, so varnosyn still names a valid RTE. And join removal didn't
touch varnosyn before 2ebf25e7d either.
Attached is a fix.
- Richard
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-join-removal-when-Vars-reference-the-removed-.patch | application/octet-stream | 4.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Paul A Jungwirth | 2026-09-17 02:44:13 | Re: Add TG_* vars for FOR PORTION OF |
| Previous Message | shihao zhong | 2026-09-17 02:23:40 | Re: Report index currently being vacuumed in pg_stat_progress_vacuum |