Skip to content

Commit

Permalink
Issue - (#7): Fix regression test suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrarahmad committed Dec 2, 2019
1 parent 269fc65 commit 8caf250
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 66 deletions.
88 changes: 44 additions & 44 deletions expected/pg_stat_monitor.out
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
CREATE EXTENSION pg_stat_statements;
CREATE EXTENSION pg_stat_monitor;
--
-- simple and compound statements
--
SET pg_stat_statements.track_utility = FALSE;
SELECT pg_stat_statements_reset();
pg_stat_statements_reset
--------------------------
SET pg_stat_monitor.track_utility = FALSE;
SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset
-----------------------

(1 row)

Expand Down Expand Up @@ -95,7 +95,7 @@ EXECUTE pgss_test(1);
(1 row)

DEALLOCATE pgss_test;
SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
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
Expand All @@ -108,7 +108,7 @@ SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
SELECT $1 AS "int" | 2 | 2
SELECT $1 AS i UNION SELECT $2 ORDER BY i | 1 | 2
SELECT $1 || $2 | 1 | 1
SELECT pg_stat_statements_reset() | 1 | 1
SELECT pg_stat_monitor_reset() | 1 | 1
WITH t(f) AS ( +| 1 | 2
VALUES ($1), ($2) +| |
) +| |
Expand All @@ -119,9 +119,9 @@ SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
--
-- CRUD: INSERT SELECT UPDATE DELETE on test table
--
SELECT pg_stat_statements_reset();
pg_stat_statements_reset
--------------------------
SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset
-----------------------

(1 row)

Expand Down Expand Up @@ -195,7 +195,7 @@ SELECT * FROM test WHERE a IN (1, 2, 3, 4, 5);
3 | c
(8 rows)

SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
query | calls | rows
-------------------------------------------------------------+-------+------
DELETE FROM test WHERE a > $1 | 1 | 1
Expand All @@ -204,18 +204,18 @@ SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
SELECT * FROM test ORDER BY a | 1 | 12
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_statements_reset() | 1 | 1
SELECT pg_stat_monitor_reset() | 1 | 1
UPDATE test SET b = $1 WHERE a = $2 | 6 | 6
UPDATE test SET b = $1 WHERE a > $2 | 1 | 3
(9 rows)

--
-- pg_stat_statements.track = none
-- pg_stat_monitor.track = none
--
SET pg_stat_statements.track = 'none';
SELECT pg_stat_statements_reset();
pg_stat_statements_reset
--------------------------
SET pg_stat_monitor.track = 'none';
SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset
-----------------------

(1 row)

Expand All @@ -231,18 +231,18 @@ SELECT 1 + 1 AS "two";
2
(1 row)

SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
query | calls | rows
-------+-------+------
(0 rows)

--
-- pg_stat_statements.track = top
-- pg_stat_monitor.track = top
--
SET pg_stat_statements.track = 'top';
SELECT pg_stat_statements_reset();
pg_stat_statements_reset
--------------------------
SET pg_stat_monitor.track = 'top';
SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset
-----------------------

(1 row)

Expand Down Expand Up @@ -287,22 +287,22 @@ SELECT PLUS_ONE(10);
11
(1 row)

SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
query | calls | rows
-----------------------------------+-------+------
SELECT $1::TEXT | 1 | 1
SELECT PLUS_ONE($1) | 2 | 2
SELECT PLUS_TWO($1) | 2 | 2
SELECT pg_stat_statements_reset() | 1 | 1
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
query | calls | rows
--------------------------------+-------+------
SELECT $1::TEXT | 1 | 1
SELECT PLUS_ONE($1) | 2 | 2
SELECT PLUS_TWO($1) | 2 | 2
SELECT pg_stat_monitor_reset() | 1 | 1
(4 rows)

--
-- pg_stat_statements.track = all
-- pg_stat_monitor.track = all
--
SET pg_stat_statements.track = 'all';
SELECT pg_stat_statements_reset();
pg_stat_statements_reset
--------------------------
SET pg_stat_monitor.track = 'all';
SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset
-----------------------

(1 row)

Expand Down Expand Up @@ -344,23 +344,23 @@ SELECT PLUS_ONE(1);
2
(1 row)

SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";
query | calls | rows
-----------------------------------+-------+------
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_statements_reset() | 1 | 1
SELECT pg_stat_monitor_reset() | 1 | 1
(5 rows)

--
-- utility commands
--
SET pg_stat_statements.track_utility = TRUE;
SELECT pg_stat_statements_reset();
pg_stat_statements_reset
--------------------------
SET pg_stat_monitor.track_utility = TRUE;
SELECT pg_stat_monitor_reset();
pg_stat_monitor_reset
-----------------------

(1 row)

Expand All @@ -382,7 +382,7 @@ NOTICE: table "test" does not exist, skipping
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_statements ORDER BY query COLLATE "C";
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
Expand All @@ -392,7 +392,7 @@ SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
DROP TABLE IF EXISTS test | 3 | 0
DROP TABLE test | 1 | 0
SELECT $1 | 1 | 1
SELECT pg_stat_statements_reset() | 1 | 1
SELECT pg_stat_monitor_reset() | 1 | 1
(8 rows)

DROP EXTENSION pg_stat_statements;
DROP EXTENSION pg_stat_monitor;
44 changes: 22 additions & 22 deletions sql/pg_stat_monitor.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
CREATE EXTENSION pg_stat_statements;
CREATE EXTENSION pg_stat_monitor;

--
-- simple and compound statements
--
SET pg_stat_statements.track_utility = FALSE;
SELECT pg_stat_statements_reset();
SET pg_stat_monitor.track_utility = FALSE;
SELECT pg_stat_monitor_reset();

SELECT 1 AS "int";

Expand Down Expand Up @@ -51,12 +51,12 @@ PREPARE pgss_test (int) AS SELECT $1, 'test' LIMIT 1;
EXECUTE pgss_test(1);
DEALLOCATE pgss_test;

SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";

--
-- CRUD: INSERT SELECT UPDATE DELETE on test table
--
SELECT pg_stat_statements_reset();
SELECT pg_stat_monitor_reset();

-- utility "create table" should not be shown
CREATE TEMP TABLE test (a int, b char(20));
Expand Down Expand Up @@ -99,24 +99,24 @@ SELECT * FROM test ORDER BY a;
-- SELECT with IN clause
SELECT * FROM test WHERE a IN (1, 2, 3, 4, 5);

SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";

--
-- pg_stat_statements.track = none
-- pg_stat_monitor.track = none
--
SET pg_stat_statements.track = 'none';
SELECT pg_stat_statements_reset();
SET pg_stat_monitor.track = 'none';
SELECT pg_stat_monitor_reset();

SELECT 1 AS "one";
SELECT 1 + 1 AS "two";

SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";

--
-- pg_stat_statements.track = top
-- pg_stat_monitor.track = top
--
SET pg_stat_statements.track = 'top';
SELECT pg_stat_statements_reset();
SET pg_stat_monitor.track = 'top';
SELECT pg_stat_monitor_reset();

DO LANGUAGE plpgsql $$
BEGIN
Expand Down Expand Up @@ -144,13 +144,13 @@ $$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL;
SELECT PLUS_ONE(8);
SELECT PLUS_ONE(10);

SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";

--
-- pg_stat_statements.track = all
-- pg_stat_monitor.track = all
--
SET pg_stat_statements.track = 'all';
SELECT pg_stat_statements_reset();
SET pg_stat_monitor.track = 'all';
SELECT pg_stat_monitor_reset();

-- we drop and recreate the functions to avoid any caching funnies
DROP FUNCTION PLUS_ONE(INTEGER);
Expand All @@ -175,13 +175,13 @@ $$ SELECT (i + 1.0)::INTEGER LIMIT 1 $$ LANGUAGE SQL;
SELECT PLUS_ONE(3);
SELECT PLUS_ONE(1);

SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";

--
-- utility commands
--
SET pg_stat_statements.track_utility = TRUE;
SELECT pg_stat_statements_reset();
SET pg_stat_monitor.track_utility = TRUE;
SELECT pg_stat_monitor_reset();

SELECT 1;
CREATE INDEX test_b ON test(b);
Expand All @@ -193,6 +193,6 @@ DROP TABLE IF EXISTS test \;
DROP FUNCTION IF EXISTS PLUS_ONE(INTEGER);
DROP FUNCTION PLUS_TWO(INTEGER);

SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
SELECT query, calls, rows FROM pg_stat_monitor ORDER BY query COLLATE "C";

DROP EXTENSION pg_stat_statements;
DROP EXTENSION pg_stat_monitor;

0 comments on commit 8caf250

Please sign in to comment.