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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
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:27:35
Message-ID: 30149.1556224055@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Dmitry Dolgov <9erthalion6(at)gmail(dot)com> writes:
>> 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,

Well, that's just coincidental for the case where the problem fdw_expr is
a Param. I haven't tried to figure out exactly what upper-path generation
thinks it should put into fdw_exprs, but is it really only Params?

Anyway, ideally we'd not have any entries in fdw_scan_tlist that don't
include at least one foreign Var, and then there can't be a false match.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-04-25 20:36:14 Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)
Previous Message Dmitry Dolgov 2019-04-25 20:20:59 Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2019-04-25 20:34:41 "Routine Reindexing" docs should be updated to reference REINDEX CONCURRENTLY
Previous Message Dmitry Dolgov 2019-04-25 20:20:59 Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)