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 1tIsNl-00HDHb-GL for pgsql-bugs@arkaria.postgresql.org; Wed, 04 Dec 2024 16:37:45 +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 1tIsNi-001Hx6-Se for pgsql-bugs@arkaria.postgresql.org; Wed, 04 Dec 2024 16:37:44 +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 1tIsNi-001Hwy-KZ for pgsql-bugs@lists.postgresql.org; Wed, 04 Dec 2024 16:37:43 +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 1tIsNg-0012gh-Sg for pgsql-bugs@lists.postgresql.org; Wed, 04 Dec 2024 16:37:43 +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 4B4Gbcx12363023; Wed, 4 Dec 2024 11:37:38 -0500 From: Tom Lane To: AKASH cc: pgsql-bugs@lists.postgresql.org Subject: Re: Issue with pg_dump Including Ownership Metadata for pg_trgm Extension in PostgreSQL 17 In-reply-to: References: Comments: In-reply-to AKASH message dated "Wed, 04 Dec 2024 15:12:21 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2363021.1733330258.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 04 Dec 2024 11:37:38 -0500 Message-ID: <2363022.1733330258@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk AKASH writes: > Steps to reproduce: > 1. Install the pg_trgm extension. > 2. Change the ownership of the objects created by the extension. We don't support *any* hand modification of extension member objects, other than grant/revoke operations. Having said that, pg_dump doesn't record ownership of extension members, because it doesn't record extension members. What it emits is CREATE EXTENSION, plus possibly GRANT/REVOKE if any member objects' permissions have changed since the original CREATE EXTENSION. > 4. Restore the dump in a different environment where ownership constr= aints > differ. What is happening there is not what you claim. What is happening is that the CREATE EXTENSION is run by the restoring user, who becomes the owner of the extension and its contained objects. In the original conception of extensions, this didn't matter a lot: the owner pretty much had to be a superuser, and since all superusers are interchangeable from a permissions standpoint, it didn't matter if it was a different superuser in the restored database. Since we invented "trusted" extensions, the owner of the extension itself could be a non-superuser. pg_dump fails to reproduce that (with or without --no-owner), and that's a deficiency we should fix but haven't yet. However, the individual objects in such an extension are still owned by a superuser for security reasons we needn't get into here. That being the case, it still doesn't matter too much which superuser that is. > Actual behavior: Ownership metadata is still included in the dump, causi= ng > issues when restoring to different environments. If you can provide any evidence that that actually happens, I'd be interested to see it. I just re-tested the point and what I see in the dump has nothing about extension member objects. There is -- -- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: - -- CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public; and nothing else. > I would appreciate any assistance in resolving this issue, or any guidan= ce > on how to work around this limitation in the meantime. Changing extension member objects directly (not through an extension update script) is not supported and is unlikely ever to be supported. The reason is that you lose any ability to re-create the state of the extension when you make changes that aren't memorialized in an update script. The sole exception to that is that we do track manual granting/revoking of permissions ... and that's proven to be enough of a mess that nobody is likely to consider extending it to any other object properties. Rethink whatever it is you're doing that leads to wanting to do that. regards, tom lane