PostgreSQL Source Code  git master
nodeForeignscan.c File Reference
#include "postgres.h"
#include "executor/executor.h"
#include "executor/nodeForeignscan.h"
#include "foreign/fdwapi.h"
#include "utils/rel.h"
Include dependency graph for nodeForeignscan.c:

Go to the source code of this file.

Functions

static TupleTableSlotForeignNext (ForeignScanState *node)
 
static bool ForeignRecheck (ForeignScanState *node, TupleTableSlot *slot)
 
static TupleTableSlotExecForeignScan (PlanState *pstate)
 
ForeignScanStateExecInitForeignScan (ForeignScan *node, EState *estate, int eflags)
 
void ExecEndForeignScan (ForeignScanState *node)
 
void ExecReScanForeignScan (ForeignScanState *node)
 
void ExecForeignScanEstimate (ForeignScanState *node, ParallelContext *pcxt)
 
void ExecForeignScanInitializeDSM (ForeignScanState *node, ParallelContext *pcxt)
 
void ExecForeignScanReInitializeDSM (ForeignScanState *node, ParallelContext *pcxt)
 
void ExecForeignScanInitializeWorker (ForeignScanState *node, ParallelWorkerContext *pwcxt)
 
void ExecShutdownForeignScan (ForeignScanState *node)
 
void ExecAsyncForeignScanRequest (AsyncRequest *areq)
 
void ExecAsyncForeignScanConfigureWait (AsyncRequest *areq)
 
void ExecAsyncForeignScanNotify (AsyncRequest *areq)
 

Function Documentation

◆ ExecAsyncForeignScanConfigureWait()

void ExecAsyncForeignScanConfigureWait ( AsyncRequest areq)

Definition at line 472 of file nodeForeignscan.c.

473 {
474  ForeignScanState *node = (ForeignScanState *) areq->requestee;
475  FdwRoutine *fdwroutine = node->fdwroutine;
476 
477  Assert(fdwroutine->ForeignAsyncConfigureWait != NULL);
478  fdwroutine->ForeignAsyncConfigureWait(areq);
479 }
#define Assert(condition)
Definition: c.h:849
struct PlanState * requestee
Definition: execnodes.h:612
struct FdwRoutine * fdwroutine
Definition: execnodes.h:2081

References Assert, ForeignScanState::fdwroutine, and AsyncRequest::requestee.

Referenced by ExecAsyncConfigureWait().

◆ ExecAsyncForeignScanNotify()

void ExecAsyncForeignScanNotify ( AsyncRequest areq)

Definition at line 488 of file nodeForeignscan.c.

489 {
490  ForeignScanState *node = (ForeignScanState *) areq->requestee;
491  FdwRoutine *fdwroutine = node->fdwroutine;
492 
493  Assert(fdwroutine->ForeignAsyncNotify != NULL);
494  fdwroutine->ForeignAsyncNotify(areq);
495 }

References Assert, ForeignScanState::fdwroutine, and AsyncRequest::requestee.

Referenced by ExecAsyncNotify().

◆ ExecAsyncForeignScanRequest()

void ExecAsyncForeignScanRequest ( AsyncRequest areq)

Definition at line 456 of file nodeForeignscan.c.

457 {
458  ForeignScanState *node = (ForeignScanState *) areq->requestee;
459  FdwRoutine *fdwroutine = node->fdwroutine;
460 
461  Assert(fdwroutine->ForeignAsyncRequest != NULL);
462  fdwroutine->ForeignAsyncRequest(areq);
463 }

References Assert, ForeignScanState::fdwroutine, and AsyncRequest::requestee.

Referenced by ExecAsyncRequest().

◆ ExecEndForeignScan()

void ExecEndForeignScan ( ForeignScanState node)

Definition at line 297 of file nodeForeignscan.c.

