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 1hTKi0-0005Mw-NN for pgsql-bugs@arkaria.postgresql.org; Wed, 22 May 2019 06:26:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hTKhy-0003ri-MA for pgsql-bugs@arkaria.postgresql.org; Wed, 22 May 2019 06:26:38 +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 1hTKhw-0003ra-Up for pgsql-bugs@lists.postgresql.org; Wed, 22 May 2019 06:26:38 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hTKht-0007hh-0d for pgsql-bugs@lists.postgresql.org; Wed, 22 May 2019 06:26:36 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id CB616245C9; Wed, 22 May 2019 02:26:30 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 22 May 2019 02:26:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=0s6aY8B59+6FQr5CXZ/6C4ftujI VmiY7c4o3Y6Vghjg=; b=v3Ce2WfNnbr/8zg8l5ierPANxxpvKSIQWxYSQxkiBZ1 9n3GKl40HV6iXytktcpPR/zJ6t8Q6wJu5oZzsLk68AVFK3nUglpGefx45j2lw2cS vacrLgxM2dpvDD32pQh2AuTYRB8UeSyIk2i0QWZSxemLoinTHBH3rJdAutv3rJ7K /foZEvaZrHnpHUgxNCEYte3wgjL0dp0H3gqbZi9RusSDRGsq6zmAjiQkXOP0yG/d 2qGLzWSLTjX3KPtSDcPSk7oqHq+f4LWr0cjb2JqNxawa/TRgoPkazGAdchlT8IfB Zi+U12V1nKQ87ey3sAxlo27uhFQQBdoLV3QMMmBukKg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm2; bh=0s6aY8 B59+6FQr5CXZ/6C4ftujIVmiY7c4o3Y6Vghjg=; b=sf3UmRl9f14CUIsXtMSwr9 jctMlO119426eT7BJMqCc3e294hY7g9z/2+5SoKdU+kvydaM2FWttJl02luhamLz aEF6pNbrAWCcW8+tcP169kyRbvrrkxWVS8eabAlMt6uuam21yxO7Im+0qxk9h/Am i2lcqgUS2K09h2293tSgtyoKrpVFLmtTYAeLSVmtnEvJKO8LUVbINjWQ9cq+deTe 5OldWIP4gxg9bLZvINSHJmXOCd6jLaBgjkqHBP0Nm8+v7e+uGgmViIzSwZwkRt+f Swm4v+gvdwl3HQ/jKAea5caA6tuQPfcO3NiRcGpfy8WBJfHaDcYYzvaeH0wWT7hQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudduuddguddtkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enfghrlhcuvffnffculdejtddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecukfhppeduuddurddutddvrddukedtrddukeehnecurfgr rhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiinecuve hluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 1962C380084; Wed, 22 May 2019 02:26:28 -0400 (EDT) Date: Wed, 22 May 2019 15:26:26 +0900 From: Michael Paquier To: "Bossart, Nathan" Cc: Haribabu Kommi , "pgsql-bugs@lists.postgresql.org" Subject: Re: BUG #15788: 'pg_dump --create' orders database GRANTs incorrectly Message-ID: <20190522062626.GC1486@paquier.xyz> References: <15788-4e18847520ebcc75@postgresql.org> <9C9271CF-9A7A-45AE-B034-1246A93788C9@amazon.com> <4D066CB2-B177-40B4-8510-9318B9A184CE@amazon.com> <20190504123221.GA2127@paquier.xyz> <0AF6E4BC-EE9A-4158-85BE-3EAE4308D228@amazon.com> <20190520082705.GA1921@paquier.xyz> <92E61F31-BD06-49B1-950F-8863239E342F@amazon.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="bAmEntskrkuBymla" Content-Disposition: inline In-Reply-To: <92E61F31-BD06-49B1-950F-8863239E342F@amazon.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --bAmEntskrkuBymla Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, May 20, 2019 at 10:37:50PM +0000, Bossart, Nathan wrote: > On 5/20/19, 1:27 AM, "Michael Paquier" wrote: >> I had first a hard time parsing the subqueries added, so I have >> tweaked your patch with more indentation, and a comment block with >> more details about why we need to preserve the ACL ordering (you will >> note that I don't have a lot of imagination here). >=20 > Thanks. Your version looks good to me. Okay, I have done more tests, checks and tweaks on this stuff, and pushed the fix for databases down to 9.6. Now, I have noticed two separate issues while testing:=20 1) We need a similar fix for tablespaces and pg_dumpall 1-1) Take for example this set of commands, reusing your previous example: \! rm -rf /tmp/tbspc/ \! mkdir -p /tmp/tbspc/ CREATE ROLE a_user; CREATE ROLE b_user WITH SUPERUSER; CREATE ROLE c_user; CREATE TABLESPACE poo LOCATION '/tmp/tbspc/'; SET SESSION AUTHORIZATION b_user; REVOKE ALL ON TABLESPACE poo FROM public; GRANT CREATE ON TABLESPACE poo TO c_user WITH GRANT OPTION; SET SESSION AUTHORIZATION c_user; GRANT CREATE ON TABLESPACE poo TO a_user; 1-2) And then run pg_dumpall -g (-t is fine but including roles ensures a correct test), where you will notice the following GRANT ordering: CREATE TABLESPACE poo OWNER ioltas LOCATION '/tmp/tbspc'; SET SESSION AUTHORIZATION c_user; GRANT ALL ON TABLESPACE poo TO a_user; -- breaks here RESET SESSION AUTHORIZATION; GRANT ALL ON TABLESPACE poo TO c_user WITH GRANT OPTION; The problem comes from dumpTablespaces() which still has a broken ACL ordering logic. I'll start a new thread about that as this thread is actually now fixed. It would be interesting to refactor all that stuff, but I'd like to think that it would be much more interesting if we could get pg_init_privs to work with databases and tablespace instead, but that would not be back-patchable. So I'll focus on the bug fix. 2) On HEAD, before the patch, I am able to trigger the following failure in libpq when using for example pg_dumpall and a 9.5 backend: pg_dump: column number -1 is out of range 0..36 I am not sure yet what's exactly causing that, but this is just a heads-up. -- Michael --bAmEntskrkuBymla Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlzk65IACgkQnvQgOdby QH0n+xAAqHQCk0U8Xtio6Ik25W4bstd/D6h2hae6j5VypSP7pDsiRUX5j/v461bD rjo46lBA7Zg3WmtFMn8O5UUTtfYdgLF0uXFd3+SrlcFEQcoG/fiyEM79NH3aujKJ /uRWEFiIhJV2A/GxwzYSXnzvVQ1XwmX0G0rjWH9+SiBr/8WiWtE8bxSIKKTFK38Q JMvgjl2KgIuvv2Zm11eao2pNdTzfYRtNbn2VjPugduqcZg0n3e/MI7laojN1ZmJ1 PYa5EZuEGieOAGdrBkBgz7oLzO0XfiiSxScE78zFCpsnfsXm2dQFZlOqWuxTy8e0 jBZqn2xJQLEGQJ2fM5199qFARtEv1pUAFWH/1MCVpJvTW8MRFsmNpajIKo+rJmDO dEPJ7Xpg7JH16gUTzx2Y7VPuRaN7SkqHw8EjivIEa2eHnERdtkhhdboqrcdOGq4N gfmPrJg+h1ZjRJo/V1B1gFPrJ7gxsirmmPrBjbsAjg4ZkwWIUGFyjlTOspoe81yY g+ED6P4oaw8yzAArUO+yABN7SgIO5GFjJgtlJbYvMbXcCP/EzXzqoSC+jI6OBa5n Bhq6dIAWCrAu/vM/CHrc/GcHlWzV+bi17xfpof2sAQJ4hAr4ZncpXtizaVEPhUmu cEXl/1PrklGrgba+NxHbGfFV0eRGEG1aHcYJC8j5JnLv5wSoRYc= =CJQ7 -----END PGP SIGNATURE----- --bAmEntskrkuBymla--