PG-293: Add pg_stat_monitor.extract_comments GUC.
This new GUC allows the user to enable/disable extracting query comments.pull/157/head
parent
30a328f381
commit
6042795930
12
guc.c
12
guc.c
|
@ -191,6 +191,18 @@ init_guc(void)
|
||||||
}
|
}
|
||||||
DefineEnumGUC(&conf[i++], track_options);
|
DefineEnumGUC(&conf[i++], track_options);
|
||||||
|
|
||||||
|
conf[i] = (GucVariable) {
|
||||||
|
.guc_name = "pg_stat_monitor.extract_comments",
|
||||||
|
.guc_desc = "Enable/Disable extracting comments from queries.",
|
||||||
|
.guc_default = 0,
|
||||||
|
.guc_min = 0,
|
||||||
|
.guc_max = 0,
|
||||||
|
.guc_restart = false,
|
||||||
|
.guc_unit = 0,
|
||||||
|
.guc_value = &PGSM_EXTRACT_COMMENTS
|
||||||
|
};
|
||||||
|
DefineBoolGUC(&conf[i++]);
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= 130000
|
#if PG_VERSION_NUM >= 130000
|
||||||
conf[i] = (GucVariable) {
|
conf[i] = (GucVariable) {
|
||||||
.guc_name = "pg_stat_monitor.pgsm_track_planning",
|
.guc_name = "pg_stat_monitor.pgsm_track_planning",
|
||||||
|
|
|
@ -1496,8 +1496,6 @@ pgss_store(uint64 queryid,
|
||||||
planid = plan_info ? plan_info->planid : 0;
|
planid = plan_info ? plan_info->planid : 0;
|
||||||
appid = djb2_hash((unsigned char *)application_name, application_name_len);
|
appid = djb2_hash((unsigned char *)application_name, application_name_len);
|
||||||
|
|
||||||
extract_query_comments(query, comments, sizeof(comments));
|
|
||||||
|
|
||||||
prev_bucket_id = pg_atomic_read_u64(&pgss->current_wbucket);
|
prev_bucket_id = pg_atomic_read_u64(&pgss->current_wbucket);
|
||||||
bucketid = get_next_wbucket(pgss);
|
bucketid = get_next_wbucket(pgss);
|
||||||
|
|
||||||
|
@ -1608,6 +1606,10 @@ pgss_store(uint64 queryid,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jstate == NULL)
|
if (jstate == NULL)
|
||||||
|
{
|
||||||
|
if (PGSM_EXTRACT_COMMENTS)
|
||||||
|
extract_query_comments(query, comments, sizeof(comments));
|
||||||
|
|
||||||
pgss_update_entry(entry, /* entry */
|
pgss_update_entry(entry, /* entry */
|
||||||
bucketid, /* bucketid */
|
bucketid, /* bucketid */
|
||||||
queryid, /* queryid */
|
queryid, /* queryid */
|
||||||
|
@ -1625,6 +1627,7 @@ pgss_store(uint64 queryid,
|
||||||
kind, /* kind */
|
kind, /* kind */
|
||||||
application_name,
|
application_name,
|
||||||
application_name_len);
|
application_name_len);
|
||||||
|
}
|
||||||
|
|
||||||
LWLockRelease(pgss->lock);
|
LWLockRelease(pgss->lock);
|
||||||
if (norm_query)
|
if (norm_query)
|
||||||
|
|
|
@ -95,9 +95,9 @@
|
||||||
#define SQLCODE_LEN 20
|
#define SQLCODE_LEN 20
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= 130000
|
#if PG_VERSION_NUM >= 130000
|
||||||
#define MAX_SETTINGS 14
|
#define MAX_SETTINGS 15
|
||||||
#else
|
#else
|
||||||
#define MAX_SETTINGS 13
|
#define MAX_SETTINGS 14
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update this if need a enum GUC with more options. */
|
/* Update this if need a enum GUC with more options. */
|
||||||
|
@ -443,7 +443,8 @@ static const struct config_enum_entry track_options[] =
|
||||||
#define PGSM_OVERFLOW_TARGET get_conf(10)->guc_variable
|
#define PGSM_OVERFLOW_TARGET get_conf(10)->guc_variable
|
||||||
#define PGSM_QUERY_PLAN get_conf(11)->guc_variable
|
#define PGSM_QUERY_PLAN get_conf(11)->guc_variable
|
||||||
#define PGSM_TRACK get_conf(12)->guc_variable
|
#define PGSM_TRACK get_conf(12)->guc_variable
|
||||||
#define PGSM_TRACK_PLANNING get_conf(13)->guc_variable
|
#define PGSM_EXTRACT_COMMENTS get_conf(13)->guc_variable
|
||||||
|
#define PGSM_TRACK_PLANNING get_conf(14)->guc_variable
|
||||||
|
|
||||||
|
|
||||||
/*---- Benchmarking ----*/
|
/*---- Benchmarking ----*/
|
||||||
|
|
Loading…
Reference in New Issue