Martijn van Oosterhout wrote:
-- Start of PGP signed section.
> On Tue, Feb 28, 2006 at 12:45:18AM -0500, Bruce Momjian wrote:
> >
> > I have developed a patch which creates a new pg_config.h define called
> > PG_VERSION_NUM, which is a number like 80200, with no beta/devel
> > designation. I think this will be helpful (eventually) for people
> > writing plug-ins. Attached.
>
> I like it. Arguably the development period between 8.1 and 8.2 could be
> designated 80190 (8.1.90) with various betas being 80191-80199. But
> hey, having any symbol define the current version is better than
> nothing at all.
>
> Thanks for this,
> --
> Martijn van Oosterhout <[email protected]> http://svana.org/kleptog/
> > Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> > tool for doing 5% of the work and then sitting around waiting for someone
> > else to do the other 95% so you can sue them.
OK, updated version of the patch attached and applied.
--
Bruce Momjian http://candle.pha.pa.us
SRA OSS, Inc. http://www.sraoss.com
+ If your life is a hard drive, Christ can be your backup. +
Index: configure
===================================================================
RCS file: /cvsroot/pgsql/configure,v
retrieving revision 1.480
diff -c -c -r1.480 configure
*** configure 21 Feb 2006 06:06:44 -0000 1.480
--- configure 28 Feb 2006 16:39:09 -0000
***************
*** 4742,4747 ****
--- 4742,4755 ----
fi
+ # Supply a numeric version string for use by 3rd party add-ons
+ PG_VERSION_NUM="`echo "$PACKAGE_VERSION" | sed 's/A-Za-z.*$//' |
+ $AWK -F'\.' '{printf \"%d%02d%02d\", $1, $2, (NF >= 3) ? $3 : 0}'`"
+
+ cat >>confdefs.h <<_ACEOF
+ #define PG_VERSION_NUM $PG_VERSION_NUM
+ _ACEOF
+
##
## Libraries
Index: configure.in
===================================================================
RCS file: /cvsroot/pgsql/configure.in,v
retrieving revision 1.450
diff -c -c -r1.450 configure.in
*** configure.in 21 Feb 2006 06:06:50 -0000 1.450
--- configure.in 28 Feb 2006 16:39:10 -0000
***************
*** 26,32 ****
AC_PREFIX_DEFAULT(/usr/local/pgsql)
AC_SUBST(configure_args, [$ac_configure_args])
! AC_DEFINE_UNQUOTED(PG_VERSION, "$PACKAGE_VERSION", [PostgreSQL version])
AC_CANONICAL_HOST
--- 26,32 ----
AC_PREFIX_DEFAULT(/usr/local/pgsql)
AC_SUBST(configure_args, [$ac_configure_args])
! AC_DEFINE_UNQUOTED(PG_VERSION, "$PACKAGE_VERSION", [PostgreSQL version as a
string])
AC_CANONICAL_HOST
***************
*** 585,590 ****
--- 585,594 ----
PGAC_CHECK_PYTHON_EMBED_SETUP
fi
+ # Supply a numeric version string for use by 3rd party add-ons
+ PG_VERSION_NUM="`echo "$PACKAGE_VERSION" | sed 's/[A-Za-z].*$//' |
+ $AWK -F'\.' '{printf \"%d%02d%02d\", $1, $2, (NF >= 3) ? $3 : 0}'`"
+ AC_DEFINE_UNQUOTED(PG_VERSION_NUM, $PG_VERSION_NUM, [PostgreSQL version as a
number])
##
## Libraries
Index: src/include/pg_config.h.in
===================================================================
RCS file: /cvsroot/pgsql/src/include/pg_config.h.in,v
retrieving revision 1.93
diff -c -c -r1.93 pg_config.h.in
*** src/include/pg_config.h.in 21 Feb 2006 06:06:50 -0000 1.93
--- src/include/pg_config.h.in 28 Feb 2006 16:39:19 -0000
***************
*** 547,555 ****
(--with-krb-srvnam=NAME) */
#undef PG_KRB_SRVNAM
! /* PostgreSQL version */
#undef PG_VERSION
/* A string containing the version number, platform, and C compiler */
#undef PG_VERSION_STR
--- 547,558 ----
(--with-krb-srvnam=NAME) */
#undef PG_KRB_SRVNAM
! /* PostgreSQL version as a string */
#undef PG_VERSION
+ /* PostgreSQL version as a number */
+ #undef PG_VERSION_NUM
+
/* A string containing the version number, platform, and C compiler */
#undef PG_VERSION_STR
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend