On Sat, Mar 25, 2023 at 11:01:33AM -0600, Markus Pilman wrote: > Now the problem is that I need to find a TCP port for each running postgres > instance. There's multiple ways to do this, but by far the easiest one I > know is to bind to port 0. So my plan was to start postgres with "-p 0" and > then parse stdout to figure out which port it actually uses. But that > doesn't seem to work: Note that you can find some inspiration about that in the code tree within src/test/perl/PostgreSQL/Test/Cluster.pm, particularly get_free_port(), where we have now accumulated a couple of years of experience in designing something that's rather safe, even if it comes with its own limits. It is in perl so perhaps you could just reuse it rather than reinvent the wheel? Of course, still it should not be complicated to translate that in a different language, but there may be no need to reinvent the wheel. And seeing your first message with the requirements you list, this does what you are looking for: - Create an empty cluster. - Freely create databases, tablespaces, queries, etc. - Wipe out the whole. The test cases around src/test/recovery/t/ could be a good starting point, as well. -- Michael
Attachment:
signature.asc
Description: PGP signature