diff options
author | Magnus Hagander <magnus@hagander.net> | 2013-01-25 09:44:14 +0100 |
---|---|---|
committer | Magnus Hagander <magnus@hagander.net> | 2013-01-25 09:46:07 +0100 |
commit | be926474be57ae73ae2052b968fd785a0096514e (patch) | |
tree | 9f0932d9625ff3debe8fdeb6180abe1dd5f40ef9 /src | |
parent | 760f3c043ad4ee622b596d005ec31bb5e0322c4a (diff) | |
download | postgresql-be926474be57ae73ae2052b968fd785a0096514e.tar.gz postgresql-be926474be57ae73ae2052b968fd785a0096514e.zip |
Make pg_dump exclude unlogged table data on hot standby slaves
Noted by Joe Van Dyk
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_dump/pg_dump.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 6295b5bf2cc..9f1ef32b158 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -606,6 +606,24 @@ main(int argc, char **argv) no_security_labels = 1; /* + * When running against 9.0 or later, check if we are in recovery mode, + * which means we are on a hot standby. + */ + if (fout->remoteVersion >= 90000) + { + PGresult *res = ExecuteSqlQueryForSingleRow(fout, "SELECT pg_catalog.pg_is_in_recovery()"); + if (strcmp(PQgetvalue(res, 0, 0), "t") == 0) + { + /* + * On hot standby slaves, never try to dump unlogged table data, + * since it will just throw an error. + */ + no_unlogged_table_data = true; + } + PQclear(res); + } + + /* * Start transaction-snapshot mode transaction to dump consistent data. */ ExecuteSqlStatement(fout, "BEGIN"); |