Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ae3P8-0002NG-Bn for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Mar 2016 16:25:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ae3P7-0006lO-Id for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Mar 2016 16:25:37 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ae3OU-0005zA-ES for pgsql-bugs@postgresql.org; Thu, 10 Mar 2016 16:24:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ae3OS-0000w3-0y for pgsql-bugs@postgresql.org; Thu, 10 Mar 2016 16:24:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u2AGOswY004510; Thu, 10 Mar 2016 11:24:54 -0500 From: Tom Lane To: Alexander Spiteri cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14009: pg_restore not restoring privilegs when one login/group role is missing In-reply-to: References: <20160309151510.8903.22052@wrigleys.postgresql.org> <20365.1457555577@sss.pgh.pa.us> Comments: In-reply-to Alexander Spiteri message dated "Thu, 10 Mar 2016 10:24:15 +0100" Date: Thu, 10 Mar 2016 11:24:54 -0500 Message-ID: <4509.1457627094@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Alexander Spiteri 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