{
const char *remoteversion_str;
int remoteversion;
+ PGresult *res;
remoteversion_str = PQparameterStatus(AH->connection, "server_version");
remoteversion = PQserverVersion(AH->connection);
remoteversion_str, progname, PG_VERSION);
exit_horribly(NULL, "aborting because of server version mismatch\n");
}
+
+ /*
+ * When running against 9.0 or later, check if we are in recovery mode,
+ * which means we are on a hot standby.
+ */
+ if (remoteversion >= 90000)
+ {
+ res = ExecuteSqlQueryForSingleRow((Archive *) AH, "SELECT pg_catalog.pg_is_in_recovery()");
+
+ AH->public.isStandby = (strcmp(PQgetvalue(res, 0, 0), "t") == 0);
+ PQclear(res);
+ }
+ else
+ AH->public.isStandby = false;
}
/*
return res;
}
+/*
+ * Execute an SQL query and verify that we got exactly one row back.
+ */
+PGresult *
+ExecuteSqlQueryForSingleRow(Archive *fout, char *query)
+{
+ PGresult *res;
+ int ntups;
+
+ res = ExecuteSqlQuery(fout, query, PGRES_TUPLES_OK);
+
+ /* Expecting a single result only */
+ ntups = PQntuples(res);
+ if (ntups != 1)
+ exit_horribly(NULL,
+ ngettext("query returned %d row instead of one: %s\n",
+ "query returned %d rows instead of one: %s\n",
+ ntups),
+ ntups, query);
+
+ return res;
+}
+
/*
* Convenience function to send a query.
* Monitors result to detect COPY statements
static void appendReloptionsArrayAH(PQExpBuffer buffer, const char *reloptions,
const char *prefix, Archive *fout);
static char *get_synchronized_snapshot(Archive *fout);
-static PGresult *ExecuteSqlQueryForSingleRow(Archive *fout, char *query);
static void setupDumpWorker(Archive *AHX);
dopt.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.
+ * On hot standby slaves, never try to dump unlogged table data, since it
+ * will just throw an error.
*/
- 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.
- */
- dopt.no_unlogged_table_data = true;
- }
- PQclear(res);
- }
+ if (fout->isStandby)
+ dopt.no_unlogged_table_data = true;
/* Select the appropriate subquery to convert user IDs to names */
if (fout->remoteVersion >= 80100)
else if (AH->numWorkers > 1 &&
AH->remoteVersion >= 90200 &&
!dopt->no_synchronized_snapshots)
+ {
+ if (AH->isStandby)
+ exit_horribly(NULL,
+ "Synchronized snapshots are not supported on standby servers.\n"
+ "Run with --no-synchronized-snapshots instead if you do not need\n"
+ "synchronized snapshots.\n");
+
+
AH->sync_snapshot_id = get_synchronized_snapshot(AH);
+ }
}
static void
if (!res)
write_msg(NULL, "WARNING: could not parse reloptions array\n");
}
-
-/*
- * Execute an SQL query and verify that we got exactly one row back.
- */
-static PGresult *
-ExecuteSqlQueryForSingleRow(Archive *fout, char *query)
-{
- PGresult *res;
- int ntups;
-
- res = ExecuteSqlQuery(fout, query, PGRES_TUPLES_OK);
-
- /* Expecting a single result only */
- ntups = PQntuples(res);
- if (ntups != 1)
- exit_horribly(NULL,
- ngettext("query returned %d row instead of one: %s\n",
- "query returned %d rows instead of one: %s\n",
- ntups),
- ntups, query);
-
- return res;
-}