Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r32n4-001wqu-KH for pgsql-admin@arkaria.postgresql.org; Tue, 14 Nov 2023 23:25:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r32n2-00BlBv-Ks for pgsql-admin@arkaria.postgresql.org; Tue, 14 Nov 2023 23:25:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r32n2-00BlBm-9e for pgsql-admin@lists.postgresql.org; Tue, 14 Nov 2023 23:25:52 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r32mz-006TFg-Oq for pgsql-admin@lists.postgresql.org; Tue, 14 Nov 2023 23:25:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3AENPkV72543036; Tue, 14 Nov 2023 18:25:46 -0500 From: Tom Lane To: Andres Freund cc: Aditya D , pgsql-admin Subject: Re: pg_restore -L reordering of the statements does not work In-reply-to: <20231114231347.lmnu5q5t7yq62vga@awork3.anarazel.de> References: <1589825.1698431686@sss.pgh.pa.us> <20231114194933.ci3nxol3avtisyrs@awork3.anarazel.de> <2522830.1699994542@sss.pgh.pa.us> <20231114222743.x2c2r74ttgom2cfx@awork3.anarazel.de> <2537261.1700001602@sss.pgh.pa.us> <20231114231347.lmnu5q5t7yq62vga@awork3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Tue, 14 Nov 2023 15:13:47 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2543034.1700004346.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 14 Nov 2023 18:25:46 -0500 Message-ID: <2543035.1700004346@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > On 2023-11-14 17:40:02 -0500, Tom Lane wrote: >> ... no, it should be for the user executing the ALTER to have permissio= n. > That check succeed - what fails is a check on the new owner of the table= . See > tablecmds.c ATExecChangeOwner: > /* New owner must have CREATE privilege on namespace */ > aclresult =3D object_aclcheck(NamespaceRelationId, names= paceOid, newOwnerId, > ACL_CREATE); Oh! I was just thinking about the initial object-lookup check, I'd forgotten about the one in the ALTER OWNER code itself. Hm. The intent of that check is to ensure that the ALTER doesn't produce a situation that the object-recipient user couldn't have created by himself. But I wonder if that's too narrow-minded, and we should craft a new rule that allows things dependent on only the calling user's permissions. Maybe allow if either the calling user or the recipient has CREATE on the schema? Or allow if calling user has ownership on the schema (implying that he could temporarily GRANT the necessary rights and then undo it)? Either of those would legitimize what pg_dump wants to do. This is getting way off-topic for pgsql-admin, btw. regards, tom lane