Re: Feature bug dumpall CREATE ROLE postgres - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: Feature bug dumpall CREATE ROLE postgres
Date
Msg-id CAKFQuwag7VP3Xz=U1xUwCLXo_CGiE5ZBBsjBR+MGhLbvMxP+Ww@mail.gmail.com
Whole thread Raw
In response to Re: Feature bug dumpall CREATE ROLE postgres  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On Tue, Feb 27, 2024 at 1:12 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Jim Wilson <jim@wreath.com> writes:
> Including "CREATE ROLE postgres;" in the dumpall will cause the script to
> throw an error.

I believe the reason pg_dumpall does that is to avoid worse failures
if the target installation has a different bootstrap superuser name
than the source did.  One error is easier to ignore than hundreds
of 'em.

Why are we catering to the 0.0001 percent here?

Put this in the dumpall file instead of a create role command:
pseudo-code
DO $$
if 10::oid::regrole != 'postgres' then
raise error 'bootstrap superuser is named postgres in source database'
raise error 'either rename your bootstrap superuser to postgres or create a new superuser named postgres'
end if;
$$;

Or, any chance we can just write:

alter table tbl owner to 10::oid;

and not care what specific label the bootstrap superuser is using?

More simply I suppose is to have an option on pg_dumpall to omit the bootstrap superuser create role command to at least avoid having people have to modify the dump file after the fact.

David J.


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Feature bug dumpall CREATE ROLE postgres
Next
From: PG Bug reporting form
Date:
Subject: BUG #18369: logical decoding core on AssertTXNLsnOrder()