diff options
author | Etsuro Fujita <efujita@postgresql.org> | 2019-04-15 19:01:09 +0900 |
---|---|---|
committer | Etsuro Fujita <efujita@postgresql.org> | 2019-04-15 19:01:09 +0900 |
commit | 3a45321a491711b556d2cf8f6904ab989b9d0b08 (patch) | |
tree | 9b7ee192ba793439dfa3d013d32d6c6f4f080e04 /src/backend/executor/execPartition.c | |
parent | abb9c63b2c00109183cdb9f588d2f23fc383ed38 (diff) | |
download | postgresql-3a45321a491711b556d2cf8f6904ab989b9d0b08.tar.gz postgresql-3a45321a491711b556d2cf8f6904ab989b9d0b08.zip |
Fix thinko in ExecCleanupTupleRouting().
Commit 3f2393edef changed ExecCleanupTupleRouting() so that it skipped
cleaning up subplan resultrels before calling EndForeignInsert(), but
that would cause an issue: when those resultrels were foreign tables,
the FDWs would fail to shut down. Repair by skipping it after calling
EndForeignInsert() as before.
Author: Etsuro Fujita
Reviewed-by: David Rowley and Amit Langote
Discussion: https://postgr.es/m/5CAF3B8F.2090905@lab.ntt.co.jp
Diffstat (limited to 'src/backend/executor/execPartition.c')
-rw-r--r-- | src/backend/executor/execPartition.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c index 50800aa5ca5..70709e5deab 100644 --- a/src/backend/executor/execPartition.c +++ b/src/backend/executor/execPartition.c @@ -1126,6 +1126,12 @@ ExecCleanupTupleRouting(ModifyTableState *mtstate, { ResultRelInfo *resultRelInfo = proute->partitions[i]; + /* Allow any FDWs to shut down */ + if (resultRelInfo->ri_FdwRoutine != NULL && + resultRelInfo->ri_FdwRoutine->EndForeignInsert != NULL) + resultRelInfo->ri_FdwRoutine->EndForeignInsert(mtstate->ps.state, + resultRelInfo); + /* * Check if this result rel is one belonging to the node's subplans, * if so, let ExecEndPlan() clean it up. @@ -1142,12 +1148,6 @@ ExecCleanupTupleRouting(ModifyTableState *mtstate, continue; } - /* Allow any FDWs to shut down if they've been exercised */ - if (resultRelInfo->ri_FdwRoutine != NULL && - resultRelInfo->ri_FdwRoutine->EndForeignInsert != NULL) - resultRelInfo->ri_FdwRoutine->EndForeignInsert(mtstate->ps.state, - resultRelInfo); - ExecCloseIndices(resultRelInfo); table_close(resultRelInfo->ri_RelationDesc, NoLock); } |