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));
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 */
*/
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;
}
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" : "")));
}
/*
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))));
}
/*
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;
}
}
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;
}
(struct sockaddr *) &port->laddr.addr,
&port->laddr.salen) < 0)
{
- elog(LOG, "getsockname() failed: %m");
+ ereport(LOG,
+ (errmsg("getsockname() failed: %m")));
return STATUS_ERROR;
}
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
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;
}
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;
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;
}
}
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)
(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 */
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;
}
#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
(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
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;
}
#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
(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 */
}
}
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;
}
#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
(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 */
}
}
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;
}
#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
*/
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;
}
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;
}
{
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")));
}
}
/* 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);
}
/* 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);
}
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
/* 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 */
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;
}
}
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;
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;
/* 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
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;
}
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;
}
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 */
/* 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)
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)));
}
}
* 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