Re: How to check the postgresql version - Mailing list pgsql-hackers

From Thomas Hallgren
Subject Re: How to check the postgresql version
Date
Msg-id thhal-0X1V8Arvgby4EsC5vD9POvBK8s9HQae@mailblocks.com
Whole thread Raw
In response to Re: How to check the postgresql version  (Joe Conway <mail@joeconway.com>)
List pgsql-hackers
Joe Conway wrote:
> Along those lines, this is what I've been using in PL/R:
> 
> #if (CATALOG_VERSION_NO <= 200211021)
> #define PG_VERSION_73_COMPAT
> #elif (CATALOG_VERSION_NO <= 200310211)
> #define PG_VERSION_74_COMPAT
> #else
> #define PG_VERSION_80_COMPAT
> #endif
> 
> I wasn't following this thread earlier, but if you need to distinguish 
> between, for example, 7.4.3 and 7.4.6, the above won't help. If you just 
> need major Postgres version, it works well.
> 
PL/Java used to have this in the Makefile.

SS_VERSION := $(subst ., ,$(subst devel,.devel,$(VERSION)))
PGSQL_MAJOR_VER    = $(word 1,$(SS_VERSION))
PGSQL_MINOR_VER    = $(word 2,$(SS_VERSION))
PGSQL_PATCH_VER    = $(word 3,$(SS_VERSION))

override CPPFLAGS := \-DPGSQL_MAJOR_VER=$(PGSQL_MAJOR_VER) \-DPGSQL_MINOR_VER=$(PGSQL_MINOR_VER)
\-DPGSQL_PATCH_VER=$(PGSQL_MINOR_VER)

but I later removed the PGSQL_PATCH_VER since I don't plan to support 
different binaries for different patch levels. I'll try to do that using 
a more dynamic approach (i.e. through "SELECT version").

In the code, I do things like:

#if PGSQL_MAJOR_VER >= 8

or

#if PGSQL_MAJOR_VER == 7 && PGSQL_MINOR_VER < 3

Regards,
Thomas Hallgren



pgsql-hackers by date:

Previous
From: Thomas Hallgren
Date:
Subject: Preventing some SQL commands
Next
From: jseymour@linxnet.com (Jim Seymour)
Date:
Subject: Fix for "q" with psql display paging dumps out of psql