Skip to content

Commit

Permalink
Report search_path to make it possible to use it in pgbouncer track_e…
Browse files Browse the repository at this point in the history
…xtra_parameters
  • Loading branch information
Konstantin Knizhnik committed Jul 6, 2024
1 parent 0a937b7 commit 83d64f8
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion pgxn/neon/neon.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "utils/builtins.h"
#include "utils/pg_lsn.h"
#include "utils/guc.h"
#include "utils/guc_tables.h"
#include "utils/wait_event.h"

#include "extension_server.h"
Expand Down Expand Up @@ -554,7 +555,39 @@ RestoreRunningXactsFromClog(CheckPoint *checkpoint, TransactionId **xids, int *n
pfree(restored_xids);
if (prepared_xids)
pfree(prepared_xids);
return false;
return false;}


/*
* Right now we only enable reporting of "search_path" to allow to use it
* in pgbouncer track_extra_parameters
*/
static void
OverridePostgresGUCs(void)
{
#if PG_VERSION_NUM >= 160000
int gucCount = 0;
struct config_generic **guc_vars = get_guc_variables(&gucCount);
#else
struct config_generic **guc_vars = get_guc_variables();
int gucCount = GetNumConfigOptions();
#endif

for (int gucIndex = 0; gucIndex < gucCount; gucIndex++)
{
struct config_generic *var = (struct config_generic *) guc_vars[gucIndex];

/*
* 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;
}
}
}

void
Expand Down Expand Up @@ -587,6 +620,8 @@ _PG_init(void)
* extension was loaded will be removed.
*/
EmitWarningsOnPlaceholders("neon");

OverridePostgresGUCs();
}

PG_FUNCTION_INFO_V1(pg_cluster_size);
Expand Down

0 comments on commit 83d64f8

Please sign in to comment.