Thread: [HACKERS] Location of PG_CATALOG_VERSION

[HACKERS] Location of PG_CATALOG_VERSION

From
Vicky Vergara
Date:

Hello all


The postgreSQL version is needed internally in order to make the code work because for example the type of funcctx->max_calls  changed on 9.6



uint64_t result_count = 0;

...


#if PGSQL_VERSION > 95
        funcctx->max_calls = result_count;
#else
        funcctx->max_calls = (uint32_t)result_count;
#endif

PGSQL_VERSION is a result of a manipulation of the version found using FindPostgres.cmake (which uses pg_config --version)


From this message: https://www.postgresql.org/message-id/1585.1472410329%40sss.pgh.pa.us


I deduced that in the code I can use

PG_CATALOG_VERSION


I made the following experiment:


#define STRINGIFY(s) XSTRINGIFY(s)
#define XSTRINGIFY(s) #s

#pragma message ("The value PGSQL_VERSION: " STRINGIFY(PGSQL_VERSION))
#ifdef PG_CATALOG_VERSION
#pragma message ("The value PG_CATALOG_VERSION: " STRINGIFY(PG_CATALOG_VERSION))
#endif


I have this result:

note: #pragma message: The value PGSQL_VERSION: 93

So PG_CATALOG_VERSION is not defined, then I went to see the doxygen page to find out which file I have to include to get the definition.
But PG_CATALOG_VERSION its not there.

So, what am I missing?

I have no problem on doing more manipulations to get a value that I can use in the #if PGSQL_VERSION > 95 comparison (like 100 for postgreSQL 10betaX) but if PG_CATALOG_VERSION is considered the best thing to look at, where can I find it?

Vicky








Re: [HACKERS] Location of PG_CATALOG_VERSION

From
Tom Lane
Date:
Vicky Vergara <vicky_vergara@hotmail.com> writes:
> From this message:
> https://www.postgresql.org/message-id/1585.1472410329%40sss.pgh.pa.us
> I deduced that in the code I can use
> PG_CATALOG_VERSION

No, sorry, thinko on my part.  It's CATALOG_VERSION_NO, from
<catalog/catversion.h>, that people usually use for this sort of thing.
That gives you finer grain than PG_VERSION would, although that only
matters if you're concerned about working with development versions.
        regards, tom lane