Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes16kdownloads
fdwapi.h295 linesDownload Raw Back to foreign
1/*-------------------------------------------------------------------------2 *3 * fdwapi.h4 *	  API for foreign-data wrappers5 *6 * Copyright (c) 2010-2023, PostgreSQL Global Development Group7 *8 * src/include/foreign/fdwapi.h9 *10 *-------------------------------------------------------------------------11 */12#ifndef FDWAPI_H13#define FDWAPI_H14 15#include "access/parallel.h"16#include "nodes/execnodes.h"17#include "nodes/pathnodes.h"18 19/* To avoid including explain.h here, reference ExplainState thus: */20struct ExplainState;21 22 23/*24 * Callback function signatures --- see fdwhandler.sgml for more info.25 */26 27typedef void (*GetForeignRelSize_function) (PlannerInfo *root,28											RelOptInfo *baserel,29											Oid foreigntableid);30 31typedef void (*GetForeignPaths_function) (PlannerInfo *root,32										  RelOptInfo *baserel,33										  Oid foreigntableid);34 35typedef ForeignScan *(*GetForeignPlan_function) (PlannerInfo *root,36												 RelOptInfo *baserel,37												 Oid foreigntableid,38												 ForeignPath *best_path,39												 List *tlist,40												 List *scan_clauses,41												 Plan *outer_plan);42 43typedef void (*BeginForeignScan_function) (ForeignScanState *node,44										   int eflags);45 46typedef TupleTableSlot *(*IterateForeignScan_function) (ForeignScanState *node);47 48typedef bool (*RecheckForeignScan_function) (ForeignScanState *node,49											 TupleTableSlot *slot);50 51typedef void (*ReScanForeignScan_function) (ForeignScanState *node);52 53typedef void (*EndForeignScan_function) (ForeignScanState *node);54 55typedef void (*GetForeignJoinPaths_function) (PlannerInfo *root,56											  RelOptInfo *joinrel,57											  RelOptInfo *outerrel,58											  RelOptInfo *innerrel,59											  JoinType jointype,60											  JoinPathExtraData *extra);61 62typedef void (*GetForeignUpperPaths_function) (PlannerInfo *root,63											   UpperRelationKind stage,64											   RelOptInfo *input_rel,65											   RelOptInfo *output_rel,66											   void *extra);67 68typedef void (*AddForeignUpdateTargets_function) (PlannerInfo *root,69												  Index rtindex,70												  RangeTblEntry *target_rte,71												  Relation target_relation);72 73typedef List *(*PlanForeignModify_function) (PlannerInfo *root,74											 ModifyTable *plan,75											 Index resultRelation,76											 int subplan_index);77 78typedef void (*BeginForeignModify_function) (ModifyTableState *mtstate,79											 ResultRelInfo *rinfo,80											 List *fdw_private,81											 int subplan_index,82											 int eflags);83 84typedef TupleTableSlot *(*ExecForeignInsert_function) (EState *estate,85													   ResultRelInfo *rinfo,86													   TupleTableSlot *slot,87													   TupleTableSlot *planSlot);88 89typedef TupleTableSlot **(*ExecForeignBatchInsert_function) (EState *estate,90															 ResultRelInfo *rinfo,91															 TupleTableSlot **slots,92															 TupleTableSlot **planSlots,93															 int *numSlots);94 95typedef int (*GetForeignModifyBatchSize_function) (ResultRelInfo *rinfo);96 97typedef TupleTableSlot *(*ExecForeignUpdate_function) (EState *estate,98													   ResultRelInfo *rinfo,99													   TupleTableSlot *slot,100													   TupleTableSlot *planSlot);101 102typedef TupleTableSlot *(*ExecForeignDelete_function) (EState *estate,103													   ResultRelInfo *rinfo,104													   TupleTableSlot *slot,105													   TupleTableSlot *planSlot);106 107typedef void (*EndForeignModify_function) (EState *estate,108										   ResultRelInfo *rinfo);109 110typedef void (*BeginForeignInsert_function) (ModifyTableState *mtstate,111											 ResultRelInfo *rinfo);112 113typedef void (*EndForeignInsert_function) (EState *estate,114										   ResultRelInfo *rinfo);115 116typedef int (*IsForeignRelUpdatable_function) (Relation rel);117 118typedef bool (*PlanDirectModify_function) (PlannerInfo *root,119										   ModifyTable *plan,120										   Index resultRelation,121										   int subplan_index);122 123typedef void (*BeginDirectModify_function) (ForeignScanState *node,124											int eflags);125 126typedef TupleTableSlot *(*IterateDirectModify_function) (ForeignScanState *node);127 128typedef void (*EndDirectModify_function) (ForeignScanState *node);129 130typedef RowMarkType (*GetForeignRowMarkType_function) (RangeTblEntry *rte,131													   LockClauseStrength strength);132 133typedef void (*RefetchForeignRow_function) (EState *estate,134											ExecRowMark *erm,135											Datum rowid,136											TupleTableSlot *slot,137											bool *updated);138 139typedef void (*ExplainForeignScan_function) (ForeignScanState *node,140											 struct ExplainState *es);141 142typedef void (*ExplainForeignModify_function) (ModifyTableState *mtstate,143											   ResultRelInfo *rinfo,144											   List *fdw_private,145											   int subplan_index,146											   struct ExplainState *es);147 148typedef void (*ExplainDirectModify_function) (ForeignScanState *node,149											  struct ExplainState *es);150 151typedef int (*AcquireSampleRowsFunc) (Relation relation, int elevel,152									  HeapTuple *rows, int targrows,153									  double *totalrows,154									  double *totaldeadrows);155 156typedef bool (*AnalyzeForeignTable_function) (Relation relation,157											  AcquireSampleRowsFunc *func,158											  BlockNumber *totalpages);159 160typedef List *(*ImportForeignSchema_function) (ImportForeignSchemaStmt *stmt,161											   Oid serverOid);162 163typedef void (*ExecForeignTruncate_function) (List *rels,164											  DropBehavior behavior,165											  bool restart_seqs);166 167typedef Size (*EstimateDSMForeignScan_function) (ForeignScanState *node,168												 ParallelContext *pcxt);169typedef void (*InitializeDSMForeignScan_function) (ForeignScanState *node,170												   ParallelContext *pcxt,171												   void *coordinate);172typedef void (*ReInitializeDSMForeignScan_function) (ForeignScanState *node,173													 ParallelContext *pcxt,174													 void *coordinate);175typedef void (*InitializeWorkerForeignScan_function) (ForeignScanState *node,176													  shm_toc *toc,177													  void *coordinate);178typedef void (*ShutdownForeignScan_function) (ForeignScanState *node);179typedef bool (*IsForeignScanParallelSafe_function) (PlannerInfo *root,180													RelOptInfo *rel,181													RangeTblEntry *rte);182typedef List *(*ReparameterizeForeignPathByChild_function) (PlannerInfo *root,183															List *fdw_private,184															RelOptInfo *child_rel);185 186typedef bool (*IsForeignPathAsyncCapable_function) (ForeignPath *path);187 188typedef void (*ForeignAsyncRequest_function) (AsyncRequest *areq);189 190typedef void (*ForeignAsyncConfigureWait_function) (AsyncRequest *areq);191 192typedef void (*ForeignAsyncNotify_function) (AsyncRequest *areq);193 194/*195 * FdwRoutine is the struct returned by a foreign-data wrapper's handler196 * function.  It provides pointers to the callback functions needed by the197 * planner and executor.198 *199 * More function pointers are likely to be added in the future.  Therefore200 * it's recommended that the handler initialize the struct with201 * makeNode(FdwRoutine) so that all fields are set to NULL.  This will202 * ensure that no fields are accidentally left undefined.203 */204typedef struct FdwRoutine205{206	NodeTag		type;207 208	/* Functions for scanning foreign tables */209	GetForeignRelSize_function GetForeignRelSize;210	GetForeignPaths_function GetForeignPaths;211	GetForeignPlan_function GetForeignPlan;212	BeginForeignScan_function BeginForeignScan;213	IterateForeignScan_function IterateForeignScan;214	ReScanForeignScan_function ReScanForeignScan;215	EndForeignScan_function EndForeignScan;216 217	/*218	 * Remaining functions are optional.  Set the pointer to NULL for any that219	 * are not provided.220	 */221 222	/* Functions for remote-join planning */223	GetForeignJoinPaths_function GetForeignJoinPaths;224 225	/* Functions for remote upper-relation (post scan/join) planning */226	GetForeignUpperPaths_function GetForeignUpperPaths;227 228	/* Functions for updating foreign tables */229	AddForeignUpdateTargets_function AddForeignUpdateTargets;230	PlanForeignModify_function PlanForeignModify;231	BeginForeignModify_function BeginForeignModify;232	ExecForeignInsert_function ExecForeignInsert;233	ExecForeignBatchInsert_function ExecForeignBatchInsert;234	GetForeignModifyBatchSize_function GetForeignModifyBatchSize;235	ExecForeignUpdate_function ExecForeignUpdate;236	ExecForeignDelete_function ExecForeignDelete;237	EndForeignModify_function EndForeignModify;238	BeginForeignInsert_function BeginForeignInsert;239	EndForeignInsert_function EndForeignInsert;240	IsForeignRelUpdatable_function IsForeignRelUpdatable;241	PlanDirectModify_function PlanDirectModify;242	BeginDirectModify_function BeginDirectModify;243	IterateDirectModify_function IterateDirectModify;244	EndDirectModify_function EndDirectModify;245 246	/* Functions for SELECT FOR UPDATE/SHARE row locking */247	GetForeignRowMarkType_function GetForeignRowMarkType;248	RefetchForeignRow_function RefetchForeignRow;249	RecheckForeignScan_function RecheckForeignScan;250 251	/* Support functions for EXPLAIN */252	ExplainForeignScan_function ExplainForeignScan;253	ExplainForeignModify_function ExplainForeignModify;254	ExplainDirectModify_function ExplainDirectModify;255 256	/* Support functions for ANALYZE */257	AnalyzeForeignTable_function AnalyzeForeignTable;258 259	/* Support functions for IMPORT FOREIGN SCHEMA */260	ImportForeignSchema_function ImportForeignSchema;261 262	/* Support functions for TRUNCATE */263	ExecForeignTruncate_function ExecForeignTruncate;264 265	/* Support functions for parallelism under Gather node */266	IsForeignScanParallelSafe_function IsForeignScanParallelSafe;267	EstimateDSMForeignScan_function EstimateDSMForeignScan;268	InitializeDSMForeignScan_function InitializeDSMForeignScan;269	ReInitializeDSMForeignScan_function ReInitializeDSMForeignScan;270	InitializeWorkerForeignScan_function InitializeWorkerForeignScan;271	ShutdownForeignScan_function ShutdownForeignScan;272 273	/* Support functions for path reparameterization. */274	ReparameterizeForeignPathByChild_function ReparameterizeForeignPathByChild;275 276	/* Support functions for asynchronous execution */277	IsForeignPathAsyncCapable_function IsForeignPathAsyncCapable;278	ForeignAsyncRequest_function ForeignAsyncRequest;279	ForeignAsyncConfigureWait_function ForeignAsyncConfigureWait;280	ForeignAsyncNotify_function ForeignAsyncNotify;281} FdwRoutine;282 283 284/* Functions in foreign/foreign.c */285extern FdwRoutine *GetFdwRoutine(Oid fdwhandler);286extern Oid	GetForeignServerIdByRelId(Oid relid);287extern FdwRoutine *GetFdwRoutineByServerId(Oid serverid);288extern FdwRoutine *GetFdwRoutineByRelId(Oid relid);289extern FdwRoutine *GetFdwRoutineForRelation(Relation relation, bool makecopy);290extern bool IsImportableForeignTable(const char *tablename,291									 ImportForeignSchemaStmt *stmt);292extern Path *GetExistingLocalJoinPath(RelOptInfo *joinrel);293 294#endif							/* FDWAPI_H */295 
codekingpro/portable-devtools · Team Ai