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 1hq3eq-000375-IV for pgsql-general@arkaria.postgresql.org; Tue, 23 Jul 2019 22:53:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hq3dr-0006AP-AN for pgsql-general@arkaria.postgresql.org; Tue, 23 Jul 2019 22:52:19 +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 1hq3dr-00067S-0E for pgsql-general@lists.postgresql.org; Tue, 23 Jul 2019 22:52:19 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hq3dk-0001vM-8o for pgsql-general@lists.postgresql.org; Tue, 23 Jul 2019 22:52:18 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 33C3221F57; Tue, 23 Jul 2019 18:52:11 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 23 Jul 2019 18:52:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=h lIqEPKLQ0hSBzu7sNT3CEeX7rxxSYgmmGHqyOeYtso=; b=YTAkIPrZEJN7YtvWw ju47azlmI2wj2CbxCVgWgk6Ptpn+NZLBiVyN5aEUVI2+LQ9qgBsfl+zMM/bsUHWR fA+98vCPtF3e/zznSuEXZADLf21ERmWHKD/oahqBhl1vWjB0JjhlMUfdi2iork0P Gc5hWRBfL39Swf/Y3XInJQS1mkPGFpRlXtfe1WOsM1cD9Tpbmq3/yhf9nc1kaFaR YfV83FxrNgg/u83jlVvo0iIgl6gywLlaS4vGmqUXmnana696dSNureqNOZyGq7y6 u7P0+h+9SyGOE3TN+7+tqnADIWwc4+IkrM/hahGJyuWrYbwww2E4MhjF0G980Bp5 4bzLg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=hlIqEPKLQ0hSBzu7sNT3CEeX7rxxSYgmmGHqyOeYt so=; b=Qmg75XNyjJ1FFpeY6MdXKDDdOltG7P+pUi5+n4v9NjwmwDHLI20eeiQn2 Sw0peiHdM4eGGZofmgHsIozcp6RIpGSRFWiM0Q/Ahul/NOEhc/ydqdehtaE1hM68 oVx1QvwtGXiGAjEEAFIMzuF1bVIR83epL0Qa5Ki4SHF4rLoYay+lBempgsBpR924 NBVQw0KGYAFZo9jXPfIJnHB710GHIejRmQF8/1F636SNg0n/PWBCiNvS4y8kkTVR /UKZ+aywYlJCVeu5UBiTyBQKhANZd185qAgrv9ZWGWzMFACiWsJibyc/JH4tDw0z IjysuYBH/Ce1yyU/Mbe10gTJX6J8g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrjeelgdduhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghenucfkphepjeefrddvfeel rdduudejrddvfeeknecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrg hvvghrsegrkhhlrghvvghrrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from ranger.suse (c-73-239-117-238.hsd1.wa.comcast.net [73.239.117.238]) by mail.messagingengine.com (Postfix) with ESMTPA id 46997380079; Tue, 23 Jul 2019 18:52:10 -0400 (EDT) Subject: Re: pg_dump schema in pg11 without global permissions To: Sergey Koposov , "pgsql-general@lists.postgresql.org" References: <1563920367.29206.91.camel@cmu.edu> <3c27ead3-134a-d27d-1097-684af2e6a811@aklaver.com> <1563920629.29206.93.camel@cmu.edu> <1563921764.29206.97.camel@cmu.edu> From: Adrian Klaver Message-ID: Date: Tue, 23 Jul 2019 15:52:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <1563921764.29206.97.camel@cmu.edu> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 7/23/19 3:42 PM, Sergey Koposov wrote: > On Tue, 2019-07-23 at 15:37 -0700, Adrian Klaver wrote: >> On 7/23/19 3:23 PM, Sergey Koposov wrote: >>> >>> On Tue, 2019-07-23 at 15:21 -0700, Adrian Klaver wrote: >>>> >>>> On 7/23/19 3:19 PM, Sergey Koposov wrote: >>>>> >>>>> >>>>> Hi, >>>>> >>>>> I'm trying to copy a schema from one PG database (ver 11) to PG 10. >>>>> Previously the first database version was 9.6 and the way I did the copying was >>>>> >>>>> ssh -o Compression=no user@host '/opt/pgsql/bin/pg_dump --no-tablespaces -n schemaname -Fc  -U dbadmin dbname'  | pg_restore -U dbadmin -h localhost -1 -d dbnme >>>>> >>>>> However after migrating from PG 9.6 to 11, when I did the same thing as before, I started getting a bunch of commands in the dump like this >>>>> >>>>> GRANT CONNECT ON DATABASE dbname TO usernameXX; >>>>> >>>>> which don't work for me because the list of users is different between different machines. >>>>> It is clear that the change is related to the way pg_dump is implemented now in PG11 that global objects are dumped. >>>>> But the question is how do I duplicate the previous behaviour, i.e. Dump just the schema and permission on the schema, not on the database. >>>> https://www.postgresql.org/docs/11/app-pgdump.html >>>> >>>> -x >>>> --no-privileges >>>> --no-acl >>>> >>>>       Prevent dumping of access privileges (grant/revoke commands). >>> Yes I saw that, but that will not dump privileges on the schema itself, which were dumped before as far as I understand ... >> So the roles for the schema don't change, but everything else does? > > The schema permissions are granted to a generic user 'dbuser'. And a bunch of users are members of this role and that's how they access the schema. > The database permissions on the other hand are granted specifically per individual user. What version of pg_dump are you using? When I dump a version 10 database using a version 11 pg_dump I do not see: GRANT CONNECT ON DATABASE pg_dump -Fc -n utility -s -d production -U postgres -p 5422 -f schema_test.out pg_restore -f schema_test_fc.sql schema_test.out aklaver@ranger:~> grep CONNECT schema_test_fc.sql aklaver@ranger:~> > > I am not saying this is optimal, but it would be very annoying if now it became impossible to deal with this... > >       S > -- Adrian Klaver adrian.klaver@aklaver.com