summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2020-11-25 16:40:44 +0000
committerTom Lane2020-11-25 16:40:44 +0000
commit2432b1a04087edc2fd9536c7c9aa4ca03fd1b363 (patch)
tree4540b2dc58b1e75c8341f4268b69de1a5d5977c9 /src/include
parentf73999262ed6c40d9a7c3d7cccec7143d4d15287 (diff)
Avoid spamming the client with multiple ParameterStatus messages.
Up to now, we sent a ParameterStatus message to the client immediately upon any change in the active value of any GUC_REPORT variable. This was only barely okay when the feature was designed; now that we have things like function SET clauses, there are very plausible use-cases where a GUC_REPORT variable might change many times within a query --- and even end up back at its original value, perhaps. Fortunately most of our GUC_REPORT variables are unlikely to be changed often; but there are proposals in play to enlarge that set, or even make it user-configurable. Hence, let's fix things to not generate more than one ParameterStatus message per variable per query, and to not send any message at all unless the end-of-query value is different from what we last reported. Discussion: https://postgr.es/m/5708.1601145259@sss.pgh.pa.us
Diffstat (limited to 'src/include')
-rw-r--r--src/include/utils/guc.h1
-rw-r--r--src/include/utils/guc_tables.h5
2 files changed, 5 insertions, 1 deletions
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index 073c8f3e062..6a20a3bcece 100644
--- a/src/include/utils/guc.h
+++ b/src/include/utils/guc.h
@@ -363,6 +363,7 @@ extern void AtStart_GUC(void);
extern int NewGUCNestLevel(void);
extern void AtEOXact_GUC(bool isCommit, int nestLevel);
extern void BeginReportingGUCOptions(void);
+extern void ReportChangedGUCOptions(void);
extern void ParseLongOption(const char *string, char **name, char **value);
extern bool parse_int(const char *value, int *result, int flags,
const char **hintmsg);
diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h
index 04431d0eb25..7f36e1146f2 100644
--- a/src/include/utils/guc_tables.h
+++ b/src/include/utils/guc_tables.h
@@ -161,6 +161,8 @@ struct config_generic
GucContext reset_scontext; /* context that set the reset value */
GucStack *stack; /* stacked prior values */
void *extra; /* "extra" pointer for current actual value */
+ char *last_reported; /* if variable is GUC_REPORT, value last sent
+ * to client (NULL if not yet sent) */
char *sourcefile; /* file current setting is from (NULL if not
* set in config file) */
int sourceline; /* line in source file */
@@ -172,7 +174,8 @@ struct config_generic
* Caution: the GUC_IS_IN_FILE bit is transient state for ProcessConfigFile.
* Do not assume that its value represents useful information elsewhere.
*/
-#define GUC_PENDING_RESTART 0x0002
+#define GUC_PENDING_RESTART 0x0002 /* changed value cannot be applied yet */
+#define GUC_NEEDS_REPORT 0x0004 /* new value must be reported to client */
/* GUC records for specific variable types */