]> git.ipfire.org Git - thirdparty/postgresql.git/commit
postgres_fdw: Avoid 'variable not found in subplan target list' error.
authorEtsuro Fujita <efujita@postgresql.org>
Wed, 14 Sep 2022 09:45:06 +0000 (18:45 +0900)
committerEtsuro Fujita <efujita@postgresql.org>
Wed, 14 Sep 2022 09:45:06 +0000 (18:45 +0900)
commit87fd3c9025da2db0f35b3c898126f32ed35bb15c
treecb5492bc5e6bbef162e3cf1ca5e29f13c8f801d4
parentadb371c9cd95ad48cbcedb21a8cb9b0208295dc6
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
contrib/postgres_fdw/expected/postgres_fdw.out
contrib/postgres_fdw/postgres_fdw.c
contrib/postgres_fdw/sql/postgres_fdw.sql