Re: Bogus EPQ plan construction in postgres_fdw

Robert Haas <robertmhaas@gmail.com>

From: Robert Haas <robertmhaas@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2018-12-14T22:07:00Z
Lists: pgsql-hackers
On Wed, Dec 12, 2018 at 8:00 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> By chance I noticed that postgres_fdw's postgresGetForeignPlan() assumes
> --- without any checking --- that the outer_plan it's given for a join
> relation must have a NestLoop, MergeJoin, or HashJoin node at the top.
> That's been wrong at least since commit 4bbf6edfb (which could cause
> insertion of a Sort node on top) and it seems like a pretty unsafe
> thing to Just Assume even without that.

Thanks for taking care of this.  I've looked at this code any number
of times and never quite noticed the assumption that outer_plan had to
be a join.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Commits

  1. Repair bogus EPQ plans generated for postgres_fdw foreign joins.

  2. postgres_fdw: Avoid 'outer pathkeys do not match mergeclauses' error.