diff options
Diffstat (limited to 'src/backend/executor/nodeForeignscan.c')
| -rw-r--r-- | src/backend/executor/nodeForeignscan.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/backend/executor/nodeForeignscan.c b/src/backend/executor/nodeForeignscan.c index 388c922749..300f947d43 100644 --- a/src/backend/executor/nodeForeignscan.c +++ b/src/backend/executor/nodeForeignscan.c @@ -48,7 +48,10 @@ ForeignNext(ForeignScanState *node) /* Call the Iterate function in short-lived context */ oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory); - slot = node->fdwroutine->IterateForeignScan(node); + if (plan->operation != CMD_SELECT) + slot = node->fdwroutine->IterateDirectModify(node); + else + slot = node->fdwroutine->IterateForeignScan(node); MemoryContextSwitchTo(oldcontext); /* @@ -226,7 +229,10 @@ ExecInitForeignScan(ForeignScan *node, EState *estate, int eflags) /* * Tell the FDW to initialize the scan. */ - fdwroutine->BeginForeignScan(scanstate, eflags); + if (node->operation != CMD_SELECT) + fdwroutine->BeginDirectModify(scanstate, eflags); + else + fdwroutine->BeginForeignScan(scanstate, eflags); return scanstate; } @@ -240,8 +246,13 @@ ExecInitForeignScan(ForeignScan *node, EState *estate, int eflags) void ExecEndForeignScan(ForeignScanState *node) { + ForeignScan *plan = (ForeignScan *) node->ss.ps.plan; + /* Let the FDW shut down */ - node->fdwroutine->EndForeignScan(node); + if (plan->operation != CMD_SELECT) + node->fdwroutine->EndDirectModify(node); + else + node->fdwroutine->EndForeignScan(node); /* Shut down any outer plan. */ if (outerPlanState(node)) |
