Hi all

While looking into client code that relies on parsing server_version
instead of checking server_version_num, I was surprised to discover that
server_version_num isn't sent to the client by the server as part of the
standard set of parameters reported post-auth.

The docs reflect this:

http://www.postgresql.org/docs/current/static/protocol-flow.html#PROTOCOL-ASYNC

The attached patch marks server_version_num GUC_REPORT and documents
that it's reported to the client automatically.

(See mention here:
https://github.com/impossibl/pgjdbc-ng/commit/40b6dc658a9b38725be220e2fa653a5a8a0cbae4#commitcomment-8427979)

-- 
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

>From abb5db65094710155d723f2848f21d61d25e6994 Mon Sep 17 00:00:00 2001
From: Craig Ringer <cr...@2ndquadrant.com>
Date: Fri, 9 Jan 2015 13:54:26 +0800
Subject: [PATCH] Send server_version_num to client on start

Add server_version_num to the list of parameters the server
automatically sends the client on startup.

Previously we sent ParameterStatus messages for server_version and
various other parameters, but didn't include server_version_num. Since
we're trying to discourage clients from parsing the version number
it'd make sense to actually send it to them when they need it.
---
 doc/src/sgml/protocol.sgml   | 4 +++-
 src/backend/utils/misc/guc.c | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 31bbc0d..cbeedc0 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -1091,6 +1091,7 @@
     At present there is a hard-wired set of parameters for which
     ParameterStatus will be generated: they are
     <varname>server_version</>,
+    <varname>server_version_num</>,
     <varname>server_encoding</>,
     <varname>client_encoding</>,
     <varname>application_name</>,
@@ -1106,7 +1107,8 @@
     <varname>standard_conforming_strings</> was not reported by releases
     before 8.1;
     <varname>IntervalStyle</> was not reported by releases before 8.4;
-    <varname>application_name</> was not reported by releases before 9.0.)
+    <varname>application_name</> was not reported by releases before 9.0;
+    <varname>server_version_num</> was not reported by releases before 9.5)
     Note that
     <varname>server_version</>,
     <varname>server_encoding</> and
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index d4a77ea..a51e511 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2510,7 +2510,7 @@ static struct config_int ConfigureNamesInt[] =
 		{"server_version_num", PGC_INTERNAL, PRESET_OPTIONS,
 			gettext_noop("Shows the server version as an integer."),
 			NULL,
-			GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
+			GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
 		},
 		&server_version_num,
 		PG_VERSION_NUM, PG_VERSION_NUM, PG_VERSION_NUM,
-- 
2.1.0

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to