Skip to content

Commit 9be244d

Browse files
committed
Add minimal set of regression tests for pg_stat_statements.
While the set of covered functionality is fairly small, the added tests still are useful to get some basic buildfarm testing of pg_stat_statements itself, but also to exercise the lwlock tranch code on the buildfarm. Author: Amit Kapila, slightly editorialized by me Reviewed-By: Ashutosh Sharma, Andres Freund Discussion: <CAA4eK1JOjkdXYtHxh=2aDK4VgDtN-LNGKY_YqX0N=YEvuzQVWg@mail.gmail.com>
1 parent 1c14755 commit 9be244d

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

contrib/pg_stat_statements/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ PGFILEDESC = "pg_stat_statements - execution statistics of SQL statements"
1111

1212
LDFLAGS_SL += $(filter -lm, $(LIBS))
1313

14+
REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/pg_stat_statements/pg_stat_statements.conf
15+
REGRESS = pg_stat_statements
16+
1417
ifdef USE_PGXS
1518
PG_CONFIG = pg_config
1619
PGXS := $(shell $(PG_CONFIG) --pgxs)
@@ -21,3 +24,7 @@ top_builddir = ../..
2124
include $(top_builddir)/src/Makefile.global
2225
include $(top_srcdir)/contrib/contrib-global.mk
2326
endif
27+
28+
# Disabled because these tests require "shared_preload_libraries=pg_stat_statements",
29+
# which typical installcheck users do not have (e.g. buildfarm clients).
30+
installcheck: REGRESS=
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
CREATE EXTENSION pg_stat_statements;
2+
CREATE TABLE test (a int, b char(20));
3+
-- test the basic functionality of pg_stat_statements
4+
SELECT pg_stat_statements_reset();
5+
pg_stat_statements_reset
6+
--------------------------
7+
8+
(1 row)
9+
10+
INSERT INTO test VALUES(generate_series(1, 10), 'aaa');
11+
UPDATE test SET b = 'bbb' WHERE a > 5;
12+
SELECT query, calls, rows from pg_stat_statements ORDER BY rows;
13+
query | calls | rows
14+
----------------------------------------------------+-------+------
15+
SELECT pg_stat_statements_reset(); | 1 | 1
16+
UPDATE test SET b = ? WHERE a > ?; | 1 | 5
17+
INSERT INTO test VALUES(generate_series(?, ?), ?); | 1 | 10
18+
(3 rows)
19+
20+
DROP TABLE test;
21+
DROP EXTENSION pg_stat_statements;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shared_preload_libraries = 'pg_stat_statements'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CREATE EXTENSION pg_stat_statements;
2+
3+
CREATE TABLE test (a int, b char(20));
4+
5+
-- test the basic functionality of pg_stat_statements
6+
SELECT pg_stat_statements_reset();
7+
8+
INSERT INTO test VALUES(generate_series(1, 10), 'aaa');
9+
UPDATE test SET b = 'bbb' WHERE a > 5;
10+
11+
SELECT query, calls, rows from pg_stat_statements ORDER BY rows;
12+
13+
DROP TABLE test;
14+
15+
DROP EXTENSION pg_stat_statements;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy