How to check the postgresql version

From: Ruey-Lung Hsiao <rlhsiao(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: How to check the postgresql version
Date: 2004-11-17 21:25:52
Message-ID: AlPmd.22363$6q2.1705@newssvr14.news.prodigy.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Sorry if this problem seems stupid but I would appreciate it if
someone helps.

I've been implementing several user-defined types and their
corresponding GiST index in postgresql 7.4.3. They worked well. However,
I have noticed there are several changes in SPI functions and their
parameters in 8.0beta. I want to be able to compile my codes in
Postgresql 7.4.X and 8.0.X, so the only way to do that is to use the C
preprocessor directives to check PG_VERSION (defined in pg_config.h).

My problem is: I can't find a way to compare strings in C
preprocessor directive since PG_VERSION is defined as something like
"7.4.3" or "7.4.6". I ultimately want to do the following things:

#if PG_VERSION starts with "8.X"
... call 8.0 compatible functions
#else
... call 7.4.x compatible functions
#endif

Could anyone tell me how to do this kind of version check task?
Thank you very much.

Ruey-Lung Hsiao

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-11-17 21:32:22 Re: 7.4.5 / 7.4.6 crash (pg_hba.conf issue)
Previous Message Devrim GUNDUZ 2004-11-17 21:15:03 Re: 7.4.5 / 7.4.6 crash (pg_hba.conf issue)