Commit eb93f3a0 authored by Peter Eisentraut's avatar Peter Eisentraut

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: default avatarAlvaro Herrera <alvherre@alvh.no-ip.org>
Reviewed-by: default avatarMichael Paquier <michael@paquier.xyz>
Reviewed-by: default avatarNoah Misch <noah@leadboat.com>
Discussion: https://www.postgresql.org/message-id/flat/92d6f545-5102-65d8-3c87-489f71ea0a37%40enterprisedb.com
parent a6964bc1
...@@ -1167,8 +1167,9 @@ gistfixsplit(GISTInsertState *state, GISTSTATE *giststate) ...@@ -1167,8 +1167,9 @@ gistfixsplit(GISTInsertState *state, GISTSTATE *giststate)
Page page; Page page;
List *splitinfo = NIL; List *splitinfo = NIL;
elog(LOG, "fixing incomplete split in index \"%s\", block %u", ereport(LOG,
RelationGetRelationName(state->r), stack->blkno); (errmsg("fixing incomplete split in index \"%s\", block %u",
RelationGetRelationName(state->r), stack->blkno)));
Assert(GistFollowRight(stack->page)); Assert(GistFollowRight(stack->page));
Assert(OffsetNumberIsValid(stack->downlinkoffnum)); Assert(OffsetNumberIsValid(stack->downlinkoffnum));
......
...@@ -2151,9 +2151,10 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, BlockNumber scanblkno, ...@@ -2151,9 +2151,10 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, BlockNumber scanblkno,
if (leftsib == P_NONE) if (leftsib == P_NONE)
{ {
elog(LOG, "no left sibling (concurrent deletion?) of block %u in \"%s\"", ereport(LOG,
(errmsg("no left sibling (concurrent deletion?) of block %u in \"%s\"",
target, target,
RelationGetRelationName(rel)); RelationGetRelationName(rel))));
if (target != leafblkno) if (target != leafblkno)
{ {
/* we have only a pin on target, but pin+lock on leafbuf */ /* we have only a pin on target, but pin+lock on leafbuf */
......
...@@ -1811,9 +1811,10 @@ WaitXLogInsertionsToFinish(XLogRecPtr upto) ...@@ -1811,9 +1811,10 @@ WaitXLogInsertionsToFinish(XLogRecPtr upto)
*/ */
if (upto > reservedUpto) if (upto > reservedUpto)
{ {
elog(LOG, "request to flush past end of generated WAL; request %X/%X, currpos %X/%X", ereport(LOG,
(errmsg("request to flush past end of generated WAL; request %X/%X, current position %X/%X",
(uint32) (upto >> 32), (uint32) upto, (uint32) (upto >> 32), (uint32) upto,
(uint32) (reservedUpto >> 32), (uint32) reservedUpto); (uint32) (reservedUpto >> 32), (uint32) reservedUpto)));
upto = reservedUpto; upto = reservedUpto;
} }
...@@ -8532,8 +8533,10 @@ ShutdownXLOG(int code, Datum arg) ...@@ -8532,8 +8533,10 @@ ShutdownXLOG(int code, Datum arg)
static void static void
LogCheckpointStart(int flags, bool restartpoint) LogCheckpointStart(int flags, bool restartpoint)
{ {
elog(LOG, "%s starting:%s%s%s%s%s%s%s%s", if (restartpoint)
restartpoint ? "restartpoint" : "checkpoint", 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_IS_SHUTDOWN) ? " shutdown" : "",
(flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "", (flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "",
(flags & CHECKPOINT_IMMEDIATE) ? " immediate" : "", (flags & CHECKPOINT_IMMEDIATE) ? " immediate" : "",
...@@ -8541,7 +8544,19 @@ LogCheckpointStart(int flags, bool restartpoint) ...@@ -8541,7 +8544,19 @@ LogCheckpointStart(int flags, bool restartpoint)
(flags & CHECKPOINT_WAIT) ? " wait" : "", (flags & CHECKPOINT_WAIT) ? " wait" : "",
(flags & CHECKPOINT_CAUSE_XLOG) ? " wal" : "", (flags & CHECKPOINT_CAUSE_XLOG) ? " wal" : "",
(flags & CHECKPOINT_CAUSE_TIME) ? " time" : "", (flags & CHECKPOINT_CAUSE_TIME) ? " time" : "",
(flags & CHECKPOINT_FLUSH_ALL) ? " flush-all" : ""); (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,12 +8606,33 @@ LogCheckpointEnd(bool restartpoint) ...@@ -8591,12 +8606,33 @@ LogCheckpointEnd(bool restartpoint)
CheckpointStats.ckpt_sync_rels; CheckpointStats.ckpt_sync_rels;
average_msecs = (long) ((average_sync_time + 999) / 1000); average_msecs = (long) ((average_sync_time + 999) / 1000);
elog(LOG, "%s complete: wrote %d buffers (%.1f%%); " 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; " "%d WAL file(s) added, %d removed, %d recycled; "
"write=%ld.%03d s, sync=%ld.%03d s, total=%ld.%03d s; " "write=%ld.%03d s, sync=%ld.%03d s, total=%ld.%03d s; "
"sync files=%d, longest=%ld.%03d s, average=%ld.%03d s; " "sync files=%d, longest=%ld.%03d s, average=%ld.%03d s; "
"distance=%d kB, estimate=%d kB", "distance=%d kB, estimate=%d kB",
restartpoint ? "restartpoint" : "checkpoint",
CheckpointStats.ckpt_bufs_written, CheckpointStats.ckpt_bufs_written,
(double) CheckpointStats.ckpt_bufs_written * 100 / NBuffers, (double) CheckpointStats.ckpt_bufs_written * 100 / NBuffers,
CheckpointStats.ckpt_segs_added, CheckpointStats.ckpt_segs_added,
...@@ -8609,7 +8645,7 @@ LogCheckpointEnd(bool restartpoint) ...@@ -8609,7 +8645,7 @@ LogCheckpointEnd(bool restartpoint)
longest_msecs / 1000, (int) (longest_msecs % 1000), longest_msecs / 1000, (int) (longest_msecs % 1000),
average_msecs / 1000, (int) (average_msecs % 1000), average_msecs / 1000, (int) (average_msecs % 1000),
(int) (PrevCheckPointDistance / 1024.0), (int) (PrevCheckPointDistance / 1024.0),
(int) (CheckPointDistanceEstimate / 1024.0)); (int) (CheckPointDistanceEstimate / 1024.0))));
} }
/* /*
......
...@@ -2131,9 +2131,10 @@ pam_passwd_conv_proc(int num_msg, const struct pam_message **msg, ...@@ -2131,9 +2131,10 @@ pam_passwd_conv_proc(int num_msg, const struct pam_message **msg,
reply[i].resp_retcode = PAM_SUCCESS; reply[i].resp_retcode = PAM_SUCCESS;
break; break;
default: default:
elog(LOG, "unsupported PAM conversation %d/\"%s\"", ereport(LOG,
(errmsg("unsupported PAM conversation %d/\"%s\"",
msg[i]->msg_style, msg[i]->msg_style,
msg[i]->msg ? msg[i]->msg : "(none)"); msg[i]->msg ? msg[i]->msg : "(none)")));
goto fail; goto fail;
} }
} }
......
...@@ -857,7 +857,8 @@ check_same_host_or_net(SockAddr *raddr, IPCompareMethod method) ...@@ -857,7 +857,8 @@ check_same_host_or_net(SockAddr *raddr, IPCompareMethod method)
errno = 0; errno = 0;
if (pg_foreach_ifaddr(check_network_callback, &cn) < 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; return false;
} }
......
...@@ -750,7 +750,8 @@ StreamConnection(pgsocket server_fd, Port *port) ...@@ -750,7 +750,8 @@ StreamConnection(pgsocket server_fd, Port *port)
(struct sockaddr *) &port->laddr.addr, (struct sockaddr *) &port->laddr.addr,
&port->laddr.salen) < 0) &port->laddr.salen) < 0)
{ {
elog(LOG, "getsockname() failed: %m"); ereport(LOG,
(errmsg("getsockname() failed: %m")));
return STATUS_ERROR; return STATUS_ERROR;
} }
...@@ -769,7 +770,8 @@ StreamConnection(pgsocket server_fd, Port *port) ...@@ -769,7 +770,8 @@ StreamConnection(pgsocket server_fd, Port *port)
if (setsockopt(port->sock, IPPROTO_TCP, TCP_NODELAY, if (setsockopt(port->sock, IPPROTO_TCP, TCP_NODELAY,
(char *) &on, sizeof(on)) < 0) (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; return STATUS_ERROR;
} }
#endif #endif
...@@ -777,7 +779,8 @@ StreamConnection(pgsocket server_fd, Port *port) ...@@ -777,7 +779,8 @@ StreamConnection(pgsocket server_fd, Port *port)
if (setsockopt(port->sock, SOL_SOCKET, SO_KEEPALIVE, if (setsockopt(port->sock, SOL_SOCKET, SO_KEEPALIVE,
(char *) &on, sizeof(on)) < 0) (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; return STATUS_ERROR;
} }
...@@ -808,7 +811,8 @@ StreamConnection(pgsocket server_fd, Port *port) ...@@ -808,7 +811,8 @@ StreamConnection(pgsocket server_fd, Port *port)
if (getsockopt(port->sock, SOL_SOCKET, SO_SNDBUF, (char *) &oldopt, if (getsockopt(port->sock, SOL_SOCKET, SO_SNDBUF, (char *) &oldopt,
&optlen) < 0) &optlen) < 0)
{ {
elog(LOG, "getsockopt(%s) failed: %m", "SO_SNDBUF"); ereport(LOG,
(errmsg("getsockopt(%s) failed: %m", "SO_SNDBUF")));
return STATUS_ERROR; return STATUS_ERROR;
} }
newopt = PQ_SEND_BUFFER_SIZE * 4; newopt = PQ_SEND_BUFFER_SIZE * 4;
...@@ -817,7 +821,8 @@ StreamConnection(pgsocket server_fd, Port *port) ...@@ -817,7 +821,8 @@ StreamConnection(pgsocket server_fd, Port *port)
if (setsockopt(port->sock, SOL_SOCKET, SO_SNDBUF, (char *) &newopt, if (setsockopt(port->sock, SOL_SOCKET, SO_SNDBUF, (char *) &newopt,
sizeof(newopt)) < 0) sizeof(newopt)) < 0)
{ {
elog(LOG, "setsockopt(%s) failed: %m", "SO_SNDBUF"); ereport(LOG,
(errmsg("setsockopt(%s) failed: %m", "SO_SNDBUF")));
return STATUS_ERROR; return STATUS_ERROR;
} }
} }
...@@ -1677,8 +1682,9 @@ pq_setkeepaliveswin32(Port *port, int idle, int interval) ...@@ -1677,8 +1682,9 @@ pq_setkeepaliveswin32(Port *port, int idle, int interval)
NULL) NULL)
!= 0) != 0)
{ {
elog(LOG, "WSAIoctl(SIO_KEEPALIVE_VALS) failed: %ui", ereport(LOG,
WSAGetLastError()); (errmsg("WSAIoctl(%s) failed: %ui",
"SIO_KEEPALIVE_VALS", WSAGetLastError())));
return STATUS_ERROR; return STATUS_ERROR;
} }
if (port->keepalives_idle != idle) if (port->keepalives_idle != idle)
...@@ -1708,7 +1714,8 @@ pq_getkeepalivesidle(Port *port) ...@@ -1708,7 +1714,8 @@ pq_getkeepalivesidle(Port *port)
(char *) &port->default_keepalives_idle, (char *) &port->default_keepalives_idle,
&size) < 0) &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 */ port->default_keepalives_idle = -1; /* don't know */
} }
#else /* WIN32 */ #else /* WIN32 */
...@@ -1752,7 +1759,8 @@ pq_setkeepalivesidle(int idle, Port *port) ...@@ -1752,7 +1759,8 @@ pq_setkeepalivesidle(int idle, Port *port)
if (setsockopt(port->sock, IPPROTO_TCP, PG_TCP_KEEPALIVE_IDLE, if (setsockopt(port->sock, IPPROTO_TCP, PG_TCP_KEEPALIVE_IDLE,
(char *) &idle, sizeof(idle)) < 0) (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; return STATUS_ERROR;
} }
...@@ -1763,7 +1771,8 @@ pq_setkeepalivesidle(int idle, Port *port) ...@@ -1763,7 +1771,8 @@ pq_setkeepalivesidle(int idle, Port *port)
#else #else
if (idle != 0) 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; return STATUS_ERROR;
} }
#endif #endif
...@@ -1790,7 +1799,8 @@ pq_getkeepalivesinterval(Port *port) ...@@ -1790,7 +1799,8 @@ pq_getkeepalivesinterval(Port *port)
(char *) &port->default_keepalives_interval, (char *) &port->default_keepalives_interval,
&size) < 0) &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 */ port->default_keepalives_interval = -1; /* don't know */
} }
#else #else
...@@ -1833,7 +1843,8 @@ pq_setkeepalivesinterval(int interval, Port *port) ...@@ -1833,7 +1843,8 @@ pq_setkeepalivesinterval(int interval, Port *port)
if (setsockopt(port->sock, IPPROTO_TCP, TCP_KEEPINTVL, if (setsockopt(port->sock, IPPROTO_TCP, TCP_KEEPINTVL,
(char *) &interval, sizeof(interval)) < 0) (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; return STATUS_ERROR;
} }
...@@ -1844,7 +1855,8 @@ pq_setkeepalivesinterval(int interval, Port *port) ...@@ -1844,7 +1855,8 @@ pq_setkeepalivesinterval(int interval, Port *port)
#else #else
if (interval != 0) if (interval != 0)
{ {
elog(LOG, "setsockopt(%s) not supported", "TCP_KEEPINTVL"); ereport(LOG,
(errmsg("setsockopt(%s) not supported", "TCP_KEEPINTVL")));
return STATUS_ERROR; return STATUS_ERROR;
} }
#endif #endif
...@@ -1870,7 +1882,8 @@ pq_getkeepalivescount(Port *port) ...@@ -1870,7 +1882,8 @@ pq_getkeepalivescount(Port *port)
(char *) &port->default_keepalives_count, (char *) &port->default_keepalives_count,
&size) < 0) &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 */ port->default_keepalives_count = -1; /* don't know */
} }
} }
...@@ -1908,7 +1921,8 @@ pq_setkeepalivescount(int count, Port *port) ...@@ -1908,7 +1921,8 @@ pq_setkeepalivescount(int count, Port *port)
if (setsockopt(port->sock, IPPROTO_TCP, TCP_KEEPCNT, if (setsockopt(port->sock, IPPROTO_TCP, TCP_KEEPCNT,
(char *) &count, sizeof(count)) < 0) (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; return STATUS_ERROR;
} }
...@@ -1916,7 +1930,8 @@ pq_setkeepalivescount(int count, Port *port) ...@@ -1916,7 +1930,8 @@ pq_setkeepalivescount(int count, Port *port)
#else #else
if (count != 0) if (count != 0)
{ {
elog(LOG, "setsockopt(%s) not supported", "TCP_KEEPCNT"); ereport(LOG,
(errmsg("setsockopt(%s) not supported", "TCP_KEEPCNT")));
return STATUS_ERROR; return STATUS_ERROR;
} }
#endif #endif
...@@ -1942,7 +1957,8 @@ pq_gettcpusertimeout(Port *port) ...@@ -1942,7 +1957,8 @@ pq_gettcpusertimeout(Port *port)
(char *) &port->default_tcp_user_timeout, (char *) &port->default_tcp_user_timeout,
&size) < 0) &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 */ port->default_tcp_user_timeout = -1; /* don't know */
} }
} }
...@@ -1980,7 +1996,8 @@ pq_settcpusertimeout(int timeout, Port *port) ...@@ -1980,7 +1996,8 @@ pq_settcpusertimeout(int timeout, Port *port)
if (setsockopt(port->sock, IPPROTO_TCP, TCP_USER_TIMEOUT, if (setsockopt(port->sock, IPPROTO_TCP, TCP_USER_TIMEOUT,
(char *) &timeout, sizeof(timeout)) < 0) (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; return STATUS_ERROR;
} }
...@@ -1988,7 +2005,8 @@ pq_settcpusertimeout(int timeout, Port *port) ...@@ -1988,7 +2005,8 @@ pq_settcpusertimeout(int timeout, Port *port)
#else #else
if (timeout != 0) 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; return STATUS_ERROR;
} }
#endif #endif
......
...@@ -250,10 +250,10 @@ BackgroundWorkerStateChange(void) ...@@ -250,10 +250,10 @@ BackgroundWorkerStateChange(void)
*/ */
if (max_worker_processes != BackgroundWorkerData->total_slots) if (max_worker_processes != BackgroundWorkerData->total_slots)
{ {
elog(LOG, ereport(LOG,
"inconsistent background worker state (max_worker_processes=%d, total_slots=%d", (errmsg("inconsistent background worker state (max_worker_processes=%d, total_slots=%d)",
max_worker_processes, max_worker_processes,
BackgroundWorkerData->total_slots); BackgroundWorkerData->total_slots)));
return; return;
} }
......
...@@ -636,7 +636,8 @@ retry2: ...@@ -636,7 +636,8 @@ retry2:
if (getsockopt(pgStatSock, SOL_SOCKET, SO_RCVBUF, if (getsockopt(pgStatSock, SOL_SOCKET, SO_RCVBUF,
(char *) &old_rcvbuf, &rcvbufsize) < 0) (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 */ /* if we can't get existing size, always try to set it */
old_rcvbuf = 0; old_rcvbuf = 0;
} }
...@@ -646,7 +647,8 @@ retry2: ...@@ -646,7 +647,8 @@ retry2:
{ {
if (setsockopt(pgStatSock, SOL_SOCKET, SO_RCVBUF, if (setsockopt(pgStatSock, SOL_SOCKET, SO_RCVBUF,
(char *) &new_rcvbuf, sizeof(new_rcvbuf)) < 0) (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) ...@@ -6108,8 +6110,9 @@ backend_read_statsfile(void)
/* Copy because timestamptz_to_str returns a static buffer */ /* Copy because timestamptz_to_str returns a static buffer */
filetime = pstrdup(timestamptz_to_str(file_ts)); filetime = pstrdup(timestamptz_to_str(file_ts));
mytime = pstrdup(timestamptz_to_str(cur_ts)); mytime = pstrdup(timestamptz_to_str(cur_ts));
elog(LOG, "stats collector's time %s is later than backend local time %s", ereport(LOG,
filetime, mytime); (errmsg("statistics collector's time %s is later than backend local time %s",
filetime, mytime)));
pfree(filetime); pfree(filetime);
pfree(mytime); pfree(mytime);
} }
...@@ -6251,9 +6254,9 @@ pgstat_recv_inquiry(PgStat_MsgInquiry *msg, int len) ...@@ -6251,9 +6254,9 @@ pgstat_recv_inquiry(PgStat_MsgInquiry *msg, int len)
/* Copy because timestamptz_to_str returns a static buffer */ /* Copy because timestamptz_to_str returns a static buffer */
writetime = pstrdup(timestamptz_to_str(dbentry->stats_timestamp)); writetime = pstrdup(timestamptz_to_str(dbentry->stats_timestamp));
mytime = pstrdup(timestamptz_to_str(cur_ts)); mytime = pstrdup(timestamptz_to_str(cur_ts));
elog(LOG, ereport(LOG,
"stats_timestamp %s is later than collector's time %s for database %u", (errmsg("stats_timestamp %s is later than collector's time %s for database %u",
writetime, mytime, dbentry->databaseid); writetime, mytime, dbentry->databaseid)));
pfree(writetime); pfree(writetime);
pfree(mytime); pfree(mytime);
} }
......
...@@ -1207,8 +1207,9 @@ PostmasterMain(int argc, char *argv[]) ...@@ -1207,8 +1207,9 @@ PostmasterMain(int argc, char *argv[])
NULL, NULL,
NULL); NULL);
if (err != kDNSServiceErr_NoError) if (err != kDNSServiceErr_NoError)
elog(LOG, "DNSServiceRegister() failed: error code %ld", ereport(LOG,
(long) err); (errmsg("DNSServiceRegister() failed: error code %ld",
(long) err)));
/* /*
* We don't bother to read the mDNS daemon's reply, and we expect that * We don't bother to read the mDNS daemon's reply, and we expect that
...@@ -1466,7 +1467,8 @@ getInstallationPaths(const char *argv0) ...@@ -1466,7 +1467,8 @@ getInstallationPaths(const char *argv0)
/* Locate the postgres executable itself */ /* Locate the postgres executable itself */
if (find_my_exec(argv0, my_exec_path) < 0) 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 #ifdef EXEC_BACKEND
/* Locate executable backend before we change working directory */ /* Locate executable backend before we change working directory */
...@@ -4674,16 +4676,18 @@ retry: ...@@ -4674,16 +4676,18 @@ retry:
NULL); NULL);
if (paramHandle == INVALID_HANDLE_VALUE) if (paramHandle == INVALID_HANDLE_VALUE)
{ {
elog(LOG, "could not create backend parameter file mapping: error code %lu", ereport(LOG,
GetLastError()); (errmsg("could not create backend parameter file mapping: error code %lu",
GetLastError())));
return -1; return -1;
} }
param = MapViewOfFile(paramHandle, FILE_MAP_WRITE, 0, 0, sizeof(BackendParameters)); param = MapViewOfFile(paramHandle, FILE_MAP_WRITE, 0, 0, sizeof(BackendParameters));
if (!param) if (!param)
{ {
elog(LOG, "could not map backend parameter memory: error code %lu", ereport(LOG,
GetLastError()); (errmsg("could not map backend parameter memory: error code %lu",
GetLastError())));
CloseHandle(paramHandle); CloseHandle(paramHandle);
return -1; return -1;
} }
...@@ -4708,7 +4712,8 @@ retry: ...@@ -4708,7 +4712,8 @@ retry:
} }
if (cmdLine[sizeof(cmdLine) - 2] != '\0') if (cmdLine[sizeof(cmdLine) - 2] != '\0')
{ {
elog(LOG, "subprocess command line too long"); ereport(LOG,
(errmsg("subprocess command line too long")));
UnmapViewOfFile(param); UnmapViewOfFile(param);
CloseHandle(paramHandle); CloseHandle(paramHandle);
return -1; return -1;
...@@ -4725,8 +4730,9 @@ retry: ...@@ -4725,8 +4730,9 @@ retry:
if (!CreateProcess(NULL, cmdLine, NULL, NULL, TRUE, CREATE_SUSPENDED, if (!CreateProcess(NULL, cmdLine, NULL, NULL, TRUE, CREATE_SUSPENDED,
NULL, NULL, &si, &pi)) NULL, NULL, &si, &pi))
{ {
elog(LOG, "CreateProcess call failed: %m (error code %lu)", ereport(LOG,
GetLastError()); (errmsg("CreateProcess() call failed: %m (error code %lu)",
GetLastError())));
UnmapViewOfFile(param); UnmapViewOfFile(param);
CloseHandle(paramHandle); CloseHandle(paramHandle);
return -1; return -1;
...@@ -4751,11 +4757,13 @@ retry: ...@@ -4751,11 +4757,13 @@ retry:
/* Drop the parameter shared memory that is now inherited to the backend */ /* Drop the parameter shared memory that is now inherited to the backend */
if (!UnmapViewOfFile(param)) if (!UnmapViewOfFile(param))
elog(LOG, "could not unmap view of backend parameter file: error code %lu", ereport(LOG,
GetLastError()); (errmsg("could not unmap view of backend parameter file: error code %lu",
GetLastError())));
if (!CloseHandle(paramHandle)) if (!CloseHandle(paramHandle))
elog(LOG, "could not close handle to backend parameter file: error code %lu", ereport(LOG,
GetLastError()); (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 * Reserve the memory region used by our main shared memory segment before
...@@ -5639,7 +5647,9 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname) ...@@ -5639,7 +5647,9 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname)
if ((fp = fopen(OPTS_FILE, "w")) == NULL) 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; return false;
} }
...@@ -5650,7 +5660,9 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname) ...@@ -5650,7 +5660,9 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname)
if (fclose(fp)) 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; return false;
} }
......
...@@ -769,10 +769,11 @@ StartupReplicationOrigin(void) ...@@ -769,10 +769,11 @@ StartupReplicationOrigin(void)
replication_states[last_state].remote_lsn = disk_state.remote_lsn; replication_states[last_state].remote_lsn = disk_state.remote_lsn;
last_state++; last_state++;
elog(LOG, "recovered replication state of node %u to %X/%X", ereport(LOG,
(errmsg("recovered replication state of node %u to %X/%X",
disk_state.roident, disk_state.roident,
(uint32) (disk_state.remote_lsn >> 32), (uint32) (disk_state.remote_lsn >> 32),
(uint32) disk_state.remote_lsn); (uint32) disk_state.remote_lsn)));
} }
/* now check checksum */ /* now check checksum */
......
...@@ -1914,7 +1914,9 @@ FileClose(File file) ...@@ -1914,7 +1914,9 @@ FileClose(File file)
/* in any case do the unlink */ /* in any case do the unlink */
if (unlink(vfdP->fileName)) 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 */ /* and last report the stat results */
if (stat_errno == 0) if (stat_errno == 0)
...@@ -1922,7 +1924,9 @@ FileClose(File file) ...@@ -1922,7 +1924,9 @@ FileClose(File file)
else else
{ {
errno = stat_errno; 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)));
} }
} }
......
...@@ -11533,7 +11533,7 @@ assign_tcp_keepalives_idle(int newval, void *extra) ...@@ -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 * 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 * in fully implementing the check-then-assign GUC API for these
* variables. Instead we just do the assignment on demand. pqcomm.c * 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 * 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 * actual kernel value, so we use a show_hook that retrieves the kernel
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment