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";
|
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
|
||||||
query | calls | rows
|
query | calls | rows
|
||||||
---------------------------------------------------------------------------+-------+------
|
---------------------------------------------------------------------------+-------+------
|
||||||
|
BEGIN | 2 | 0
|
||||||
|
COMMIT | 2 | 0
|
||||||
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
|
||||||
|
@ -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 f FROM t ORDER BY f | |
|
||||||
select $1::jsonb ? $2 | 1 | 1
|
select $1::jsonb ? $2 | 1 | 1
|
||||||
(11 rows)
|
(14 rows)
|
||||||
|
|
||||||
--
|
--
|
||||||
-- CRUD: INSERT SELECT UPDATE DELETE on test table
|
-- CRUD: INSERT SELECT UPDATE DELETE on test table
|
||||||
|
@ -197,18 +199,22 @@ SELECT * FROM test WHERE a IN (1, 2, 3, 4, 5);
|
||||||
(8 rows)
|
(8 rows)
|
||||||
|
|
||||||
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
|
||||||
-------------------------------------------------------------+-------+------
|
---------------------------------------------------------------------------+-------+------
|
||||||
DELETE FROM test WHERE a > $1 | 1 | 1
|
BEGIN | 3 | 0
|
||||||
INSERT INTO test (a, b) VALUES ($1, $2), ($3, $4), ($5, $6) | 1 | 3
|
COMMIT | 3 | 0
|
||||||
INSERT INTO test VALUES(generate_series($1, $2), $3) | 1 | 10
|
CREATE TEMP TABLE test (a int, b char(20)) | 1 | 0
|
||||||
SELECT * FROM test ORDER BY a | 1 | 12
|
DELETE FROM test WHERE a > $1 | 1 | 1
|
||||||
SELECT * FROM test WHERE a > $1 ORDER BY a | 2 | 4
|
INSERT INTO test (a, b) VALUES ($1, $2), ($3, $4), ($5, $6) | 1 | 3
|
||||||
SELECT * FROM test WHERE a IN ($1, $2, $3, $4, $5) | 1 | 8
|
INSERT INTO test VALUES(generate_series($1, $2), $3) | 1 | 10
|
||||||
SELECT pg_stat_monitor_reset() | 1 | 1
|
SELECT * FROM test ORDER BY a | 1 | 12
|
||||||
UPDATE test SET b = $1 WHERE a = $2 | 6 | 6
|
SELECT * FROM test WHERE a > $1 ORDER BY a | 2 | 4
|
||||||
UPDATE test SET b = $1 WHERE a > $2 | 1 | 3
|
SELECT * FROM test WHERE a IN ($1, $2, $3, $4, $5) | 1 | 8
|
||||||
(9 rows)
|
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
|
||||||
|
(13 rows)
|
||||||
|
|
||||||
--
|
--
|
||||||
-- pg_stat_monitor.track = none
|
-- pg_stat_monitor.track = none
|
||||||
|
@ -233,12 +239,13 @@ 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
|
||||||
--------------------------------+-------+------
|
---------------------------------------------------------------------------+-------+------
|
||||||
SELECT $1 | 1 | 1
|
SELECT $1 | 1 | 1
|
||||||
SELECT $1 + $2 | 1 | 1
|
SELECT $1 + $2 | 1 | 1
|
||||||
SELECT pg_stat_monitor_reset() | 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
|
-- pg_stat_monitor.track = top
|
||||||
|
@ -292,17 +299,33 @@ 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
|
CREATE FUNCTION PLUS_ONE(i INTEGER) RETURNS INTEGER AS +| 1 | 0
|
||||||
+| |
|
$$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL | |
|
||||||
AS "text" | |
|
CREATE FUNCTION PLUS_TWO(i INTEGER) RETURNS INTEGER AS $$ +| 1 | 0
|
||||||
SELECT (i + $2 + $3)::INTEGER | 2 | 2
|
DECLARE +| |
|
||||||
SELECT (i + $2)::INTEGER LIMIT $3 | 2 | 2
|
r INTEGER; +| |
|
||||||
SELECT PLUS_ONE($1) | 2 | 2
|
BEGIN +| |
|
||||||
SELECT PLUS_TWO($1) | 2 | 2
|
SELECT (i + 1 + 1.0)::INTEGER INTO r; +| |
|
||||||
SELECT pg_stat_monitor_reset() | 1 | 1
|
RETURN r; +| |
|
||||||
(6 rows)
|
END; $$ LANGUAGE plpgsql | |
|
||||||
|
DO LANGUAGE plpgsql $$ +| 1 | 0
|
||||||
|
BEGIN +| |
|
||||||
|
-- this is a SELECT +| |
|
||||||
|
PERFORM 'hello world'::TEXT; +| |
|
||||||
|
END; +| |
|
||||||
|
$$ | |
|
||||||
|
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
|
||||||
|
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0
|
||||||
|
(10 rows)
|
||||||
|
|
||||||
--
|
--
|
||||||
-- pg_stat_monitor.track = all
|
-- pg_stat_monitor.track = all
|
||||||
|
@ -353,14 +376,26 @@ SELECT PLUS_ONE(1);
|
||||||
(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 (i + $2 + $3)::INTEGER | 2 | 2
|
CREATE FUNCTION PLUS_ONE(i INTEGER) RETURNS INTEGER AS +| 1 | 0
|
||||||
SELECT (i + $2)::INTEGER LIMIT $3 | 2 | 2
|
$$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL | |
|
||||||
SELECT PLUS_ONE($1) | 2 | 2
|
CREATE FUNCTION PLUS_TWO(i INTEGER) RETURNS INTEGER AS $$ +| 1 | 0
|
||||||
SELECT PLUS_TWO($1) | 2 | 2
|
DECLARE +| |
|
||||||
SELECT pg_stat_monitor_reset() | 1 | 1
|
r INTEGER; +| |
|
||||||
(5 rows)
|
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
|
||||||
|
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0
|
||||||
|
(10 rows)
|
||||||
|
|
||||||
--
|
--
|
||||||
-- utility commands
|
-- utility commands
|
||||||
|
@ -391,10 +426,17 @@ 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
|
||||||
--------------------------------+-------+------
|
---------------------------------------------------------------------------+-------+------
|
||||||
SELECT $1 | 1 | 1
|
CREATE INDEX test_b ON test(b) | 1 | 0
|
||||||
SELECT pg_stat_monitor_reset() | 1 | 1
|
DROP FUNCTION IF EXISTS PLUS_ONE(INTEGER) | 1 | 0
|
||||||
(2 rows)
|
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
|
||||||
|
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | 0
|
||||||
|
(9 rows)
|
||||||
|
|
||||||
DROP EXTENSION pg_stat_monitor;
|
DROP EXTENSION pg_stat_monitor;
|
||||||
|
|
|
@ -9,6 +9,12 @@ CREATE TABLE foo1(a int);
|
||||||
CREATE TABLE foo2(a int);
|
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 pg_stat_monitor_reset();
|
||||||
|
pg_stat_monitor_reset
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
SELECT * FROM foo1, foo2, foo3, foo4;
|
SELECT * FROM foo1, foo2, foo3, foo4;
|
||||||
a | a | a | a
|
a | a | a | a
|
||||||
---+---+---+---
|
---+---+---+---
|
||||||
|
@ -21,14 +27,14 @@ SELECT query, relations from pg_stat_monitor ORDER BY query;
|
||||||
SELECT pg_stat_monitor_reset() |
|
SELECT pg_stat_monitor_reset() |
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
DROP TABLE foo1;
|
|
||||||
DROP TABLE foo2;
|
|
||||||
DROP TABLE foo3;
|
|
||||||
DROP TABLE foo4;
|
|
||||||
SELECT pg_stat_monitor_reset();
|
SELECT pg_stat_monitor_reset();
|
||||||
pg_stat_monitor_reset
|
pg_stat_monitor_reset
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
DROP TABLE foo1;
|
||||||
|
DROP TABLE foo2;
|
||||||
|
DROP TABLE foo3;
|
||||||
|
DROP TABLE foo4;
|
||||||
DROP EXTENSION pg_stat_monitor;
|
DROP EXTENSION pg_stat_monitor;
|
||||||
|
|
|
@ -9,27 +9,33 @@ CREATE TABLE foo1(a int);
|
||||||
CREATE TABLE foo2(a int);
|
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;
|
|
||||||
a | a | a | a
|
|
||||||
---+---+---+---
|
|
||||||
(0 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;
|
|
||||||
DROP TABLE foo4;
|
|
||||||
SELECT pg_stat_monitor_reset();
|
SELECT pg_stat_monitor_reset();
|
||||||
pg_stat_monitor_reset
|
pg_stat_monitor_reset
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
SELECT * FROM foo1, foo2, foo3, foo4;
|
||||||
|
a | a | a | a
|
||||||
|
---+---+---+---
|
||||||
|
(0 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 ORDER BY query |
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
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;
|
DROP EXTENSION pg_stat_monitor;
|
||||||
|
|
2
guc.c
2
guc.c
|
@ -68,7 +68,7 @@ init_guc(void)
|
||||||
conf[i] = (GucVariable) {
|
conf[i] = (GucVariable) {
|
||||||
.guc_name = "pg_stat_monitor.pgsm_track_utility",
|
.guc_name = "pg_stat_monitor.pgsm_track_utility",
|
||||||
.guc_desc = "Selects whether utility commands are tracked.",
|
.guc_desc = "Selects whether utility commands are tracked.",
|
||||||
.guc_default = 0,
|
.guc_default = 1,
|
||||||
.guc_min = 0,
|
.guc_min = 0,
|
||||||
.guc_max = 0,
|
.guc_max = 0,
|
||||||
.guc_restart = false,
|
.guc_restart = false,
|
||||||
|
|
|
@ -4,11 +4,12 @@ CREATE TABLE foo1(a int);
|
||||||
CREATE TABLE foo2(a int);
|
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 pg_stat_monitor_reset();
|
||||||
SELECT * FROM foo1, foo2, foo3, foo4;
|
SELECT * FROM foo1, foo2, foo3, foo4;
|
||||||
SELECT query, relations from pg_stat_monitor ORDER BY query;
|
SELECT query, relations from pg_stat_monitor ORDER BY query;
|
||||||
|
SELECT pg_stat_monitor_reset();
|
||||||
DROP TABLE foo1;
|
DROP TABLE foo1;
|
||||||
DROP TABLE foo2;
|
DROP TABLE foo2;
|
||||||
DROP TABLE foo3;
|
DROP TABLE foo3;
|
||||||
DROP TABLE foo4;
|
DROP TABLE foo4;
|
||||||
SELECT pg_stat_monitor_reset();
|
|
||||||
DROP EXTENSION pg_stat_monitor;
|
DROP EXTENSION pg_stat_monitor;
|
||||||
|
|
Loading…
Reference in New Issue