pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use the "pg_temp" schema alias in EXPLAIN and related output.
Date: Tue, 27 Jul 2021 16:08:28 +0000
Message-ID: <E1m8Pd6-0004Gw-TZ@gemulon.postgresql.org> (raw)

Use the "pg_temp" schema alias in EXPLAIN and related output.

This patch causes EXPLAIN output to refer to objects that are in
the current session's temp schema with the "pg_temp" schema alias
rather than that schema's actual name.  This is useful for our own
testing purposes since it will stabilize EXPLAIN VERBOSE output
for such cases, allowing us to use that in regression tests.
It should be less confusing for end users too.

Since ruleutils.c needs to change behavior for this, the change
also leaks into a few other users of ruleutils.c, for example
pg_get_viewdef().  AFAICS that won't cause any problems.
We did find that aggressively trying to change this behavior
across-the-board would cause issues, but as long as "pg_temp"
only appears within generated SQL text, I think it'll be fine.

Along the way, make get_namespace_name_or_temp conform to the
same API as get_namespace_name, ie that it returns a palloc'd
string or NULL.  The current behavior hasn't caused any bugs
since no callers attempt to pfree the result, but if it gets
more widespread usage that could become a problem.

Amul Sul, reviewed and extended by me

Discussion: https://postgr.es/m/CAAJ_b97W=QaGmag9AhWNbmx3uEYsNkXWL+OVW1_E1D3BtgWvtw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/48c5c9068211e0a04fd9553c8714b2821ed3ad17

Modified Files
--------------
contrib/postgres_fdw/postgres_fdw.c   |  2 +-
src/backend/commands/explain.c        |  5 ++---
src/backend/utils/adt/ruleutils.c     | 20 ++++++++++----------
src/backend/utils/cache/lsyscache.c   |  2 +-
src/test/regress/expected/explain.out | 13 +++++++++++++
src/test/regress/sql/explain.sql      |  9 +++++++++
6 files changed, 36 insertions(+), 15 deletions(-)



Message-ID: <E1m8Pd6-0004Gw-TZ@gemulon.postgresql.org>
Permalink:  ../E1m8Pd6-0004Gw-TZ@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1m8Pd6-0004Gw-TZ@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 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: Use the "pg_temp" schema alias in EXPLAIN and related output.
  In-Reply-To: <E1m8Pd6-0004Gw-TZ@gemulon.postgresql.org>
  References: <E1m8Pd6-0004Gw-TZ@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