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 1rSggD-00FGVV-HO for pgsql-docs@arkaria.postgresql.org; Wed, 24 Jan 2024 17:04:50 +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 1rSggC-006g9C-Mi for pgsql-docs@arkaria.postgresql.org; Wed, 24 Jan 2024 17:04:48 +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 1rSgep-006e3a-11 for pgsql-docs@lists.postgresql.org; Wed, 24 Jan 2024 17:03:23 +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 1rSgem-003VO2-P2 for pgsql-docs@lists.postgresql.org; Wed, 24 Jan 2024 17:03:22 +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 40OH3ErJ166814; Wed, 24 Jan 2024 12:03:14 -0500 From: Tom Lane To: "David G. Johnston" cc: Laurenz Albe , gparc@free.fr, Daniel Gustafsson , pgsql-docs Subject: Re: SQL command : ALTER DATABASE OWNER TO In-reply-to: References: <2023185982.281851219.1646733038464.JavaMail.root@zimbra15-e2.priv.proxad.net> <1712096587.208766558.1706090901073.JavaMail.zimbra@free.fr> <1327973565.212682013.1706107220766.JavaMail.zimbra@free.fr> Comments: In-reply-to "David G. Johnston" message dated "Wed, 24 Jan 2024 08:47:06 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <166812.1706115794.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Wed, 24 Jan 2024 12:03:14 -0500 Message-ID: <166813.1706115794@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Wed, Jan 24, 2024 at 8:35 AM Laurenz Albe > wrote: >> The permissions are transferred to the new owner, so the old owner doesn't >> have any privileges on the object (and, in your case, cannot connect to >> the database any more). > I dislike this change, ownership of an object is completely independent of > the grant system of privileges. The granted privileges of the old row do > not transfer to the new owner when alter ... owner to is executed. The > separate object attribute "owner" is the only thing that changes. Laurenz is correct, as you can easily find out by testing. For example, regression=# create user joe; CREATE ROLE regression=# create database joe owner joe; CREATE DATABASE regression=# grant connect on database joe to joe; GRANT regression=# select datacl from pg_database where datname = 'joe'; datacl ----------------------- {=Tc/joe,joe=CTc/joe} (1 row) regression=# create user bob; CREATE ROLE regression=# alter database joe owner to bob; ALTER DATABASE regression=# select datacl from pg_database where datname = 'joe'; datacl ----------------------- {=Tc/bob,bob=CTc/bob} (1 row) If no explicit GRANTs have ever been done, so that the ACL column is null, then it stays null --- but that has the same effect, because the default privileges implied by the null entry now attach to the new owner. For myself, I thought Laurenz's proposed patch is an improvement. regards, tom lane