summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path/allpaths.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-03-05 16:15:59 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2012-03-05 16:15:59 -0500
commit6b289942bfdbbfa2955cedc591c522822a7ffbfe (patch)
tree6205261ee347d578153391cec4dbd99e55e1a6bd /src/backend/optimizer/path/allpaths.c
parent3f47e145f1869f147a807e5a2cb80d21a13e10ae (diff)
Redesign PlanForeignScan API to allow multiple paths for a foreign table.
The original API specification only allowed an FDW to create a single access path, which doesn't seem like a terribly good idea in hindsight. Instead, move the responsibility for building the Path node and calling add_path() into the FDW's PlanForeignScan function. Now, it can do that more than once if appropriate. There is no longer any need for the transient FdwPlan struct, so get rid of that. Etsuro Fujita, Shigeru Hanada, Tom Lane
Diffstat (limited to 'src/backend/optimizer/path/allpaths.c')
-rw-r--r--src/backend/optimizer/path/allpaths.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index 8f034176e7c..6e81ce0fc26 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -18,6 +18,7 @@
#include <math.h>
#include "catalog/pg_class.h"
+#include "foreign/fdwapi.h"
#include "nodes/nodeFuncs.h"
#ifdef OPTIMIZER_DEBUG
#include "nodes/print.h"
@@ -399,15 +400,18 @@ set_foreign_size(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
/*
* set_foreign_pathlist
- * Build the (single) access path for a foreign table RTE
+ * Build access paths for a foreign table RTE
*/
static void
set_foreign_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
{
- /* Generate appropriate path */
- add_path(rel, (Path *) create_foreignscan_path(root, rel));
+ FdwRoutine *fdwroutine;
- /* Select cheapest path (pretty easy in this case...) */
+ /* Call the FDW's PlanForeignScan function to generate path(s) */
+ fdwroutine = GetFdwRoutineByRelId(rte->relid);
+ fdwroutine->PlanForeignScan(rte->relid, root, rel);
+
+ /* Select cheapest path */
set_cheapest(rel);
}