aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execMain.c
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2018-08-13 08:56:37 +0530
committerAmit Kapila <akapila@postgresql.org>2018-08-13 08:56:37 +0530
commit69de17186ad9d668bc0500595b47d9a24def238f (patch)
tree135887c1c836e7fe9feb97e1950382cb7487685b /src/backend/executor/execMain.c
parent0d428b6553bcedf8faf51ed9947c3a59238f8da8 (diff)
downloadpostgresql-69de17186ad9d668bc0500595b47d9a24def238f.tar.gz
postgresql-69de17186ad9d668bc0500595b47d9a24def238f.zip
Prohibit shutting down resources if there is a possibility of back up.
Currently, we release the asynchronous resources as soon as it is evident that no more rows will be needed e.g. when a Limit is filled. This can be problematic especially for custom and foreign scans where we can scan backward. Fix that by disallowing the shutting down of resources in such cases. Reported-by: Robert Haas Analysed-by: Robert Haas and Amit Kapila Author: Amit Kapila Reviewed-by: Robert Haas Backpatch-through: 9.6 where this code was introduced Discussion: https://postgr.es/m/86137f17-1dfb-42f9-7421-82fd786b04a1@anayrat.info
Diffstat (limited to 'src/backend/executor/execMain.c')
-rw-r--r--src/backend/executor/execMain.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 10ccf59b794..9c70cb7c174 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -1571,8 +1571,12 @@ ExecutePlan(EState *estate,
*/
if (TupIsNull(slot))
{
- /* Allow nodes to release or shut down resources. */
- (void) ExecShutdownNode(planstate);
+ /*
+ * If we know we won't need to back up, we can release
+ * resources at this point.
+ */
+ if (!(estate->es_top_eflags & EXEC_FLAG_BACKWARD))
+ (void) ExecShutdownNode(planstate);
break;
}