Merge pull request #182 from darkfronza/PG-326_check_histogram_minmax
PG-326: Validate histogram_min and histogram_max ranges.pull/196/head
commit
5356e2e75c
34
guc.c
34
guc.c
|
@ -20,9 +20,14 @@
|
||||||
|
|
||||||
GucVariable conf[MAX_SETTINGS];
|
GucVariable conf[MAX_SETTINGS];
|
||||||
static void DefineIntGUC(GucVariable *conf);
|
static void DefineIntGUC(GucVariable *conf);
|
||||||
|
static void DefineIntGUCWithCheck(GucVariable *conf, GucIntCheckHook check);
|
||||||
static void DefineBoolGUC(GucVariable *conf);
|
static void DefineBoolGUC(GucVariable *conf);
|
||||||
static void DefineEnumGUC(GucVariable *conf, const struct config_enum_entry *options);
|
static void DefineEnumGUC(GucVariable *conf, const struct config_enum_entry *options);
|
||||||
|
|
||||||
|
/* Check hooks to ensure histogram_min < histogram_max */
|
||||||
|
static bool check_histogram_min(int *newval, void **extra, GucSource source);
|
||||||
|
static bool check_histogram_max(int *newval, void **extra, GucSource source);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define (or redefine) custom GUC variables.
|
* Define (or redefine) custom GUC variables.
|
||||||
*/
|
*/
|
||||||
|
@ -113,7 +118,7 @@ init_guc(void)
|
||||||
.guc_unit = 0,
|
.guc_unit = 0,
|
||||||
.guc_value = &PGSM_HISTOGRAM_MIN
|
.guc_value = &PGSM_HISTOGRAM_MIN
|
||||||
};
|
};
|
||||||
DefineIntGUC(&conf[i++]);
|
DefineIntGUCWithCheck(&conf[i++], check_histogram_min);
|
||||||
|
|
||||||
conf[i] = (GucVariable) {
|
conf[i] = (GucVariable) {
|
||||||
.guc_name = "pg_stat_monitor.pgsm_histogram_max",
|
.guc_name = "pg_stat_monitor.pgsm_histogram_max",
|
||||||
|
@ -125,7 +130,7 @@ init_guc(void)
|
||||||
.guc_unit = 0,
|
.guc_unit = 0,
|
||||||
.guc_value = &PGSM_HISTOGRAM_MAX
|
.guc_value = &PGSM_HISTOGRAM_MAX
|
||||||
};
|
};
|
||||||
DefineIntGUC(&conf[i++]);
|
DefineIntGUCWithCheck(&conf[i++], check_histogram_max);
|
||||||
|
|
||||||
conf[i] = (GucVariable) {
|
conf[i] = (GucVariable) {
|
||||||
.guc_name = "pg_stat_monitor.pgsm_histogram_buckets",
|
.guc_name = "pg_stat_monitor.pgsm_histogram_buckets",
|
||||||
|
@ -218,8 +223,7 @@ init_guc(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void DefineIntGUCWithCheck(GucVariable *conf, GucIntCheckHook check)
|
||||||
DefineIntGUC(GucVariable *conf)
|
|
||||||
{
|
{
|
||||||
conf->type = PGC_INT;
|
conf->type = PGC_INT;
|
||||||
DefineCustomIntVariable(conf->guc_name,
|
DefineCustomIntVariable(conf->guc_name,
|
||||||
|
@ -231,10 +235,17 @@ DefineIntGUC(GucVariable *conf)
|
||||||
conf->guc_max,
|
conf->guc_max,
|
||||||
conf->guc_restart ? PGC_POSTMASTER : PGC_USERSET,
|
conf->guc_restart ? PGC_POSTMASTER : PGC_USERSET,
|
||||||
conf->guc_unit,
|
conf->guc_unit,
|
||||||
NULL,
|
check,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
DefineIntGUC(GucVariable *conf)
|
||||||
|
{
|
||||||
|
DefineIntGUCWithCheck(conf, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
DefineBoolGUC(GucVariable *conf)
|
DefineBoolGUC(GucVariable *conf)
|
||||||
{
|
{
|
||||||
|
@ -274,3 +285,16 @@ get_conf(int i)
|
||||||
return &conf[i];
|
return &conf[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool check_histogram_min(int *newval, void **extra, GucSource source)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* During module initialization PGSM_HISTOGRAM_MIN is initialized before
|
||||||
|
* PGSM_HISTOGRAM_MAX, in this case PGSM_HISTOGRAM_MAX will be zero.
|
||||||
|
*/
|
||||||
|
return (PGSM_HISTOGRAM_MAX == 0 || *newval < PGSM_HISTOGRAM_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool check_histogram_max(int *newval, void **extra, GucSource source)
|
||||||
|
{
|
||||||
|
return (*newval > PGSM_HISTOGRAM_MIN);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue