Re: pg_dumpall can't be restored with different bootstrap superuser

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Euler Taveira" <euler(at)eulerto(dot)com>
Cc: Álvaro Rodríguez <alvaro(at)datadoghq(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org, "Javier Maellas" <javier(dot)maellas(at)datadoghq(dot)com>, "Diego Revenga" <diego(dot)revengagonzalez(at)datadoghq(dot)com>, Nathan Bossart <nathandbossart(at)gmail(dot)com>
Subject: Re: pg_dumpall can't be restored with different bootstrap superuser
Date: 2026-05-05 19:10:47
Message-ID: 671134.1778008247@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Euler Taveira" <euler(at)eulerto(dot)com> writes:
> On Tue, May 5, 2026, at 7:51 AM, Álvaro Rodríguez wrote:
>> We have hit an issue with pg_dumpall --roles-only where the role grants
>> to other roles can't be reapplied in a clean database, if the bootstrap
>> superuser does not have the same name in both databases.

> This is not a bug. There is no way that pg_dumpall knows that the bootstrap
> user you want is another one.

I don't think that pg_dumpall is to be blamed; this is the backend's
fault. I thought we had made this better in dd1398f13, but it still
seems rather bogus:

regression=# create user super with superuser;
CREATE ROLE
regression=# create user a;
CREATE ROLE
regression=# create user b;
CREATE ROLE
regression=# grant a to b granted by super;
ERROR: permission denied to grant privileges as role "super"
DETAIL: The grantor must have the ADMIN option on role "a".

Surely a superuser should be considered to have admin options
on everything. Even more bogus, compare these results:

regression=# \c - super
You are now connected to database "regression" as user "super".
regression=# grant a to b granted by super;
ERROR: permission denied to grant privileges as role "super"
DETAIL: The grantor must have the ADMIN option on role "a".

regression=# grant a to b;
GRANT ROLE

Anyone would think that "GRANTED BY current_user" has the
same effect as omitting the clause, but here it doesn't.

So it seems to me that we're missing a superuserness check
somewhere in this, but I'm not entirely sure which bit of
code to blame.

I agree that the answer for existing branches is probably
going to be "so don't do that", but maybe we can improve
this in v19 or later.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Nathan Bossart 2026-05-05 19:40:49 Re: pg_dumpall can't be restored with different bootstrap superuser
Previous Message David G. Johnston 2026-05-05 18:59:48 Re: pg_dumpall can't be restored with different bootstrap superuser