aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/commands/explain.h11
-rw-r--r--src/include/executor/nodeForeignscan.h24
-rw-r--r--src/include/fmgr.h1
-rw-r--r--src/include/foreign/fdwapi.h98
-rw-r--r--src/include/foreign/foreign.h8
-rw-r--r--src/include/nodes/execnodes.h14
-rw-r--r--src/include/nodes/nodes.h7
-rw-r--r--src/include/nodes/plannodes.h12
-rw-r--r--src/include/nodes/relation.h10
-rw-r--r--src/include/optimizer/cost.h1
-rw-r--r--src/include/optimizer/pathnode.h1
11 files changed, 186 insertions, 1 deletions
diff --git a/src/include/commands/explain.h b/src/include/commands/explain.h
index f17548338f8..2c38c92ae51 100644
--- a/src/include/commands/explain.h
+++ b/src/include/commands/explain.h
@@ -72,4 +72,15 @@ extern void ExplainBeginOutput(ExplainState *es);
extern void ExplainEndOutput(ExplainState *es);
extern void ExplainSeparatePlans(ExplainState *es);
+extern void ExplainPropertyList(const char *qlabel, List *data,
+ ExplainState *es);
+extern void ExplainPropertyText(const char *qlabel, const char *value,
+ ExplainState *es);
+extern void ExplainPropertyInteger(const char *qlabel, int value,
+ ExplainState *es);
+extern void ExplainPropertyLong(const char *qlabel, long value,
+ ExplainState *es);
+extern void ExplainPropertyFloat(const char *qlabel, double value, int ndigits,
+ ExplainState *es);
+
#endif /* EXPLAIN_H */
diff --git a/src/include/executor/nodeForeignscan.h b/src/include/executor/nodeForeignscan.h
new file mode 100644
index 00000000000..5cfcfe72d03
--- /dev/null
+++ b/src/include/executor/nodeForeignscan.h
@@ -0,0 +1,24 @@
+/*-------------------------------------------------------------------------
+ *
+ * nodeForeignscan.h
+ *
+ *
+ *
+ * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/executor/nodeForeignscan.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef NODEFOREIGNSCAN_H
+#define NODEFOREIGNSCAN_H
+
+#include "nodes/execnodes.h"
+
+extern ForeignScanState *ExecInitForeignScan(ForeignScan *node, EState *estate, int eflags);
+extern TupleTableSlot *ExecForeignScan(ForeignScanState *node);
+extern void ExecEndForeignScan(ForeignScanState *node);
+extern void ExecReScanForeignScan(ForeignScanState *node);
+
+#endif /* NODEFOREIGNSCAN_H */
diff --git a/src/include/fmgr.h b/src/include/fmgr.h
index 9720117a7f5..7539acace82 100644
--- a/src/include/fmgr.h
+++ b/src/include/fmgr.h
@@ -488,6 +488,7 @@ extern Datum FunctionCall9(FmgrInfo *flinfo, Datum arg1, Datum arg2,
* by FunctionCallN(). If the same function is to be invoked repeatedly,
* do the FunctionLookup() once and then use FunctionCallN().
*/
+extern Datum OidFunctionCall0(Oid functionId);
extern Datum OidFunctionCall1(Oid functionId, Datum arg1);
extern Datum OidFunctionCall2(Oid functionId, Datum arg1, Datum arg2);
extern Datum OidFunctionCall3(Oid functionId, Datum arg1, Datum arg2,
diff --git a/src/include/foreign/fdwapi.h b/src/include/foreign/fdwapi.h
new file mode 100644
index 00000000000..28731873885
--- /dev/null
+++ b/src/include/foreign/fdwapi.h
@@ -0,0 +1,98 @@
+/*-------------------------------------------------------------------------
+ *
+ * fdwapi.h
+ * API for foreign-data wrappers
+ *
+ * Copyright (c) 2010-2011, PostgreSQL Global Development Group
+ *
+ * src/include/foreign/fdwapi.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef FDWAPI_H
+#define FDWAPI_H
+
+#include "nodes/execnodes.h"
+#include "nodes/relation.h"
+
+/* To avoid including explain.h here, reference ExplainState thus: */
+struct ExplainState;
+
+
+/*
+ * FdwPlan is the information returned to the planner by PlanForeignScan.
+ */
+typedef struct FdwPlan
+{
+ NodeTag type;
+
+ /*
+ * Cost estimation info. The startup_cost is time before retrieving
+ * the first row, so it should include costs of connecting to the remote
+ * host, sending over the query, etc. Note that PlanForeignScan also
+ * ought to set baserel->rows and baserel->width if it can produce any
+ * usable estimates of those values.
+ */
+ Cost startup_cost; /* cost expended before fetching any tuples */
+ Cost total_cost; /* total cost (assuming all tuples fetched) */
+
+ /*
+ * FDW private data, which will be available at execution time.
+ *
+ * Note that everything in this list must be copiable by copyObject().
+ * One way to store an arbitrary blob of bytes is to represent it as a
+ * bytea Const. Usually, though, you'll be better off choosing a
+ * representation that can be dumped usefully by nodeToString().
+ */
+ List *fdw_private;
+} FdwPlan;
+
+
+/*
+ * Callback function signatures --- see fdwhandler.sgml for more info.
+ */
+
+typedef FdwPlan * (*PlanForeignScan_function) (Oid foreigntableid,
+ PlannerInfo *root,
+ RelOptInfo *baserel);
+
+typedef void (*ExplainForeignScan_function) (ForeignScanState *node,
+ struct ExplainState *es);
+
+typedef void (*BeginForeignScan_function) (ForeignScanState *node,
+ int eflags);
+
+typedef TupleTableSlot * (*IterateForeignScan_function) (ForeignScanState *node);
+
+typedef void (*ReScanForeignScan_function) (ForeignScanState *node);
+
+typedef void (*EndForeignScan_function) (ForeignScanState *node);
+
+
+/*
+ * FdwRoutine is the struct returned by a foreign-data wrapper's handler
+ * function. It provides pointers to the callback functions needed by the
+ * planner and executor.
+ *
+ * Currently, all functions must be supplied. Later there may be optional
+ * additions. It's recommended that the handler initialize the struct with
+ * makeNode(FdwRoutine) so that all fields are set to zero.
+ */
+typedef struct FdwRoutine
+{
+ NodeTag type;
+
+ PlanForeignScan_function PlanForeignScan;
+ ExplainForeignScan_function ExplainForeignScan;
+ BeginForeignScan_function BeginForeignScan;
+ IterateForeignScan_function IterateForeignScan;
+ ReScanForeignScan_function ReScanForeignScan;
+ EndForeignScan_function EndForeignScan;
+} FdwRoutine;
+
+
+/* Functions in foreign/foreign.c */
+extern FdwRoutine *GetFdwRoutine(Oid fdwhandler);
+extern FdwRoutine *GetFdwRoutineByRelId(Oid relid);
+
+#endif /* FDWAPI_H */
diff --git a/src/include/foreign/foreign.h b/src/include/foreign/foreign.h
index 2cf0eaa09cc..d676f3fce74 100644
--- a/src/include/foreign/foreign.h
+++ b/src/include/foreign/foreign.h
@@ -60,6 +60,13 @@ typedef struct UserMapping
List *options; /* useoptions as DefElem list */
} UserMapping;
+typedef struct ForeignTable
+{
+ Oid relid; /* relation Oid */
+ Oid serverid; /* server Oid */
+ List *options; /* ftoptions as DefElem list */
+} ForeignTable;
+
extern ForeignServer *GetForeignServer(Oid serverid);
extern ForeignServer *GetForeignServerByName(const char *name, bool missing_ok);
@@ -69,5 +76,6 @@ extern ForeignDataWrapper *GetForeignDataWrapper(Oid fdwid);
extern ForeignDataWrapper *GetForeignDataWrapperByName(const char *name,
bool missing_ok);
extern Oid GetForeignDataWrapperOidByName(const char *name, bool missing_ok);
+extern ForeignTable *GetForeignTable(Oid relid);
#endif /* FOREIGN_H */
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 44da70ff608..0a6b829de4f 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1403,6 +1403,20 @@ typedef struct WorkTableScanState
RecursiveUnionState *rustate;
} WorkTableScanState;
+/* ----------------
+ * ForeignScanState information
+ *
+ * ForeignScan nodes are used to scan foreign-data tables.
+ * ----------------
+ */
+typedef struct ForeignScanState
+{
+ ScanState ss; /* its first field is NodeTag */
+ /* use struct pointer to avoid including fdwapi.h here */
+ struct FdwRoutine *fdwroutine;
+ void *fdw_state; /* foreign-data wrapper can keep state here */
+} ForeignScanState;
+
/* ----------------------------------------------------------------
* Join State Information
* ----------------------------------------------------------------
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index e0d05748daf..cbaf123ee9d 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -60,6 +60,8 @@ typedef enum NodeTag
T_ValuesScan,
T_CteScan,
T_WorkTableScan,
+ T_ForeignScan,
+ T_FdwPlan,
T_Join,
T_NestLoop,
T_MergeJoin,
@@ -103,6 +105,7 @@ typedef enum NodeTag
T_ValuesScanState,
T_CteScanState,
T_WorkTableScanState,
+ T_ForeignScanState,
T_JoinState,
T_NestLoopState,
T_MergeJoinState,
@@ -217,6 +220,7 @@ typedef enum NodeTag
T_MergePath,
T_HashPath,
T_TidPath,
+ T_ForeignPath,
T_AppendPath,
T_MergeAppendPath,
T_ResultPath,
@@ -409,7 +413,8 @@ typedef enum NodeTag
T_ReturnSetInfo, /* in nodes/execnodes.h */
T_WindowObjectData, /* private in nodeWindowAgg.c */
T_TIDBitmap, /* in nodes/tidbitmap.h */
- T_InlineCodeBlock /* in nodes/parsenodes.h */
+ T_InlineCodeBlock, /* in nodes/parsenodes.h */
+ T_FdwRoutine /* in foreign/fdwapi.h */
} NodeTag;
/*
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index b4fb4f211b5..90d61256e9c 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -436,6 +436,18 @@ typedef struct WorkTableScan
int wtParam; /* ID of Param representing work table */
} WorkTableScan;
+/* ----------------
+ * ForeignScan node
+ * ----------------
+ */
+typedef struct ForeignScan
+{
+ Scan scan;
+ bool fsSystemCol; /* true if any "system column" is needed */
+ /* use struct pointer to avoid including fdwapi.h here */
+ struct FdwPlan *fdwplan;
+} ForeignScan;
+
/*
* ==========
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h
index 6f51b6c5fe4..ab708351ed7 100644
--- a/src/include/nodes/relation.h
+++ b/src/include/nodes/relation.h
@@ -750,6 +750,16 @@ typedef struct TidPath
} TidPath;
/*
+ * ForeignPath represents a scan of a foreign table
+ */
+typedef struct ForeignPath
+{
+ Path path;
+ /* use struct pointer to avoid including fdwapi.h here */
+ struct FdwPlan *fdwplan;
+} ForeignPath;
+
+/*
* AppendPath represents an Append plan, ie, successive execution of
* several member plans.
*
diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h
index 3112bf75ccf..e3cf7464df6 100644
--- a/src/include/optimizer/cost.h
+++ b/src/include/optimizer/cost.h
@@ -127,6 +127,7 @@ extern void set_function_size_estimates(PlannerInfo *root, RelOptInfo *rel);
extern void set_values_size_estimates(PlannerInfo *root, RelOptInfo *rel);
extern void set_cte_size_estimates(PlannerInfo *root, RelOptInfo *rel,
Plan *cteplan);
+extern void set_foreign_size_estimates(PlannerInfo *root, RelOptInfo *rel);
/*
* prototypes for clausesel.c
diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h
index ff220e32a79..7a24da2c51c 100644
--- a/src/include/optimizer/pathnode.h
+++ b/src/include/optimizer/pathnode.h
@@ -61,6 +61,7 @@ extern Path *create_functionscan_path(PlannerInfo *root, RelOptInfo *rel);
extern Path *create_valuesscan_path(PlannerInfo *root, RelOptInfo *rel);
extern Path *create_ctescan_path(PlannerInfo *root, RelOptInfo *rel);
extern Path *create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel);
+extern ForeignPath *create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel);
extern NestPath *create_nestloop_path(PlannerInfo *root,
RelOptInfo *joinrel,