298 {
299  ForeignScan *plan = (ForeignScan *) node->ss.ps.plan;
300  EState *estate = node->ss.ps.state;
301 
302  /* Let the FDW shut down */
303  if (plan->operation != CMD_SELECT)
304  {
305  if (estate->es_epq_active == NULL)
306  node->fdwroutine->EndDirectModify(node);
307  }
308  else
309  node->fdwroutine->EndForeignScan(node);
310 
311  /* Shut down any outer plan. */
312  if (outerPlanState(node))
314 }
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:562
#define outerPlanState(node)
Definition: execnodes.h:1224
if(TABLE==NULL||TABLE_index==NULL)
Definition: isn.c:77
@ CMD_SELECT
Definition: nodes.h:265
#define plan(x)
Definition: pg_regress.c:162
EndForeignScan_function EndForeignScan
Definition: fdwapi.h:215
EndDirectModify_function EndDirectModify
Definition: fdwapi.h:244
ScanState ss
Definition: execnodes.h:2076
Plan * plan
Definition: execnodes.h:1128
EState * state
Definition: execnodes.h:1130
PlanState ps
Definition: execnodes.h:1575

References CMD_SELECT, FdwRoutine::EndDirectModify, FdwRoutine::EndForeignScan, ExecEndNode(), ForeignScanState::fdwroutine, if(), outerPlanState, PlanState::plan, plan, ScanState::ps, ForeignScanState::ss, and PlanState::state.

Referenced by ExecEndNode().

◆ ExecForeignScan()

static TupleTableSlot* ExecForeignScan ( PlanState pstate)
static

Definition at line 118 of file nodeForeignscan.c.

