v10-0009-psql-Warn-about-unsupported-protocol-features.patch

application/octet-stream

Filename: v10-0009-psql-Warn-about-unsupported-protocol-features.patch
Type: application/octet-stream
Part: 8
Message: Re: Add new protocol message to change GUCs for usage with future protocol-only GUCs

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v10-0009
Subject: psql: Warn about unsupported protocol features
File+
src/bin/psql/command.c 37 0
From 9d9ab454c4ba221b6561a869c1956ee000fe5169 Mon Sep 17 00:00:00 2001
From: Jelte Fennema-Nio <jelte.fennema@microsoft.com>
Date: Sat, 13 Jan 2024 15:25:13 +0100
Subject: [PATCH v10 09/13] psql: Warn about unsupported protocol features

When the requested protocol version or protocol extension parameters
are not supported by the server this warns the user of that. This is a
warning, and not an error, since most functionality continues to work
just fine.
---
 src/bin/psql/command.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index f4ba7f8d5d0..9f4d023cba1 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3802,6 +3802,7 @@ connection_warnings(bool in_startup)
 		int			client_ver = PG_VERSION_NUM;
 		char		cverbuf[32];
 		char		sverbuf[32];
+		int			server_protocol_version;
 
 		if (pset.sversion != client_ver)
 		{
@@ -3838,6 +3839,42 @@ connection_warnings(bool in_startup)
 				   formatPGVersionNumber(pset.sversion, false,
 										 sverbuf, sizeof(sverbuf)));
 
+		server_protocol_version = PQprotocolVersion(pset.db);
+		if (server_protocol_version < PG_PROTOCOL_FULL(PG_PROTOCOL_LATEST))
+		{
+			int			client_major = PG_PROTOCOL_MAJOR(PG_PROTOCOL_LATEST);
+			int			client_minor = PG_PROTOCOL_MINOR(PG_PROTOCOL_LATEST);
+			int			server_major;
+			int			server_minor;
+
+			if (server_protocol_version == 3)
+			{
+				server_major = 3;
+				server_minor = 0;
+			}
+			else
+			{
+				server_major = server_protocol_version / 10000;
+				server_minor = server_protocol_version / 10000;
+			}
+			printf(_("WARNING: psql protocol version %d.%d, server protocol version %d.%d.\n"
+					 "         \\parameterset not work.\n"),
+				   client_major, client_minor, server_major, server_minor);
+		}
+
+		if (PQunsupportedProtocolExtensionParameters(pset.db)[0] != NULL)
+		{
+			const char **unsupported_parameters = PQunsupportedProtocolExtensionParameters(pset.db);
+			int			i = 0;
+
+			printf(_("WARNING: Server does not support the following requested protocol extension parameters:\n"));
+			while (unsupported_parameters[i] != NULL)
+			{
+				printf("         %s\n", unsupported_parameters[i]);
+				i++;
+			}
+		}
+
 #ifdef WIN32
 		if (in_startup)
 			checkWin32Codepage();
-- 
2.34.1