Re: BUG #19962: pg_dumpall can't produce restorable circular grants with ADMIN OPTION

From: buyu zi <zibuyu423(at)gmail(dot)com>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: Kirill Reshke <reshkekirill(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19962: pg_dumpall can't produce restorable circular grants with ADMIN OPTION
Date: 2026-12-03 14:47:16
Message-ID: CADbAUJLfs9xZ3uBVk5WdK3+RhqY-b+TifELYMXd5H=tVUU8Rcw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Alexander,

I reproduced the restore failure with your three-role example. Once
the original grant to r2 has been revoked, there is no order in which
pg_dumpall can replay the three remaining grants on their own.

The attached patch has pg_dumpall emit a temporary ADMIN grant when it
encounters such a cycle. A temporary SQL procedure replays the remaining
grants and removes the temporary grant in one call, so a failure rolls
back the intermediate privileges.

I tested both a roles-only dump and a pg_upgrade from 19.0 to 20devel.
In both cases the restored pg_auth_members rows matched the source,
including the grantor and the ADMIN, INHERIT and SET options. I also
checked that interrupting the script partway through the procedure
definition left no temporary ADMIN grant behind.

Does using a temporary procedure for this part of the dump seem
reasonable?

Regards,
zibuyu

On Thu, Dec 3, 2026 at 10:44 PM Alexander Lakhin <exclusion(at)gmail(dot)com>
wrote:

> Hello Kirill,
>
> 01.12.2026 12:40, Kirill Reshke wrote:
> > I had reported similar case which is real-life example from prod, JFYI
> >
> > [0]
> https://www.postgresql.org/message-id/CALdSSPiJUAO2VsWy3hvWghgThT%3DAwK5-HVrCp-%2BRYAiYiDjr4Q%40mail.gmail.com
>
> Yes, I saw that thread (and another one it references), but as patches
> proposed there don't address this issue, I decided to report it
> separately.
>
> Best regards,
> Alexander
>
>
>
>
>

Attachment Content-Type Size
19962-pg-dumpall.patch text/x-patch 11.7 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message buyu zi 2026-12-03 14:54:51 Re: BUG #19936: Planning is slower on 19.0 with many partial indexes on a SQL function
Previous Message Ishjaap Singh 2026-12-03 13:50:12 Re: BUG #19851: Adding a tautological CHECK(true) to a domain changes JSON_VALUE's result (silent NULL, value/type c