explain_subplan_remove.patch

application/octet-stream

Filename: explain_subplan_remove.patch
Type: application/octet-stream
Part: 0
Message: Re: BUG #16171: Potential malformed JSON in explain output

Patch

Format: format-patch
Subject: Move subplan pruning info in EXPLAIN into group
File+
src/backend/commands/explain.c 4 0
From 0240114f145b1386f13ef50b106ca8d7761b7729 Mon Sep 17 00:00:00 2001
From: Daniel Gustafsson <daniel@yesql.se>
Date: Wed, 18 Dec 2019 16:04:52 +0100
Subject: [PATCH] Move subplan pruning info in EXPLAIN into group

The "Subplans Removed" information is printed in the Plans output
group, where for structured formats JSON and YAML each entry must
be in its own group in order for the outout to be legally formatted.

Bug: #16171
Reported-by: Mahadevan Ramachandran
---
 src/backend/commands/explain.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 949fefa23a..abab5532bd 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -3360,7 +3360,11 @@ ExplainMemberNodes(PlanState **planstates, int nsubnodes, int nplans,
 	 * here that this has happened.
 	 */
 	if (nsubnodes < nplans)
+	{
+		ExplainOpenGroup("Plan", NULL, true, es);
 		ExplainPropertyInteger("Subplans Removed", NULL, nplans - nsubnodes, es);
+		ExplainCloseGroup("Plan", NULL, true, es);
+	}
 
 	for (j = 0; j < nsubnodes; j++)
 		ExplainNode(planstates[j], ancestors,
-- 
2.21.0 (Apple Git-122.2)