Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)

From: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: sean(dot)johnston(at)edgeintelligence(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)
Date: 2019-04-25 20:20:59
Message-ID: CA+q6zcXXYdee8vyjxNqk7SPXhwSz9SrpDNTQDF=Yz_0C8LGgzw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

> On Thu, Apr 25, 2019 at 8:24 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-04-25 20:27:35 Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)
Previous Message Tom Lane 2019-04-25 18:24:41 Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-04-25 20:27:35 Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)
Previous Message Tom Lane 2019-04-25 20:02:03 Re: REINDEX INDEX results in a crash for an index of pg_class since 9.6