Issue - (#40): Cannot set pgsm_track value with psql client with alter system.

Removed the track option and added a new option pgsm_enable, which require a restart.

PG-122
pull/41/head
Ibrar Ahmed 2020-08-06 10:43:27 +00:00
parent beeb960e82
commit a2c87d8398
3 changed files with 14 additions and 34 deletions

23
guc.c
View File

@ -38,12 +38,12 @@ init_guc(void)
.guc_restart = true .guc_restart = true
}; };
conf[i++] = (GucVariable) { conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_track", .guc_name = "pg_stat_monitor.pgsm_enable",
.guc_desc = "Selects which statements are tracked by pg_stat_monitor.", .guc_desc = "Enable/Disable stistics collector.",
.guc_default = 0, .guc_default = 1,
.guc_min = 0, .guc_min = 0,
.guc_max = 0, .guc_max = 0,
.guc_restart = false .guc_restart = true
}; };
conf[i++] = (GucVariable) { conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_track_utility", .guc_name = "pg_stat_monitor.pgsm_track_utility",
@ -138,7 +138,7 @@ init_guc(void)
NULL); NULL);
DefineCustomIntVariable("pg_stat_monitor.pgsm_query_max_len", DefineCustomIntVariable("pg_stat_monitor.pgsm_query_max_len",
"Sets the maximum length of query", "Sets the maximum length of query.",
NULL, NULL,
&PGSM_QUERY_MAX_LEN, &PGSM_QUERY_MAX_LEN,
1024, 1024,
@ -150,12 +150,11 @@ init_guc(void)
NULL, NULL,
NULL); NULL);
DefineCustomEnumVariable("pg_stat_monitor.pgsm_track", DefineCustomBoolVariable("pg_stat_monitor.pgsm_enable",
"Selects which statements are tracked by pg_stat_monitor.", "Enable/Disable the statis collector.",
NULL, NULL,
&PGSM_TRACK, (bool*)&PGSM_ENABLED,
PGSM_TRACK_TOP, true,
track_options,
PGC_SUSET, PGC_SUSET,
0, 0,
NULL, NULL,
@ -167,7 +166,7 @@ init_guc(void)
NULL, NULL,
(bool*)&PGSM_TRACK_UTILITY, (bool*)&PGSM_TRACK_UTILITY,
true, true,
PGC_SUSET, PGC_USERSET,
0, 0,
NULL, NULL,
NULL, NULL,
@ -178,7 +177,7 @@ init_guc(void)
NULL, NULL,
(bool*)&PGSM_NORMALIZED_QUERY, (bool*)&PGSM_NORMALIZED_QUERY,
true, true,
PGC_SUSET, PGC_USERSET,
0, 0,
NULL, NULL,
NULL, NULL,

View File

@ -481,7 +481,7 @@ pgss_ExecutorStart(QueryDesc *queryDesc, int eflags)
* counting of optimizable statements that are directly contained in * counting of optimizable statements that are directly contained in
* utility statements. * utility statements.
*/ */
if (PGSS_ENABLED() && queryDesc->plannedstmt->queryId != UINT64CONST(0)) if (PGSM_ENABLED && queryDesc->plannedstmt->queryId != UINT64CONST(0))
{ {
/* /*
* Set up to track total elapsed time in ExecutorRun. Make sure the * Set up to track total elapsed time in ExecutorRun. Make sure the
@ -556,7 +556,7 @@ pgss_ExecutorEnd(QueryDesc *queryDesc)
float stime; float stime;
uint64 queryId = queryDesc->plannedstmt->queryId; uint64 queryId = queryDesc->plannedstmt->queryId;
if (queryId != UINT64CONST(0) && queryDesc->totaltime && PGSS_ENABLED()) if (queryId != UINT64CONST(0) && queryDesc->totaltime && PGSM_ENABLED)
{ {
/* /*
* Make sure stats accumulation is done. (Note: it's okay if several * Make sure stats accumulation is done. (Note: it's okay if several

View File

@ -325,32 +325,13 @@ typedef struct pgssJumbleState
int highest_extern_param_id; int highest_extern_param_id;
} pgssJumbleState; } pgssJumbleState;
typedef enum
{
PGSM_TRACK_NONE, /* track no statements */
PGSM_TRACK_TOP, /* only top level statements */
PGSM_TRACK_ALL /* all statements, including nested ones */
} PGSSTRACKlEVEL;
static const struct config_enum_entry track_options[] =
{
{"none", PGSM_TRACK_NONE, false},
{"top", PGSM_TRACK_TOP, false},
{"all", PGSM_TRACK_ALL, false},
{NULL, 0, false}
};
#define PGSS_ENABLED() \
(PGSM_TRACK == PGSM_TRACK_ALL || \
(PGSM_TRACK == PGSM_TRACK_TOP && nested_level == 0))
/* guc.c */ /* guc.c */
void init_guc(void); void init_guc(void);
/*---- GUC variables ----*/ /*---- GUC variables ----*/
#define PGSM_MAX conf[0].guc_variable #define PGSM_MAX conf[0].guc_variable
#define PGSM_QUERY_MAX_LEN conf[1].guc_variable #define PGSM_QUERY_MAX_LEN conf[1].guc_variable
#define PGSM_TRACK conf[2].guc_variable #define PGSM_ENABLED conf[2].guc_variable
#define PGSM_TRACK_UTILITY conf[3].guc_variable #define PGSM_TRACK_UTILITY conf[3].guc_variable
#define PGSM_NORMALIZED_QUERY conf[4].guc_variable #define PGSM_NORMALIZED_QUERY conf[4].guc_variable
#define PGSM_MAX_BUCKETS conf[5].guc_variable #define PGSM_MAX_BUCKETS conf[5].guc_variable