Issue (#42): Enable/Disable pg_stat_monitor should not require PostgreSQL restart.
PG-124pull/44/head
parent
a2c87d8398
commit
6700c9686e
8
guc.c
8
guc.c
|
@ -106,8 +106,8 @@ init_guc(void)
|
||||||
};
|
};
|
||||||
|
|
||||||
conf[i++] = (GucVariable) {
|
conf[i++] = (GucVariable) {
|
||||||
.guc_name = "pg_stat_monitor.shared_buffer",
|
.guc_name = "pg_stat_monitor.pgsm_query_shared_buffer",
|
||||||
.guc_desc = "Sets the shared_buffer size.",
|
.guc_desc = "Sets the query shared_buffer size.",
|
||||||
.guc_default = 500000,
|
.guc_default = 500000,
|
||||||
.guc_min = 500000,
|
.guc_min = 500000,
|
||||||
.guc_max = INT_MAX,
|
.guc_max = INT_MAX,
|
||||||
|
@ -155,7 +155,7 @@ init_guc(void)
|
||||||
NULL,
|
NULL,
|
||||||
(bool*)&PGSM_ENABLED,
|
(bool*)&PGSM_ENABLED,
|
||||||
true,
|
true,
|
||||||
PGC_SUSET,
|
PGC_USERSET,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -250,7 +250,7 @@ init_guc(void)
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
DefineCustomIntVariable("pg_stat_monitor.pgsm_query_shared_buffer",
|
DefineCustomIntVariable("pg_stat_monitor.pgsm_query_shared_buffer",
|
||||||
"Sets the shared_buffer size",
|
"Sets the query shared_buffer size",
|
||||||
NULL,
|
NULL,
|
||||||
&PGSM_QUERY_BUF_SIZE,
|
&PGSM_QUERY_BUF_SIZE,
|
||||||
500000,
|
500000,
|
||||||
|
|
|
@ -446,21 +446,22 @@ pgss_post_parse_analyze(ParseState *pstate, Query *query)
|
||||||
if (query->queryId == UINT64CONST(0))
|
if (query->queryId == UINT64CONST(0))
|
||||||
query->queryId = UINT64CONST(1);
|
query->queryId = UINT64CONST(1);
|
||||||
|
|
||||||
if (jstate.clocations_count > 0)
|
if (PGSM_ENABLED == 1)
|
||||||
pgss_store(pstate->p_sourcetext,
|
if (jstate.clocations_count > 0)
|
||||||
query->queryId,
|
pgss_store(pstate->p_sourcetext,
|
||||||
query->stmt_location,
|
query->queryId,
|
||||||
query->stmt_len,
|
query->stmt_location,
|
||||||
PGSS_INVALID,
|
query->stmt_len,
|
||||||
0,
|
PGSS_INVALID,
|
||||||
0,
|
0,
|
||||||
NULL,
|
0,
|
||||||
|
NULL,
|
||||||
#if PG_VERSION_NUM >= 130000
|
#if PG_VERSION_NUM >= 130000
|
||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
&jstate,
|
&jstate,
|
||||||
0.0,
|
0.0,
|
||||||
0.0);
|
0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -558,6 +559,7 @@ pgss_ExecutorEnd(QueryDesc *queryDesc)
|
||||||
|
|
||||||
if (queryId != UINT64CONST(0) && queryDesc->totaltime && PGSM_ENABLED)
|
if (queryId != UINT64CONST(0) && queryDesc->totaltime && PGSM_ENABLED)
|
||||||
{
|
{
|
||||||
|
elog(WARNING, "PGSM_ENABLED = %d", 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
|
||||||
* levels of hook all do this.)
|
* levels of hook all do this.)
|
||||||
|
@ -2715,18 +2717,19 @@ static PlannedStmt *pgss_planner_hook(Query *parse, int opt, ParamListInfo param
|
||||||
/* calc differences of WAL counters. */
|
/* calc differences of WAL counters. */
|
||||||
memset(&walusage, 0, sizeof(WalUsage));
|
memset(&walusage, 0, sizeof(WalUsage));
|
||||||
WalUsageAccumDiff(&walusage, &pgWalUsage, &walusage_start);
|
WalUsageAccumDiff(&walusage, &pgWalUsage, &walusage_start);
|
||||||
pgss_store(query_string,
|
if (PGSM_ENABLED == 1)
|
||||||
parse->queryId,
|
pgss_store(query_string,
|
||||||
parse->stmt_location,
|
parse->queryId,
|
||||||
parse->stmt_len,
|
parse->stmt_location,
|
||||||
PGSS_PLAN,
|
parse->stmt_len,
|
||||||
INSTR_TIME_GET_MILLISEC(duration),
|
PGSS_PLAN,
|
||||||
0,
|
INSTR_TIME_GET_MILLISEC(duration),
|
||||||
&bufusage,
|
0,
|
||||||
&walusage,
|
&bufusage,
|
||||||
NULL,
|
&walusage,
|
||||||
0,
|
NULL,
|
||||||
0);
|
0,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue