v31-0005-Refactoring-pg_dumpall-functions.patch
application/octet-stream
Filename: v31-0005-Refactoring-pg_dumpall-functions.patch
Type: application/octet-stream
Part: 4
Message:
Re: new heapcheck contrib module
Patch
Format: format-patch
Series: patch v31-0005
Subject: Refactoring pg_dumpall functions.
| File | + | − |
|---|---|---|
| src/bin/pg_dump/pg_dumpall.c | 3 | 28 |
From 68fd186541af667729795561b3ddbe248ed348fe Mon Sep 17 00:00:00 2001
From: Mark Dilger <mark.dilger@enterprisedb.com>
Date: Wed, 6 Jan 2021 13:37:42 -0800
Subject: [PATCH v31 5/9] Refactoring pg_dumpall functions.
The functions executeQuery and executeCommand in pg_dumpall.c were
not refactored in prior commits along with functions from
pg_backup_db.c because they were in a separate file, but now that
the infrastructure has been moved to fe_utils/query_utils,
refactoring these two functions to use it.
---
src/bin/pg_dump/pg_dumpall.c | 31 +++----------------------------
1 file changed, 3 insertions(+), 28 deletions(-)
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 85d08ad660..807226537a 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -23,6 +23,7 @@
#include "common/logging.h"
#include "common/string.h"
#include "dumputils.h"
+#include "fe_utils/query_utils.h"
#include "fe_utils/string_utils.h"
#include "getopt_long.h"
#include "pg_backup.h"
@@ -1874,21 +1875,8 @@ constructConnStr(const char **keywords, const char **values)
static PGresult *
executeQuery(PGconn *conn, const char *query)
{
- PGresult *res;
-
pg_log_info("executing %s", query);
-
- res = PQexec(conn, query);
- if (!res ||
- PQresultStatus(res) != PGRES_TUPLES_OK)
- {
- pg_log_error("query failed: %s", PQerrorMessage(conn));
- pg_log_error("query was: %s", query);
- PQfinish(conn);
- exit_nicely(1);
- }
-
- return res;
+ return ExecuteSqlQuery(conn, query, PGRES_TUPLES_OK);
}
/*
@@ -1897,21 +1885,8 @@ executeQuery(PGconn *conn, const char *query)
static void
executeCommand(PGconn *conn, const char *query)
{
- PGresult *res;
-
pg_log_info("executing %s", query);
-
- res = PQexec(conn, query);
- if (!res ||
- PQresultStatus(res) != PGRES_COMMAND_OK)
- {
- pg_log_error("query failed: %s", PQerrorMessage(conn));
- pg_log_error("query was: %s", query);
- PQfinish(conn);
- exit_nicely(1);
- }
-
- PQclear(res);
+ PQclear(ExecuteSqlQuery(conn, query, PGRES_COMMAND_OK));
}
--
2.21.1 (Apple Git-122.3)