Re: Exposing PG_VERSION_NUM in pg_config

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Exposing PG_VERSION_NUM in pg_config
Date: 2015-03-31 05:05:18
Message-ID: CAB7nPqSUHA3=T+iQXV5bH5X5+pqFT_dVKJnoXakD+i7+num8CQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 31, 2015 at 9:40 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:

> On 3/30/15 6:29 PM, Michael Paquier wrote:
> >
> >
> > On Tue, Mar 31, 2015 at 5:39 AM, Peter Eisentraut <peter_e(at)gmx(dot)net
> > <mailto:peter_e(at)gmx(dot)net>> wrote:
> >
> > On 3/25/15 1:32 AM, Michael Paquier wrote:
> > > Well, I have no other cases than ones of the type mentioned
> upthread,
> > > and honestly I am fine as long as we do not apply maths to a
> version
> > > string. So attached is a patch that adds VERSION_NUM in
> > > Makefile.global.
> >
> > How would you make use of this in an extension makefile?
> >
> >
> > One use case is regression test list filtering depending on backend
> version.
>
> I'm interested in the exact syntax you'd use, to compare it to the
> currently used techniques.
>

With the presence of VERSION_NUM directly in pg_config, the following
expression:
VERSION_NUM=$(shell $(PG_CONFIG) --version-num)

With its presence in Makefile.global, that's close to what you can do with
pg_config.h already:
VERSION_NUM := $(shell cat `$(PG_CONFIG) --libdir`/pgxs/src/Makefile.global
\
| perl -ne 'print $$1 and exit if /VERSION_NUM =\s+(\d+)/')
But that looks a little bit magic..

Another advantage of putting this information in pg_config is for
environments that do not have PGXS installed, for example MSVC.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jehan-Guillaume de Rorthais 2015-03-31 06:24:15 Re: Maximum number of WAL files in the pg_xlog directory
Previous Message Kyotaro HORIGUCHI 2015-03-31 04:02:56 GUC context information in the document.