gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

263 lines
9.3KB

  1. /*-------------------------------------------------------------------------
  2. *
  3. * fdwapi.h
  4. * API for foreign-data wrappers
  5. *
  6. * Copyright (c) 2010-2019, PostgreSQL Global Development Group
  7. *
  8. * src/include/foreign/fdwapi.h
  9. *
  10. *-------------------------------------------------------------------------
  11. */
  12. #ifndef FDWAPI_H
  13. #define FDWAPI_H
  14. #include "access/parallel.h"
  15. #include "nodes/execnodes.h"
  16. #include "nodes/pathnodes.h"
  17. /* To avoid including explain.h here, reference ExplainState thus: */
  18. struct ExplainState;
  19. /*
  20. * Callback function signatures --- see fdwhandler.sgml for more info.
  21. */
  22. typedef void (*GetForeignRelSize_function) (PlannerInfo *root,
  23. RelOptInfo *baserel,
  24. Oid foreigntableid);
  25. typedef void (*GetForeignPaths_function) (PlannerInfo *root,
  26. RelOptInfo *baserel,
  27. Oid foreigntableid);
  28. typedef ForeignScan *(*GetForeignPlan_function) (PlannerInfo *root,
  29. RelOptInfo *baserel,
  30. Oid foreigntableid,
  31. ForeignPath *best_path,
  32. List *tlist,
  33. List *scan_clauses,
  34. Plan *outer_plan);
  35. typedef void (*BeginForeignScan_function) (ForeignScanState *node,
  36. int eflags);
  37. typedef TupleTableSlot *(*IterateForeignScan_function) (ForeignScanState *node);
  38. typedef bool (*RecheckForeignScan_function) (ForeignScanState *node,
  39. TupleTableSlot *slot);
  40. typedef void (*ReScanForeignScan_function) (ForeignScanState *node);
  41. typedef void (*EndForeignScan_function) (ForeignScanState *node);
  42. typedef void (*GetForeignJoinPaths_function) (PlannerInfo *root,
  43. RelOptInfo *joinrel,
  44. RelOptInfo *outerrel,
  45. RelOptInfo *innerrel,
  46. JoinType jointype,
  47. JoinPathExtraData *extra);
  48. typedef void (*GetForeignUpperPaths_function) (PlannerInfo *root,
  49. UpperRelationKind stage,
  50. RelOptInfo *input_rel,
  51. RelOptInfo *output_rel,
  52. void *extra);
  53. typedef void (*AddForeignUpdateTargets_function) (Query *parsetree,
  54. RangeTblEntry *target_rte,
  55. Relation target_relation);
  56. typedef List *(*PlanForeignModify_function) (PlannerInfo *root,
  57. ModifyTable *plan,
  58. Index resultRelation,
  59. int subplan_index);
  60. typedef void (*BeginForeignModify_function) (ModifyTableState *mtstate,
  61. ResultRelInfo *rinfo,
  62. List *fdw_private,
  63. int subplan_index,
  64. int eflags);
  65. typedef TupleTableSlot *(*ExecForeignInsert_function) (EState *estate,
  66. ResultRelInfo *rinfo,
  67. TupleTableSlot *slot,
  68. TupleTableSlot *planSlot);
  69. typedef TupleTableSlot *(*ExecForeignUpdate_function) (EState *estate,
  70. ResultRelInfo *rinfo,
  71. TupleTableSlot *slot,
  72. TupleTableSlot *planSlot);
  73. typedef TupleTableSlot *(*ExecForeignDelete_function) (EState *estate,
  74. ResultRelInfo *rinfo,
  75. TupleTableSlot *slot,
  76. TupleTableSlot *planSlot);
  77. typedef void (*EndForeignModify_function) (EState *estate,
  78. ResultRelInfo *rinfo);
  79. typedef void (*BeginForeignInsert_function) (ModifyTableState *mtstate,
  80. ResultRelInfo *rinfo);
  81. typedef void (*EndForeignInsert_function) (EState *estate,
  82. ResultRelInfo *rinfo);
  83. typedef int (*IsForeignRelUpdatable_function) (Relation rel);
  84. typedef bool (*PlanDirectModify_function) (PlannerInfo *root,
  85. ModifyTable *plan,
  86. Index resultRelation,
  87. int subplan_index);
  88. typedef void (*BeginDirectModify_function) (ForeignScanState *node,
  89. int eflags);
  90. typedef TupleTableSlot *(*IterateDirectModify_function) (ForeignScanState *node);
  91. typedef void (*EndDirectModify_function) (ForeignScanState *node);
  92. typedef RowMarkType (*GetForeignRowMarkType_function) (RangeTblEntry *rte,
  93. LockClauseStrength strength);
  94. typedef void (*RefetchForeignRow_function) (EState *estate,
  95. ExecRowMark *erm,
  96. Datum rowid,
  97. TupleTableSlot *slot,
  98. bool *updated);
  99. typedef void (*ExplainForeignScan_function) (ForeignScanState *node,
  100. struct ExplainState *es);
  101. typedef void (*ExplainForeignModify_function) (ModifyTableState *mtstate,
  102. ResultRelInfo *rinfo,
  103. List *fdw_private,
  104. int subplan_index,
  105. struct ExplainState *es);
  106. typedef void (*ExplainDirectModify_function) (ForeignScanState *node,
  107. struct ExplainState *es);
  108. typedef int (*AcquireSampleRowsFunc) (Relation relation, int elevel,
  109. HeapTuple *rows, int targrows,
  110. double *totalrows,
  111. double *totaldeadrows);
  112. typedef bool (*AnalyzeForeignTable_function) (Relation relation,
  113. AcquireSampleRowsFunc *func,
  114. BlockNumber *totalpages);
  115. typedef List *(*ImportForeignSchema_function) (ImportForeignSchemaStmt *stmt,
  116. Oid serverOid);
  117. typedef Size (*EstimateDSMForeignScan_function) (ForeignScanState *node,
  118. ParallelContext *pcxt);
  119. typedef void (*InitializeDSMForeignScan_function) (ForeignScanState *node,
  120. ParallelContext *pcxt,
  121. void *coordinate);
  122. typedef void (*ReInitializeDSMForeignScan_function) (ForeignScanState *node,
  123. ParallelContext *pcxt,
  124. void *coordinate);
  125. typedef void (*InitializeWorkerForeignScan_function) (ForeignScanState *node,
  126. shm_toc *toc,
  127. void *coordinate);
  128. typedef void (*ShutdownForeignScan_function) (ForeignScanState *node);
  129. typedef bool (*IsForeignScanParallelSafe_function) (PlannerInfo *root,
  130. RelOptInfo *rel,
  131. RangeTblEntry *rte);
  132. typedef List *(*ReparameterizeForeignPathByChild_function) (PlannerInfo *root,
  133. List *fdw_private,
  134. RelOptInfo *child_rel);
  135. /*
  136. * FdwRoutine is the struct returned by a foreign-data wrapper's handler
  137. * function. It provides pointers to the callback functions needed by the
  138. * planner and executor.
  139. *
  140. * More function pointers are likely to be added in the future. Therefore
  141. * it's recommended that the handler initialize the struct with
  142. * makeNode(FdwRoutine) so that all fields are set to NULL. This will
  143. * ensure that no fields are accidentally left undefined.
  144. */
  145. typedef struct FdwRoutine
  146. {
  147. NodeTag type;
  148. /* Functions for scanning foreign tables */
  149. GetForeignRelSize_function GetForeignRelSize;
  150. GetForeignPaths_function GetForeignPaths;
  151. GetForeignPlan_function GetForeignPlan;
  152. BeginForeignScan_function BeginForeignScan;
  153. IterateForeignScan_function IterateForeignScan;
  154. ReScanForeignScan_function ReScanForeignScan;
  155. EndForeignScan_function EndForeignScan;
  156. /*
  157. * Remaining functions are optional. Set the pointer to NULL for any that
  158. * are not provided.
  159. */
  160. /* Functions for remote-join planning */
  161. GetForeignJoinPaths_function GetForeignJoinPaths;
  162. /* Functions for remote upper-relation (post scan/join) planning */
  163. GetForeignUpperPaths_function GetForeignUpperPaths;
  164. /* Functions for updating foreign tables */
  165. AddForeignUpdateTargets_function AddForeignUpdateTargets;
  166. PlanForeignModify_function PlanForeignModify;
  167. BeginForeignModify_function BeginForeignModify;
  168. ExecForeignInsert_function ExecForeignInsert;
  169. ExecForeignUpdate_function ExecForeignUpdate;
  170. ExecForeignDelete_function ExecForeignDelete;
  171. EndForeignModify_function EndForeignModify;
  172. BeginForeignInsert_function BeginForeignInsert;
  173. EndForeignInsert_function EndForeignInsert;
  174. IsForeignRelUpdatable_function IsForeignRelUpdatable;
  175. PlanDirectModify_function PlanDirectModify;
  176. BeginDirectModify_function BeginDirectModify;
  177. IterateDirectModify_function IterateDirectModify;
  178. EndDirectModify_function EndDirectModify;
  179. /* Functions for SELECT FOR UPDATE/SHARE row locking */
  180. GetForeignRowMarkType_function GetForeignRowMarkType;
  181. RefetchForeignRow_function RefetchForeignRow;
  182. RecheckForeignScan_function RecheckForeignScan;
  183. /* Support functions for EXPLAIN */
  184. ExplainForeignScan_function ExplainForeignScan;
  185. ExplainForeignModify_function ExplainForeignModify;
  186. ExplainDirectModify_function ExplainDirectModify;
  187. /* Support functions for ANALYZE */
  188. AnalyzeForeignTable_function AnalyzeForeignTable;
  189. /* Support functions for IMPORT FOREIGN SCHEMA */
  190. ImportForeignSchema_function ImportForeignSchema;
  191. /* Support functions for parallelism under Gather node */
  192. IsForeignScanParallelSafe_function IsForeignScanParallelSafe;
  193. EstimateDSMForeignScan_function EstimateDSMForeignScan;
  194. InitializeDSMForeignScan_function InitializeDSMForeignScan;
  195. ReInitializeDSMForeignScan_function ReInitializeDSMForeignScan;
  196. InitializeWorkerForeignScan_function InitializeWorkerForeignScan;
  197. ShutdownForeignScan_function ShutdownForeignScan;
  198. /* Support functions for path reparameterization. */
  199. ReparameterizeForeignPathByChild_function ReparameterizeForeignPathByChild;
  200. } FdwRoutine;
  201. /* Functions in foreign/foreign.c */
  202. extern FdwRoutine *GetFdwRoutine(Oid fdwhandler);
  203. extern Oid GetForeignServerIdByRelId(Oid relid);
  204. extern FdwRoutine *GetFdwRoutineByServerId(Oid serverid);
  205. extern FdwRoutine *GetFdwRoutineByRelId(Oid relid);
  206. extern FdwRoutine *GetFdwRoutineForRelation(Relation relation, bool makecopy);
  207. extern bool IsImportableForeignTable(const char *tablename,
  208. ImportForeignSchemaStmt *stmt);
  209. extern Path *GetExistingLocalJoinPath(RelOptInfo *joinrel);
  210. #endif /* FDWAPI_H */
上海开阖软件有限公司 沪ICP备12045867号-1