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

Commitc35ba14

Browse files
committed
Future-proof the recursion inside ExecShutdownNode().
The API contract for planstate_tree_walker() callbacks is that theytake a PlanState pointer and a context pointer. Somebody figuredthey could save a couple lines of code by ignoring that, and passingExecShutdownNode itself as the walker even though it has but oneargument. Somewhat remarkably, we've gotten away with that so far.However, it seems clear that the upcoming C2x standard means toforbid such cases, and compilers that actively break such codelikely won't be far behind. So spend the extra few lines of codeto do it honestly with a separate walker function.In HEAD, we might as well go further and remove ExecShutdownNode'suseless return value. I left that as-is in back branches though,to forestall complaints about ABI breakage.Back-patch, with the thought that this might become of practicalimportance before our stable branches are all out of service.It doesn't seem to be fixing any live bug on any currently knownplatform, however.Discussion:https://postgr.es/m/208054.1663534665@sss.pgh.pa.us
1 parent4fd1479 commitc35ba14

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

‎src/backend/executor/execMain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ ExecutePlan(EState *estate,
16911691
* point.
16921692
*/
16931693
if (!(estate->es_top_eflags&EXEC_FLAG_BACKWARD))
1694-
(void)ExecShutdownNode(planstate);
1694+
ExecShutdownNode(planstate);
16951695

16961696
if (use_parallel_mode)
16971697
ExitParallelMode();

‎src/backend/executor/execProcnode.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121

122122
staticTupleTableSlot*ExecProcNodeFirst(PlanState*node);
123123
staticTupleTableSlot*ExecProcNodeInstr(PlanState*node);
124+
staticboolExecShutdownNode_walker(PlanState*node,void*context);
124125

125126

126127
/* ------------------------------------------------------------------------
@@ -768,8 +769,14 @@ ExecEndNode(PlanState *node)
768769
* Give execution nodes a chance to stop asynchronous resource consumption
769770
* and release any resources still held.
770771
*/
771-
bool
772+
void
772773
ExecShutdownNode(PlanState*node)
774+
{
775+
(void)ExecShutdownNode_walker(node,NULL);
776+
}
777+
778+
staticbool
779+
ExecShutdownNode_walker(PlanState*node,void*context)
773780
{
774781
if (node==NULL)
775782
return false;
@@ -789,7 +796,7 @@ ExecShutdownNode(PlanState *node)
789796
if (node->instrument&&node->instrument->running)
790797
InstrStartNode(node->instrument);
791798

792-
planstate_tree_walker(node,ExecShutdownNode,NULL);
799+
planstate_tree_walker(node,ExecShutdownNode_walker,context);
793800

794801
switch (nodeTag(node))
795802
{

‎src/include/executor/executor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ extern PlanState *ExecInitNode(Plan *node, EState *estate, int eflags);
239239
externvoidExecSetExecProcNode(PlanState*node,ExecProcNodeMtdfunction);
240240
externNode*MultiExecProcNode(PlanState*node);
241241
externvoidExecEndNode(PlanState*node);
242-
externboolExecShutdownNode(PlanState*node);
242+
externvoidExecShutdownNode(PlanState*node);
243243
externvoidExecSetTupleBound(int64tuples_needed,PlanState*child_node);
244244

245245

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp