Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit52898e0

Browse files
committed
Fix pg_dumpall to work for databases flagged as read-only.
pg_dumpall's charter is to be able to recreate a database cluster'scontents in a virgin installation, but it was failing to honor thatcontract if the cluster had any ALTER DATABASE SETdefault_transaction_read_only settings. By including a SET commandfor the connection for each connection opened by pg_dumpall output,errors are avoided and the source cluster is successfullyrecreated.There was discussion of whether to also set this for the connectionapplying pg_dump output, but it was felt that it was both lessappropriate in that context, and far easier to work around.Backpatch to all supported branches.
1 parenta74f50a commit52898e0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,9 @@ main(int argc, char *argv[])
448448

449449
fprintf(OPF,"\\connect postgres\n\n");
450450

451+
/* Restore will need to write to the target cluster */
452+
fprintf(OPF,"SET default_transaction_read_only = off;\n\n");
453+
451454
/* Replicate encoding and std_strings in output */
452455
fprintf(OPF,"SET client_encoding = '%s';\n",
453456
pg_encoding_to_char(encoding));
@@ -1527,6 +1530,17 @@ dumpDatabases(PGconn *conn)
15271530

15281531
fprintf(OPF,"\\connect %s\n\n",fmtId(dbname));
15291532

1533+
/*
1534+
* Restore will need to write to the target cluster. This connection
1535+
* setting is emitted for pg_dumpall rather than in the code also used
1536+
* by pg_dump, so that a cluster with databases or users which have
1537+
* this flag turned on can still be replicated through pg_dumpall
1538+
* without editing the file or stream. With pg_dump there are many
1539+
* other ways to allow the file to be used, and leaving it out allows
1540+
* users to protect databases from being accidental restore targets.
1541+
*/
1542+
fprintf(OPF,"SET default_transaction_read_only = off;\n\n");
1543+
15301544
if (filename)
15311545
fclose(OPF);
15321546

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp