Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2cd0acf

Browse files
author
Amit Kapila
committed
Prohibit shutting down resources if there is a possibility of back up.
Currently, we release the asynchronous resources as soon as it is evidentthat no more rows will be needed e.g. when a Limit is filled. This can beproblematic especially for custom and foreign scans where we can scanbackward. Fix that by disallowing the shutting down of resources in suchcases.Reported-by: Robert HaasAnalysed-by: Robert Haas and Amit KapilaAuthor: Amit KapilaReviewed-by: Robert HaasBackpatch-through: 9.6 where this code was introducedDiscussion:https://postgr.es/m/86137f17-1dfb-42f9-7421-82fd786b04a1@anayrat.info
1 parent07172d5 commit2cd0acf

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

‎src/backend/executor/execMain.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,8 +1726,12 @@ ExecutePlan(EState *estate,
17261726
*/
17271727
if (TupIsNull(slot))
17281728
{
1729-
/* Allow nodes to release or shut down resources. */
1730-
(void)ExecShutdownNode(planstate);
1729+
/*
1730+
* If we know we won't need to back up, we can release
1731+
* resources at this point.
1732+
*/
1733+
if (!(estate->es_top_eflags&EXEC_FLAG_BACKWARD))
1734+
(void)ExecShutdownNode(planstate);
17311735
break;
17321736
}
17331737

@@ -1773,8 +1777,12 @@ ExecutePlan(EState *estate,
17731777
current_tuple_count++;
17741778
if (numberTuples&&numberTuples==current_tuple_count)
17751779
{
1776-
/* Allow nodes to release or shut down resources. */
1777-
(void)ExecShutdownNode(planstate);
1780+
/*
1781+
* If we know we won't need to back up, we can release
1782+
* resources at this point.
1783+
*/
1784+
if (!(estate->es_top_eflags&EXEC_FLAG_BACKWARD))
1785+
(void)ExecShutdownNode(planstate);
17781786
break;
17791787
}
17801788
}

‎src/backend/executor/nodeLimit.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,14 @@ ExecLimit(PlanState *pstate)
134134
node->position-node->offset >=node->count)
135135
{
136136
node->lstate=LIMIT_WINDOWEND;
137-
/* Allow nodes to release or shut down resources. */
138-
(void)ExecShutdownNode(outerPlan);
137+
138+
/*
139+
* If we know we won't need to back up, we can release
140+
* resources at this point.
141+
*/
142+
if (!(node->ps.state->es_top_eflags&EXEC_FLAG_BACKWARD))
143+
(void)ExecShutdownNode(outerPlan);
144+
139145
returnNULL;
140146
}
141147

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp