From a702f24465460ac9e496b12be9482542c40da656 Mon Sep 17 00:00:00 2001 From: Diego Fronza Date: Thu, 9 Dec 2021 15:56:35 -0300 Subject: [PATCH] PG-293: Update regression tests (extract_comments). guc: Add the new GUC variable to the output. tags: Handle both cases, enable/disable extracting query comments. --- regression/expected/guc.out | 3 ++- regression/expected/guc_1.out | 3 ++- regression/expected/tags.out | 40 +++++++++++++++++++++++++++++++++++ regression/sql/tags.sql | 8 +++++++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/regression/expected/guc.out b/regression/expected/guc.out index 075b3ac..90bb7b9 100644 --- a/regression/expected/guc.out +++ b/regression/expected/guc.out @@ -14,6 +14,7 @@ select pg_sleep(.5); SELECT * FROM pg_stat_monitor_settings ORDER BY name COLLATE "C"; name | value | default_value | description | minimum | maximum | options | restart ------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+--------- + pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 2147483647 | | yes @@ -28,7 +29,7 @@ SELECT * FROM pg_stat_monitor_settings ORDER BY name COLLATE "C"; pg_stat_monitor.pgsm_track_planning | yes | yes | Selects whether planning statistics are tracked. | | | yes, no | no pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no -(14 rows) +(15 rows) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset diff --git a/regression/expected/guc_1.out b/regression/expected/guc_1.out index f839a94..ed62b3c 100644 --- a/regression/expected/guc_1.out +++ b/regression/expected/guc_1.out @@ -14,6 +14,7 @@ select pg_sleep(.5); SELECT * FROM pg_stat_monitor_settings ORDER BY name COLLATE "C"; name | value | default_value | description | minimum | maximum | options | restart ------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+--------- + pg_stat_monitor.extract_comments | no | no | Enable/Disable extracting comments from queries. | | | yes, no | no pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | | yes pg_stat_monitor.pgsm_enable_query_plan | no | no | Enable/Disable query plan monitoring | | | yes, no | no pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 2147483647 | | yes @@ -27,7 +28,7 @@ SELECT * FROM pg_stat_monitor_settings ORDER BY name COLLATE "C"; pg_stat_monitor.pgsm_query_shared_buffer | 20 | 20 | Sets the maximum size of shared memory in (MB) used for query tracked by pg_stat_monitor. | 1 | 10000 | | yes pg_stat_monitor.pgsm_track_utility | yes | yes | Selects whether utility commands are tracked. | | | yes, no | no pg_stat_monitor.track | top | top | Selects which statements are tracked by pg_stat_monitor. | | | none, top, all | no -(13 rows) +(14 rows) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset diff --git a/regression/expected/tags.out b/regression/expected/tags.out index 27d37d3..8ca4ccf 100644 --- a/regression/expected/tags.out +++ b/regression/expected/tags.out @@ -11,6 +11,39 @@ SELECT 1 AS num /* { "application", psql_app, "real_ip", 192.168.1.3) */; 1 (1 row) +SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C"; + query | comments +---------------------------------------------------------------------------+---------- + SELECT $1 AS num /* { "application", psql_app, "real_ip", 192.168.1.3) */ | + SELECT pg_stat_monitor_reset() | + SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C" | +(3 rows) + +ALTER SYSTEM SET pg_stat_monitor.extract_comments TO 'yes'; +SELECT pg_reload_conf(); + pg_reload_conf +---------------- + t +(1 row) + +select pg_sleep(1); + pg_sleep +---------- + +(1 row) + +SELECT pg_stat_monitor_reset(); + pg_stat_monitor_reset +----------------------- + +(1 row) + +SELECT 1 AS num /* { "application", psql_app, "real_ip", 192.168.1.3) */; + num +----- + 1 +(1 row) + SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C"; query | comments ---------------------------------------------------------------------------+---------------------------------------------------------- @@ -19,6 +52,13 @@ SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C"; SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C" | (3 rows) +ALTER SYSTEM SET pg_stat_monitor.extract_comments TO 'no'; +SELECT pg_reload_conf(); + pg_reload_conf +---------------- + t +(1 row) + SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset ----------------------- diff --git a/regression/sql/tags.sql b/regression/sql/tags.sql index 8325598..8912080 100644 --- a/regression/sql/tags.sql +++ b/regression/sql/tags.sql @@ -2,5 +2,13 @@ CREATE EXTENSION pg_stat_monitor; SELECT pg_stat_monitor_reset(); SELECT 1 AS num /* { "application", psql_app, "real_ip", 192.168.1.3) */; SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C"; +ALTER SYSTEM SET pg_stat_monitor.extract_comments TO 'yes'; +SELECT pg_reload_conf(); +select pg_sleep(1); +SELECT pg_stat_monitor_reset(); +SELECT 1 AS num /* { "application", psql_app, "real_ip", 192.168.1.3) */; +SELECT query, comments FROM pg_stat_monitor ORDER BY query COLLATE "C"; +ALTER SYSTEM SET pg_stat_monitor.extract_comments TO 'no'; +SELECT pg_reload_conf(); SELECT pg_stat_monitor_reset(); DROP EXTENSION pg_stat_monitor;