Pass the correct PlannerInfo to PlanForeignModify/PlanDirectModify.
authorRobert Haas <rhaas@postgresql.org>
Wed, 16 May 2018 15:32:38 +0000 (11:32 -0400)
committerRobert Haas <rhaas@postgresql.org>
Wed, 16 May 2018 15:32:38 +0000 (11:32 -0400)
commit7fc7dac1a711d0dbd01d2daf6dc97d27d6c6409c
treeb7d6b20978bc54bd81788f88c77d5db974869d46
parent09b12d52db1cf1a4c72d876f3fb6c9d06919e51a
Pass the correct PlannerInfo to PlanForeignModify/PlanDirectModify.

Previously, we passed the toplevel PlannerInfo, but we actually want
to pass the relevant subroot.  One problem with passing the toplevel
PlannerInfo is that the FDW which wants to push down an UPDATE or
DELETE against a join won't find the relevant joinrel there.
As of commit 1bc0100d270e5bcc980a0629b8726a32a497e788, postgres_fdw
tries to do exactly this and can be made to fail an assertion as a
result.

It's possible that this should be regarded as a bug fix and
back-patched to earlier releases, but for lack of a test case that
fails in earlier releases, no back-patch for now.

Etsuro Fujita, reviewed by Amit Langote.

Discussion: http://postgr.es/m/5AF43E02.30000@lab.ntt.co.jp
contrib/postgres_fdw/expected/postgres_fdw.out
contrib/postgres_fdw/sql/postgres_fdw.sql
src/backend/optimizer/plan/createplan.c