PG-178: Test cases fixes.
parent
d3278c0e4c
commit
a222adc587
|
@ -0,0 +1,35 @@
|
|||
CREATE EXTENSION pg_stat_monitor;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select pg_sleep(.5);
|
||||
pg_sleep
|
||||
----------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT 1;
|
||||
?column?
|
||||
----------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT query FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query
|
||||
--------------------------------------------------------------
|
||||
SELECT $1
|
||||
SELECT pg_stat_monitor_reset()
|
||||
SELECT query FROM pg_stat_monitor ORDER BY query COLLATE "C"
|
||||
select pg_sleep($1)
|
||||
(4 rows)
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
|
@ -0,0 +1,37 @@
|
|||
CREATE EXTENSION pg_stat_monitor;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select pg_sleep(.5);
|
||||
pg_sleep
|
||||
----------
|
||||
|
||||
(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_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
|
||||
(12 rows)
|
||||
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
|
@ -98,6 +98,8 @@ DEALLOCATE pgss_test;
|
|||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls | rows
|
||||
---------------------------------------------------------------------------+-------+------
|
||||
BEGIN | 2 | 0
|
||||
COMMIT | 2 | 0
|
||||
PREPARE pgss_test (int) AS SELECT $1, $2 LIMIT $3 | 1 | 1
|
||||
SELECT $1 | 2 | 2
|
||||
SELECT $1 +| 4 | 4
|
||||
|
@ -115,7 +117,7 @@ SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|||
) +| |
|
||||
SELECT f FROM t ORDER BY f | |
|
||||
select $1::jsonb ? $2 | 1 | 1
|
||||
(11 rows)
|
||||
(14 rows)
|
||||
|
||||
--
|
||||
-- CRUD: INSERT SELECT UPDATE DELETE on test table
|
||||
|
@ -198,7 +200,10 @@ SELECT * FROM test WHERE a IN (1, 2, 3, 4, 5);
|
|||
|
||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls | rows
|
||||
-------------------------------------------------------------+-------+------
|
||||
---------------------------------------------------------------------------+-------+------
|
||||
BEGIN | 3 | 0
|
||||
COMMIT | 3 | 0
|
||||
CREATE TEMP TABLE test (a int, b char(20)) | 1 | 0
|
||||
DELETE FROM test WHERE a > $1 | 1 | 1
|
||||
INSERT INTO test (a, b) VALUES ($1, $2), ($3, $4), ($5, $6) | 1 | 3
|
||||
INSERT INTO test VALUES(generate_series($1, $2), $3) | 1 | 10
|
||||
|
@ -206,9 +211,10 @@ SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|||
SELECT * FROM test WHERE a > $1 ORDER BY a | 2 | 4
|
||||
SELECT * FROM test WHERE a IN ($1, $2, $3, $4, $5) | 1 | 8
|
||||
SELECT pg_stat_monitor_reset() | 1 | 1
|
||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0
|
||||
UPDATE test SET b = $1 WHERE a = $2 | 6 | 6
|
||||
UPDATE test SET b = $1 WHERE a > $2 | 1 | 3
|
||||
(9 rows)
|
||||
(13 rows)
|
||||
|
||||
--
|
||||
-- pg_stat_monitor.track = none
|
||||
|
@ -234,11 +240,12 @@ SELECT 1 + 1 AS "two";
|
|||
|
||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls | rows
|
||||
--------------------------------+-------+------
|
||||
---------------------------------------------------------------------------+-------+------
|
||||
SELECT $1 | 1 | 1
|
||||
SELECT $1 + $2 | 1 | 1
|
||||
SELECT pg_stat_monitor_reset() | 1 | 1
|
||||
(3 rows)
|
||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0
|
||||
(4 rows)
|
||||
|
||||
--
|
||||
-- pg_stat_monitor.track = top
|
||||
|
@ -293,7 +300,22 @@ SELECT PLUS_ONE(10);
|
|||
|
||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls | rows
|
||||
-----------------------------------+-------+------
|
||||
---------------------------------------------------------------------------+-------+------
|
||||
CREATE FUNCTION PLUS_ONE(i INTEGER) RETURNS INTEGER AS +| 1 | 0
|
||||
$$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL | |
|
||||
CREATE FUNCTION PLUS_TWO(i INTEGER) RETURNS INTEGER AS $$ +| 1 | 0
|
||||
DECLARE +| |
|
||||
r INTEGER; +| |
|
||||
BEGIN +| |
|
||||
SELECT (i + 1 + 1.0)::INTEGER INTO r; +| |
|
||||
RETURN r; +| |
|
||||
END; $$ LANGUAGE plpgsql | |
|
||||
DO LANGUAGE plpgsql $$ +| 1 | 0
|
||||
BEGIN +| |
|
||||
-- this is a SELECT +| |
|
||||
PERFORM 'hello world'::TEXT; +| |
|
||||
END; +| |
|
||||
$$ | |
|
||||
SELECT $1 +| 1 | 1
|
||||
+| |
|
||||
AS "text" | |
|
||||
|
@ -302,7 +324,8 @@ SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
|||
SELECT PLUS_ONE($1) | 2 | 2
|
||||
SELECT PLUS_TWO($1) | 2 | 2
|
||||
SELECT pg_stat_monitor_reset() | 1 | 1
|
||||
(6 rows)
|
||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0
|
||||
(10 rows)
|
||||
|
||||
--
|
||||
-- pg_stat_monitor.track = all
|
||||
|
@ -354,13 +377,25 @@ SELECT PLUS_ONE(1);
|
|||
|
||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||
query | calls | rows
|
||||
-----------------------------------+-------+------
|
||||
---------------------------------------------------------------------------+-------+------
|
||||
CREATE FUNCTION PLUS_ONE(i INTEGER) RETURNS INTEGER AS +| 1 | 0
|
||||
$$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL | |
|
||||
CREATE FUNCTION PLUS_TWO(i INTEGER) RETURNS INTEGER AS $$ +| 1 | 0
|
||||
DECLARE +| |
|
||||
r INTEGER; +| |
|
||||
BEGIN +| |
|
||||
SELECT (i + 1 + 1.0)::INTEGER INTO r; +| |
|
||||
RETURN r; +| |
|
||||
END; $$ LANGUAGE plpgsql | |
|
||||
DROP FUNCTION PLUS_ONE(INTEGER) | 1 | 0
|
||||
DROP FUNCTION PLUS_TWO(INTEGER) | 1 | 0
|
||||
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
|
||||
(5 rows)
|
||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0
|
||||
(10 rows)
|
||||
|
||||
--
|
||||
-- utility commands
|
||||
|
@ -392,9 +427,16 @@ 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
|
||||
(2 rows)
|
||||
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0
|
||||
(9 rows)
|
||||
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
|
@ -9,6 +9,12 @@ CREATE TABLE foo1(a int);
|
|||
CREATE TABLE foo2(a int);
|
||||
CREATE TABLE foo3(a int);
|
||||
CREATE TABLE foo4(a int);
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM foo1, foo2, foo3, foo4;
|
||||
a | a | a | a
|
||||
---+---+---+---
|
||||
|
@ -21,14 +27,14 @@ SELECT query, relations from pg_stat_monitor ORDER BY query;
|
|||
SELECT pg_stat_monitor_reset() |
|
||||
(2 rows)
|
||||
|
||||
DROP TABLE foo1;
|
||||
DROP TABLE foo2;
|
||||
DROP TABLE foo3;
|
||||
DROP TABLE foo4;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP TABLE foo1;
|
||||
DROP TABLE foo2;
|
||||
DROP TABLE foo3;
|
||||
DROP TABLE foo4;
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
|
@ -9,6 +9,12 @@ CREATE TABLE foo1(a int);
|
|||
CREATE TABLE foo2(a int);
|
||||
CREATE TABLE foo3(a int);
|
||||
CREATE TABLE foo4(a int);
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM foo1, foo2, foo3, foo4;
|
||||
a | a | a | a
|
||||
---+---+---+---
|
||||
|
@ -16,20 +22,20 @@ SELECT * FROM foo1, foo2, foo3, foo4;
|
|||
|
||||
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 |
|
||||
SELECT query, relations from pg_stat_monitor ORDER BY query |
|
||||
(3 rows)
|
||||
|
||||
DROP TABLE foo1;
|
||||
DROP TABLE foo2;
|
||||
DROP TABLE foo3;
|
||||
DROP TABLE foo4;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
pg_stat_monitor_reset
|
||||
-----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP TABLE foo1;
|
||||
DROP TABLE foo2;
|
||||
DROP TABLE foo3;
|
||||
DROP TABLE foo4;
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
2
guc.c
2
guc.c
|
@ -68,7 +68,7 @@ init_guc(void)
|
|||
conf[i] = (GucVariable) {
|
||||
.guc_name = "pg_stat_monitor.pgsm_track_utility",
|
||||
.guc_desc = "Selects whether utility commands are tracked.",
|
||||
.guc_default = 0,
|
||||
.guc_default = 1,
|
||||
.guc_min = 0,
|
||||
.guc_max = 0,
|
||||
.guc_restart = false,
|
||||
|
|
|
@ -4,11 +4,12 @@ CREATE TABLE foo1(a int);
|
|||
CREATE TABLE foo2(a int);
|
||||
CREATE TABLE foo3(a int);
|
||||
CREATE TABLE foo4(a int);
|
||||
SELECT pg_stat_monitor_reset();
|
||||
SELECT * FROM foo1, foo2, foo3, foo4;
|
||||
SELECT query, relations from pg_stat_monitor ORDER BY query;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
DROP TABLE foo1;
|
||||
DROP TABLE foo2;
|
||||
DROP TABLE foo3;
|
||||
DROP TABLE foo4;
|
||||
SELECT pg_stat_monitor_reset();
|
||||
DROP EXTENSION pg_stat_monitor;
|
||||
|
|
Loading…
Reference in New Issue