agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix JSON_TABLE PLAN deparse to keep parentheses around nested jo
Date: Tue, 14 Jul 2026 22:31:12 +0000
Message-ID: <E1wjlei-000CeX-09@gemulon.postgresql.org> (raw)

Fix JSON_TABLE PLAN deparse to keep parentheses around nested joins

get_json_table_plan() parenthesized the child of a parent/child
(OUTER/INNER) plan only when that child was a sibling (UNION/CROSS)
join, not when it was itself a parent/child join.  A plan such as
PLAN (p0 OUTER (p1 INNER p11)) was therefore deparsed as
PLAN (p0 OUTER p1 INNER p11), which does not parse back to the same
plan tree -- a dump/restore hazard.  Parenthesize the child whenever it
is not a bare path name, matching the logic already used for the
operands of sibling joins.

Reported-by: Thom Brown <thom@linux.com>
Discussion: https://postgr.es/m/CAA-aLv7aZGSExnbjJRw8eKkoXbu34TdoKLLA2gPye3aHjO5OSA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/160ef2751b524cbc797e59642543790c4a8132ec

Modified Files
--------------
src/backend/utils/adt/ruleutils.c               |  3 ++-
src/test/regress/expected/sqljson_jsontable.out | 29 +++++++++++++++++++++++++
src/test/regress/sql/sqljson_jsontable.sql      | 15 +++++++++++++
3 files changed, 46 insertions(+), 1 deletion(-)



Message-ID: <E1wjlei-000CeX-09@gemulon.postgresql.org>
Permalink:  ../E1wjlei-000CeX-09@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wjlei-000CeX-09@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: akorotkov@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix JSON_TABLE PLAN deparse to keep parentheses around nested jo
  In-Reply-To: <E1wjlei-000CeX-09@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