From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add public ruleutils.c entry point to deparse a Query.
Date: Mon, 28 Mar 2022 15:19:48 +0000
Message-ID: <E1nYr9n-001luN-Vg@gemulon.postgresql.org> (raw)
Add public ruleutils.c entry point to deparse a Query.
This has no in-core callers but will be wanted by extensions.
It's just a thin wrapper around get_query_def, so it adds little code.
Also, fix get_from_clause_item() to force insertion of an alias
for a SUBQUERY RTE item. This is irrelevant to existing uses because
RTE_SUBQUERY items made by the parser always have aliases already.
However, if one tried to use pg_get_querydef() to inspect a post-rewrite
Query, it could be an issue. In any case, get_from_clause_item already
contained logic to force alias insertion for VALUES items, so the lack
of the same for SUBQUERY is a pretty clear oversight.
In passing, replace duplicated code for selection of pretty-print
options with a common macro.
Julien Rouhaud, reviewed by Pavel Stehule, Gilles Darold, and myself
Discussion: https://postgr.es/m/20210627041138.zklczwmu3ms4ufnk@nol
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/d22646922d66012705e0e2948cfb5b4a07092a29
Modified Files
--------------
src/backend/utils/adt/ruleutils.c | 54 ++++++++++++++++++++++++++++++---------
src/include/utils/ruleutils.h | 1 +
2 files changed, 43 insertions(+), 12 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: Add public ruleutils.c entry point to deparse a Query.
In-Reply-To: <E1nYr9n-001luN-Vg@gemulon.postgresql.org>
References: <E1nYr9n-001luN-Vg@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