Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault) - Mailing list pgsql-bugs

From Dmitry Dolgov
Subject Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)
Date
Msg-id CA+q6zcXXYdee8vyjxNqk7SPXhwSz9SrpDNTQDF=Yz_0C8LGgzw@mail.gmail.com
Whole thread Raw
In response to Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
> On Thu, Apr 25, 2019 at 8:24 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> The proximate cause of the crash is that we have {PARAM 1}
> (representing the output of the InitPlan) in the path's fdw_exprs, and
> also the identical expression in fdw_scan_tlist, and that means that when
> setrefs.c processes the ForeignScan node it thinks it should replace the
> {PARAM 1} in fdw_exprs with a Var representing a reference to the
> fdw_scan_tlist entry.

I've noticed, that it behaves like that since f9f63ed1f2e5 (originally I found
it pretty strange, but after this explanation it does make sense). As an
experiment, I've changed the position of condition of

    if (context->subplan_itlist->has_non_vars)

back - it also made problem to disappear, and what was interesting is that the
test case for update (exactly what this commit was fixing) is not crashing
either. I've checked on the commit right before f9f63ed1f2e5, without mentioned
reordering there is a crash, but I couldn't reproduce it on the master.



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)
Next
From: Tom Lane
Date:
Subject: Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)