Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iFJY4-0000Cv-VG for pgsql-general@arkaria.postgresql.org; Tue, 01 Oct 2019 14:54:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iFJY3-0007d0-K1 for pgsql-general@arkaria.postgresql.org; Tue, 01 Oct 2019 14:54:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iFJY3-0007cc-9b for pgsql-general@lists.postgresql.org; Tue, 01 Oct 2019 14:54:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iFJXw-0007D9-NV for pgsql-general@lists.postgresql.org; Tue, 01 Oct 2019 14:54:42 +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 x91ErWnj006235; Tue, 1 Oct 2019 10:53:32 -0400 From: Tom Lane To: Mike Roest cc: pgsql-general@lists.postgresql.org Subject: Re: Schema dump/restore not restoring grants on the schema In-reply-to: References: Comments: In-reply-to Mike Roest message dated "Tue, 01 Oct 2019 06:02:17 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6233.1569941612.1@sss.pgh.pa.us> Date: Tue, 01 Oct 2019 10:53:32 -0400 Message-ID: <6234.1569941612@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Mike Roest writes: > Just trying to find out if something is intended behaviour. When doing a > schema filtered pg_dump the created dump file includes the grants on that > specific schema (in our case a grant usage to a unprivleged user) but doing > a pg_restore with a -n does not restore that grant however > individual grants on object within the filtered schema are restored. But > it's resulting in our unprivileged user not actually being able to access > the limited number of tables it should be able to as the grant usage on the > schema itself is being lost. Hm. The pg_dump man page says -n pattern --schema=pattern Dump only schemas matching pattern; this selects both the schema itself, and all its contained objects. while pg_restore says -n schema --schema=schema Restore only objects that are in the named schema. and the actual behavior seems consistent with that: pg_dump emits both a CREATE SCHEMA command and GRANTs for it, while pg_restore emits neither. So I guess this is working as documented, but it does seem not very nice that the two programs interpret the "same" switch differently. I suppose the reasoning is lost in the mists of time :-( Another thing that is not very nice is that pg_restore lacks the ability to use patterns (wildcards) here. Someday maybe somebody will get around to fixing that. I could see changing the definition of -n to include the schema itself at the same time. regards, tom lane