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 1rSg1z-00FCfs-5d for pgsql-docs@arkaria.postgresql.org; Wed, 24 Jan 2024 16:23:15 +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 1rSg1x-006HO6-NT for pgsql-docs@arkaria.postgresql.org; Wed, 24 Jan 2024 16:23:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rSg1x-006HNy-G4 for pgsql-docs@lists.postgresql.org; Wed, 24 Jan 2024 16:23:13 +0000 Received: from smtp3-g21.free.fr ([2a01:e0c:1:1599::12]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rSg1r-0039e3-Md for pgsql-docs@lists.postgresql.org; Wed, 24 Jan 2024 16:23:12 +0000 Received: from zimbra-e1-02.priv.proxad.net (unknown [172.20.243.240]) by smtp3-g21.free.fr (Postfix) with ESMTP id 2C1E913F92C; Wed, 24 Jan 2024 17:23:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=free.fr; s=smtp-20201208; t=1706113384; bh=85QVs0SFTs8rFnqO4xDnCKJ6RGse+IF2njvjpcm2rhQ=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=TM778uNDoLLsGgubpkvsm/BYQX78KlS6IwyYiaMPqiH+lCAh/v6bMKyGh5h3BYc/l pbzlgARVq2b3le57YuXze0TLHvrmByeSDIzv5hsTWAlIW3IQOhLS+8iGeqk2Fv62Sq XhqbLpGXrnQgVzxvfhhsClAD1japiLLgClFUkUf3TF2cdgYx2swa5BMQZyMYmw2a1R kR8UZdr69YPiJyxwoCUUP2LZuJ+t3JXAfIlhgOOl6t+9fqfnkakHyro5h4Fw5yY0hJ xg1vaskBHEjR76W8mHCCympnQXyAoNuTbUftoXifTzZ4f5r9AN7+WbVFR61j9CIzh7 vqfbArJNktoNw== Date: Wed, 24 Jan 2024 17:23:04 +0100 (CET) From: gparc@free.fr To: Laurenz Albe Cc: Daniel Gustafsson , pgsql-docs Message-ID: <176777248.214045315.1706113384094.JavaMail.zimbra@free.fr> 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> Subject: Re: SQL command : ALTER DATABASE OWNER TO MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [145.242.20.128] X-Mailer: Zimbra 9.0.0_GA_1337 (ZimbraWebClient - FF102 (Linux)/9.0.0_GA_1337) Thread-Topic: SQL command : ALTER DATABASE OWNER TO Thread-Index: +ht3wLlIujYDWcWncT7O+IVpVyZiiw== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ----- Mail original ----- De: "Laurenz Albe" =C3=80: "gparc" , "Daniel Gustafsson" Cc: "pgsql-docs" Envoy=C3=A9: Mercredi 24 Janvier 2024 16:35:10 Objet: Re: SQL command : ALTER DATABASE OWNER TO On Wed, 2024-01-24 at 15:40 +0100, gparc@free.fr wrote: > maybe a misunderstanding of my part, but your proposed modification doesn= 't matched > with the current behaviour of the command as precisely the object privile= ges of the old owner are **NOT** transferred > to the new owner along with the ownership But that is what happens. 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). Yours, Laurenz Albe Laurenz, may be better with an example to explain what I mean with "the old database= owner loses all his privileges on it (even connection) although it might still owns schemas or objects (tables, index,...) inside it" [postgres] $ psql psql (14.10) [postgres@PGDEV14] postgres=3D# create user tst password 'tst'; CREATE ROLE [postgres@PGDEV14] postgres=3D# create database tst owner =3D tst; CREATE DATABASE [postgres@PGDEV14] postgres=3D# grant all on database tst to tst; GRANT [postgres@PGDEV14] postgres=3D# \l+ tst Liste des bases de donn=C3=A9= es Nom | Propri=C3=A9taire | Encodage | Collationnement | Type caract. | Droi= ts d'acc=C3=A8s | Taille | Tablespace | Description -----+--------------+----------+-----------------+--------------+----------= ------+---------+------------+------------- tst | tst | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 | =3DTc/tst= +| 9809 kB | pg_default | | | | | | tst=3DCTc= /tst | | | (1 ligne) [postgres@PGDEV14] postgres=3D# \c tst tst Mot de passe pour l'utilisateur tst : Vous =C3=AAtes maintenant connect=C3=A9 =C3=A0 la base de donn=C3=A9es =C2= =AB tst =C2=BB en tant qu'utilisateur =C2=AB tst =C2=BB. [tst@PGDEV14] tst=3D> create schema tst; CREATE SCHEMA [tst@PGDEV14] tst=3D> create table t1 (x int); CREATE TABLE [tst@PGDEV14] tst=3D> \dn+ tst Liste des sch=C3=A9mas Nom | Propri=C3=A9taire | Droits d'acc=C3=A8s | Description -----+--------------+----------------+------------- tst | tst | | (1 ligne) [tst@PGDEV14] tst=3D> \dt+ t1 Liste des relations Sch=C3=A9ma | Nom | Type | Propri=C3=A9taire | Persistence | M=C3=A9thode= d'acc=C3=A8s | Taille | Description --------+-----+-------+--------------+-------------+-----------------+-----= ----+------------- tst | t1 | table | tst | permanent | heap | 0 by= tes | (1 ligne) [tst@PGDEV14] tst=3D> \c - postgres Vous =C3=AAtes maintenant connect=C3=A9 =C3=A0 la base de donn=C3=A9es =C2= =AB tst =C2=BB en tant qu'utilisateur =C2=AB postgres =C2=BB. [postgres@PGDEV14] tst=3D# alter database tst owner to postgres; ALTER DATABASE [postgres@PGDEV14] tst=3D# \l+ tst Liste des bases de donn=C3= =A9es Nom | Propri=C3=A9taire | Encodage | Collationnement | Type caract. | D= roits d'acc=C3=A8s | Taille | Tablespace | Description -----+--------------+----------+-----------------+--------------+----------= -------------+---------+------------+------------- tst | postgres | UTF8 | fr_FR.UTF-8 | fr_FR.UTF-8 | =3DTc/pos= tgres +| 9809 kB | pg_default | | | | | | postgres= =3DCTc/postgres | | | (1 ligne) [postgres@PGDEV14] tst=3D# \dn+ tst Liste des sch=C3=A9mas Nom | Propri=C3=A9taire | Droits d'acc=C3=A8s | Description -----+--------------+----------------+------------- tst | tst | | (1 ligne) [postgres@PGDEV14] tst=3D# \dt tst.t1 Liste des relations Sch=C3=A9ma | Nom | Type | Propri=C3=A9taire --------+-----+-------+-------------- tst | t1 | table | tst (1 ligne) Regards=20 Gilles