summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-09-19 12:16:02 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-09-19 12:16:02 -0400
commitc58513f095e2ccc85ab450a57f80d3f96747f626 (patch)
tree681365dffd84f9f63051f81919c57a7ad09db7be /src
parentb7558111aba277059a22ea313107f6459fa2a9cd (diff)
downloadpostgresql-c58513f095e2ccc85ab450a57f80d3f96747f626.tar.gz
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/executor/execProcnode.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/backend/executor/execProcnode.c b/src/backend/executor/execProcnode.c
index 01b7b926bf..19dd9004af 100644
--- a/src/backend/executor/execProcnode.c
+++ b/src/backend/executor/execProcnode.c
@@ -119,6 +119,7 @@
static TupleTableSlot *ExecProcNodeFirst(PlanState *node);
static TupleTableSlot *ExecProcNodeInstr(PlanState *node);
+static bool ExecShutdownNode_walker(PlanState *node, void *context);
/* ------------------------------------------------------------------------
@@ -750,6 +751,12 @@ ExecEndNode(PlanState *node)
bool
ExecShutdownNode(PlanState *node)
{
+ return ExecShutdownNode_walker(node, NULL);
+}
+
+static bool
+ExecShutdownNode_walker(PlanState *node, void *context)
+{
if (node == NULL)
return false;
@@ -768,7 +775,7 @@ ExecShutdownNode(PlanState *node)
if (node->instrument && node->instrument->running)
InstrStartNode(node->instrument);
- planstate_tree_walker(node, ExecShutdownNode, NULL);
+ planstate_tree_walker(node, ExecShutdownNode_walker, context);
switch (nodeTag(node))
{