diff --git a/regression/expected/cmd_type.out b/regression/expected/cmd_type.out index 086d230..d5dceeb 100644 --- a/regression/expected/cmd_type.out +++ b/regression/expected/cmd_type.out @@ -23,6 +23,7 @@ SELECT b FROM t2 FOR UPDATE; TRUNCATE t1; DROP TABLE t1; +DROP TABLE t2; SELECT query, cmd_type, cmd_type_text FROM pg_stat_monitor ORDER BY query COLLATE "C"; query | cmd_type | cmd_type_text ----------------------------------------------------------------------------------------+----------+--------------- @@ -30,6 +31,7 @@ SELECT query, cmd_type, cmd_type_text FROM pg_stat_monitor ORDER BY query COLLA CREATE TABLE t2 (b INTEGER) | 0 | DELETE FROM t1 | 4 | DELETE DROP TABLE t1 | 0 | + DROP TABLE t2 | 0 | INSERT INTO t1 VALUES($1) | 3 | INSERT SELECT a FROM t1 | 1 | SELECT SELECT b FROM t2 FOR UPDATE | 1 | SELECT @@ -37,7 +39,7 @@ SELECT query, cmd_type, cmd_type_text FROM pg_stat_monitor ORDER BY query COLLA SELECT query, cmd_type, cmd_type_text FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | SELECT TRUNCATE t1 | 0 | UPDATE t1 SET a = $1 | 2 | UPDATE -(11 rows) +(12 rows) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset diff --git a/regression/expected/guc.out b/regression/expected/guc.out index 0da2986..075b3ac 100644 --- a/regression/expected/guc.out +++ b/regression/expected/guc.out @@ -12,22 +12,22 @@ select pg_sleep(.5); (1 row) SELECT * FROM pg_stat_monitor_settings ORDER BY name COLLATE "C"; - name | value | default_value | description | minimum | maximum | restart -------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+--------- - pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | 1 - pg_stat_monitor.pgsm_enable | 1 | 1 | Enable/Disable statistics collector. | 0 | 0 | 0 - pg_stat_monitor.pgsm_enable_query_plan | 0 | 0 | Enable/Disable query plan monitoring | 0 | 0 | 0 - pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 2147483647 | 1 - pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | 1 - pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | 1 - pg_stat_monitor.pgsm_max | 100 | 100 | Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor. | 1 | 1000 | 1 - pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | 1 - pg_stat_monitor.pgsm_normalized_query | 1 | 1 | Selects whether save query in normalized format. | 0 | 0 | 0 - pg_stat_monitor.pgsm_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | 1 - pg_stat_monitor.pgsm_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | 1 - 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 | 1 - pg_stat_monitor.pgsm_track_planning | 1 | 1 | Selects whether planning statistics are tracked. | 0 | 0 | 0 - pg_stat_monitor.pgsm_track_utility | 1 | 1 | Selects whether utility commands are tracked. | 0 | 0 | 0 + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+--------- + 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 + pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes + pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes + pg_stat_monitor.pgsm_max | 100 | 100 | Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor. | 1 | 1000 | | yes + pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes + pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no + pg_stat_monitor.pgsm_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes + pg_stat_monitor.pgsm_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes + 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_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) SELECT pg_stat_monitor_reset(); diff --git a/regression/expected/guc_1.out b/regression/expected/guc_1.out index ef3da0b..f839a94 100644 --- a/regression/expected/guc_1.out +++ b/regression/expected/guc_1.out @@ -12,21 +12,21 @@ select pg_sleep(.5); (1 row) SELECT * FROM pg_stat_monitor_settings ORDER BY name COLLATE "C"; - name | value | default_value | description | minimum | maximum | restart -------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+--------- - pg_stat_monitor.pgsm_bucket_time | 60 | 60 | Sets the time in seconds per bucket. | 1 | 2147483647 | 1 - pg_stat_monitor.pgsm_enable | 1 | 1 | Enable/Disable statistics collector. | 0 | 0 | 0 - pg_stat_monitor.pgsm_enable_query_plan | 0 | 0 | Enable/Disable query plan monitoring | 0 | 0 | 0 - pg_stat_monitor.pgsm_histogram_buckets | 10 | 10 | Sets the maximum number of histogram buckets | 2 | 2147483647 | 1 - pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | 1 - pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | 1 - pg_stat_monitor.pgsm_max | 100 | 100 | Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor. | 1 | 1000 | 1 - pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | 1 - pg_stat_monitor.pgsm_normalized_query | 1 | 1 | Selects whether save query in normalized format. | 0 | 0 | 0 - pg_stat_monitor.pgsm_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | 1 - pg_stat_monitor.pgsm_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | 1 - 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 | 1 - pg_stat_monitor.pgsm_track_utility | 1 | 1 | Selects whether utility commands are tracked. | 0 | 0 | 0 + name | value | default_value | description | minimum | maximum | options | restart +------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+----------------+--------- + 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 + pg_stat_monitor.pgsm_histogram_max | 100000 | 100000 | Sets the time in millisecond. | 10 | 2147483647 | | yes + pg_stat_monitor.pgsm_histogram_min | 0 | 0 | Sets the time in millisecond. | 0 | 2147483647 | | yes + pg_stat_monitor.pgsm_max | 100 | 100 | Sets the maximum size of shared memory in (MB) used for statement's metadata tracked by pg_stat_monitor. | 1 | 1000 | | yes + pg_stat_monitor.pgsm_max_buckets | 10 | 10 | Sets the maximum number of buckets. | 1 | 10 | | yes + pg_stat_monitor.pgsm_normalized_query | yes | yes | Selects whether save query in normalized format. | | | yes, no | no + pg_stat_monitor.pgsm_overflow_target | 1 | 1 | Sets the overflow target for pg_stat_monitor | 0 | 1 | | yes + pg_stat_monitor.pgsm_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | | yes + 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) SELECT pg_stat_monitor_reset(); diff --git a/regression/expected/rows.out b/regression/expected/rows.out index c68a9d8..fe4cb94 100644 --- a/regression/expected/rows.out +++ b/regression/expected/rows.out @@ -1,7 +1,6 @@ CREATE EXTENSION pg_stat_monitor; CREATE TABLE t1(a int); CREATE TABLE t2(b int); -ERROR: relation "t2" already exists INSERT INTO t1 VALUES(generate_series(1,1000)); INSERT INTO t2 VALUES(generate_series(1,5000)); SELECT pg_stat_monitor_reset(); @@ -8558,4 +8557,5 @@ SELECT pg_stat_monitor_reset(); (1 row) DROP TABLE t1; +DROP TABLE t2; DROP EXTENSION pg_stat_monitor; diff --git a/regression/expected/top_query.out b/regression/expected/top_query.out index 42d4f3b..e980297 100644 --- a/regression/expected/top_query.out +++ b/regression/expected/top_query.out @@ -22,6 +22,55 @@ SELECT add2(1,2); 3 (1 row) +SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C"; + query | top_query +-------------------------------------------------------------------------+----------- + CREATE OR REPLACE FUNCTION add(int, int) RETURNS INTEGER AS +| + $$ +| + BEGIN +| + return (select $1 + $2); +| + END; $$ language plpgsql | + CREATE OR REPLACE function add2(int, int) RETURNS int as +| + $$ +| + BEGIN +| + return add($1,$2); +| + END; +| + $$ language plpgsql | + SELECT add2($1,$2) | + SELECT pg_stat_monitor_reset() | + SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C" | +(5 rows) + +ALTER SYSTEM SET pg_stat_monitor.track TO 'all'; +SELECT pg_reload_conf(); + pg_reload_conf +---------------- + t +(1 row) + +SELECT pg_stat_monitor_reset(); + pg_stat_monitor_reset +----------------------- + +(1 row) + +CREATE OR REPLACE FUNCTION add(int, int) RETURNS INTEGER AS +$$ +BEGIN + return (select $1 + $2); +END; $$ language plpgsql; +CREATE OR REPLACE function add2(int, int) RETURNS int as +$$ +BEGIN + return add($1,$2); +END; +$$ language plpgsql; +SELECT add2(1,2); + add2 +------ + 3 +(1 row) + SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C"; query | top_query -------------------------------------------------------------------------+-------------------- @@ -42,6 +91,13 @@ SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C"; SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C" | (6 rows) +ALTER SYSTEM SET pg_stat_monitor.track TO 'top'; +SELECT pg_reload_conf(); + pg_reload_conf +---------------- + t +(1 row) + SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset ----------------------- diff --git a/regression/expected/top_query_1.out b/regression/expected/top_query_1.out index b8e71a8..59a19e5 100644 --- a/regression/expected/top_query_1.out +++ b/regression/expected/top_query_1.out @@ -22,6 +22,55 @@ SELECT add2(1,2); 3 (1 row) +SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C"; + query | top_query +-------------------------------------------------------------------------+----------- + CREATE OR REPLACE FUNCTION add(int, int) RETURNS INTEGER AS +| + $$ +| + BEGIN +| + return (select $1 + $2); +| + END; $$ language plpgsql | + CREATE OR REPLACE function add2(int, int) RETURNS int as +| + $$ +| + BEGIN +| + return add($1,$2); +| + END; +| + $$ language plpgsql | + SELECT add2($1,$2) | + SELECT pg_stat_monitor_reset() | + SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C" | +(5 rows) + +ALTER SYSTEM SET pg_stat_monitor.track TO 'all'; +SELECT pg_reload_conf(); + pg_reload_conf +---------------- + t +(1 row) + +SELECT pg_stat_monitor_reset(); + pg_stat_monitor_reset +----------------------- + +(1 row) + +CREATE OR REPLACE FUNCTION add(int, int) RETURNS INTEGER AS +$$ +BEGIN + return (select $1 + $2); +END; $$ language plpgsql; +CREATE OR REPLACE function add2(int, int) RETURNS int as +$$ +BEGIN + return add($1,$2); +END; +$$ language plpgsql; +SELECT add2(1,2); + add2 +------ + 3 +(1 row) + SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C"; query | top_query -------------------------------------------------------------------------+-------------------- @@ -42,6 +91,13 @@ SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C"; SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C" | (6 rows) +ALTER SYSTEM SET pg_stat_monitor.track TO 'top'; +SELECT pg_reload_conf(); + pg_reload_conf +---------------- + t +(1 row) + SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset ----------------------- diff --git a/regression/sql/cmd_type.sql b/regression/sql/cmd_type.sql index 5f1fa1b..9fb2fa6 100644 --- a/regression/sql/cmd_type.sql +++ b/regression/sql/cmd_type.sql @@ -10,6 +10,7 @@ DELETE FROM t1; SELECT b FROM t2 FOR UPDATE; TRUNCATE t1; DROP TABLE t1; +DROP TABLE t2; SELECT query, cmd_type, cmd_type_text FROM pg_stat_monitor ORDER BY query COLLATE "C"; SELECT pg_stat_monitor_reset(); diff --git a/regression/sql/rows.sql b/regression/sql/rows.sql index 93ae9c1..ffd449c 100644 --- a/regression/sql/rows.sql +++ b/regression/sql/rows.sql @@ -16,4 +16,5 @@ SELECT query, rows_retrieved FROM pg_stat_monitor ORDER BY query COLLATE "C"; SELECT pg_stat_monitor_reset(); DROP TABLE t1; +DROP TABLE t2; DROP EXTENSION pg_stat_monitor; diff --git a/regression/sql/top_query.sql b/regression/sql/top_query.sql index 3642f99..16aa2ce 100644 --- a/regression/sql/top_query.sql +++ b/regression/sql/top_query.sql @@ -1,5 +1,6 @@ CREATE EXTENSION pg_stat_monitor; SELECT pg_stat_monitor_reset(); + CREATE OR REPLACE FUNCTION add(int, int) RETURNS INTEGER AS $$ BEGIN @@ -15,5 +16,28 @@ $$ language plpgsql; SELECT add2(1,2); SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C"; + +ALTER SYSTEM SET pg_stat_monitor.track TO 'all'; +SELECT pg_reload_conf(); SELECT pg_stat_monitor_reset(); + +CREATE OR REPLACE FUNCTION add(int, int) RETURNS INTEGER AS +$$ +BEGIN + return (select $1 + $2); +END; $$ language plpgsql; + +CREATE OR REPLACE function add2(int, int) RETURNS int as +$$ +BEGIN + return add($1,$2); +END; +$$ language plpgsql; + +SELECT add2(1,2); +SELECT query, top_query FROM pg_stat_monitor ORDER BY query COLLATE "C"; +ALTER SYSTEM SET pg_stat_monitor.track TO 'top'; +SELECT pg_reload_conf(); +SELECT pg_stat_monitor_reset(); + DROP EXTENSION pg_stat_monitor;