pgsql: Use the "pg_temp" schema alias in EXPLAIN and related output. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Use the "pg_temp" schema alias in EXPLAIN and related output.
Date
Msg-id E1m8Pd6-0004Gw-TZ@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Andrew Dunstan
Date:
Subject: pgsql: Disable command echo in pg_upgrade-created windows scripts
Next
From: Simon Riggs
Date:
Subject: Re: pgsql: Allow numeric scale to be negative or greater than precision.