Wiki / Plan Nodes / Extensibility
Foreign Scan
ForeignScan
Delegates a foreign scan or supported direct modification to the foreign-data wrapper.
Reading PostgreSQL 18.6.
Description
Delegates a foreign scan or supported direct modification to the foreign-data wrapper.
- Core node tag
- T_ForeignScan
- Structured EXPLAIN Node Type
- Foreign Scan
- Inputs
- Foreign-data wrapper plan and callbacks
- Output
- Provider-defined scan or RETURNING tuples
- Executor initializer
- ExecInitForeignScan
- Memory mechanism
- unclassified
EXPLAIN names and attributes
Structured formats use the Node Type above. Text-format spellings can also include operation, strategy, join type, scan direction or aggregation-stage attributes.
Text names recorded by this source: Foreign Scan, Foreign Insert, Foreign Update, Foreign Delete.
Parallel-aware and parallel-safe are different plan properties. A node running inside a parallel worker is not necessarily a parallel-aware node.
Memory and temporary storage
This extraction does not assign a universal memory limit or spill policy to this node. Inspect the same-build implementation and its expressions or provider.
Parallel execution and instrumentation
The source callbacks below can coordinate execution or collect worker instrumentation. Their presence is not a blanket claim that this node supports a shared parallel scan or shared state.
Callbacks in this build: ExecForeignScanEstimate, ExecForeignScanInitializeDSM, ExecForeignScanInitializeWorker, ExecForeignScanReInitializeDSM.
Executor implementation notes
nodeForeignscan.c Routines to support scans of foreign tables
ExecForeignScan scans a foreign table. ExecInitForeignScan creates and initializes state info. ExecReScanForeignScan rescans the foreign relation. ExecEndForeignScan releases any resources allocated.
direct modifications cannot be re-evaluated, so shouldn't get here during EvalPlanQual processing
Insert valid value into tableoid, the only actually-useful system column.
ForeignRecheck -- access method routine to recheck a tuple in EvalPlanQual
EXPLAIN identity in core source
case T_ForeignScan:
sname = "Foreign Scan";
switch (((ForeignScan *) plan)->operation)
{
case CMD_SELECT:
pname = "Foreign Scan";
operation = "Select";
break;
case CMD_INSERT:
pname = "Foreign Insert";
operation = "Insert";
break;
case CMD_UPDATE:
pname = "Foreign Update";
operation = "Update";
break;
case CMD_DELETE:
pname = "Foreign Delete";
operation = "Delete";
break;
default:
pname = "???";
break;
}
break;EXPLAIN labels in this source build
| Text-format label | Structured node identity |
|---|---|
| Foreign Scan | Foreign Scan |
| Foreign Insert | Foreign Scan |
| Foreign Update | Foreign Scan |
| Foreign Delete | Foreign Scan |
Related entries
Documentation and source
- src/backend/commands/explain.c:1483
- src/backend/executor/execProcnode.c:284
- src/backend/executor/nodeForeignscan.c
- src/include/nodes/plannodes.h
Source build
- Version
- 18.6
- Build
- PostgreSQL 18.6 source archive
- Source fingerprint
555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f
Compare versions
PostgreSQL 17 → 18: unchanged.
Compares recorded interfaces and attributes. Source fingerprints and build metadata are excluded; an absent sample is not proof of the introduction or removal release.
Related entries
Custom ScanCustomScan
Export JSON · Back to Plan Nodes · Recorded in PostgreSQL 10 through 20; the first sample is not necessarily its introduction.