| From: | SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | pg_overexplain produces invalid JSON with RANGE_TABLE option |
| Date: | 2026-04-15 21:35:46 |
| Message-ID: | CAHg+QDdDrdqMr98a_OBYDYmK3RaT7XwCEShZfvDYKZpZTfOEjQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Fix-pg_overexplain-invalid-JSON-with-RANGE_TABLE.patch | application/octet-stream | 10.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tristan Partin | 2026-04-15 21:36:35 | Re: Validate user-supplied c_args in meson builds |
| Previous Message | Tristan Partin | 2026-04-15 21:33:41 | Re: Minor cleanup of Meson files given that we require 0.57 |