Standardize format for printing PIDs

Most code prints PIDs as %d, but some code tried to print them as long
or unsigned long.  While this is in theory allowed, the fact that PIDs
fit into int is deeply baked into all PostgreSQL code, so these random
deviations don't accomplish anything except confusion.

Note that we still need casts from pid_t to int, because on 64-bit
MinGW, pid_t is long long int.  (But per above, actually supporting
that range in PostgreSQL code would be major surgery and probably not
useful.)

Discussion: https://www.postgresql.org/message-id/289c2e45-c7d9-5ce4-7eff-a9e2a33e1580@enterprisedb.com
This commit is contained in:
Peter Eisentraut 2022-10-14 08:37:12 +02:00
parent 34df7b9dfd
commit 1b11561cc1
3 changed files with 14 additions and 14 deletions

View File

@ -193,8 +193,8 @@ autoprewarm_main(Datum main_arg)
{
LWLockRelease(&apw_state->lock);
ereport(LOG,
(errmsg("autoprewarm worker is already running under PID %lu",
(unsigned long) apw_state->bgworker_pid)));
(errmsg("autoprewarm worker is already running under PID %d",
(int) apw_state->bgworker_pid)));
return;
}
apw_state->bgworker_pid = MyProcPid;
@ -303,8 +303,8 @@ apw_load_buffers(void)
{
LWLockRelease(&apw_state->lock);
ereport(LOG,
(errmsg("skipping prewarm because block dump file is being written by PID %lu",
(unsigned long) apw_state->pid_using_dumpfile)));
(errmsg("skipping prewarm because block dump file is being written by PID %d",
(int) apw_state->pid_using_dumpfile)));
return;
}
LWLockRelease(&apw_state->lock);
@ -599,12 +599,12 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
{
if (!is_bgworker)
ereport(ERROR,
(errmsg("could not perform block dump because dump file is being used by PID %lu",
(unsigned long) apw_state->pid_using_dumpfile)));
(errmsg("could not perform block dump because dump file is being used by PID %d",
(int) apw_state->pid_using_dumpfile)));
ereport(LOG,
(errmsg("skipping block dump because it is already being performed by PID %lu",
(unsigned long) apw_state->pid_using_dumpfile)));
(errmsg("skipping block dump because it is already being performed by PID %d",
(int) apw_state->pid_using_dumpfile)));
return 0;
}
@ -737,8 +737,8 @@ autoprewarm_start_worker(PG_FUNCTION_ARGS)
if (pid != InvalidPid)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("autoprewarm worker is already running under PID %lu",
(unsigned long) pid)));
errmsg("autoprewarm worker is already running under PID %d",
(int) pid)));
apw_start_leader_worker();

View File

@ -389,8 +389,8 @@ BackgroundWorkerStateChange(bool allow_new_workers)
rw->rw_worker.bgw_notify_pid = slot->worker.bgw_notify_pid;
if (!PostmasterMarkPIDForWorkerNotify(rw->rw_worker.bgw_notify_pid))
{
elog(DEBUG1, "worker notification PID %ld is not valid",
(long) rw->rw_worker.bgw_notify_pid);
elog(DEBUG1, "worker notification PID %d is not valid",
(int) rw->rw_worker.bgw_notify_pid);
rw->rw_worker.bgw_notify_pid = 0;
}

View File

@ -416,8 +416,8 @@ WaitForProcSignalBarrier(uint64 generation)
5000,
WAIT_EVENT_PROC_SIGNAL_BARRIER))
ereport(LOG,
(errmsg("still waiting for backend with PID %lu to accept ProcSignalBarrier",
(unsigned long) slot->pss_pid)));
(errmsg("still waiting for backend with PID %d to accept ProcSignalBarrier",
(int) slot->pss_pid)));
oldval = pg_atomic_read_u64(&slot->pss_barrierGeneration);
}
ConditionVariableCancelSleep();