From 1cc43979cf44db0b3da77e34493689fe13484fa0 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Fri, 25 Jan 2013 09:44:14 +0100 Subject: Make pg_dump exclude unlogged table data on hot standby slaves Noted by Joe Van Dyk --- src/bin/pg_dump/pg_dump.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index d6e4220ad5a..bef2b430fe7 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -652,6 +652,24 @@ main(int argc, char **argv) if (g_fout->remoteVersion < 90100) 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. */ -- cgit v1.2.3