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

Commit1cc4397

Browse files
committed
Make pg_dump exclude unlogged table data on hot standby slaves
Noted by Joe Van Dyk
1 parent49e0ea5 commit1cc4397

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

‎doc/src/sgml/ref/pg_dump.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,8 @@ PostgreSQL documentation
678678
<para>
679679
Do not dump the contents of unlogged tables. This option has no
680680
effect on whether or not the table definitions (schema) are dumped;
681-
it only suppresses dumping the table data.
681+
it only suppresses dumping the table data. Data in unlogged tables
682+
is always excluded when dumping from a standby server.
682683
</para>
683684
</listitem>
684685
</varlistentry>

‎src/bin/pg_dump/pg_dump.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,24 @@ main(int argc, char **argv)
652652
if (g_fout->remoteVersion<90100)
653653
no_security_labels=1;
654654

655+
/*
656+
* When running against 9.0 or later, check if we are in recovery mode,
657+
* which means we are on a hot standby.
658+
*/
659+
if (fout->remoteVersion >=90000)
660+
{
661+
PGresult*res=ExecuteSqlQueryForSingleRow(fout,"SELECT pg_catalog.pg_is_in_recovery()");
662+
if (strcmp(PQgetvalue(res,0,0),"t")==0)
663+
{
664+
/*
665+
* On hot standby slaves, never try to dump unlogged table data,
666+
* since it will just throw an error.
667+
*/
668+
no_unlogged_table_data= true;
669+
}
670+
PQclear(res);
671+
}
672+
655673
/*
656674
* Start transaction-snapshot mode transaction to dump consistent data.
657675
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp