Re: createuser unexpectedly creates superuser with createdb and createrole - Mailing list pgsql-general

From Erik Wienhold
Subject Re: createuser unexpectedly creates superuser with createdb and createrole
Date
Msg-id 1624623948.136031.1693791136215@office.mailbox.org
Whole thread Raw
In response to Re: createuser unexpectedly creates superuser with createdb and createrole  (Laurenz Albe <laurenz.albe@cybertec.at>)
Responses Re: createuser unexpectedly creates superuser with createdb and createrole
List pgsql-general
On 30/08/2023 03:21 CEST Laurenz Albe <laurenz.albe@cybertec.at> wrote:

> I am somewhat surprised too, but it has been like that since commit 8ae0d476a9
> in 2005.

Yeah, unlikely to find out why after 18 years.

> The code is pretty clear about that:
>
>     if (superuser == TRI_YES)
>     {
>         /* Not much point in trying to restrict a superuser */
>         createdb = TRI_YES;
>         createrole = TRI_YES;
>     }
>
> I would say that changing that long standing behavior would cause more harm
> than benefit.

Sure, but it sounds like a reasonable change for a future major release.

> First, as the code says, it doesn't make a lot of difference.  And who knows,
> perhaps someone somewhere creates superusers, later changes them to NOSUPERUSER
> and expects CREATEDB and CREATEROLE to be set after that.

Just realized that the bootstrap user has all attributes even though not needed
as a superuser.  Maybe that's the reason for createuser's behavior.  But why
only CREATEDB and CREATEROLE then?

> If anything, we could add something to the documentation.

Anyway, I prepared a patch for the docs.  But I'm not sure if the description
should still read "There is no effective difference between creating users via
this utility and via other methods for accessing the server."

--
Erik
Attachment

pgsql-general by date:

Previous
From: Amn Ojee Uw
Date:
Subject: Re: PSQL = Yes ... JDBC = no ??
Next
From: Tom Lane
Date:
Subject: Re: createuser unexpectedly creates superuser with createdb and createrole