Re: Automatic detection of PostgreSQL version - Mailing list pgsql-interfaces

From Tom Lane
Subject Re: Automatic detection of PostgreSQL version
Date
Msg-id 20150.1047331866@sss.pgh.pa.us
Whole thread Raw
In response to Automatic detection of PostgreSQL version  (Roberto Costa <rob.costa@libero.it>)
List pgsql-interfaces
Roberto Costa <rob.costa@libero.it> writes:
> What I'm currently doing is searching typical include directories (like
> /usr/include, /usr/local/share/include, ...) for the presence of a
> directory named postgresql or pgsql that contains config.h or
> pg_config.h (used since PostgreSQL 7.2, if I'm not wrong). When such a
> file is found, I grep it for a line that starts with "#define
> PG_VERSION" and I expect the version follow and be in the form
> "x.y.z".

This requires that the Postgres include files be installed, which seems
an unreliable bet to me.  It'd be better to look for the executable
pg_config and run "pg_config --version".  If you find multiple
pg_config's, you can select the most preferable version.  After that,
you can ask pg_config where the include and library files are supposed
to be.

One advantage of doing it this way is that it should be sufficient to
look in the $PATH directories, rather than searching some ad-hoc
collection of likely include locations.
        regards, tom lane


pgsql-interfaces by date:

Previous
From: Tom Lane
Date:
Subject: Re: Roadmap for FE/BE protocol redesign
Next
From: Bruce Badger
Date:
Subject: Re: Roadmap for FE/BE protocol redesign