Yurii Rashkovskii <yrashk@gmail.com> writes:
> Thank you all for the feedback. It's quite useful. I think it is important
> to separate this into two concerns:
> 1. Letting Postgres pick an unused port.
> 2. Retrieving the port it picked.
Yeah, those are distinguishable implementation concerns, but ...
> The bottom line is this decouples (1) from (2), and we can resolve them
> separately if there's too much (understandable) hesitation to commit to a
> particular approach to it (documenting postmaster.pid, changing its format,
> amending pg_ctl functionality, etc.)
... AFAICS, there is exactly zero value in committing a solution for (1)
without also committing a solution for (2). I don't think any of the
alternative methods you proposed are attractive or things we should
recommend.
regards, tom lane