pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Etsuro Fujita <efujita@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: postgres_fdw: Avoid 'variable not found in subplan target list'
Date: Wed, 14 Sep 2022 09:54:39 +0000
Message-ID: <E1oYP6M-000Hxe-Id@gemulon.postgresql.org> (raw)

postgres_fdw: Avoid 'variable not found in subplan target list' error.

The tlist of the EvalPlanQual outer plan for a ForeignScan node is
adjusted to produce a tuple whose descriptor matches the scan tuple slot
for the ForeignScan node.  But in the case where the outer plan contains
an extra Sort node, if the new tlist contained columns required only for
evaluating PlaceHolderVars or columns required only for evaluating local
conditions, this would cause setrefs.c to fail with the error.

The cause of this is that when creating the outer plan by injecting the
Sort node into an alternative local join plan that could emit such extra
columns as well, we fail to arrange for the outer plan to propagate them
up through the Sort node, causing setrefs.c to fail to match up them in
the new tlist to what is available from the outer plan.  Repair.

Per report from Alexander Pyhalov.

Richard Guo and Etsuro Fujita, reviewed by Alexander Pyhalov and Tom Lane.
Backpatch to all supported versions.

Discussion: http://postgr.es/m/cfb17bf6dfdf876467bd5ef533852d18%40postgrespro.ru

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9320cfdd06e5975b7bf60ab4c3d03195bf3fb5ff

Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 79 ++++++++++++++++++++++++++
contrib/postgres_fdw/postgres_fdw.c            | 49 ++++++++++++++++
contrib/postgres_fdw/sql/postgres_fdw.sql      | 13 +++++
3 files changed, 141 insertions(+)



view thread (7+ messages)  latest in thread

Message-ID: <E1oYP6M-000Hxe-Id@gemulon.postgresql.org>
Permalink:  ../E1oYP6M-000Hxe-Id@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oYP6M-000Hxe-Id@gemulon.postgresql.org

 · 

reply

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-committers@postgresql.org
  Cc: efujita@postgresql.org
  Subject: Re: pgsql: postgres_fdw: Avoid 'variable not found in subplan target list'
  In-Reply-To: <E1oYP6M-000Hxe-Id@gemulon.postgresql.org>
  References: <E1oYP6M-000Hxe-Id@gemulon.postgresql.org>

* 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