X-Original-To: pgsql-interfaces@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id C2E27475C15 for ; Mon, 10 Mar 2003 16:31:06 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2ALV6ub020151; Mon, 10 Mar 2003 16:31:06 -0500 (EST) To: Roberto Costa Cc: PostgreSQL interfaces mailing list Subject: Re: Automatic detection of PostgreSQL version In-reply-to: <3E6CFF49.54AF36EB@libero.it> References: <3E6CFF49.54AF36EB@libero.it> Comments: In-reply-to Roberto Costa message dated "Mon, 10 Mar 2003 22:10:33 +0100" Date: Mon, 10 Mar 2003 16:31:06 -0500 Message-ID: <20150.1047331866@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/26 X-Sequence-Number: 3775 Roberto Costa 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