PG-178: Test cases fixes.

pull/74/head
Ibrar Ahmed 2021-02-15 12:29:03 +00:00
parent a48538523a
commit d3278c0e4c
6 changed files with 67 additions and 65 deletions

View File

@ -12,19 +12,20 @@ select pg_sleep(.5);
(1 row) (1 row)
SELECT * FROM pg_stat_monitor_settings ORDER BY name COLLATE "C"; SELECT * FROM pg_stat_monitor_settings ORDER BY name COLLATE "C";
name | value | default_value | description | minimum | maximum | restart 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_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_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_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_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_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 | 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_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_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_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 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
(10 rows) pg_stat_monitor.pgsm_track_utility | 0 | 0 | Selects whether utility commands are tracked. | 0 | 0 | 0
(11 rows)
SELECT pg_stat_monitor_reset(); SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset pg_stat_monitor_reset

View File

@ -96,24 +96,25 @@ EXECUTE pgss_test(1);
DEALLOCATE pgss_test; DEALLOCATE pgss_test;
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C"; SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
query | calls | rows query | calls | rows
---------------------------------------------------+-------+------ ---------------------------------------------------------------------------+-------+------
PREPARE pgss_test (int) AS SELECT $1, $2 LIMIT $3 | 1 | 1 PREPARE pgss_test (int) AS SELECT $1, $2 LIMIT $3 | 1 | 1
SELECT $1 | 2 | 2 SELECT $1 | 2 | 2
SELECT $1 +| 4 | 4 SELECT $1 +| 4 | 4
+| | +| |
AS "text" | | AS "text" | |
SELECT $1 + $2 | 2 | 2 SELECT $1 + $2 | 2 | 2
SELECT $1 + $2 + $3 AS "add" | 3 | 3 SELECT $1 + $2 + $3 AS "add" | 3 | 3
SELECT $1 AS "float" | 1 | 1 SELECT $1 AS "float" | 1 | 1
SELECT $1 AS i UNION SELECT $2 ORDER BY i | 1 | 2 SELECT $1 AS i UNION SELECT $2 ORDER BY i | 1 | 2
SELECT $1 || $2 | 1 | 1 SELECT $1 || $2 | 1 | 1
SELECT pg_stat_monitor_reset() | 1 | 1 SELECT pg_stat_monitor_reset() | 1 | 1
WITH t(f) AS ( +| 1 | 2 SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0
VALUES ($1), ($2) +| | WITH t(f) AS ( +| 1 | 2
) +| | VALUES ($1), ($2) +| |
SELECT f FROM t ORDER BY f | | ) +| |
select $1::jsonb ? $2 | 1 | 1 SELECT f FROM t ORDER BY f | |
select $1::jsonb ? $2 | 1 | 1
(11 rows) (11 rows)
-- --
@ -232,9 +233,12 @@ SELECT 1 + 1 AS "two";
(1 row) (1 row)
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C"; SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
query | calls | rows query | calls | rows
-------+-------+------ --------------------------------+-------+------
(0 rows) SELECT $1 | 1 | 1
SELECT $1 + $2 | 1 | 1
SELECT pg_stat_monitor_reset() | 1 | 1
(3 rows)
-- --
-- pg_stat_monitor.track = top -- pg_stat_monitor.track = top
@ -288,15 +292,17 @@ SELECT PLUS_ONE(10);
(1 row) (1 row)
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C"; SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
query | calls | rows query | calls | rows
--------------------------------+-------+------ -----------------------------------+-------+------
SELECT $1 +| 1 | 1 SELECT $1 +| 1 | 1
+| | +| |
AS "text" | | AS "text" | |
SELECT PLUS_ONE($1) | 2 | 2 SELECT (i + $2 + $3)::INTEGER | 2 | 2
SELECT PLUS_TWO($1) | 2 | 2 SELECT (i + $2)::INTEGER LIMIT $3 | 2 | 2
SELECT pg_stat_monitor_reset() | 1 | 1 SELECT PLUS_ONE($1) | 2 | 2
(4 rows) SELECT PLUS_TWO($1) | 2 | 2
SELECT pg_stat_monitor_reset() | 1 | 1
(6 rows)
-- --
-- pg_stat_monitor.track = all -- 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 NOTICE: function plus_one(pg_catalog.int4) does not exist, skipping
DROP FUNCTION PLUS_TWO(INTEGER); DROP FUNCTION PLUS_TWO(INTEGER);
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C"; SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
query | calls | rows query | calls | rows
-------------------------------------------+-------+------ --------------------------------+-------+------
CREATE INDEX test_b ON test(b) | 1 | 0 SELECT $1 | 1 | 1
DROP FUNCTION IF EXISTS PLUS_ONE(INTEGER) | 1 | 0 SELECT pg_stat_monitor_reset() | 1 | 1
DROP FUNCTION PLUS_ONE(INTEGER) | 1 | 0 (2 rows)
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)
DROP EXTENSION pg_stat_monitor; DROP EXTENSION pg_stat_monitor;

View File

@ -14,7 +14,7 @@ SELECT * FROM foo1, foo2, foo3, foo4;
---+---+---+--- ---+---+---+---
(0 rows) (0 rows)
SELECT query, relations from pg_stat_monitor; SELECT query, relations from pg_stat_monitor ORDER BY query;
query | relations query | relations
--------------------------------------+--------------------------------------------------- --------------------------------------+---------------------------------------------------
SELECT * FROM foo1, foo2, foo3, foo4 | {public.foo1,public.foo2,public.foo3,public.foo4} SELECT * FROM foo1, foo2, foo3, foo4 | {public.foo1,public.foo2,public.foo3,public.foo4}

View File

@ -14,13 +14,14 @@ SELECT * FROM foo1, foo2, foo3, foo4;
---+---+---+--- ---+---+---+---
(0 rows) (0 rows)
SELECT query, relations from pg_stat_monitor; SELECT query, relations from pg_stat_monitor ORDER BY query;
query | relations query | relations
--------------------------------------+--------------------------------------------------- ----------------------------------------------+---------------------------------------------------
SELECT pg_stat_monitor_reset() | SELECT * FROM foo1, foo2, foo3, foo4 | {public.foo1,public.foo2,public.foo3,public.foo4}
SELECT * FROM foo1, foo2, foo3, foo4 | {public.foo1,public.foo2,public.foo3,public.foo4} SELECT pg_stat_monitor_reset() |
(2 rows) SELECT query, relations from pg_stat_monitor |
(3 rows)
DROP TABLE foo1; DROP TABLE foo1;
DROP TABLE foo2; DROP TABLE foo2;
DROP TABLE foo3; DROP TABLE foo3;

View File

@ -2551,9 +2551,9 @@ pg_stat_monitor_settings(PG_FUNCTION_ARGS)
MemoryContextSwitchTo(oldcontext); MemoryContextSwitchTo(oldcontext);
#if PG_VERSION_NUM >= 130000 #if PG_VERSION_NUM >= 130000
for(i = 0; i < 11; i++) for(i = 0; i < 12; i++)
#else #else
for(i = 0; i < 10; i++) for(i = 0; i < 11; i++)
#endif #endif
{ {
Datum values[7]; Datum values[7];

View File

@ -5,7 +5,7 @@ CREATE TABLE foo2(a int);
CREATE TABLE foo3(a int); CREATE TABLE foo3(a int);
CREATE TABLE foo4(a int); CREATE TABLE foo4(a int);
SELECT * FROM foo1, foo2, foo3, foo4; 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 foo1;
DROP TABLE foo2; DROP TABLE foo2;
DROP TABLE foo3; DROP TABLE foo3;