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