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.