diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 4711f912390f6..0c4afbe272fe3 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -555,6 +555,7 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions, result->relationOids = glob->relationOids; result->invalItems = glob->invalItems; result->paramExecTypes = glob->paramExecTypes; + result->plan_nodes_count = glob->lastPlanNodeId + 1; /* utilityStmt should be null, but we might as well copy it */ result->utilityStmt = parse->utilityStmt; result->stmt_location = parse->stmt_location; diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index 1aeeaec95e14c..0c405040bd2a0 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -97,6 +97,8 @@ typedef struct PlannedStmt /* statement location in source string (copied from Query) */ ParseLoc stmt_location; /* start location, or -1 if unknown */ ParseLoc stmt_len; /* length in bytes; 0 means "rest of string" */ + + int plan_nodes_count; /* indicates the number of plan nodes in the statement */ } PlannedStmt; /* macro for fetching the Plan associated with a SubPlan node */