postgresql/contrib/postgres_fdw
Etsuro Fujita d4adff0e97 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
2022-09-14 18:45:09 +09:00
..
expected postgres_fdw: Avoid 'variable not found in subplan target list' error. 2022-09-14 18:45:09 +09:00
sql postgres_fdw: Avoid 'variable not found in subplan target list' error. 2022-09-14 18:45:09 +09:00
.gitignore Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
Makefile Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-07-09 17:23:31 -04:00
connection.c postgres_fdw: Fix unexpected reporting of empty message. 2021-12-03 17:37:31 +09:00
deparse.c Fix postgres_fdw to check shippability of sort clauses properly. 2022-03-31 14:29:24 -04:00
option.c Avoid using ambiguous word "non-negative" in error messages. 2021-07-28 01:25:53 +09:00
postgres_fdw--1.0.sql Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
postgres_fdw.c postgres_fdw: Avoid 'variable not found in subplan target list' error. 2022-09-14 18:45:09 +09:00
postgres_fdw.control Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
postgres_fdw.h Fix postgres_fdw to check shippability of sort clauses properly. 2022-03-31 14:29:24 -04:00
shippable.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00