Thread

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix pg_overexplain to emit valid output with RANGE_TABLE option.

  1. pg_overexplain produces invalid JSON with RANGE_TABLE option

    SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com> — 2026-04-15T21:35:46Z

    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.
    
    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.
    
    Repro:
    
    LOAD 'pg_overexplain';
      CREATE TABLE t1 (id serial PRIMARY KEY, val text);
      CREATE TABLE t2 (id serial PRIMARY KEY, a_id int REFERENCES t1(id), data
    text);
      INSERT INTO t1 VALUES (1, 'x'), (2, 'y');
      INSERT INTO t2 VALUES (1, 1, 'd1'), (2, 2, 'd2');
    
    EXPLAIN (FORMAT JSON, RANGE_TABLE)
       EXPLAIN (FORMAT JSON, RANGE_TABLE)
        SELECT * FROM t1 a JOIN t2 b ON a.id = b.a_id WHERE a.id = 1; "
    | tail -n +2 | python3 -c "import json,sys; json.loads(sys.stdin.read());
    print('VALID JSON')"
    
    Thanks,
    Satya
    
  2. Re: pg_overexplain produces invalid JSON with RANGE_TABLE option

    amit <amitlangote09@gmail.com> — 2026-04-16T00:06:21Z

    Hi,
    
    On Thu, Apr 16, 2026 at 6:36 AM SATYANARAYANA NARLAPURAM
    <satyanarlapuram@gmail.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.
    
    -- 
    Thanks, Amit Langote
    
  3. Re: pg_overexplain produces invalid JSON with RANGE_TABLE option

    Chao Li <li.evan.chao@gmail.com> — 2026-04-16T01:22:03Z

    
    > On Apr 16, 2026, at 08:06, Amit Langote <amitlangote09@gmail.com> wrote:
    > 
    > Hi,
    > 
    > On Thu, Apr 16, 2026 at 6:36 AM SATYANARAYANA NARLAPURAM
    > <satyanarlapuram@gmail.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.
    > 
    > -- 
    > Thanks, Amit Langote
    > <v1-0001-Fix-pg_overexplain-to-emit-valid-output-with-RANG.patch>
    
    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.
    
    Best regards,
    --
    Chao Li (Evan)
    HighGo Software Co., Ltd.
    https://www.highgo.com/
    
    
    
    
    
  4. Re: pg_overexplain produces invalid JSON with RANGE_TABLE option

    amit <amitlangote09@gmail.com> — 2026-04-16T03:08:19Z

    Hi,
    
    On Thu, Apr 16, 2026 at 10:22 AM Chao Li <li.evan.chao@gmail.com> wrote:
    > > On Apr 16, 2026, at 08:06, Amit Langote <amitlangote09@gmail.com> wrote:
    > > On Thu, Apr 16, 2026 at 6:36 AM SATYANARAYANA NARLAPURAM
    > > <satyanarlapuram@gmail.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
    
    
    
    
  5. Re: pg_overexplain produces invalid JSON with RANGE_TABLE option

    amit <amitlangote09@gmail.com> — 2026-04-16T05:17:08Z

    On Thu, Apr 16, 2026 at 9:06 AM Amit Langote <amitlangote09@gmail.com> wrote:
    > On Thu, Apr 16, 2026 at 6:36 AM SATYANARAYANA NARLAPURAM
    > <satyanarlapuram@gmail.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.
    
    Pushed.
    
    -- 
    Thanks, Amit Langote