0001-Fix-backpatch-of-unlogged-table-check-for-pg_dump.patch
text/x-patch
Filename: 0001-Fix-backpatch-of-unlogged-table-check-for-pg_dump.patch
Type: text/x-patch
Part: 0
Patch
Format: unified
Series: patch 0001
| File | + | − |
|---|---|---|
| src/bin/pg_dump/pg_dump.c | 18 | 2 |
>From c6a4ffe4c70a861c676a2447dfd3ab518d2e2f2b Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Fri, 25 Jan 2013 13:21:03 +0100
Subject: [PATCH] Fix backpatch of unlogged table check for pg_dump
The previous commit used ExecuteSqlQueryForSingleRow which is only there in
9.2+.
---
src/bin/pg_dump/pg_dump.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index bef2b43..964823f 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -656,9 +656,25 @@ main(int argc, char **argv)
* 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)
+ if (g_fout->remoteVersion >= 90000)
{
- PGresult *res = ExecuteSqlQueryForSingleRow(fout, "SELECT pg_catalog.pg_is_in_recovery()");
+ PGresult *res;
+ const char *query = "SELECT pg_catalog.pg_is_in_recovery()";
+ int ntups;
+
+ res = PQexec(g_conn, query);
+ check_sql_result(res, g_conn, query, PGRES_TUPLES_OK);
+ ntups = PQntuples(res);
+
+ if (ntups != 1)
+ {
+ write_msg(NULL, ngettext("query returned %d row instead of one: %s\n",
+ "query returned %d rows instead of one: %s\n",
+ ntups),
+ ntups, query);
+ exit_nicely();
+ }
+
if (strcmp(PQgetvalue(res, 0, 0), "t") == 0)
{
/*
--
1.7.12.289.g0ce9864.dirty