Re: Automatic detection of PostgreSQL version

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Roberto Costa <rob(dot)costa(at)libero(dot)it>
Cc: PostgreSQL interfaces mailing list <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: Automatic detection of PostgreSQL version
Date: 2003-03-10 21:31:06
Message-ID: 20150.1047331866@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Roberto Costa <rob(dot)costa(at)libero(dot)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

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Ashley Cambrell 2003-03-10 21:37:28 Re: Roadmap for FE/BE protocol redesign
Previous Message Tom Lane 2003-03-10 21:26:24 Re: [INTERFACES] Roadmap for FE/BE protocol redesign