X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 50B0D9DC831 for ; Sat, 11 Feb 2006 11:01:45 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34926-05 for ; Sat, 11 Feb 2006 11:01:49 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) by postgresql.org (Postfix) with ESMTP id B77509DC839 for ; Sat, 11 Feb 2006 11:01:42 -0400 (AST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id k1BF1i017587; Sat, 11 Feb 2006 10:01:44 -0500 (EST) From: Bruce Momjian Message-Id: <200602111501.k1BF1i017587@candle.pha.pa.us> Subject: Re: Finding the pqlib version In-Reply-To: <43EDC399.6060203@online.de> To: Christoph Zwerschke Date: Sat, 11 Feb 2006 10:01:44 -0500 (EST) CC: pgsql-interfaces@postgresql.org X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.125 required=5 tests=[AWL=0.125] X-Spam-Score: 0.125 X-Spam-Level: X-Archive-Number: 200602/27 X-Sequence-Number: 5991 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, compiled by 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, Pennsylvania 19073