From 4f793abc4a72fd0cd7b0feb213b027a517562a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emel=20=C5=9Eim=C5=9Fek?= Date: Wed, 14 Jun 2023 17:35:52 +0300 Subject: [PATCH] Turn on GUC_REPORT flag for search_path to enable reporting back the parameter value upon change. (#6983) DESCRIPTION: Turns on the GUC_REPORT flag for search_path. This results in postgres to report the parameter status back in addition to Command Complete packet. In response to the following command, > SET search_path TO client1; postgres sends back the following packets (shown in pseudo form): C (Command Complete) SET + **S (Parameter Status) search_path = client1** --- src/backend/distributed/shared_library_init.c | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/backend/distributed/shared_library_init.c b/src/backend/distributed/shared_library_init.c index 57bfb7197..a9b49e7c9 100644 --- a/src/backend/distributed/shared_library_init.c +++ b/src/backend/distributed/shared_library_init.c @@ -191,7 +191,7 @@ static void CitusCleanupConnectionsAtExit(int code, Datum arg); static void DecrementExternalClientBackendCounterAtExit(int code, Datum arg); static void CreateRequiredDirectories(void); static void RegisterCitusConfigVariables(void); -static void OverridePostgresConfigAssignHooks(void); +static void OverridePostgresConfigProperties(void); static bool ErrorIfNotASuitableDeadlockFactor(double *newval, void **extra, GucSource source); static bool WarnIfDeprecatedExecutorUsed(int *newval, void **extra, GucSource source); @@ -2587,16 +2587,17 @@ RegisterCitusConfigVariables(void) /* warn about config items in the citus namespace that are not registered above */ EmitWarningsOnPlaceholders("citus"); - OverridePostgresConfigAssignHooks(); + OverridePostgresConfigProperties(); } /* - * OverridePostgresConfigAssignHooks overrides GUC assign hooks where we want - * custom behaviour. + * OverridePostgresConfigProperties overrides GUC properties where we want + * custom behaviour. We should consider using Postgres function find_option + * in this function once it is exported by Postgres in a later release. */ static void -OverridePostgresConfigAssignHooks(void) +OverridePostgresConfigProperties(void) { struct config_generic **guc_vars = get_guc_variables(); int gucCount = GetNumConfigOptions(); @@ -2612,6 +2613,17 @@ OverridePostgresConfigAssignHooks(void) OldApplicationNameAssignHook = stringVar->assign_hook; stringVar->assign_hook = ApplicationNameAssignHook; } + + /* + * Turn on GUC_REPORT for search_path. GUC_REPORT provides that an S (Parameter Status) + * packet is appended after the C (Command Complete) packet sent from the server + * for SET command. S packet contains the new value of the parameter + * if its value has been changed. + */ + if (strcmp(var->name, "search_path") == 0) + { + var->flags |= GUC_REPORT; + } } }