pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: mahadevan@rapidloop.com
Subject: BUG #16171: Potential malformed JSON in explain output
Date: Wed, 18 Dec 2019 10:28:43 +0000
Message-ID: <16171-b72259ab75505fa2@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      16171
Logged by:          Mahadevan Ramachandran
Email address:      mahadevan@rapidloop.com
PostgreSQL version: 12.1
Operating system:   any
Description:        

Refer src/backend/commands/explain.c, version 12.1.

When a plan node has children, the function ExplainNode starts a JSON array
with the key "Plans" (line 1955), like so:

    "Plans": [ 

with the intention of creating an array of "Plan" objects, one for each
child:

    "Plans": [
        { .. a child plan goes here ..},
        { .. a child plan goes here ..}
    ]

However, if the node (the current, parent one) is of a certain type (see
switch at line 1975), then ExplainMemberNodes is called, which does this
(lines 3335-6):

	if (nsubnodes < nplans)
		ExplainPropertyInteger("Subplans Removed", NULL, nplans - nsubnodes,
es);

This can potentially cause a malformed JSON output like this:

    "Plans": [
        { .. a child plan goes here ..},
        "Subplans Removed": 5,
        { .. a child plan goes here ..}
    ]

I don't have a sample explain output that exhibits this error, this was
found while reviewing the code.



view thread (11+ messages)  latest in thread

Message-ID: <16171-b72259ab75505fa2@postgresql.org>
Permalink:  ../16171-b72259ab75505fa2@postgresql.org/
Also on:    postgresql.org/message-id/16171-b72259ab75505fa2@postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, mahadevan@rapidloop.com
  Subject: Re: BUG #16171: Potential malformed JSON in explain output
  In-Reply-To: <16171-b72259ab75505fa2@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox