| From: | Josef Šimánek <josef(dot)simanek(at)gmail(dot)com> |
|---|---|
| To: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> |
| Cc: | Daniel Gustafsson <daniel(at)yesql(dot)se>, gparc(at)free(dot)fr, pgsql-docs <pgsql-docs(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: SQL command : ALTER DATABASE OWNER TO |
| Date: | 2025-11-02 17:25:01 |
| Message-ID: | CAFp7Qwo=FxcLS23-XkJ+sXmUECfnVZkXo96ru=X9JG+g_62J5A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-docs |
ne 2. 11. 2025 v 18:23 odesílatel Laurenz Albe
<laurenz(dot)albe(at)cybertec(dot)at> napsal:
>
> On Wed, 2024-01-24 at 15:26 +0100, Daniel Gustafsson wrote:
> > > On 24 Jan 2024, at 15:23, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> wrote:
> > >
> > > On Wed, 2024-01-24 at 11:08 +0100, gparc(at)free(dot)fr wrote:
> > > > for this "ALTER DATABASE" form, it should be mentioned that after execution of the command,
> > > > the old database owner loses all his privileges on it (even connection) although it might
> > > > still owns schemas or objects (tables, index,...) inside it.
> > > >
> > > > Thanks in advance to add this important precision.
> > >
> > > How about this:
> > >
> > > diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
> > > index 4044f0908f..44042f863c 100644
> > > --- a/doc/src/sgml/ddl.sgml
> > > +++ b/doc/src/sgml/ddl.sgml
> > > @@ -1891,6 +1891,8 @@ ALTER TABLE <replaceable>table_name</replaceable> OWNER TO <replaceable>new_owne
> > > Superusers can always do this; ordinary roles can only do it if they are
> > > both the current owner of the object (or inherit the privileges of the
> > > owning role) and able to <literal>SET ROLE</literal> to the new owning role.
> > > + All object privileges of the old owner are transferred to the new owner
> > > + along with the ownership.
> > > </para>
> >
> > Doesn't seem unreasonable to me, it won't make the docs harder to read and use
> > for experienced users while it may make them easier to follow for new users.
>
> Here is a patch for this change.
Did a quick test: during review
retro=# CREATE USER josef;
CREATE DATABASE testdb OWNER josef;
GRANT ALL ON DATABASE testdb TO josef;
CREATE ROLE
CREATE DATABASE
GRANT
retro=# \l testdb
List of databases
Name | Owner | Encoding | Locale Provider | Collate | Ctype
| ICU Locale | ICU Rules | Access privileges
--------+-------+----------+-----------------+-------------+-------------+------------+-----------+-------------------
testdb | josef | UTF8 | libc | cs_CZ.UTF-8 |
cs_CZ.UTF-8 | | | =Tc/josef +
| | | | |
| | | josef=CTc/josef
(1 row)
retro=# ALTER DATABASE testdb OWNER TO retro;
ALTER DATABASE
retro=# \l testdb
List of databases
Name | Owner | Encoding | Locale Provider | Collate | Ctype
| ICU Locale | ICU Rules | Access privileges
--------+-------+----------+-----------------+-------------+-------------+------------+-----------+-------------------
testdb | retro | UTF8 | libc | cs_CZ.UTF-8 |
cs_CZ.UTF-8 | | | =Tc/retro +
| | | | |
| | | retro=CTc/retro
(1 row)
It works exactly as described in this patch. +1
> Yours,
> Laurenz Albe
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Adrián Cuadrado Chavarría | 2025-11-02 19:17:33 | Re: Feature request: Add a llms.txt file to the docs for AIs to learn |
| Previous Message | Laurenz Albe | 2025-11-02 08:58:08 | Re: Feature request: Add a llms.txt file to the docs for AIs to learn |