aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2020-12-04 14:25:23 +0100
committerPeter Eisentraut <peter@eisentraut.org>2020-12-04 14:25:23 +0100
commiteb93f3a0b633ad6afb0f37391b87f460c4b0663b (patch)
tree7590fcb99e536615cfdb89bb4698b75f6e33ec14
parenta6964bc1bb0793e20636ccb573cd2a5ad3ef7667 (diff)
downloadpostgresql-eb93f3a0b633ad6afb0f37391b87f460c4b0663b.tar.gz
postgresql-eb93f3a0b633ad6afb0f37391b87f460c4b0663b.zip
Convert elog(LOG) calls to ereport() where appropriate
User-visible log messages should go through ereport(), so they are subject to translation. Many remaining elog(LOG) calls are really debugging calls. Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Noah Misch <noah@leadboat.com> Discussion: https://www.postgresql.org/message-id/flat/92d6f545-5102-65d8-3c87-489f71ea0a37%40enterprisedb.com
-rw-r--r--src/backend/access/gist/gist.c5
-rw-r--r--src/backend/access/nbtree/nbtpage.c7
-rw-r--r--src/backend/access/transam/xlog.c100
-rw-r--r--src/backend/libpq/auth.c7
-rw-r--r--src/backend/libpq/hba.c3
-rw-r--r--src/backend/libpq/pqcomm.c56
-rw-r--r--src/backend/postmaster/bgworker.c8
-rw-r--r--src/backend/postmaster/pgstat.c17
-rw-r--r--src/backend/postmaster/postmaster.c44
-rw-r--r--src/backend/replication/logical/origin.c9
-rw-r--r--src/backend/storage/file/fd.c8
-rw-r--r--src/backend/utils/misc/guc.c2
12 files changed, 172 insertions, 94 deletions
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index 25b42e38f22..3f2b416ce1c 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -1167,8 +1167,9 @@ gistfixsplit(GISTInsertState *state, GISTSTATE *giststate)
Page page;
List *splitinfo = NIL;
- elog(LOG, "fixing incomplete split in index \"%s\", block %u",
- RelationGetRelationName(state->r), stack->blkno);
+ ereport(LOG,
+ (errmsg("fixing incomplete split in index \"%s\", block %u",
+ RelationGetRelationName(state->r), stack->blkno)));
Assert(GistFollowRight(stack->page));
Assert(OffsetNumberIsValid(stack->downlinkoffnum));
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c
index 848123d9218..793434c026c 100644
--- a/src/backend/access/nbtree/nbtpage.c
+++ b/src/backend/access/nbtree/nbtpage.c
@@ -2151,9 +2151,10 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, BlockNumber scanblkno,
if (leftsib == P_NONE)
{
- elog(LOG, "no left sibling (concurrent deletion?) of block %u in \"%s\"",
- target,
- RelationGetRelationName(rel));
+ ereport(LOG,
+ (errmsg("no left sibling (concurrent deletion?) of block %u in \"%s\"",
+ target,
+ RelationGetRelationName(rel))));
if (target != leafblkno)
{
/* we have only a pin on target, but pin+lock on leafbuf */
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 13f1d8c3dc7..7e81ce4f173 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -1811,9 +1811,10 @@ WaitXLogInsertionsToFinish(XLogRecPtr upto)
*/
if (upto > reservedUpto)
{
- elog(LOG, "request to flush past end of generated WAL; request %X/%X, currpos %X/%X",
- (uint32) (upto >> 32), (uint32) upto,
- (uint32) (reservedUpto >> 32), (uint32) reservedUpto);
+ ereport(LOG,
+ (errmsg("request to flush past end of generated WAL; request %X/%X, current position %X/%X",
+ (uint32) (upto >> 32), (uint32) upto,
+ (uint32) (reservedUpto >> 32), (uint32) reservedUpto)));
upto = reservedUpto;
}
@@ -8532,16 +8533,30 @@ ShutdownXLOG(int code, Datum arg)
static void
LogCheckpointStart(int flags, bool restartpoint)
{
- elog(LOG, "%s starting:%s%s%s%s%s%s%s%s",
- restartpoint ? "restartpoint" : "checkpoint",
- (flags & CHECKPOINT_IS_SHUTDOWN) ? " shutdown" : "",
- (flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "",
- (flags & CHECKPOINT_IMMEDIATE) ? " immediate" : "",
- (flags & CHECKPOINT_FORCE) ? " force" : "",
- (flags & CHECKPOINT_WAIT) ? " wait" : "",
- (flags & CHECKPOINT_CAUSE_XLOG) ? " wal" : "",
- (flags & CHECKPOINT_CAUSE_TIME) ? " time" : "",
- (flags & CHECKPOINT_FLUSH_ALL) ? " flush-all" : "");
+ if (restartpoint)
+ ereport(LOG,
+ /* translator: the placeholders show checkpoint options */
+ (errmsg("restartpoint starting:%s%s%s%s%s%s%s%s",
+ (flags & CHECKPOINT_IS_SHUTDOWN) ? " shutdown" : "",
+ (flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "",
+ (flags & CHECKPOINT_IMMEDIATE) ? " immediate" : "",
+ (flags & CHECKPOINT_FORCE) ? " force" : "",
+ (flags & CHECKPOINT_WAIT) ? " wait" : "",
+ (flags & CHECKPOINT_CAUSE_XLOG) ? " wal" : "",
+ (flags & CHECKPOINT_CAUSE_TIME) ? " time" : "",
+ (flags & CHECKPOINT_FLUSH_ALL) ? " flush-all" : "")));
+ else
+ ereport(LOG,
+ /* translator: the placeholders show checkpoint options */
+ (errmsg("checkpoint starting:%s%s%s%s%s%s%s%s",
+ (flags & CHECKPOINT_IS_SHUTDOWN) ? " shutdown" : "",
+ (flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "",
+ (flags & CHECKPOINT_IMMEDIATE) ? " immediate" : "",
+ (flags & CHECKPOINT_FORCE) ? " force" : "",
+ (flags & CHECKPOINT_WAIT) ? " wait" : "",
+ (flags & CHECKPOINT_CAUSE_XLOG) ? " wal" : "",
+ (flags & CHECKPOINT_CAUSE_TIME) ? " time" : "",
+ (flags & CHECKPOINT_FLUSH_ALL) ? " flush-all" : "")));
}
/*
@@ -8591,25 +8606,46 @@ LogCheckpointEnd(bool restartpoint)
CheckpointStats.ckpt_sync_rels;
average_msecs = (long) ((average_sync_time + 999) / 1000);
- elog(LOG, "%s complete: wrote %d buffers (%.1f%%); "
- "%d WAL file(s) added, %d removed, %d recycled; "
- "write=%ld.%03d s, sync=%ld.%03d s, total=%ld.%03d s; "
- "sync files=%d, longest=%ld.%03d s, average=%ld.%03d s; "
- "distance=%d kB, estimate=%d kB",
- restartpoint ? "restartpoint" : "checkpoint",
- CheckpointStats.ckpt_bufs_written,
- (double) CheckpointStats.ckpt_bufs_written * 100 / NBuffers,
- CheckpointStats.ckpt_segs_added,
- CheckpointStats.ckpt_segs_removed,
- CheckpointStats.ckpt_segs_recycled,
- write_msecs / 1000, (int) (write_msecs % 1000),
- sync_msecs / 1000, (int) (sync_msecs % 1000),
- total_msecs / 1000, (int) (total_msecs % 1000),
- CheckpointStats.ckpt_sync_rels,
- longest_msecs / 1000, (int) (longest_msecs % 1000),
- average_msecs / 1000, (int) (average_msecs % 1000),
- (int) (PrevCheckPointDistance / 1024.0),
- (int) (CheckPointDistanceEstimate / 1024.0));
+ if (restartpoint)
+ ereport(LOG,
+ (errmsg("restartpoint complete: wrote %d buffers (%.1f%%); "
+ "%d WAL file(s) added, %d removed, %d recycled; "
+ "write=%ld.%03d s, sync=%ld.%03d s, total=%ld.%03d s; "
+ "sync files=%d, longest=%ld.%03d s, average=%ld.%03d s; "
+ "distance=%d kB, estimate=%d kB",
+ CheckpointStats.ckpt_bufs_written,
+ (double) CheckpointStats.ckpt_bufs_written * 100 / NBuffers,
+ CheckpointStats.ckpt_segs_added,
+ CheckpointStats.ckpt_segs_removed,
+ CheckpointStats.ckpt_segs_recycled,
+ write_msecs / 1000, (int) (write_msecs % 1000),
+ sync_msecs / 1000, (int) (sync_msecs % 1000),
+ total_msecs / 1000, (int) (total_msecs % 1000),
+ CheckpointStats.ckpt_sync_rels,
+ longest_msecs / 1000, (int) (longest_msecs % 1000),
+ average_msecs / 1000, (int) (average_msecs % 1000),
+ (int) (PrevCheckPointDistance / 1024.0),
+ (int) (CheckPointDistanceEstimate / 1024.0))));
+ else
+ ereport(LOG,
+ (errmsg("checkpoint complete: wrote %d buffers (%.1f%%); "
+ "%d WAL file(s) added, %d removed, %d recycled; "
+ "write=%ld.%03d s, sync=%ld.%03d s, total=%ld.%03d s; "
+ "sync files=%d, longest=%ld.%03d s, average=%ld.%03d s; "
+ "distance=%d kB, estimate=%d kB",
+ CheckpointStats.ckpt_bufs_written,
+ (double) CheckpointStats.ckpt_bufs_written * 100 / NBuffers,
+ CheckpointStats.ckpt_segs_added,
+ CheckpointStats.ckpt_segs_removed,
+ CheckpointStats.ckpt_segs_recycled,
+ write_msecs / 1000, (int) (write_msecs % 1000),
+ sync_msecs / 1000, (int) (sync_msecs % 1000),
+ total_msecs / 1000, (int) (total_msecs % 1000),
+ CheckpointStats.ckpt_sync_rels,
+ longest_msecs / 1000, (int) (longest_msecs % 1000),
+ average_msecs / 1000, (int) (average_msecs % 1000),
+ (int) (PrevCheckPointDistance / 1024.0),
+ (int) (CheckPointDistanceEstimate / 1024.0))));
}
/*
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index d132c5cb48b..3d809309685 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -2131,9 +2131,10 @@ pam_passwd_conv_proc(int num_msg, const struct pam_message **msg,
reply[i].resp_retcode = PAM_SUCCESS;
break;
default:
- elog(LOG, "unsupported PAM conversation %d/\"%s\"",
- msg[i]->msg_style,
- msg[i]->msg ? msg[i]->msg : "(none)");
+ ereport(LOG,
+ (errmsg("unsupported PAM conversation %d/\"%s\"",
+ msg[i]->msg_style,
+ msg[i]->msg ? msg[i]->msg : "(none)")));
goto fail;
}
}
diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c
index 3a78d2043e5..0cc43977691 100644
--- a/src/backend/libpq/hba.c
+++ b/src/backend/libpq/hba.c
@@ -857,7 +857,8 @@ check_same_host_or_net(SockAddr *raddr, IPCompareMethod method)
errno = 0;
if (pg_foreach_ifaddr(check_network_callback, &cn) < 0)
{
- elog(LOG, "error enumerating network interfaces: %m");
+ ereport(LOG,
+ (errmsg("error enumerating network interfaces: %m")));
return false;
}
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index 64a351cedcb..0b511008fc8 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -750,7 +750,8 @@ StreamConnection(pgsocket server_fd, Port *port)
(struct sockaddr *) &port->laddr.addr,
&port->laddr.salen) < 0)
{
- elog(LOG, "getsockname() failed: %m");
+ ereport(LOG,
+ (errmsg("getsockname() failed: %m")));
return STATUS_ERROR;
}
@@ -769,7 +770,8 @@ StreamConnection(pgsocket server_fd, Port *port)
if (setsockopt(port->sock, IPPROTO_TCP, TCP_NODELAY,
(char *) &on, sizeof(on)) < 0)
{
- elog(LOG, "setsockopt(%s) failed: %m", "TCP_NODELAY");
+ ereport(LOG,
+ (errmsg("setsockopt(%s) failed: %m", "TCP_NODELAY")));
return STATUS_ERROR;
}
#endif
@@ -777,7 +779,8 @@ StreamConnection(pgsocket server_fd, Port *port)
if (setsockopt(port->sock, SOL_SOCKET, SO_KEEPALIVE,
(char *) &on, sizeof(on)) < 0)
{
- elog(LOG, "setsockopt(%s) failed: %m", "SO_KEEPALIVE");
+ ereport(LOG,
+ (errmsg("setsockopt(%s) failed: %m", "SO_KEEPALIVE")));
return STATUS_ERROR;
}
@@ -808,7 +811,8 @@ StreamConnection(pgsocket server_fd, Port *port)
if (getsockopt(port->sock, SOL_SOCKET, SO_SNDBUF, (char *) &oldopt,
&optlen) < 0)
{
- elog(LOG, "getsockopt(%s) failed: %m", "SO_SNDBUF");
+ ereport(LOG,
+ (errmsg("getsockopt(%s) failed: %m", "SO_SNDBUF")));
return STATUS_ERROR;
}
newopt = PQ_SEND_BUFFER_SIZE * 4;
@@ -817,7 +821,8 @@ StreamConnection(pgsocket server_fd, Port *port)
if (setsockopt(port->sock, SOL_SOCKET, SO_SNDBUF, (char *) &newopt,
sizeof(newopt)) < 0)
{
- elog(LOG, "setsockopt(%s) failed: %m", "SO_SNDBUF");
+ ereport(LOG,
+ (errmsg("setsockopt(%s) failed: %m", "SO_SNDBUF")));
return STATUS_ERROR;
}
}
@@ -1677,8 +1682,9 @@ pq_setkeepaliveswin32(Port *port, int idle, int interval)
NULL)
!= 0)
{
- elog(LOG, "WSAIoctl(SIO_KEEPALIVE_VALS) failed: %ui",
- WSAGetLastError());
+ ereport(LOG,
+ (errmsg("WSAIoctl(%s) failed: %ui",
+ "SIO_KEEPALIVE_VALS", WSAGetLastError())));
return STATUS_ERROR;
}
if (port->keepalives_idle != idle)
@@ -1708,7 +1714,8 @@ pq_getkeepalivesidle(Port *port)
(char *) &port->default_keepalives_idle,
&size) < 0)
{
- elog(LOG, "getsockopt(%s) failed: %m", PG_TCP_KEEPALIVE_IDLE_STR);
+ ereport(LOG,
+ (errmsg("getsockopt(%s) failed: %m", PG_TCP_KEEPALIVE_IDLE_STR)));
port->default_keepalives_idle = -1; /* don't know */
}
#else /* WIN32 */
@@ -1752,7 +1759,8 @@ pq_setkeepalivesidle(int idle, Port *port)
if (setsockopt(port->sock, IPPROTO_TCP, PG_TCP_KEEPALIVE_IDLE,
(char *) &idle, sizeof(idle)) < 0)
{
- elog(LOG, "setsockopt(%s) failed: %m", PG_TCP_KEEPALIVE_IDLE_STR);
+ ereport(LOG,
+ (errmsg("setsockopt(%s) failed: %m", PG_TCP_KEEPALIVE_IDLE_STR)));
return STATUS_ERROR;
}
@@ -1763,7 +1771,8 @@ pq_setkeepalivesidle(int idle, Port *port)
#else
if (idle != 0)
{
- elog(LOG, "setting the keepalive idle time is not supported");
+ ereport(LOG,
+ (errmsg("setting the keepalive idle time is not supported")));
return STATUS_ERROR;
}
#endif
@@ -1790,7 +1799,8 @@ pq_getkeepalivesinterval(Port *port)
(char *) &port->default_keepalives_interval,
&size) < 0)
{
- elog(LOG, "getsockopt(%s) failed: %m", "TCP_KEEPINTVL");
+ ereport(LOG,
+ (errmsg("getsockopt(%s) failed: %m", "TCP_KEEPINTVL")));
port->default_keepalives_interval = -1; /* don't know */
}
#else
@@ -1833,7 +1843,8 @@ pq_setkeepalivesinterval(int interval, Port *port)
if (setsockopt(port->sock, IPPROTO_TCP, TCP_KEEPINTVL,
(char *) &interval, sizeof(interval)) < 0)
{
- elog(LOG, "setsockopt(%s) failed: %m", "TCP_KEEPINTVL");
+ ereport(LOG,
+ (errmsg("setsockopt(%s) failed: %m", "TCP_KEEPINTVL")));
return STATUS_ERROR;
}
@@ -1844,7 +1855,8 @@ pq_setkeepalivesinterval(int interval, Port *port)
#else
if (interval != 0)
{
- elog(LOG, "setsockopt(%s) not supported", "TCP_KEEPINTVL");
+ ereport(LOG,
+ (errmsg("setsockopt(%s) not supported", "TCP_KEEPINTVL")));
return STATUS_ERROR;
}
#endif
@@ -1870,7 +1882,8 @@ pq_getkeepalivescount(Port *port)
(char *) &port->default_keepalives_count,
&size) < 0)
{
- elog(LOG, "getsockopt(%s) failed: %m", "TCP_KEEPCNT");
+ ereport(LOG,
+ (errmsg("getsockopt(%s) failed: %m", "TCP_KEEPCNT")));
port->default_keepalives_count = -1; /* don't know */
}
}
@@ -1908,7 +1921,8 @@ pq_setkeepalivescount(int count, Port *port)
if (setsockopt(port->sock, IPPROTO_TCP, TCP_KEEPCNT,
(char *) &count, sizeof(count)) < 0)
{
- elog(LOG, "setsockopt(%s) failed: %m", "TCP_KEEPCNT");
+ ereport(LOG,
+ (errmsg("setsockopt(%s) failed: %m", "TCP_KEEPCNT")));
return STATUS_ERROR;
}
@@ -1916,7 +1930,8 @@ pq_setkeepalivescount(int count, Port *port)
#else
if (count != 0)
{
- elog(LOG, "setsockopt(%s) not supported", "TCP_KEEPCNT");
+ ereport(LOG,
+ (errmsg("setsockopt(%s) not supported", "TCP_KEEPCNT")));
return STATUS_ERROR;
}
#endif
@@ -1942,7 +1957,8 @@ pq_gettcpusertimeout(Port *port)
(char *) &port->default_tcp_user_timeout,
&size) < 0)
{
- elog(LOG, "getsockopt(%s) failed: %m", "TCP_USER_TIMEOUT");
+ ereport(LOG,
+ (errmsg("getsockopt(%s) failed: %m", "TCP_USER_TIMEOUT")));
port->default_tcp_user_timeout = -1; /* don't know */
}
}
@@ -1980,7 +1996,8 @@ pq_settcpusertimeout(int timeout, Port *port)
if (setsockopt(port->sock, IPPROTO_TCP, TCP_USER_TIMEOUT,
(char *) &timeout, sizeof(timeout)) < 0)
{
- elog(LOG, "setsockopt(%s) failed: %m", "TCP_USER_TIMEOUT");
+ ereport(LOG,
+ (errmsg("setsockopt(%s) failed: %m", "TCP_USER_TIMEOUT")));
return STATUS_ERROR;
}
@@ -1988,7 +2005,8 @@ pq_settcpusertimeout(int timeout, Port *port)
#else
if (timeout != 0)
{
- elog(LOG, "setsockopt(%s) not supported", "TCP_USER_TIMEOUT");
+ ereport(LOG,
+ (errmsg("setsockopt(%s) not supported", "TCP_USER_TIMEOUT")));
return STATUS_ERROR;
}
#endif
diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c
index 5a9a0e34353..7ef6259eb50 100644
--- a/src/backend/postmaster/bgworker.c
+++ b/src/backend/postmaster/bgworker.c
@@ -250,10 +250,10 @@ BackgroundWorkerStateChange(void)
*/
if (max_worker_processes != BackgroundWorkerData->total_slots)
{
- elog(LOG,
- "inconsistent background worker state (max_worker_processes=%d, total_slots=%d",
- max_worker_processes,
- BackgroundWorkerData->total_slots);
+ ereport(LOG,
+ (errmsg("inconsistent background worker state (max_worker_processes=%d, total_slots=%d)",
+ max_worker_processes,
+ BackgroundWorkerData->total_slots)));
return;
}
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 9bad14981b8..7c75a25d210 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -636,7 +636,8 @@ retry2:
if (getsockopt(pgStatSock, SOL_SOCKET, SO_RCVBUF,
(char *) &old_rcvbuf, &rcvbufsize) < 0)
{
- elog(LOG, "getsockopt(SO_RCVBUF) failed: %m");
+ ereport(LOG,
+ (errmsg("getsockopt(%s) failed: %m", "SO_RCVBUF")));
/* if we can't get existing size, always try to set it */
old_rcvbuf = 0;
}
@@ -646,7 +647,8 @@ retry2:
{
if (setsockopt(pgStatSock, SOL_SOCKET, SO_RCVBUF,
(char *) &new_rcvbuf, sizeof(new_rcvbuf)) < 0)
- elog(LOG, "setsockopt(SO_RCVBUF) failed: %m");
+ ereport(LOG,
+ (errmsg("setsockopt(%s) failed: %m", "SO_RCVBUF")));
}
}
@@ -6108,8 +6110,9 @@ backend_read_statsfile(void)
/* Copy because timestamptz_to_str returns a static buffer */
filetime = pstrdup(timestamptz_to_str(file_ts));
mytime = pstrdup(timestamptz_to_str(cur_ts));
- elog(LOG, "stats collector's time %s is later than backend local time %s",
- filetime, mytime);
+ ereport(LOG,
+ (errmsg("statistics collector's time %s is later than backend local time %s",
+ filetime, mytime)));
pfree(filetime);
pfree(mytime);
}
@@ -6251,9 +6254,9 @@ pgstat_recv_inquiry(PgStat_MsgInquiry *msg, int len)
/* Copy because timestamptz_to_str returns a static buffer */
writetime = pstrdup(timestamptz_to_str(dbentry->stats_timestamp));
mytime = pstrdup(timestamptz_to_str(cur_ts));
- elog(LOG,
- "stats_timestamp %s is later than collector's time %s for database %u",
- writetime, mytime, dbentry->databaseid);
+ ereport(LOG,
+ (errmsg("stats_timestamp %s is later than collector's time %s for database %u",
+ writetime, mytime, dbentry->databaseid)));
pfree(writetime);
pfree(mytime);
}
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index b7799ed1d24..5d09822c818 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -1207,8 +1207,9 @@ PostmasterMain(int argc, char *argv[])
NULL,
NULL);
if (err != kDNSServiceErr_NoError)
- elog(LOG, "DNSServiceRegister() failed: error code %ld",
- (long) err);
+ ereport(LOG,
+ (errmsg("DNSServiceRegister() failed: error code %ld",
+ (long) err)));
/*
* We don't bother to read the mDNS daemon's reply, and we expect that
@@ -1466,7 +1467,8 @@ getInstallationPaths(const char *argv0)
/* Locate the postgres executable itself */
if (find_my_exec(argv0, my_exec_path) < 0)
- elog(FATAL, "%s: could not locate my own executable path", argv0);
+ ereport(FATAL,
+ (errmsg("%s: could not locate my own executable path", argv0)));
#ifdef EXEC_BACKEND
/* Locate executable backend before we change working directory */
@@ -4674,16 +4676,18 @@ retry:
NULL);
if (paramHandle == INVALID_HANDLE_VALUE)
{
- elog(LOG, "could not create backend parameter file mapping: error code %lu",
- GetLastError());
+ ereport(LOG,
+ (errmsg("could not create backend parameter file mapping: error code %lu",
+ GetLastError())));
return -1;
}
param = MapViewOfFile(paramHandle, FILE_MAP_WRITE, 0, 0, sizeof(BackendParameters));
if (!param)
{
- elog(LOG, "could not map backend parameter memory: error code %lu",
- GetLastError());
+ ereport(LOG,
+ (errmsg("could not map backend parameter memory: error code %lu",
+ GetLastError())));
CloseHandle(paramHandle);
return -1;
}
@@ -4708,7 +4712,8 @@ retry:
}
if (cmdLine[sizeof(cmdLine) - 2] != '\0')
{
- elog(LOG, "subprocess command line too long");
+ ereport(LOG,
+ (errmsg("subprocess command line too long")));
UnmapViewOfFile(param);
CloseHandle(paramHandle);
return -1;
@@ -4725,8 +4730,9 @@ retry:
if (!CreateProcess(NULL, cmdLine, NULL, NULL, TRUE, CREATE_SUSPENDED,
NULL, NULL, &si, &pi))
{
- elog(LOG, "CreateProcess call failed: %m (error code %lu)",
- GetLastError());
+ ereport(LOG,
+ (errmsg("CreateProcess() call failed: %m (error code %lu)",
+ GetLastError())));
UnmapViewOfFile(param);
CloseHandle(paramHandle);
return -1;
@@ -4751,11 +4757,13 @@ retry:
/* Drop the parameter shared memory that is now inherited to the backend */
if (!UnmapViewOfFile(param))
- elog(LOG, "could not unmap view of backend parameter file: error code %lu",
- GetLastError());
+ ereport(LOG,
+ (errmsg("could not unmap view of backend parameter file: error code %lu",
+ GetLastError())));
if (!CloseHandle(paramHandle))
- elog(LOG, "could not close handle to backend parameter file: error code %lu",
- GetLastError());
+ ereport(LOG,
+ (errmsg("could not close handle to backend parameter file: error code %lu",
+ GetLastError())));
/*
* Reserve the memory region used by our main shared memory segment before
@@ -5639,7 +5647,9 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname)
if ((fp = fopen(OPTS_FILE, "w")) == NULL)
{
- elog(LOG, "could not create file \"%s\": %m", OPTS_FILE);
+ ereport(LOG,
+ (errcode_for_file_access(),
+ errmsg("could not create file \"%s\": %m", OPTS_FILE)));
return false;
}
@@ -5650,7 +5660,9 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname)
if (fclose(fp))
{
- elog(LOG, "could not write file \"%s\": %m", OPTS_FILE);
+ ereport(LOG,
+ (errcode_for_file_access(),
+ errmsg("could not write file \"%s\": %m", OPTS_FILE)));
return false;
}
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c
index 1b220315dff..15ab8e7204b 100644
--- a/src/backend/replication/logical/origin.c
+++ b/src/backend/replication/logical/origin.c
@@ -769,10 +769,11 @@ StartupReplicationOrigin(void)
replication_states[last_state].remote_lsn = disk_state.remote_lsn;
last_state++;
- elog(LOG, "recovered replication state of node %u to %X/%X",
- disk_state.roident,
- (uint32) (disk_state.remote_lsn >> 32),
- (uint32) disk_state.remote_lsn);
+ ereport(LOG,
+ (errmsg("recovered replication state of node %u to %X/%X",
+ disk_state.roident,
+ (uint32) (disk_state.remote_lsn >> 32),
+ (uint32) disk_state.remote_lsn)));
}
/* now check checksum */
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 88004c6fae8..f07b5325aa5 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -1914,7 +1914,9 @@ FileClose(File file)
/* in any case do the unlink */
if (unlink(vfdP->fileName))
- elog(LOG, "could not unlink file \"%s\": %m", vfdP->fileName);
+ ereport(LOG,
+ (errcode_for_file_access(),
+ errmsg("could not delete file \"%s\": %m", vfdP->fileName)));
/* and last report the stat results */
if (stat_errno == 0)
@@ -1922,7 +1924,9 @@ FileClose(File file)
else
{
errno = stat_errno;
- elog(LOG, "could not stat file \"%s\": %m", vfdP->fileName);
+ ereport(LOG,
+ (errcode_for_file_access(),
+ errmsg("could not stat file \"%s\": %m", vfdP->fileName)));
}
}
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 02d2d267b5c..635d91d50ac 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -11533,7 +11533,7 @@ assign_tcp_keepalives_idle(int newval, void *extra)
* once we set it we might fail to unset it. So there seems little point
* in fully implementing the check-then-assign GUC API for these
* variables. Instead we just do the assignment on demand. pqcomm.c
- * reports any problems via elog(LOG).
+ * reports any problems via ereport(LOG).
*
* This approach means that the GUC value might have little to do with the
* actual kernel value, so we use a show_hook that retrieves the kernel