*/
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;
}
current_tuple_count++;
if (numberTuples && numberTuples == current_tuple_count)
{
- /* 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;
}
}
node->position - node->offset >= node->count)
{
node->lstate = LIMIT_WINDOWEND;
- /* Allow nodes to release or shut down resources. */
- (void) ExecShutdownNode(outerPlan);
+
+ /*
+ * If we know we won't need to back up, we can release
+ * resources at this point.
+ */
+ if (!(node->ps.state->es_top_eflags & EXEC_FLAG_BACKWARD))
+ (void) ExecShutdownNode(outerPlan);
+
return NULL;
}