sanitize_globals_dump

Function sanitize_globals_dump 

Source
pub fn sanitize_globals_dump(path: &str) -> Result<()>
Expand description

Update a globals dump so duplicate role creation errors become harmless notices.

pg_dumpall --globals-only emits CREATE ROLE statements that fail if the role already exists on the target cluster. When an operator reruns replication against the same target, those statements cause psql to exit with status 3 which previously triggered noisy retries and prevented the rest of the globals from being applied. By wrapping each CREATE ROLE statement in a DO $$ ... EXCEPTION WHEN duplicate_object block, we allow Postgres to skip recreating existing roles while still applying subsequent ALTER ROLE and GRANT statements.