pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Frank van Vugt <ftm.van.vugt@foxi.nl>
Cc: pgsql-bugs@postgresql.org
Subject: Re: minor annoyance - search_path not reset in/after dump/restore
Date: Tue, 23 Jan 2018 21:51:30 -0500
Message-ID: <20180124025130.GB17109@momjian.us> (raw)
In-Reply-To: <3103514.ugGH0nFkBt@techfox>
References: <3103514.ugGH0nFkBt@techfox>

On Mon, Nov 27, 2017 at 03:04:19PM +0100, Frank van Vugt wrote:
> L.S.
> 
> I'm not sure the following qualifies as a 'real' bug, but since it suprised me, 
> I'd like to raise it here, just in case it surprises others as well.
> 
> Postgresql version 9.6.6
> 
> The default value for the search_path is "$user", public.
> 
> Since I'm using schema's, my pg_dump files contain lines like this:
> 	SET search_path = cnt_user, pg_catalog;
> for each particular schema part in the dump.
> 
> However, at the end of the dump file, there's nothing to restore the 
> search_path to the default / last value.
> 
> This means that after restoring a dump via a psql console using a line like:
> 	\i /tmp/daily-db-backup
> the search_path value will be equal to that of the last schema restored...
> 
> This causes unexpected output of commands like '\d' afterwards.
> 
> Obviously, disconnecting/reconnecting 'fixes' things.

Interesting.  I had not considered someone would include a dump file,
but it makes sense.

The attached patch adds a RESET ALL to the end of the text dump to cause
a reset of all GUC variables.  Does this make sense to folks?  It would
only be applied to head, so it would only appear in PG 11.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +

Attachments:

reset.diff (text/x-diff, 584B) download diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c new file mode 100644 index f55aa36..4c28c30 *** a/src/bin/pg_dump/pg_backup_archiver.c --- b/src/bin/pg_dump/pg_backup_archiver.c *************** RestoreArchive(Archive *AHX) *** 721,726 **** --- 721,729 ---- if (AH->public.verbose) dumpTimestamp(AH, "Completed on", time(NULL)); + /* Reset session in case we are included by another session */ + ahprintf(AH, "--\n-- Reset session\n\nRESET ALL;\n\n"); + ahprintf(AH, "--\n-- PostgreSQL database dump complete\n--\n\n"); /*

view thread (4+ messages)  latest in thread

Message-ID: <20180124025130.GB17109@momjian.us>
Permalink:  ../20180124025130.GB17109@momjian.us/
Also on:    postgresql.org/message-id/20180124025130.GB17109@momjian.us

 ·  · 

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-bugs@postgresql.org
  Cc: bruce@momjian.us, ftm.van.vugt@foxi.nl
  Subject: Re: minor annoyance - search_path not reset in/after dump/restore
  In-Reply-To: <20180124025130.GB17109@momjian.us>
  References: <3103514.ugGH0nFkBt@techfox> <20180124025130.GB17109@momjian.us>

* 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