From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: In deparsing, parenthesize IS DOCUMENT where it is an operand.
Date: Tue, 20 Oct 2026 18:29:22 +0000
Message-ID: <E1xJEaQ-000000002v8-0jDR@gemulon.postgresql.org> (raw)
In deparsing, parenthesize IS DOCUMENT where it is an operand.
isSimpleNode() and related code treated every XmlExpr as
self-delimiting. Most of them are, because they look like function
calls with some extra decoration. But "x IS DOCUMENT" is not: it is
a postfix test, like IS NULL. Printed as the operand of another
operator, or as the operand of a postfix test, it was therefore not
parenthesized and could not be parsed back, or was parsed as something
unintended. Under-parenthesization occurred even in non-pretty-print
cases, so that this could break dump/restore workflows.
To fix, treat IS DOCUMENT as neither simple nor function-like, and
give it the same treatment as other postfix tests.
Also pass the single argument of IS DOCUMENT, not the argument list,
to get_rule_expr_paren(). This avoids unnecessary parenthesization
of the argument.
Author: Henson Choi <assam258@gmail.com>
Reviewed-by: Prashant Chinnam <crprashant@hotmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAAAe_zDuPSkc8ihCctV67Lxbqock+S4wqCHHo8xxZ1t4teXo0g@mail.gmail.com
Backpatch-through: 14
Branch
------
REL_16_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/715bf03057480fba9dc1905053f78bdc2b9f9cb8
Modified Files
--------------
src/backend/utils/adt/ruleutils.c | 33 ++++++++++++++++++++++++++-----
src/test/regress/expected/create_view.out | 21 +++++++++++++++++++-
src/test/regress/sql/create_view.sql | 10 ++++++++++
3 files changed, 58 insertions(+), 6 deletions(-)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: In deparsing, parenthesize IS DOCUMENT where it is an operand.
In-Reply-To: <E1xJEaQ-000000002v8-0jDR@gemulon.postgresql.org>
References: <E1xJEaQ-000000002v8-0jDR@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox