Re: pg_overexplain produces invalid JSON with RANGE_TABLE option

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_overexplain produces invalid JSON with RANGE_TABLE option
Date: 2026-04-16 03:08:19
Message-ID: CA+HiwqEzH2ndNf+Ss5aeS8QZ1mSENuY_1FNUe5NyOcF-h-R5vw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Thu, Apr 16, 2026 at 10:22 AM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
> > On Apr 16, 2026, at 08:06, Amit Langote <amitlangote09(at)gmail(dot)com> wrote:
> > On Thu, Apr 16, 2026 at 6:36 AM SATYANARAYANA NARLAPURAM
> > <satyanarlapuram(at)gmail(dot)com> wrote:
> >>
> >> Hi Hackers,
> >>
> >> It appears that pg_overexplain produces invalid JSON output when
> >> EXPLAIN (FORMAT JSON, RANGE_TABLE) is used. The "Unprunable RTIs" and
> >> "Result RTIs" properties are emitted as key:value pairs directly inside
> >> the "Range Table" JSON array, which is structurally invalid.
> >
> > Thanks for the report and the patch. That makes sense.
> >
> >> Attempted to fix this by moving ExplainCloseGroup() before the two overexplain_bitmapset()
> >> calls, so the properties are emitted as siblings of "Range Table" in the parent object rather
> >> than inside the array.
> >>
> >> Attached a patch to address this which also includes a test.
> >
> > I have added a commit message. Will commit shortly to master and v18.
>
> Hi Amit, as the commit message mentions YAML format as well, but I don’t find a test case in pg_overexplain.sql, would it make sense to also add a test case for YAML. I tried to add one, see the attached diff file.

Thanks, but I think the JSON test is sufficient here. The fix is in
format-agnostic code (the ordering of ExplainCloseGroup relative to
the bitmapset calls), so any regression that affects YAML would show
up in the JSON test too. Generally, we should avoid adding test cases
that only duplicate existing coverage (though I'm sure I've been
guilty of it myself), as this increases the maintenance burden on
expected-output files without catching anything new.

--
Thanks, Amit Langote

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-04-16 03:32:40 repack: clarify final phase of concurrent mode in file header comment
Previous Message Amit Langote 2026-04-16 03:03:22 Re: [PATCH] Fix wrong comment in JsonTablePlanJoinNextRow()