Today on IRC David Fetter and some others were discussing version numbers and we realized that although libpq now provides the version of Postgres as a number, this is still a wheel that is being reinvented by apps many times over, as it is not available any other way. Hence, a small patch to provide a new variable "server_version_num", which is almost the same as "server_version" but uses the handy PG_VERSION_NUM which allows apps to do things like if ($version >= 80200) without having to parse apart the value of server_version themselves.
-- Greg Sabino Mullane [EMAIL PROTECTED] End Point Corporation http://www.endpoint.com/ PGP Key: 0x14964AC8 200607292113 http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
Index: doc/src/sgml/config.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/config.sgml,v
retrieving revision 1.71
diff -u -c -r1.71 config.sgml
*** doc/src/sgml/config.sgml 27 Jul 2006 08:30:41 -0000 1.71
--- doc/src/sgml/config.sgml 29 Jul 2006 23:31:58 -0000
***************
*** 4141,4146 ****
--- 4141,4159 ----
</listitem>
</varlistentry>
+ <varlistentry id="guc-server-version-num" xreflabel="server_version_num">
+ <term><varname>server_version_num</varname> (<type>integer</type>)</term>
+ <indexterm>
+ <primary><varname>server_version_num</> configuration parameter</primary>
+ </indexterm>
+ <listitem>
+ <para>
+ Reports the version number of the server as an integer. It is determined
+ by the value of <literal>PG_VERSION_NUM</> when building the server.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect1>
Index: src/backend/utils/misc/check_guc
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/misc/check_guc,v
retrieving revision 1.9
diff -u -c -r1.9 check_guc
*** src/backend/utils/misc/check_guc 25 Jul 2005 22:12:33 -0000 1.9
--- src/backend/utils/misc/check_guc 29 Jul 2006 23:31:59 -0000
***************
*** 18,26 ****
## can be ignored
INTENTIONALLY_NOT_INCLUDED="autocommit debug_deadlocks exit_on_error \
is_superuser lc_collate lc_ctype lc_messages lc_monetary lc_numeric lc_time \
! pre_auth_delay role seed server_encoding server_version session_authorization \
! trace_lock_oidmin trace_lock_table trace_locks trace_lwlocks trace_notify \
! trace_userlocks transaction_isolation transaction_read_only \
zero_damaged_pages"
### What options are listed in postgresql.conf.sample, but don't appear
--- 18,26 ----
## can be ignored
INTENTIONALLY_NOT_INCLUDED="autocommit debug_deadlocks exit_on_error \
is_superuser lc_collate lc_ctype lc_messages lc_monetary lc_numeric lc_time \
! pre_auth_delay role seed server_encoding server_version server_version_int \
! session_authorization trace_lock_oidmin trace_lock_table trace_locks trace_lwlocks \
! trace_notify trace_userlocks transaction_isolation transaction_read_only \
zero_damaged_pages"
### What options are listed in postgresql.conf.sample, but don't appear
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.333
diff -u -c -r1.333 guc.c
*** src/backend/utils/misc/guc.c 29 Jul 2006 03:02:56 -0000 1.333
--- src/backend/utils/misc/guc.c 29 Jul 2006 23:31:59 -0000
***************
*** 220,225 ****
--- 220,226 ----
static char *regex_flavor_string;
static char *server_encoding_string;
static char *server_version_string;
+ static int server_version_num;
static char *timezone_string;
static char *timezone_abbreviations_string;
static char *XactIsoLevel_string;
***************
*** 1617,1622 ****
--- 1618,1634 ----
DEFAULT_EFFECTIVE_CACHE_SIZE, 1, INT_MAX, NULL, NULL
},
+ {
+ /* Can't be set in postgresql.conf */
+ {"server_version_num", PGC_INTERNAL, PRESET_OPTIONS,
+ gettext_noop("Shows the server version as an integer."),
+ NULL,
+ GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
+ },
+ &server_version_num,
+ PG_VERSION_NUM, PG_VERSION_NUM, PG_VERSION_NUM, NULL, NULL
+ },
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, 0, 0, 0, NULL, NULL
signature.asc
Description: This is a digitally signed message part
