From d3278c0e4c01357e65347bdef66c3ff043866437 Mon Sep 17 00:00:00 2001 From: Ibrar Ahmed Date: Mon, 15 Feb 2021 12:29:03 +0000 Subject: [PATCH] PG-178: Test cases fixes. --- expected/guc.out | 27 +++++------ expected/pg_stat_monitor_1.out | 82 +++++++++++++++++----------------- expected/relations.out | 2 +- expected/relations_1.out | 15 ++++--- pg_stat_monitor.c | 4 +- sql/relations.sql | 2 +- 6 files changed, 67 insertions(+), 65 deletions(-) diff --git a/expected/guc.out b/expected/guc.out index 12d18f3..4f859dc 100644 --- a/expected/guc.out +++ b/expected/guc.out @@ -12,19 +12,20 @@ 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 | 300 | 300 | 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_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_query_max_len | 1024 | 1024 | Sets the maximum length of query. | 1024 | 2147483647 | 1 - pg_stat_monitor.pgsm_track_utility | 0 | 0 | Selects whether utility commands are tracked. | 0 | 0 | 0 -(10 rows) + name | value | default_value | description | minimum | maximum | restart +------------------------------------------+--------+---------------+----------------------------------------------------------------------------------------------------------+---------+------------+--------- + pg_stat_monitor.pgsm_bucket_time | 300 | 300 | 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_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_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 | 0 | 0 | Selects whether utility commands are tracked. | 0 | 0 | 0 +(11 rows) SELECT pg_stat_monitor_reset(); pg_stat_monitor_reset diff --git a/expected/pg_stat_monitor_1.out b/expected/pg_stat_monitor_1.out index b3de989..a16de31 100644 --- a/expected/pg_stat_monitor_1.out +++ b/expected/pg_stat_monitor_1.out @@ -96,24 +96,25 @@ EXECUTE pgss_test(1); DEALLOCATE pgss_test; SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C"; - query | calls | rows ----------------------------------------------------+-------+------ - PREPARE pgss_test (int) AS SELECT $1, $2 LIMIT $3 | 1 | 1 - SELECT $1 | 2 | 2 - SELECT $1 +| 4 | 4 - +| | - AS "text" | | - SELECT $1 + $2 | 2 | 2 - SELECT $1 + $2 + $3 AS "add" | 3 | 3 - SELECT $1 AS "float" | 1 | 1 - SELECT $1 AS i UNION SELECT $2 ORDER BY i | 1 | 2 - SELECT $1 || $2 | 1 | 1 - SELECT pg_stat_monitor_reset() | 1 | 1 - WITH t(f) AS ( +| 1 | 2 - VALUES ($1), ($2) +| | - ) +| | - SELECT f FROM t ORDER BY f | | - select $1::jsonb ? $2 | 1 | 1 + query | calls | rows +---------------------------------------------------------------------------+-------+------ + PREPARE pgss_test (int) AS SELECT $1, $2 LIMIT $3 | 1 | 1 + SELECT $1 | 2 | 2 + SELECT $1 +| 4 | 4 + +| | + AS "text" | | + SELECT $1 + $2 | 2 | 2 + SELECT $1 + $2 + $3 AS "add" | 3 | 3 + SELECT $1 AS "float" | 1 | 1 + SELECT $1 AS i UNION SELECT $2 ORDER BY i | 1 | 2 + SELECT $1 || $2 | 1 | 1 + SELECT pg_stat_monitor_reset() | 1 | 1 + SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0 + WITH t(f) AS ( +| 1 | 2 + VALUES ($1), ($2) +| | + ) +| | + SELECT f FROM t ORDER BY f | | + select $1::jsonb ? $2 | 1 | 1 (11 rows) -- @@ -232,9 +233,12 @@ SELECT 1 + 1 AS "two"; (1 row) SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C"; - query | calls | rows --------+-------+------ -(0 rows) + query | calls | rows +--------------------------------+-------+------ + SELECT $1 | 1 | 1 + SELECT $1 + $2 | 1 | 1 + SELECT pg_stat_monitor_reset() | 1 | 1 +(3 rows) -- -- pg_stat_monitor.track = top @@ -288,15 +292,17 @@ SELECT PLUS_ONE(10); (1 row) SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C"; - query | calls | rows ---------------------------------+-------+------ - SELECT $1 +| 1 | 1 - +| | - AS "text" | | - SELECT PLUS_ONE($1) | 2 | 2 - SELECT PLUS_TWO($1) | 2 | 2 - SELECT pg_stat_monitor_reset() | 1 | 1 -(4 rows) + query | calls | rows +-----------------------------------+-------+------ + SELECT $1 +| 1 | 1 + +| | + AS "text" | | + SELECT (i + $2 + $3)::INTEGER | 2 | 2 + SELECT (i + $2)::INTEGER LIMIT $3 | 2 | 2 + SELECT PLUS_ONE($1) | 2 | 2 + SELECT PLUS_TWO($1) | 2 | 2 + SELECT pg_stat_monitor_reset() | 1 | 1 +(6 rows) -- -- pg_stat_monitor.track = all @@ -385,16 +391,10 @@ NOTICE: table "test" does not exist, skipping NOTICE: function plus_one(pg_catalog.int4) does not exist, skipping DROP FUNCTION PLUS_TWO(INTEGER); SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C"; - query | calls | rows --------------------------------------------+-------+------ - CREATE INDEX test_b ON test(b) | 1 | 0 - DROP FUNCTION IF EXISTS PLUS_ONE(INTEGER) | 1 | 0 - DROP FUNCTION PLUS_ONE(INTEGER) | 1 | 0 - DROP FUNCTION PLUS_TWO(INTEGER) | 1 | 0 - DROP TABLE IF EXISTS test | 3 | 0 - DROP TABLE test | 1 | 0 - SELECT $1 | 1 | 1 - SELECT pg_stat_monitor_reset() | 1 | 1 -(8 rows) + query | calls | rows +--------------------------------+-------+------ + SELECT $1 | 1 | 1 + SELECT pg_stat_monitor_reset() | 1 | 1 +(2 rows) DROP EXTENSION pg_stat_monitor; diff --git a/expected/relations.out b/expected/relations.out index a611c5b..88d57bd 100644 --- a/expected/relations.out +++ b/expected/relations.out @@ -14,7 +14,7 @@ SELECT * FROM foo1, foo2, foo3, foo4; ---+---+---+--- (0 rows) -SELECT query, relations from pg_stat_monitor; +SELECT query, relations from pg_stat_monitor ORDER BY query; query | relations --------------------------------------+--------------------------------------------------- SELECT * FROM foo1, foo2, foo3, foo4 | {public.foo1,public.foo2,public.foo3,public.foo4} diff --git a/expected/relations_1.out b/expected/relations_1.out index 8176aea..3bfb623 100644 --- a/expected/relations_1.out +++ b/expected/relations_1.out @@ -14,13 +14,14 @@ SELECT * FROM foo1, foo2, foo3, foo4; ---+---+---+--- (0 rows) -SELECT query, relations from pg_stat_monitor; - query | relations ---------------------------------------+--------------------------------------------------- - SELECT pg_stat_monitor_reset() | - SELECT * FROM foo1, foo2, foo3, foo4 | {public.foo1,public.foo2,public.foo3,public.foo4} -(2 rows) - +SELECT query, relations from pg_stat_monitor ORDER BY query; + query | relations +----------------------------------------------+--------------------------------------------------- + SELECT * FROM foo1, foo2, foo3, foo4 | {public.foo1,public.foo2,public.foo3,public.foo4} + SELECT pg_stat_monitor_reset() | + SELECT query, relations from pg_stat_monitor | +(3 rows) + DROP TABLE foo1; DROP TABLE foo2; DROP TABLE foo3; diff --git a/pg_stat_monitor.c b/pg_stat_monitor.c index 76a5df3..d8df167 100644 --- a/pg_stat_monitor.c +++ b/pg_stat_monitor.c @@ -2551,9 +2551,9 @@ pg_stat_monitor_settings(PG_FUNCTION_ARGS) MemoryContextSwitchTo(oldcontext); #if PG_VERSION_NUM >= 130000 - for(i = 0; i < 11; i++) + for(i = 0; i < 12; i++) #else - for(i = 0; i < 10; i++) + for(i = 0; i < 11; i++) #endif { Datum values[7]; diff --git a/sql/relations.sql b/sql/relations.sql index 50701c1..fbeefa2 100644 --- a/sql/relations.sql +++ b/sql/relations.sql @@ -5,7 +5,7 @@ CREATE TABLE foo2(a int); CREATE TABLE foo3(a int); CREATE TABLE foo4(a int); SELECT * FROM foo1, foo2, foo3, foo4; -SELECT query, relations from pg_stat_monitor; +SELECT query, relations from pg_stat_monitor ORDER BY query; DROP TABLE foo1; DROP TABLE foo2; DROP TABLE foo3;