From d3a738ea6427df908b61a5fdd3ee14a7b78b724a Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 22 May 2018 08:59:33 +0300 Subject: [PATCH 1/3] Add comment to explain that SubPlan can return its results in two ways. It took me a while to understand this, I hope this helps the next person reading the code to grok it faster. --- src/backend/executor/nodeSubplan.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c index 44f551bcf1..aab1c7942a 100644 --- a/src/backend/executor/nodeSubplan.c +++ b/src/backend/executor/nodeSubplan.c @@ -10,6 +10,12 @@ * direct correlation variables from the parent plan level), and "regular" * subplans, which are re-evaluated every time their result is required. * + * There are two ways a SubPlan node can return the result. The first is + * that ExecSubPlan() runs the subquery, and returns its result like any + * other expression. The second way is to return the result in executor + * Params. In this method, the execution happens when ExecSetParamPlan() is + * called, and the subquery's results are set as the current values of + * executor Params, as indicated by SubPlan->setParam. * * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California -- 2.11.0