Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1b11561

Browse files
committed
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
1 parent 34df7b9 commit 1b11561

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

contrib/pg_prewarm/autoprewarm.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ autoprewarm_main(Datum main_arg)
193193
{
194194
LWLockRelease(&apw_state->lock);
195195
ereport(LOG,
196-
(errmsg("autoprewarm worker is already running under PID %lu",
197-
(unsigned long) apw_state->bgworker_pid)));
196+
(errmsg("autoprewarm worker is already running under PID %d",
197+
(int) apw_state->bgworker_pid)));
198198
return;
199199
}
200200
apw_state->bgworker_pid = MyProcPid;
@@ -303,8 +303,8 @@ apw_load_buffers(void)
303303
{
304304
LWLockRelease(&apw_state->lock);
305305
ereport(LOG,
306-
(errmsg("skipping prewarm because block dump file is being written by PID %lu",
307-
(unsigned long) apw_state->pid_using_dumpfile)));
306+
(errmsg("skipping prewarm because block dump file is being written by PID %d",
307+
(int) apw_state->pid_using_dumpfile)));
308308
return;
309309
}
310310
LWLockRelease(&apw_state->lock);
@@ -599,12 +599,12 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
599599
{
600600
if (!is_bgworker)
601601
ereport(ERROR,
602-
(errmsg("could not perform block dump because dump file is being used by PID %lu",
603-
(unsigned long) apw_state->pid_using_dumpfile)));
602+
(errmsg("could not perform block dump because dump file is being used by PID %d",
603+
(int) apw_state->pid_using_dumpfile)));
604604

605605
ereport(LOG,
606-
(errmsg("skipping block dump because it is already being performed by PID %lu",
607-
(unsigned long) apw_state->pid_using_dumpfile)));
606+
(errmsg("skipping block dump because it is already being performed by PID %d",
607+
(int) apw_state->pid_using_dumpfile)));
608608
return 0;
609609
}
610610

@@ -737,8 +737,8 @@ autoprewarm_start_worker(PG_FUNCTION_ARGS)
737737
if (pid != InvalidPid)
738738
ereport(ERROR,
739739
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
740-
errmsg("autoprewarm worker is already running under PID %lu",
741-
(unsigned long) pid)));
740+
errmsg("autoprewarm worker is already running under PID %d",
741+
(int) pid)));
742742

743743
apw_start_leader_worker();
744744

src/backend/postmaster/bgworker.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ BackgroundWorkerStateChange(bool allow_new_workers)
389389
rw->rw_worker.bgw_notify_pid = slot->worker.bgw_notify_pid;
390390
if (!PostmasterMarkPIDForWorkerNotify(rw->rw_worker.bgw_notify_pid))
391391
{
392-
elog(DEBUG1, "worker notification PID %ld is not valid",
393-
(long) rw->rw_worker.bgw_notify_pid);
392+
elog(DEBUG1, "worker notification PID %d is not valid",
393+
(int) rw->rw_worker.bgw_notify_pid);
394394
rw->rw_worker.bgw_notify_pid = 0;
395395
}
396396

src/backend/storage/ipc/procsignal.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ WaitForProcSignalBarrier(uint64 generation)
416416
5000,
417417
WAIT_EVENT_PROC_SIGNAL_BARRIER))
418418
ereport(LOG,
419-
(errmsg("still waiting for backend with PID %lu to accept ProcSignalBarrier",
420-
(unsigned long) slot->pss_pid)));
419+
(errmsg("still waiting for backend with PID %d to accept ProcSignalBarrier",
420+
(int) slot->pss_pid)));
421421
oldval = pg_atomic_read_u64(&slot->pss_barrierGeneration);
422422
}
423423
ConditionVariableCancelSleep();

0 commit comments

Comments
 (0)