Re: Version Number Function?

From: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Version Number Function?
Date: 2008-10-12 21:39:14
Message-ID: 0B482C37-19B8-4F05-94F2-86DA6625CE2C@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Oct 12, 2008, at 14:11, Tom Lane wrote:

> You'd have to parse the result of version().

As I figured. This is what I'm trying:

pg_version_num(PG_FUNCTION_ARGS)
{
#ifdef PG_VERSION_NUM
PG_RETURN_INT32(PG_VERSION_NUM);
#else
/* Code borrowed from dumputils.c. */
int cnt;
int vmaj,
vmin,
vrev;

cnt = sscanf(PG_VERSION, "%d.%d.%d", &vmaj, &vmin, &vrev);

if (cnt < 2)
return -1;

if (cnt == 2)
vrev = 0;

PG_RETURN_INT32( (100 * vmaj + vmin) * 100 + vrev );
#endif

Best,

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Grzegorz Jaskiewicz 2008-10-12 23:14:14 Re: SELECT TOP %d PERCENT, or SELECT ... LIMIT %d PERCENT ?
Previous Message Devrim GÜNDÜZ 2008-10-12 21:21:26 New shapshot RPMs (Oct 11 2008) are ready for testing