fix_explain_planning-v1.diff

text/plain

Filename: fix_explain_planning-v1.diff
Type: text/plain
Part: 0
Message: Re: [PG13] Planning (time + buffers) data structure in explain plan (format text)

Patch

Format: unified
Series: patch v1
File+
src/backend/commands/explain.c 12 6
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 30e0a7ee7f..375431acee 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -587,7 +587,15 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es,
 	ExplainPrintPlan(es, queryDesc);
 
 	if (es->summary && (planduration || bufusage))
+	{
 		ExplainOpenGroup("Planning", "Planning", true, es);
+		if (es->format == EXPLAIN_FORMAT_TEXT)
+		{
+			ExplainIndentText(es);
+			appendStringInfoString(es->str, "Planning:\n");
+			es->indent++;
+		}
+	}
 
 	if (es->summary && planduration)
 	{
@@ -598,16 +606,14 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es,
 
 	/* Show buffer usage */
 	if (es->summary && bufusage)
-	{
-		if (es->format == EXPLAIN_FORMAT_TEXT)
-			es->indent++;
 		show_buffer_usage(es, bufusage);
-		if (es->format == EXPLAIN_FORMAT_TEXT)
-			es->indent--;
-	}
 
 	if (es->summary && (planduration || bufusage))
+	{
+		if (es->format == EXPLAIN_FORMAT_TEXT)
+			es->indent--;
 		ExplainCloseGroup("Planning", "Planning", true, es);
+	}
 
 	/* Print info about runtime of triggers */
 	if (es->analyze)