summaryrefslogtreecommitdiff
path: root/src/fe_utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/fe_utils')
-rw-r--r--src/fe_utils/archive.c35
-rw-r--r--src/fe_utils/connect_utils.c10
-rw-r--r--src/fe_utils/parallel_slot.c5
-rw-r--r--src/fe_utils/query_utils.c4
-rw-r--r--src/fe_utils/recovery_gen.c40
5 files changed, 24 insertions, 70 deletions
diff --git a/src/fe_utils/archive.c b/src/fe_utils/archive.c
index 361c1c25ead..53d42c2be41 100644
--- a/src/fe_utils/archive.c
+++ b/src/fe_utils/archive.c
@@ -49,10 +49,7 @@ RestoreArchivedFile(const char *path, const char *xlogfname,
xlogRestoreCmd = BuildRestoreCommand(restoreCommand, xlogpath,
xlogfname, NULL);
if (xlogRestoreCmd == NULL)
- {
- pg_log_fatal("cannot use restore_command with %%r placeholder");
- exit(1);
- }
+ pg_fatal("cannot use restore_command with %%r placeholder");
/*
* Execute restore_command, which should copy the missing file from
@@ -70,22 +67,16 @@ RestoreArchivedFile(const char *path, const char *xlogfname,
if (stat(xlogpath, &stat_buf) == 0)
{
if (expectedSize > 0 && stat_buf.st_size != expectedSize)
- {
- pg_log_fatal("unexpected file size for \"%s\": %lld instead of %lld",
- xlogfname, (long long int) stat_buf.st_size,
- (long long int) expectedSize);
- exit(1);
- }
+ pg_fatal("unexpected file size for \"%s\": %lld instead of %lld",
+ xlogfname, (long long int) stat_buf.st_size,
+ (long long int) expectedSize);
else
{
int xlogfd = open(xlogpath, O_RDONLY | PG_BINARY, 0);
if (xlogfd < 0)
- {
- pg_log_fatal("could not open file \"%s\" restored from archive: %m",
- xlogpath);
- exit(1);
- }
+ pg_fatal("could not open file \"%s\" restored from archive: %m",
+ xlogpath);
else
return xlogfd;
}
@@ -93,11 +84,8 @@ RestoreArchivedFile(const char *path, const char *xlogfname,
else
{
if (errno != ENOENT)
- {
- pg_log_fatal("could not stat file \"%s\": %m",
- xlogpath);
- exit(1);
- }
+ pg_fatal("could not stat file \"%s\": %m",
+ xlogpath);
}
}
@@ -108,11 +96,8 @@ RestoreArchivedFile(const char *path, const char *xlogfname,
* fatal too.
*/
if (wait_result_is_any_signal(rc, true))
- {
- pg_log_fatal("restore_command failed: %s",
- wait_result_to_str(rc));
- exit(1);
- }
+ pg_fatal("restore_command failed: %s",
+ wait_result_to_str(rc));
/*
* The file is not available, so just let the caller decide what to do
diff --git a/src/fe_utils/connect_utils.c b/src/fe_utils/connect_utils.c
index a30c66f13aa..f2e583f9fac 100644
--- a/src/fe_utils/connect_utils.c
+++ b/src/fe_utils/connect_utils.c
@@ -88,11 +88,8 @@ connectDatabase(const ConnParams *cparams, const char *progname,
conn = PQconnectdbParams(keywords, values, true);
if (!conn)
- {
- pg_log_error("could not connect to database %s: out of memory",
- cparams->dbname);
- exit(1);
- }
+ pg_fatal("could not connect to database %s: out of memory",
+ cparams->dbname);
/*
* No luck? Trying asking (again) for a password.
@@ -117,8 +114,7 @@ connectDatabase(const ConnParams *cparams, const char *progname,
PQfinish(conn);
return NULL;
}
- pg_log_error("%s", PQerrorMessage(conn));
- exit(1);
+ pg_fatal("%s", PQerrorMessage(conn));
}
/* Start strict; callers may override this. */
diff --git a/src/fe_utils/parallel_slot.c b/src/fe_utils/parallel_slot.c
index 5896a8a6ca0..684327885d3 100644
--- a/src/fe_utils/parallel_slot.c
+++ b/src/fe_utils/parallel_slot.c
@@ -298,10 +298,7 @@ connect_slot(ParallelSlotArray *sa, int slotno, const char *dbname)
sa->cparams->override_dbname = old_override;
if (PQsocket(slot->connection) >= FD_SETSIZE)
- {
- pg_log_fatal("too many jobs for this platform");
- exit(1);
- }
+ pg_fatal("too many jobs for this platform");
/* Setup the connection using the supplied command, if any. */
if (sa->initcmd)
diff --git a/src/fe_utils/query_utils.c b/src/fe_utils/query_utils.c
index 0b31b33f17b..2fc6e2405b4 100644
--- a/src/fe_utils/query_utils.c
+++ b/src/fe_utils/query_utils.c
@@ -31,7 +31,7 @@ executeQuery(PGconn *conn, const char *query, bool echo)
PQresultStatus(res) != PGRES_TUPLES_OK)
{
pg_log_error("query failed: %s", PQerrorMessage(conn));
- pg_log_info("query was: %s", query);
+ pg_log_error_detail("Query was: %s", query);
PQfinish(conn);
exit(1);
}
@@ -56,7 +56,7 @@ executeCommand(PGconn *conn, const char *query, bool echo)
PQresultStatus(res) != PGRES_COMMAND_OK)
{
pg_log_error("query failed: %s", PQerrorMessage(conn));
- pg_log_info("query was: %s", query);
+ pg_log_error_detail("Query was: %s", query);
PQfinish(conn);
exit(1);
}
diff --git a/src/fe_utils/recovery_gen.c b/src/fe_utils/recovery_gen.c
index 9407e76bba3..c9a423038a4 100644
--- a/src/fe_utils/recovery_gen.c
+++ b/src/fe_utils/recovery_gen.c
@@ -31,10 +31,7 @@ GenerateRecoveryConfig(PGconn *pgconn, char *replication_slot)
contents = createPQExpBuffer();
if (!contents)
- {
- pg_log_error("out of memory");
- exit(1);
- }
+ pg_fatal("out of memory");
/*
* In PostgreSQL 12 and newer versions, standby_mode is gone, replaced by
@@ -45,10 +42,7 @@ GenerateRecoveryConfig(PGconn *pgconn, char *replication_slot)
connOptions = PQconninfo(pgconn);
if (connOptions == NULL)
- {
- pg_log_error("out of memory");
- exit(1);
- }
+ pg_fatal("out of memory");
initPQExpBuffer(&conninfo_buf);
for (PQconninfoOption *opt = connOptions; opt && opt->keyword; opt++)
@@ -73,10 +67,7 @@ GenerateRecoveryConfig(PGconn *pgconn, char *replication_slot)
appendConnStrVal(&conninfo_buf, opt->val);
}
if (PQExpBufferDataBroken(conninfo_buf))
- {
- pg_log_error("out of memory");
- exit(1);
- }
+ pg_fatal("out of memory");
/*
* Escape the connection string, so that it can be put in the config file.
@@ -96,10 +87,7 @@ GenerateRecoveryConfig(PGconn *pgconn, char *replication_slot)
}
if (PQExpBufferBroken(contents))
- {
- pg_log_error("out of memory");
- exit(1);
- }
+ pg_fatal("out of memory");
PQconninfoFree(connOptions);
@@ -130,16 +118,10 @@ WriteRecoveryConfig(PGconn *pgconn, char *target_dir, PQExpBuffer contents)
cf = fopen(filename, use_recovery_conf ? "w" : "a");
if (cf == NULL)
- {
- pg_log_error("could not open file \"%s\": %m", filename);
- exit(1);
- }
+ pg_fatal("could not open file \"%s\": %m", filename);
if (fwrite(contents->data, contents->len, 1, cf) != 1)
- {
- pg_log_error("could not write to file \"%s\": %m", filename);
- exit(1);
- }
+ pg_fatal("could not write to file \"%s\": %m", filename);
fclose(cf);
@@ -148,10 +130,7 @@ WriteRecoveryConfig(PGconn *pgconn, char *target_dir, PQExpBuffer contents)
snprintf(filename, MAXPGPATH, "%s/%s", target_dir, "standby.signal");
cf = fopen(filename, "w");
if (cf == NULL)
- {
- pg_log_error("could not create file \"%s\": %m", filename);
- exit(1);
- }
+ pg_fatal("could not create file \"%s\": %m", filename);
fclose(cf);
}
@@ -167,9 +146,6 @@ escape_quotes(const char *src)
char *result = escape_single_quotes_ascii(src);
if (!result)
- {
- pg_log_error("out of memory");
- exit(1);
- }
+ pg_fatal("out of memory");
return result;
}