v6-0003-Prepare-server-code-for-addition-of-protocol-exte.patch

application/octet-stream

Filename: v6-0003-Prepare-server-code-for-addition-of-protocol-exte.patch
Type: application/octet-stream
Part: 0
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 v6-0003
Subject: Prepare server code for addition of protocol extensions
File+
src/backend/postmaster/postmaster.c 3 4
src/include/utils/guc_tables.h 1 0
From b0b30c73f5cd8d30a39986e174fa0f2cfa0cc6b4 Mon Sep 17 00:00:00 2001
From: Jelte Fennema-Nio <jelte.fennema@microsoft.com>
Date: Fri, 5 Jan 2024 14:45:04 +0100
Subject: [PATCH v6 03/10] Prepare server code for addition of protocol
 extensions

This adds some small changes to are necessary to support protocol
extension parameter GUCs in the future.

The server now checks if a GUC with the name of the protocol extension
parameter exists before reporting it as unsupported. The final behaviour
is still the same, since we have no GUCs yet that start with the `_pq_.`
prefix. It also adds a PROTOCOL_EXTENSION variant to the config_group
enum so protocol extension parameters can be grouped together.
---
 src/backend/postmaster/postmaster.c | 7 +++----
 src/include/utils/guc_tables.h      | 1 +
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index feb471dd1df..ad31e1046bb 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -2210,12 +2210,11 @@ retry1:
 									valptr),
 							 errhint("Valid values are: \"false\", 0, \"true\", 1, \"database\".")));
 			}
-			else if (strncmp(nameptr, "_pq_.", 5) == 0)
+			else if (strncmp(nameptr, "_pq_.", 5) == 0 && !find_option(nameptr, false, true, ERROR))
 			{
 				/*
-				 * Any option beginning with _pq_. is reserved for use as a
-				 * protocol-level option, but at present no such options are
-				 * defined.
+				 * We report unkown protocol extensions using the
+				 * NegotiateProtocolVersion message instead of erroring
 				 */
 				unrecognized_protocol_options =
 					lappend(unrecognized_protocol_options, pstrdup(nameptr));
diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h
index 0a2e274ebb2..4bba3dc3ccd 100644
--- a/src/include/utils/guc_tables.h
+++ b/src/include/utils/guc_tables.h
@@ -99,6 +99,7 @@ enum config_group
 	PRESET_OPTIONS,
 	CUSTOM_OPTIONS,
 	DEVELOPER_OPTIONS,
+	PROTOCOL_EXTENSION,
 };
 
 /*
-- 
2.34.1