diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index d50561f88b2..d0f53e8cc62 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -441,6 +441,9 @@ main(int argc, char *argv[]) fprintf(OPF, "\\connect postgres\n\n"); + /* Restore will need to write to the target cluster */ + fprintf(OPF, "SET default_transaction_read_only = off;\n\n"); + /* Replicate encoding and std_strings in output */ fprintf(OPF, "SET client_encoding = '%s';\n", pg_encoding_to_char(encoding)); @@ -1550,6 +1553,17 @@ dumpDatabases(PGconn *conn) fprintf(OPF, "\\connect %s\n\n", fmtId(dbname)); + /* + * Restore will need to write to the target cluster. This connection + * setting is emitted for pg_dumpall rather than in the code also used + * by pg_dump, so that a cluster with databases or users which have + * this flag turned on can still be replicated through pg_dumpall + * without editing the file or stream. With pg_dump there are many + * other ways to allow the file to be used, and leaving it out allows + * users to protect databases from being accidental restore targets. + */ + fprintf(OPF, "SET default_transaction_read_only = off;\n\n"); + if (filename) fclose(OPF);