Re: Finding the pqlib version - Mailing list pgsql-interfaces

From Bruce Momjian
Subject Re: Finding the pqlib version
Date
Msg-id 200602111501.k1BF1i017587@candle.pha.pa.us
Whole thread Raw
In response to Finding the pqlib version  (Christoph Zwerschke <cito@online.de>)
Responses Re: Finding the pqlib version
List pgsql-interfaces
Christoph Zwerschke wrote:
> I want to add the PQCancel() functionality to PyGreSQL.
> Until now, PyGreSQL works with PostgreSQL 7.3+, but
> unfortunately, PQCancel() is only available from 8.0+.
> 
> In order to not break compilation of PyGreSQL on systems with PG7,
> I would like to do something like the following:
> 
> #if PQLIB_VERSION_MAJOR < 8
>    PQRequestCancel(conn)
> #else
>    c = PQgetCancel(conn)
>    PQCancel(c, errbuf, 256)
>    PQfreeCancel(c)
> #end
> 
> However, there is no such thing as "PQLIB_VERSION_MAJOR".
> Anything else I could query instead?

You want the server version.  In PostgreSQL 8.0 and later you can use
libpq's PQserverVersion(), but for pre-8.0, I think you have to do
SELECT version(), and parse that:
test=> SELECT version();
version------------------------------------------------------------------PostgreSQL 8.2devel on i386-pc-bsdi4.3.1,
compiledby GCC 2.95.3(1 row)
 

I would also look how other interfaces are doing this.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-interfaces by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Finding the pqlib version
Next
From: Christoph Zwerschke
Date:
Subject: Re: Finding the pqlib version