agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Amit Langote <amitlan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix pg_overexplain to emit valid output with RANGE_TABLE option.
Date: Thu, 16 Apr 2026 05:16:37 +0000
Message-ID: <E1wDF5g-001CRS-2p@gemulon.postgresql.org> (raw)

Fix pg_overexplain to emit valid output with RANGE_TABLE option.

overexplain_range_table() emitted the "Unprunable RTIs" and "Result
RTIs" properties before closing the "Range Table" group.  In the JSON
and YAML formats the Range Table group is rendered as an array of RTE
objects, so emitting key/value pairs inside it produced structurally
invalid output.  The XML format had a related oddity, with these
elements nested inside <Range-Table> rather than appearing as its
siblings.

These fields are properties of the PlannedStmt as a whole, not of any
individual RTE, so close the Range Table group before emitting them.
They now appear as siblings of "Range Table" in the parent Query
object, which is what was intended.

Also add a test exercising FORMAT JSON with RANGE_TABLE so that any
future regression in the output structure is caught.

Reported-by: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Reviewed-by: Amit Langote <amitlangote09@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDdDrdqMr98a_OBYDYmK3RaT7XwCEShZfvDYKZpZTfOEjQ@mail.gmail.com
Backpatch-through: 18

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/059cf7f58d23fc53423e4e58feaaa717faef53c5

Modified Files
--------------
contrib/pg_overexplain/expected/pg_overexplain.out | 122 ++++++++++++++++++++-
contrib/pg_overexplain/pg_overexplain.c            |  12 +-
contrib/pg_overexplain/sql/pg_overexplain.sql      |   6 +
3 files changed, 134 insertions(+), 6 deletions(-)



view thread (2+ messages)

Message-ID: <E1wDF5g-001CRS-2p@gemulon.postgresql.org>
Permalink:  ../E1wDF5g-001CRS-2p@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wDF5g-001CRS-2p@gemulon.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-committers@postgresql.org
  Cc: amitlan@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix pg_overexplain to emit valid output with RANGE_TABLE option.
  In-Reply-To: <E1wDF5g-001CRS-2p@gemulon.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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox