pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alexander Spiteri <alexander@spiteri.org>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14009: pg_restore not restoring privilegs when one login/group role is missing
Date: Thu, 10 Mar 2016 11:24:54 -0500
Message-ID: <4509.1457627094@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKmUXWtc+AUEPbG1NYJGM4KgChfCawLyd2yn_mO4NGrbLgBY_A@mail.gmail.com>
References: <20160309151510.8903.22052@wrigleys.postgresql.org>
	<20365.1457555577@sss.pgh.pa.us>
	<CAKmUXWtc+AUEPbG1NYJGM4KgChfCawLyd2yn_mO4NGrbLgBY_A@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Alexander Spiteri <alexander@spiteri.org> writes:
> Please find a test case attached. I tried to put as much detail as i could.

Okay, I see what's going on.  I really doubt that there is a regression
here from 8.4 though.  I will bet that the difference is you used plain
text output from pg_dump back in 8.4, and now in 9.5 you are trying to
use pg_restore direct-to-database mode.

The proximate cause of the problem is that pg_dump bundles up GRANT/REVOKE
statements for any object into a single "ACL" entry in the archive file.
If you dump to SQL text this doesn't matter because it just looks like a
stream of separate statements.  But if pg_restore is trying to restore
direct to database then it issues the whole text of each archive file
entry as a single PQexec() operation, which means that an error in one
statement in that string causes the rest of 'em to be skipped.

As a short-term workaround you could try restoring in this way:

   pg_restore foo.dump | psql

To really fix it, I think we'd need either to expand "ACL" archive entries
into a separate entry for each target user, or to change pg_restore to
parse the entry contents into separate statements.  The latter seems
messy and bug-prone.  The former solution wouldn't fix the problem
for dumps from existing pg_dump versions; but on the other hand, it might
provide additional flexibility for selective restores, so I'm not sure
that it's a bad idea going forward.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (8+ messages)  latest in thread

Message-ID: <4509.1457627094@sss.pgh.pa.us>
Permalink:  ../4509.1457627094@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4509.1457627094@sss.pgh.pa.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: tgl@sss.pgh.pa.us, alexander@spiteri.org
  Subject: Re: BUG #14009: pg_restore not restoring privilegs when one login/group role is missing
  In-Reply-To: <4509.1457627094@sss.pgh.pa.us>
  References: <20160309151510.8903.22052@wrigleys.postgresql.org> <20365.1457555577@sss.pgh.pa.us> <CAKmUXWtc+AUEPbG1NYJGM4KgChfCawLyd2yn_mO4NGrbLgBY_A@mail.gmail.com> <4509.1457627094@sss.pgh.pa.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