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

From Ruey-Lung Hsiao
Subject How to check the postgresql version
Date
Msg-id AlPmd.22363$6q2.1705@newssvr14.news.prodigy.com
Whole thread Raw
Responses Re: How to check the postgresql version
Re: How to check the postgresql version
List 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


pgsql-hackers by date:

Previous
From: Ruey-Lung Hsiao
Date:
Subject: "no snapshot has been set" error
Next
From: "Premsun Choltanwanich"
Date:
Subject: How to make lo_import and lo_export to use file on client local machine?