summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2022-10-14 06:37:12 +0000
committerPeter Eisentraut2022-10-14 06:38:53 +0000
commit1b11561cc1de7596f6f7cb750743af94b9d168f7 (patch)
treea16c63b0dfd1d35a520337f5342f8cf59c0ffd1e
parent34df7b9dfdeee442cf43060b6499bedc5f619f7f (diff)
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/[email protected]
-rw-r--r--contrib/pg_prewarm/autoprewarm.c20
-rw-r--r--src/backend/postmaster/bgworker.c4
-rw-r--r--src/backend/storage/ipc/procsignal.c4
3 files changed, 14 insertions, 14 deletions
diff --git a/contrib/pg_prewarm/autoprewarm.c b/contrib/pg_prewarm/autoprewarm.c
index c8d673a20e..1843b1862e 100644
--- a/contrib/pg_prewarm/autoprewarm.c
+++ b/contrib/pg_prewarm/autoprewarm.c
@@ -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();
diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c
index 8dd7d64630..0d72de24b0 100644
--- a/src/backend/postmaster/bgworker.c
+++ b/src/backend/postmaster/bgworker.c
@@ -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;
}
diff --git a/src/backend/storage/ipc/procsignal.c b/src/backend/storage/ipc/procsignal.c
index 21a9fc0fdd..7767657f27 100644
--- a/src/backend/storage/ipc/procsignal.c
+++ b/src/backend/storage/ipc/procsignal.c
@@ -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();