Skip to content

Commit 68707e9

Browse files
committed
Future-proof the recursion inside ExecShutdownNode().
The API contract for planstate_tree_walker() callbacks is that they take a PlanState pointer and a context pointer. Somebody figured they could save a couple lines of code by ignoring that, and passing ExecShutdownNode itself as the walker even though it has but one argument. Somewhat remarkably, we've gotten away with that so far. However, it seems clear that the upcoming C2x standard means to forbid such cases, and compilers that actively break such code likely won't be far behind. So spend the extra few lines of code to do it honestly with a separate walker function. In HEAD, we might as well go further and remove ExecShutdownNode's useless 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 practical importance before our stable branches are all out of service. It doesn't seem to be fixing any live bug on any currently known platform, however. Discussion: https://postgr.es/m/208054.1663534665@sss.pgh.pa.us
1 parent 109836a commit 68707e9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/backend/executor/execProcnode.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119

120120
static TupleTableSlot *ExecProcNodeFirst(PlanState *node);
121121
static TupleTableSlot *ExecProcNodeInstr(PlanState *node);
122+
static bool ExecShutdownNode_walker(PlanState *node, void *context);
122123

123124

124125
/* ------------------------------------------------------------------------
@@ -725,6 +726,12 @@ ExecEndNode(PlanState *node)
725726
*/
726727
bool
727728
ExecShutdownNode(PlanState *node)
729+
{
730+
return ExecShutdownNode_walker(node, NULL);
731+
}
732+
733+
static bool
734+
ExecShutdownNode_walker(PlanState *node, void *context)
728735
{
729736
if (node == NULL)
730737
return false;
@@ -744,7 +751,7 @@ ExecShutdownNode(PlanState *node)
744751
if (node->instrument && node->instrument->running)
745752
InstrStartNode(node->instrument);
746753

747-
planstate_tree_walker(node, ExecShutdownNode, NULL);
754+
planstate_tree_walker(node, ExecShutdownNode_walker, context);
748755

749756
switch (nodeTag(node))
750757
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy