From e7cb7ee14555cc9c5773e2c102efd6371f6f2005 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 1 May 2015 08:50:35 -0400 Subject: Allow FDWs and custom scan providers to replace joins with scans. Foreign data wrappers can use this capability for so-called "join pushdown"; that is, instead of executing two separate foreign scans and then joining the results locally, they can generate a path which performs the join on the remote server and then is scanned locally. This commit does not extend postgres_fdw to take advantage of this capability; it just provides the infrastructure. Custom scan providers can use this in a similar way. Previously, it was only possible for a custom scan provider to scan a single relation. Now, it can scan an entire join tree, provided of course that it knows how to produce the same results that the join would have produced if executed normally. KaiGai Kohei, reviewed by Shigeru Hanada, Ashutosh Bapat, and me. --- src/backend/executor/execScan.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/backend/executor/execScan.c') diff --git a/src/backend/executor/execScan.c b/src/backend/executor/execScan.c index 3f0d8093875..fa475014f13 100644 --- a/src/backend/executor/execScan.c +++ b/src/backend/executor/execScan.c @@ -251,6 +251,12 @@ ExecAssignScanProjectionInfo(ScanState *node) /* Vars in an index-only scan's tlist should be INDEX_VAR */ if (IsA(scan, IndexOnlyScan)) varno = INDEX_VAR; + /* Also foreign or custom scan on pseudo relation should be INDEX_VAR */ + else if (scan->scanrelid == 0) + { + Assert(IsA(scan, ForeignScan) || IsA(scan, CustomScan)); + varno = INDEX_VAR; + } else varno = scan->scanrelid; -- cgit v1.2.3