From 5d4171d1c70edfe3e9be1de9e66603af28e3afe1 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Mon, 28 Mar 2016 21:50:28 -0400 Subject: Don't require a user mapping for FDWs to work. Commit fbe5a3fb73102c2cfec11aaaa4a67943f4474383 accidentally changed this behavior; put things back the way they were, and add some regression tests. Report by Andres Freund; patch by Ashutosh Bapat, with a bit of kibitzing by me. --- contrib/postgres_fdw/postgres_fdw.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'contrib/postgres_fdw/postgres_fdw.c') diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c index f21689e73d1..4fbbde13bc5 100644 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c @@ -3910,6 +3910,16 @@ foreign_join_ok(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype, List *joinclauses; List *otherclauses; + /* + * Core code may call GetForeignJoinPaths hook even when the join + * relation doesn't have a valid user mapping associated with it. See + * build_join_rel() for details. We can't push down such join, since + * there doesn't exist a user mapping which can be used to connect to the + * foreign server. + */ + if (!OidIsValid(joinrel->umid)) + return false; + /* * We support pushing down INNER, LEFT, RIGHT and FULL OUTER joins. * Constructing queries representing SEMI and ANTI joins is hard, hence -- cgit v1.2.3