From 0fe9864c32ef7babcce1549e0f3ee7ddc95704fa Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Fri, 5 Jan 2024 14:45:04 +0100 Subject: [PATCH v12 04/14] 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/tcop/backend_startup.c | 8 ++++---- src/include/utils/guc_tables.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/tcop/backend_startup.c b/src/backend/tcop/backend_startup.c index 0b9f899cd8b..27618e11e38 100644 --- a/src/backend/tcop/backend_startup.c +++ b/src/backend/tcop/backend_startup.c @@ -33,6 +33,7 @@ #include "tcop/backend_startup.h" #include "tcop/tcopprot.h" #include "utils/builtins.h" +#include "utils/guc_tables.h" #include "utils/memutils.h" #include "utils/ps_status.h" #include "utils/timeout.h" @@ -632,12 +633,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 unknown 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 0c0277c4230..f9caaf6f2ab 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