On Wed, Mar 3, 2021 at 8:16 PM Tom Lane <t...@sss.pgh.pa.us> wrote: > > Vik Fearing <v...@postgresfriends.org> writes: > > On 3/3/21 6:35 PM, Peter Eisentraut wrote: > >> If what you want to know is whether a given binary can run against a > >> given data directory then CATALOG_VERSION_NO isn't the only thing you > >> need to check. The full truth of this is in ReadControlFile(). The > >> best way to get that answer is to start a server and see if it > >> complains. You can even grep the log for "It looks like you need to > >> initdb.". > > > In that case, what would everyone think about a `pg_ctl check` option? > > The trouble with Peter's recipe is that it doesn't work if there is > already a server instance running there (or at least I think we'll > bitch about the existing postmaster first, maybe I'm wrong). Now, > that's not such a big problem for the use-case you were describing. > But I bet if we expose this method as an apparently-general-purpose > pg_ctl option, there'll be complaints.
Another option could be to provide a switch to the postmaster binary. Using pg_config as originally suggested is risky because you might pick up the wrong postmaster, but if you put it on the actual postmaster binary you certainly know which one you're on... As this is something that's primarily of interest to developers, it's also a bit lower weight than having a "heavy" solution like an entire mode for pg_ctl. -- Magnus Hagander Me: https://www.hagander.net/ Work: https://www.redpill-linpro.com/