Re: How to check the postgresql version

From: Thomas Hallgren <thhal(at)mailblocks(dot)com>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Ruey-Lung Hsiao <rlhsiao(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: How to check the postgresql version
Date: 2004-11-21 16:05:48
Message-ID: thhal-0X1V8Arvgby4EsC5vD9POvBK8s9HQae@mailblocks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Seymour 2004-11-21 17:39:56 Fix for "q" with psql display paging dumps out of psql
Previous Message Thomas Hallgren 2004-11-21 15:55:37 Preventing some SQL commands