Re: remove_useless_joins vs. bug #19560

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Richard Guo <guofenglinux(at)gmail(dot)com>, 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-08-29 03:03:49
Message-ID: CAHewXN=kWGAXV537mKtSyBYobGdHhYJVDJJMXXZEmmPWE_zaPw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> 于2026年8月28日周五 21:43写道:
>
> Richard Guo <guofenglinux(at)gmail(dot)com> writes:
> > On Fri, Aug 28, 2026 at 12:53 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >> I take your point that the early-exit-for-trivial-jointree path now
> >> fails to set these fields at all, but I'd rather handle that by
> >> adding a couple more lines in that path to fill them in. Yup, it'd
> >> be duplicate logic, but it seems cleaner that way.
>
> > Fair enough. I agree that keeping all of this together at the end of
> > query_planner makes it clear that these fields are not valid before
> > then, and that a half-filled set during the restart loop is a hazard.
> > Adding the few lines to the early-exit path sounds good to me.
>
> Cool.
>
> >> Well, yeah, but on that argument we could drop the entire stanza,
> >> because it's just checking that join_is_removable didn't mess up.
> >> Maybe we should? I've not heard that anybody ever hit those Asserts.
>
> > I think so.
>
> Sold. I'll make it so and push. Thanks for reviewing!

After 2ebf25e7d70a8, I hit a crash.

How to reproduce:

1. Run the regression tests.
2. Run the following query against the regression database:
psql (20devel)
Type "help" for help.

postgres=# \c regression
You are now connected to database "regression" as user "ubuntu".
regression=# SELECT
FROM (SELECT CASE
WHEN NULL
THEN sample_1.a
ELSE NULL
END AS c2
FROM public.shoelace_ok AS ref_2
LEFT JOIN fkpart5.pk31 AS sample_1 ON ref_2.ok_quant =
sample_1.a) AS subq_0
RIGHT JOIN public.ruletest_tbl2 AS ref_3 ON NULL,
LATERAL (SELECT subq_0.c2 AS c0,
public.logging_agg_nonstrict(ref_4.a) AS c8
FROM public.test_inh_check AS ref_4) AS subq_3;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.

The crash was originally found by SQLSmith. I reduced the original large
query to the reproducer above.

--
Thanks,
Tender Wang

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-08-29 03:27:24 Re: remove_useless_joins vs. bug #19560
Previous Message Bertrand Drouvot 2026-08-29 02:41:03 Re: Offline data checksum changes can cause incorrect checksum state on standbys