From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: sean.johnston@edgeintelligence.com, pgsql-bugs@lists.postgresql.org, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Subject: Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)
Date: Thu, 25 Apr 2019 16:27:35 -0400
Message-ID: <30149.1556224055@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+q6zcXXYdee8vyjxNqk7SPXhwSz9SrpDNTQDF=Yz_0C8LGgzw@mail.gmail.com>
References: <15781-2601b1002bad087c@postgresql.org>
<25734.1556216681@sss.pgh.pa.us>
<CA+q6zcXXYdee8vyjxNqk7SPXhwSz9SrpDNTQDF=Yz_0C8LGgzw@mail.gmail.com>
Dmitry Dolgov <9erthalion6@gmail.com> writes:
>> 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,
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, 9erthalion6@gmail.com, pgsql-hackers@lists.postgresql.org
Subject: Re: BUG #15781: subselect on foreign table (postgres_fdw) can crash (segfault)
In-Reply-To: <30149.1556224055@sss.pgh.pa.us>
References: <15781-2601b1002bad087c@postgresql.org> <25734.1556216681@sss.pgh.pa.us> <CA+q6zcXXYdee8vyjxNqk7SPXhwSz9SrpDNTQDF=Yz_0C8LGgzw@mail.gmail.com> <30149.1556224055@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox