mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
postgres_fdw: Fix join push down with extensions
Objects in an extension are shippable to a foreign server if the
extension is part of the foreign server definition's shippable
extensions list. But this was not properly considered in some cases
when checking whether a join condition can be pushed to a foreign server
and the join condition uses an object from a shippable extension. So
the join would never be pushed down in those cases.
So, the list of extensions needs to be made available in fpinfo of the
relation being considered to be pushed down before any expressions are
assessed for being shippable. Fix foreign_join_ok() to do that for a
join relation.
David Rowley and Ashutosh Bapat, per report from David Rowley
reduced version of patch 332bec1e60
for
backpatch to 9.6, first release with join push down
This commit is contained in:
@ -3990,6 +3990,15 @@ foreign_join_ok(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype,
|
||||
joinclauses = NIL;
|
||||
}
|
||||
|
||||
/* Get foreign server */
|
||||
fpinfo->server = fpinfo_o->server;
|
||||
|
||||
/*
|
||||
* Copy shippable_extensions before checking whether the foreign join is
|
||||
* OK, so that we know which quals can be evaluated on the foreign server.
|
||||
*/
|
||||
fpinfo->shippable_extensions = fpinfo_o->shippable_extensions;
|
||||
|
||||
/* Join quals must be safe to push down. */
|
||||
foreach(lc, joinclauses)
|
||||
{
|
||||
@ -4133,9 +4142,6 @@ foreign_join_ok(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype,
|
||||
else
|
||||
fpinfo->user = NULL;
|
||||
|
||||
/* Get foreign server */
|
||||
fpinfo->server = fpinfo_o->server;
|
||||
|
||||
/*
|
||||
* Since both the joining relations come from the same server, the server
|
||||
* level options should have same value for both the relations. Pick from
|
||||
|
Reference in New Issue
Block a user