Hi, On 2021-02-21 20:53:52 -0500, Tom Lane wrote: > Andres Freund <and...@anarazel.de> writes: > >> If we're going to bother with providing a way > >> to get this info, we should make it possible to ask the running server. > > > In Vik's case there is no running server to ask, IIUC. > > Hm. If you're about to initdb or start the server then there's more > reason to think you can find a matching pg_config. Still, pg_config > is not going to tell you what is actually in the data directory, so > it's not clear to me how it helps with "do I need to initdb?".
Imagine trying to run regular tests of HEAD, where the tests require a large database to be loaded. Re-loading the data for every [few] commits is prohibitively time consuming, and even just running pg_upgrade is painful. So you'd like to re-use a "template" data directory with the data loaded if possible (i.e. no catversion / WAL / ... version bumps), and a pg_upgrade otherwise. In such a situation it's easy to access the catalog version for the existing data directory (pg_controldata, or pg_control_system()) - but there's no convenient way to figure out what the catversion of the to-be-tested version will be. Vik's approach to figuring that out was initdb'ing a throw-away data directory, using pg_controldata, and discarding that data directory - not pretty. There's no version skew issue here as far as I can tell, given he's initdbing freshly anyway. The only argument I see against such an option is that arguably just grepping for the information in the headers isn't too hard. But that's then something everybody has to do, there's the issue of plain unix commands not working on windows, etc. Greetings, Andres Freund