119 {
120  ForeignScanState *node = castNode(ForeignScanState, pstate);
121  ForeignScan *plan = (ForeignScan *) node->ss.ps.plan;
122  EState *estate = node->ss.ps.state;
123 
124  /*
125  * Ignore direct modifications when EvalPlanQual is active --- they are
126  * irrelevant for EvalPlanQual rechecking
127  */
128  if (estate->es_epq_active != NULL && plan->operation != CMD_SELECT)
129  return NULL;
130 
131  return ExecScan(&node->ss,
134 }
TupleTableSlot * ExecScan(ScanState *node, ExecScanAccessMtd accessMtd, ExecScanRecheckMtd recheckMtd)
Definition: execScan.c:156
TupleTableSlot *(* ExecScanAccessMtd)(ScanState *node)
Definition: executor.h:484
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
Definition: executor.h:485
static bool ForeignRecheck(ForeignScanState *node, TupleTableSlot *slot)
static TupleTableSlot * ForeignNext(ForeignScanState *node)
#define castNode(_type_, nodeptr)
Definition: nodes.h:176

References castNode, CMD_SELECT, ExecScan(), ForeignNext(), ForeignRecheck(), if(), PlanState::plan, plan, ScanState::ps, ForeignScanState::ss, and PlanState::state.

Referenced by ExecInitForeignScan().

◆ ExecForeignScanEstimate()

void ExecForeignScanEstimate ( ForeignScanState node,
ParallelContext pcxt 
)

Definition at line 356 of file nodeForeignscan.c.

357 {
358  FdwRoutine *fdwroutine = node->fdwroutine;
359 
360  if (fdwroutine->EstimateDSMForeignScan)
361  {
362  node->pscan_len = fdwroutine->EstimateDSMForeignScan(node, pcxt);
364  shm_toc_estimate_keys(&pcxt->estimator, 1);
365  }
366 }
#define shm_toc_estimate_chunk(e, sz)
Definition: shm_toc.h:51
#define shm_toc_estimate_keys(e, cnt)
Definition: shm_toc.h:53
EstimateDSMForeignScan_function EstimateDSMForeignScan
Definition: fdwapi.h:267
shm_toc_estimator estimator
Definition: parallel.h:41

References FdwRoutine::EstimateDSMForeignScan, ParallelContext::estimator, ForeignScanState::fdwroutine, ForeignScanState::pscan_len, shm_toc_estimate_chunk, and shm_toc_estimate_keys.

Referenced by ExecParallelEstimate().

◆ ExecForeignScanInitializeDSM()

void ExecForeignScanInitializeDSM ( ForeignScanState node,
ParallelContext pcxt 
)

Definition at line 375 of file nodeForeignscan.c.

376 {
377  FdwRoutine *fdwroutine = node->fdwroutine;
378 
379  if (fdwroutine->InitializeDSMForeignScan)
380  {
381  int plan_node_id = node->ss.ps.plan->plan_node_id;
382  void *coordinate;
383 
384  coordinate = shm_toc_allocate(pcxt->toc, node->pscan_len);
385  fdwroutine->InitializeDSMForeignScan(node, pcxt, coordinate);
386  shm_toc_insert(pcxt->toc, plan_node_id, coordinate);
387  }
388 }
void shm_toc_insert(shm_toc *toc, uint64 key, void *address)
Definition: shm_toc.c:171
void * shm_toc_allocate(shm_toc *toc, Size nbytes)
Definition: shm_toc.c:88
InitializeDSMForeignScan_function InitializeDSMForeignScan
Definition: fdwapi.h:268
shm_toc * toc
Definition: parallel.h:44
int plan_node_id
Definition: plannodes.h:152

References ForeignScanState::fdwroutine, FdwRoutine::InitializeDSMForeignScan, PlanState::plan, Plan::plan_node_id, ScanState::ps, ForeignScanState::pscan_len, shm_toc_allocate(), shm_toc_insert(), ForeignScanState::ss, and ParallelContext::toc.

Referenced by ExecParallelInitializeDSM().

◆ ExecForeignScanInitializeWorker()

void ExecForeignScanInitializeWorker ( ForeignScanState node,
ParallelWorkerContext pwcxt 
)

Definition at line 418 of file nodeForeignscan.c.

420 {
421  FdwRoutine *fdwroutine = node->fdwroutine;
422 
423  if (fdwroutine->InitializeWorkerForeignScan)
424  {
425  int plan_node_id = node->ss.ps.plan->plan_node_id;
426  void *coordinate;
427 
428  coordinate = shm_toc_lookup(pwcxt->toc, plan_node_id, false);
429  fdwroutine->InitializeWorkerForeignScan(node, pwcxt->toc, coordinate);
430  }
431 }
void * shm_toc_lookup(shm_toc *toc, uint64 key, bool noError)
Definition: shm_toc.c:232
InitializeWorkerForeignScan_function InitializeWorkerForeignScan
Definition: fdwapi.h:270

References ForeignScanState::fdwroutine, FdwRoutine::InitializeWorkerForeignScan, PlanState::plan, Plan::plan_node_id, ScanState::ps, shm_toc_lookup(), ForeignScanState::ss, and ParallelWorkerContext::toc.

Referenced by ExecParallelInitializeWorker().

◆ ExecForeignScanReInitializeDSM()

void ExecForeignScanReInitializeDSM ( ForeignScanState node,
ParallelContext pcxt 
)

Definition at line 397 of file nodeForeignscan.c.

398 {
399  FdwRoutine *fdwroutine = node->fdwroutine;
400 
401  if (fdwroutine->ReInitializeDSMForeignScan)
402  {
403  int plan_node_id = node->ss.ps.plan->plan_node_id;
404  void *coordinate;
405 
406  coordinate = shm_toc_lookup(pcxt->toc, plan_node_id, false);
407  fdwroutine->ReInitializeDSMForeignScan(node, pcxt, coordinate);
408  }
409 }
ReInitializeDSMForeignScan_function ReInitializeDSMForeignScan
Definition: fdwapi.h:269

References ForeignScanState::fdwroutine, PlanState::plan, Plan::plan_node_id, ScanState::ps, FdwRoutine::ReInitializeDSMForeignScan, shm_toc_lookup(), ForeignScanState::ss, and ParallelContext::toc.

Referenced by ExecParallelReInitializeDSM().

◆ ExecInitForeignScan()

ForeignScanState* ExecInitForeignScan ( ForeignScan node,
EState estate,
int  eflags 
)

Definition at line 142 of file nodeForeignscan.c.

143 {
144  ForeignScanState *scanstate;
145  Relation currentRelation = NULL;
146  Index scanrelid = node->scan.scanrelid;
147  int tlistvarno;
148  FdwRoutine *fdwroutine;
149 
150  /* check for unsupported flags */
151  Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
152 
153  /*
154  * create state structure
155  */
156  scanstate = makeNode(ForeignScanState);
157  scanstate->ss.ps.plan = (Plan *) node;
158  scanstate->ss.ps.state = estate;
159  scanstate->ss.ps.ExecProcNode = ExecForeignScan;
160 
161  /*
162  * Miscellaneous initialization
163  *
164  * create expression context for node
165  */
166  ExecAssignExprContext(estate, &scanstate->ss.ps);
167 
168  /*
169  * open the scan relation, if any; also acquire function pointers from the
170  * FDW's handler
171  */
172  if (scanrelid > 0)
173  {
174  currentRelation = ExecOpenScanRelation(estate, scanrelid, eflags);
175  scanstate->ss.ss_currentRelation = currentRelation;
176  fdwroutine = GetFdwRoutineForRelation(currentRelation, true);
177  }
178  else
179  {
180  /* We can't use the relcache, so get fdwroutine the hard way */
181  fdwroutine = GetFdwRoutineByServerId(node->fs_server);
182  }
183 
184  /*
185  * Determine the scan tuple type. If the FDW provided a targetlist
186  * describing the scan tuples, use that; else use base relation's rowtype.
187  */
188  if (node->fdw_scan_tlist != NIL || currentRelation == NULL)
189  {
190  TupleDesc scan_tupdesc;
191 
192  scan_tupdesc = ExecTypeFromTL(node->fdw_scan_tlist);
193  ExecInitScanTupleSlot(estate, &scanstate->ss, scan_tupdesc,
194  &TTSOpsHeapTuple);
195  /* Node's targetlist will contain Vars with varno = INDEX_VAR */
196  tlistvarno = INDEX_VAR;
197  }
198  else
199  {
200  TupleDesc scan_tupdesc;
201 
202  /* don't trust FDWs to return tuples fulfilling NOT NULL constraints */
203  scan_tupdesc = CreateTupleDescCopy(RelationGetDescr(currentRelation));
204  ExecInitScanTupleSlot(estate, &scanstate->ss, scan_tupdesc,
205  &TTSOpsHeapTuple);
206  /* Node's targetlist will contain Vars with varno = scanrelid */
207  tlistvarno = scanrelid;
208  }
209 
210  /* Don't know what an FDW might return */
211  scanstate->ss.ps.scanopsfixed = false;
212  scanstate->ss.ps.scanopsset = true;
213 
214  /*
215  * Initialize result slot, type and projection.
216  */
217  ExecInitResultTypeTL(&scanstate->ss.ps);
218  ExecAssignScanProjectionInfoWithVarno(&scanstate->ss, tlistvarno);
219 
220  /*
221  * initialize child expressions
222  */
223  scanstate->ss.ps.qual =
224  ExecInitQual(node->scan.plan.qual, (PlanState *) scanstate);
225  scanstate->fdw_recheck_quals =
226  ExecInitQual(node->fdw_recheck_quals, (PlanState *) scanstate);
227 
228  /*
229  * Determine whether to scan the foreign relation asynchronously or not;
230  * this has to be kept in sync with the code in ExecInitAppend().
231  */
232  scanstate->ss.ps.async_capable = (((Plan *) node)->async_capable &&
233  estate->es_epq_active == NULL);
234 
235  /*
236  * Initialize FDW-related state.
237  */
238  scanstate->fdwroutine = fdwroutine;
239  scanstate->fdw_state = NULL;
240 
241  /*
242  * For the FDW's convenience, look up the modification target relation's
243  * ResultRelInfo. The ModifyTable node should have initialized it for us,
244  * see ExecInitModifyTable.
245  *
246  * Don't try to look up the ResultRelInfo when EvalPlanQual is active,
247  * though. Direct modifications cannot be re-evaluated as part of
248  * EvalPlanQual. The lookup wouldn't work anyway because during
249  * EvalPlanQual processing, EvalPlanQual only initializes the subtree
250  * under the ModifyTable, and doesn't run ExecInitModifyTable.
251  */
252  if (node->resultRelation > 0 && estate->es_epq_active == NULL)
253  {
254  if (estate->es_result_relations == NULL ||
255  estate->es_result_relations[node->resultRelation - 1] == NULL)
256  {
257  elog(ERROR, "result relation not initialized");
258  }
259  scanstate->resultRelInfo = estate->es_result_relations[node->resultRelation - 1];
260  }
261 
262  /* Initialize any outer plan. */
263  if (outerPlan(node))
264  outerPlanState(scanstate) =
265  ExecInitNode(outerPlan(node), estate, eflags);
266 
267  /*
268  * Tell the FDW to initialize the scan.
269  */
270  if (node->operation != CMD_SELECT)
271  {
272  /*
273  * Direct modifications cannot be re-evaluated by EvalPlanQual, so
274  * don't bother preparing the FDW.
275  *
276  * In case of an inherited UPDATE/DELETE with foreign targets there
277  * can be direct-modify ForeignScan nodes in the EvalPlanQual subtree,
278  * so we need to ignore such ForeignScan nodes during EvalPlanQual
279  * processing. See also ExecForeignScan/ExecReScanForeignScan.
280  */
281  if (estate->es_epq_active == NULL)
282  fdwroutine->BeginDirectModify(scanstate, eflags);
283  }
284  else
285  fdwroutine->BeginForeignScan(scanstate, eflags);
286 
287  return scanstate;
288 }
unsigned int Index
Definition: c.h:605
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:225
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:224
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:142
void ExecAssignScanProjectionInfoWithVarno(ScanState *node, int varno)
Definition: execScan.c:283
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1898
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1842
const TupleTableSlotOps TTSOpsHeapTuple
Definition: execTuples.c:85
TupleDesc ExecTypeFromTL(List *targetList)
Definition: execTuples.c:2025
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:485
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
Definition: execUtils.c:699
#define EXEC_FLAG_BACKWARD
Definition: executor.h:68
#define EXEC_FLAG_MARK
Definition: executor.h:69
FdwRoutine * GetFdwRoutineForRelation(Relation relation, bool makecopy)
Definition: foreign.c:442
FdwRoutine * GetFdwRoutineByServerId(Oid serverid)
Definition: foreign.c:377
static TupleTableSlot * ExecForeignScan(PlanState *pstate)
#define makeNode(_type_)
Definition: nodes.h:155
#define NIL
Definition: pg_list.h:68
#define outerPlan(node)
Definition: plannodes.h:183
#define INDEX_VAR
Definition: primnodes.h:238
#define RelationGetDescr(relation)
Definition: rel.h:531
ResultRelInfo ** es_result_relations
Definition: execnodes.h:650
struct EPQState * es_epq_active
Definition: execnodes.h:707
BeginDirectModify_function BeginDirectModify
Definition: fdwapi.h:242
BeginForeignScan_function BeginForeignScan
Definition: fdwapi.h:212
ExprState * fdw_recheck_quals
Definition: execnodes.h:2077
ResultRelInfo * resultRelInfo
Definition: execnodes.h:2079
CmdType operation
Definition: plannodes.h:711
Oid fs_server
Definition: plannodes.h:715
Index resultRelation
Definition: plannodes.h:712
List * fdw_recheck_quals
Definition: plannodes.h:719
List * fdw_scan_tlist
Definition: plannodes.h:718
ExprState * qual
Definition: execnodes.h:1149
bool scanopsset
Definition: execnodes.h:1210
bool scanopsfixed
Definition: execnodes.h:1206
bool async_capable
Definition: execnodes.h:1170
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:1134
Relation ss_currentRelation
Definition: execnodes.h:1576
Index scanrelid
Definition: plannodes.h:390
TupleDesc CreateTupleDescCopy(TupleDesc tupdesc)
Definition: tupdesc.c:133

References Assert, PlanState::async_capable, FdwRoutine::BeginDirectModify, FdwRoutine::BeginForeignScan, CMD_SELECT, CreateTupleDescCopy(), elog, ERROR, EState::es_epq_active, EState::es_result_relations, EXEC_FLAG_BACKWARD, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecAssignScanProjectionInfoWithVarno(), ExecForeignScan(), ExecInitNode(), ExecInitQual(), ExecInitResultTypeTL(), ExecInitScanTupleSlot(), ExecOpenScanRelation(), PlanState::ExecProcNode, ExecTypeFromTL(), ForeignScanState::fdw_recheck_quals, ForeignScan::fdw_recheck_quals, ForeignScan::fdw_scan_tlist, ForeignScanState::fdw_state, ForeignScanState::fdwroutine, ForeignScan::fs_server, GetFdwRoutineByServerId(), GetFdwRoutineForRelation(), INDEX_VAR, makeNode, NIL, ForeignScan::operation, outerPlan, outerPlanState, PlanState::plan, ScanState::ps, PlanState::qual, RelationGetDescr, ForeignScan::resultRelation, ForeignScanState::resultRelInfo, ForeignScan::scan, PlanState::scanopsfixed, PlanState::scanopsset, Scan::scanrelid, ForeignScanState::ss, ScanState::ss_currentRelation, PlanState::state, and TTSOpsHeapTuple.

Referenced by ExecInitNode().

◆ ExecReScanForeignScan()

void ExecReScanForeignScan ( ForeignScanState node)

Definition at line 323 of file nodeForeignscan.c.

324 {
325  ForeignScan *plan = (ForeignScan *) node->ss.ps.plan;
326  EState *estate = node->ss.ps.state;
328 
329  /*
330  * Ignore direct modifications when EvalPlanQual is active --- they are
331  * irrelevant for EvalPlanQual rechecking
332  */
333  if (estate->es_epq_active != NULL && plan->operation != CMD_SELECT)
334  return;
335 
336  node->fdwroutine->ReScanForeignScan(node);
337 
338  /*
339  * If chgParam of subnode is not null then plan will be re-scanned by
340  * first ExecProcNode. outerPlan may also be NULL, in which case there is
341  * nothing to rescan at all.
342  */
343  if (outerPlan != NULL && outerPlan->chgParam == NULL)
345 
346  ExecScanReScan(&node->ss);
347 }
void ExecReScan(PlanState *node)
Definition: execAmi.c:76
void ExecScanReScan(ScanState *node)
Definition: execScan.c:297
ReScanForeignScan_function ReScanForeignScan
Definition: fdwapi.h:214

References CMD_SELECT, ExecReScan(), ExecScanReScan(), ForeignScanState::fdwroutine, outerPlan, outerPlanState, PlanState::plan, plan, ScanState::ps, FdwRoutine::ReScanForeignScan, ForeignScanState::ss, and PlanState::state.

Referenced by ExecReScan().

◆ ExecShutdownForeignScan()

void ExecShutdownForeignScan ( ForeignScanState node)

Definition at line 441 of file nodeForeignscan.c.

442 {
443  FdwRoutine *fdwroutine = node->fdwroutine;
444 
445  if (fdwroutine->ShutdownForeignScan)
446  fdwroutine->ShutdownForeignScan(node);
447 }
ShutdownForeignScan_function ShutdownForeignScan
Definition: fdwapi.h:271

References ForeignScanState::fdwroutine, and FdwRoutine::ShutdownForeignScan.

Referenced by ExecShutdownNode_walker().

◆ ForeignNext()

static TupleTableSlot * ForeignNext ( ForeignScanState node)
static

Definition at line 41 of file nodeForeignscan.c.

42 {
43  TupleTableSlot *slot;
44  ForeignScan *plan = (ForeignScan *) node->ss.ps.plan;
45  ExprContext *econtext = node->ss.ps.ps_ExprContext;
46  MemoryContext oldcontext;
47 
48  /* Call the Iterate function in short-lived context */
49  oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
50  if (plan->operation != CMD_SELECT)
51  {
52  /*
53  * direct modifications cannot be re-evaluated, so shouldn't get here
54  * during EvalPlanQual processing
55  */
56  Assert(node->ss.ps.state->es_epq_active == NULL);
57 
58  slot = node->fdwroutine->IterateDirectModify(node);
59  }
60  else
61  slot = node->fdwroutine->IterateForeignScan(node);
62  MemoryContextSwitchTo(oldcontext);
63 
64  /*
65  * Insert valid value into tableoid, the only actually-useful system
66  * column.
67  */
68  if (plan->fsSystemCol && !TupIsNull(slot))
70 
71  return slot;
72 }
MemoryContextSwitchTo(old_ctx)
#define RelationGetRelid(relation)
Definition: rel.h:505
IterateDirectModify_function IterateDirectModify
Definition: fdwapi.h:243
IterateForeignScan_function IterateForeignScan
Definition: fdwapi.h:213
ExprContext * ps_ExprContext
Definition: execnodes.h:1167
Oid tts_tableOid
Definition: tuptable.h:130
#define TupIsNull(slot)
Definition: tuptable.h:306

References Assert, CMD_SELECT, EState::es_epq_active, ForeignScanState::fdwroutine, FdwRoutine::IterateDirectModify, FdwRoutine::IterateForeignScan, MemoryContextSwitchTo(), PlanState::plan, plan, ScanState::ps, PlanState::ps_ExprContext, RelationGetRelid, ForeignScanState::ss, ScanState::ss_currentRelation, PlanState::state, TupleTableSlot::tts_tableOid, and TupIsNull.

Referenced by ExecForeignScan().

◆ ForeignRecheck()

static bool ForeignRecheck ( ForeignScanState node,
TupleTableSlot slot 
)
static

Definition at line 78 of file nodeForeignscan.c.

79 {
80  FdwRoutine *fdwroutine = node->fdwroutine;
81  ExprContext *econtext;
82 
83  /*
84  * extract necessary information from foreign scan node
85  */
86  econtext = node->ss.ps.ps_ExprContext;
87 
88  /* Does the tuple meet the remote qual condition? */
89  econtext->ecxt_scantuple = slot;
90 
91  ResetExprContext(econtext);
92 
93  /*
94  * If an outer join is pushed down, RecheckForeignScan may need to store a
95  * different tuple in the slot, because a different set of columns may go
96  * to NULL upon recheck. Otherwise, it shouldn't need to change the slot
97  * contents, just return true or false to indicate whether the quals still
98  * pass. For simple cases, setting fdw_recheck_quals may be easier than
99  * providing this callback.
100  */
101  if (fdwroutine->RecheckForeignScan &&
102  !fdwroutine->RecheckForeignScan(node, slot))
103  return false;
104 
105  return ExecQual(node->fdw_recheck_quals, econtext);
106 }
#define ResetExprContext(econtext)
Definition: executor.h:555
static bool ExecQual(ExprState *state, ExprContext *econtext)
Definition: executor.h:424
TupleTableSlot * ecxt_scantuple
Definition: execnodes.h:258
RecheckForeignScan_function RecheckForeignScan
Definition: fdwapi.h:249

References ExprContext::ecxt_scantuple, ExecQual(), ForeignScanState::fdw_recheck_quals, ForeignScanState::fdwroutine, ScanState::ps, PlanState::ps_ExprContext, FdwRoutine::RecheckForeignScan, ResetExprContext, and ForeignScanState::ss.

Referenced by ExecForeignScan().