Have BackendXidGetPid return pid_t
Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.
You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:
docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t52679psql -h localhost -U postgresBuilt from patchset v1 (message #1), September 20, 2026 at 02:24 AM.
Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:
git clone --branch t52679_1 https://github.com/hackorum-dev/postgres.gitIn a checkout you already have, add the fork once:
git remote add hackorum https://github.com/hackorum-dev/postgres.gitthen, for this patchset and every later one:
git fetch hackorum t52679_1 && git checkout t52679_1Patchset v1 (message #1) is on t52679_1
Hi,
While looking at something nearby, I noticed that BackendXidGetPid()
uses an "int" for "pid", where it should be used "pid_t" like in other
places in the code including in procarray.c.
Here is a small patch to fix this.
Thanks,
--
Sami Imseih
Amazon Web Services (AWS)
Sami Imseih <samimseih@gmail.com> writes:
While looking at something nearby, I noticed that BackendXidGetPid()
uses an "int" for "pid", where it should be used "pid_t" like in other
places in the code including in procarray.c.
I don't think this is an amazingly good idea, considering that the
value it's returning is from an "int" field in struct PGPROC.
You didn't change the function's "result" variable either, nor
is it clear what callers like
snprintf(buf, NCHARS, "%d",
BackendXidGetPid(members[j].xid));
should be doing.
Perhaps at some point we should try to uniformly represent PIDs
as pid_t, but it'll require a far larger patch than this.
(I have a vague recollection also that some places expect PIDs in
shared memory to be atomically updatable, so machines where pid_t
is actually different from int might start to have issues.)
regards, tom lane