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

Commit65fc0ab

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

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
@@ -603,6 +603,24 @@ main(int argc, char **argv)
603603
if (fout->remoteVersion<90100)
604604
no_security_labels=1;
605605

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp