Re: Have BackendXidGetPid return pid_t - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Have BackendXidGetPid return pid_t
Date
Msg-id 3233362.1763153534@sss.pgh.pa.us
Whole thread Raw
In response to Have BackendXidGetPid return pid_t  (Sami Imseih <samimseih@gmail.com>)
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Sami Imseih
Date:
Subject: Have BackendXidGetPid return pid_t
Next
From: Bruce Momjian
Date:
Subject: Re: should we have a fast-path planning for OLTP starjoins?