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

Commitbe92647

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

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
@@ -713,7 +713,8 @@ PostgreSQL documentation
713713
<para>
714714
Do not dump the contents of unlogged tables. This option has no
715715
effect on whether or not the table definitions (schema) are dumped;
716-
it only suppresses dumping the table data.
716+
it only suppresses dumping the table data. Data in unlogged tables
717+
is always excluded when dumping from a standby server.
717718
</para>
718719
</listitem>
719720
</varlistentry>

‎src/bin/pg_dump/pg_dump.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,24 @@ main(int argc, char **argv)
605605
if (fout->remoteVersion<90100)
606606
no_security_labels=1;
607607

608+
/*
609+
* When running against 9.0 or later, check if we are in recovery mode,
610+
* which means we are on a hot standby.
611+
*/
612+
if (fout->remoteVersion >=90000)
613+
{
614+
PGresult*res=ExecuteSqlQueryForSingleRow(fout,"SELECT pg_catalog.pg_is_in_recovery()");
615+
if (strcmp(PQgetvalue(res,0,0),"t")==0)
616+
{
617+
/*
618+
* On hot standby slaves, never try to dump unlogged table data,
619+
* since it will just throw an error.
620+
*/
621+
no_unlogged_table_data= true;
622+
}
623+
PQclear(res);
624+
}
625+
608626
/*
609627
* Start transaction-snapshot mode transaction to dump consistent data.
610628
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp