#include "postgres.h"#include "executor/executor.h"#include "executor/nodeForeignscan.h"#include "foreign/fdwapi.h"#include "utils/rel.h"
Go to the source code of this file.
Functions | |
| static TupleTableSlot * | ForeignNext (ForeignScanState *node) |
| static bool | ForeignRecheck (ForeignScanState *node, TupleTableSlot *slot) |
| TupleTableSlot * | ExecForeignScan (ForeignScanState *node) |
| ForeignScanState * | ExecInitForeignScan (ForeignScan *node, EState *estate, int eflags) |
| void | ExecEndForeignScan (ForeignScanState *node) |
| void | ExecReScanForeignScan (ForeignScanState *node) |
| void ExecEndForeignScan | ( | ForeignScanState * | node | ) |
Definition at line 183 of file nodeForeignscan.c.
References FdwRoutine::EndForeignScan, ExecClearTuple(), ExecCloseScanRelation(), ExecFreeExprContext(), ForeignScanState::fdwroutine, ScanState::ps, PlanState::ps_ResultTupleSlot, ForeignScanState::ss, ScanState::ss_currentRelation, and ScanState::ss_ScanTupleSlot.
Referenced by ExecEndNode().
{
/* Let the FDW shut down */
node->fdwroutine->EndForeignScan(node);
/* Free the exprcontext */
ExecFreeExprContext(&node->ss.ps);
/* clean out the tuple table */
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
ExecClearTuple(node->ss.ss_ScanTupleSlot);
/* close the relation. */
ExecCloseScanRelation(node->ss.ss_currentRelation);
}
| TupleTableSlot* ExecForeignScan | ( | ForeignScanState * | node | ) |
Definition at line 89 of file nodeForeignscan.c.
References ExecScan(), ForeignNext(), and ForeignRecheck().
Referenced by ExecProcNode().
{
return ExecScan((ScanState *) node,
(ExecScanAccessMtd) ForeignNext,
(ExecScanRecheckMtd) ForeignRecheck);
}
| ForeignScanState* ExecInitForeignScan | ( | ForeignScan * | node, | |
| EState * | estate, | |||
| int | eflags | |||
| ) |
Definition at line 102 of file nodeForeignscan.c.
References Assert, FdwRoutine::BeginForeignScan, EXEC_FLAG_BACKWARD, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecAssignResultTypeFromTL(), ExecAssignScanProjectionInfo(), ExecAssignScanType(), ExecInitExpr(), ExecInitResultTupleSlot(), ExecInitScanTupleSlot(), ExecOpenScanRelation(), ForeignScanState::fdw_state, ForeignScanState::fdwroutine, GetFdwRoutineForRelation(), makeNode, Scan::plan, PlanState::plan, ScanState::ps, PlanState::ps_TupFromTlist, Plan::qual, PlanState::qual, RelationGetDescr, ForeignScan::scan, Scan::scanrelid, ForeignScanState::ss, ScanState::ss_currentRelation, PlanState::state, Plan::targetlist, and PlanState::targetlist.
Referenced by ExecInitNode().
{
ForeignScanState *scanstate;
Relation currentRelation;
FdwRoutine *fdwroutine;
/* check for unsupported flags */
Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
/*
* create state structure
*/
scanstate = makeNode(ForeignScanState);
scanstate->ss.ps.plan = (Plan *) node;
scanstate->ss.ps.state = estate;
/*
* Miscellaneous initialization
*
* create expression context for node
*/
ExecAssignExprContext(estate, &scanstate->ss.ps);
scanstate->ss.ps.ps_TupFromTlist = false;
/*
* initialize child expressions
*/
scanstate->ss.ps.targetlist = (List *)
ExecInitExpr((Expr *) node->scan.plan.targetlist,
(PlanState *) scanstate);
scanstate->ss.ps.qual = (List *)
ExecInitExpr((Expr *) node->scan.plan.qual,
(PlanState *) scanstate);
/*
* tuple table initialization
*/
ExecInitResultTupleSlot(estate, &scanstate->ss.ps);
ExecInitScanTupleSlot(estate, &scanstate->ss);
/*
* open the base relation and acquire appropriate lock on it.
*/
currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid, eflags);
scanstate->ss.ss_currentRelation = currentRelation;
/*
* get the scan type from the relation descriptor. (XXX at some point we
* might want to let the FDW editorialize on the scan tupdesc.)
*/
ExecAssignScanType(&scanstate->ss, RelationGetDescr(currentRelation));
/*
* Initialize result tuple type and projection info.
*/
ExecAssignResultTypeFromTL(&scanstate->ss.ps);
ExecAssignScanProjectionInfo(&scanstate->ss);
/*
* Acquire function pointers from the FDW's handler, and init fdw_state.
*/
fdwroutine = GetFdwRoutineForRelation(currentRelation, true);
scanstate->fdwroutine = fdwroutine;
scanstate->fdw_state = NULL;
/*
* Tell the FDW to initiate the scan.
*/
fdwroutine->BeginForeignScan(scanstate, eflags);
return scanstate;
}
| void ExecReScanForeignScan | ( | ForeignScanState * | node | ) |
Definition at line 206 of file nodeForeignscan.c.
References ExecScanReScan(), ForeignScanState::fdwroutine, FdwRoutine::ReScanForeignScan, and ForeignScanState::ss.
Referenced by ExecReScan().
{
node->fdwroutine->ReScanForeignScan(node);
ExecScanReScan(&node->ss);
}
| static TupleTableSlot * ForeignNext | ( | ForeignScanState * | node | ) | [static] |
Definition at line 41 of file nodeForeignscan.c.
References ExecMaterializeSlot(), ForeignScanState::fdwroutine, ForeignScan::fsSystemCol, FdwRoutine::IterateForeignScan, MemoryContextSwitchTo(), PlanState::plan, ScanState::ps, PlanState::ps_ExprContext, RelationGetRelid, ForeignScanState::ss, ScanState::ss_currentRelation, HeapTupleData::t_tableOid, and TupIsNull.
Referenced by ExecForeignScan().
{
TupleTableSlot *slot;
ForeignScan *plan = (ForeignScan *) node->ss.ps.plan;
ExprContext *econtext = node->ss.ps.ps_ExprContext;
MemoryContext oldcontext;
/* Call the Iterate function in short-lived context */
oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
slot = node->fdwroutine->IterateForeignScan(node);
MemoryContextSwitchTo(oldcontext);
/*
* If any system columns are requested, we have to force the tuple into
* physical-tuple form to avoid "cannot extract system attribute from
* virtual tuple" errors later. We also insert a valid value for
* tableoid, which is the only actually-useful system column.
*/
if (plan->fsSystemCol && !TupIsNull(slot))
{
HeapTuple tup = ExecMaterializeSlot(slot);
tup->t_tableOid = RelationGetRelid(node->ss.ss_currentRelation);
}
return slot;
}
| static bool ForeignRecheck | ( | ForeignScanState * | node, | |
| TupleTableSlot * | slot | |||
| ) | [static] |
Definition at line 73 of file nodeForeignscan.c.
Referenced by ExecForeignScan().
{
/* There are no access-method-specific conditions to recheck. */
return true;
}
1.7.1