mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-05 19:09:58 +08:00
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>
This commit is contained in:
parent
1c14755776
commit
9be244dbe8
@ -11,6 +11,9 @@ PGFILEDESC = "pg_stat_statements - execution statistics of SQL statements"
|
|||||||
|
|
||||||
LDFLAGS_SL += $(filter -lm, $(LIBS))
|
LDFLAGS_SL += $(filter -lm, $(LIBS))
|
||||||
|
|
||||||
|
REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/pg_stat_statements/pg_stat_statements.conf
|
||||||
|
REGRESS = pg_stat_statements
|
||||||
|
|
||||||
ifdef USE_PGXS
|
ifdef USE_PGXS
|
||||||
PG_CONFIG = pg_config
|
PG_CONFIG = pg_config
|
||||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||||
@ -21,3 +24,7 @@ top_builddir = ../..
|
|||||||
include $(top_builddir)/src/Makefile.global
|
include $(top_builddir)/src/Makefile.global
|
||||||
include $(top_srcdir)/contrib/contrib-global.mk
|
include $(top_srcdir)/contrib/contrib-global.mk
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Disabled because these tests require "shared_preload_libraries=pg_stat_statements",
|
||||||
|
# which typical installcheck users do not have (e.g. buildfarm clients).
|
||||||
|
installcheck: REGRESS=
|
||||||
|
21
contrib/pg_stat_statements/expected/pg_stat_statements.out
Normal file
21
contrib/pg_stat_statements/expected/pg_stat_statements.out
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
CREATE EXTENSION pg_stat_statements;
|
||||||
|
CREATE TABLE test (a int, b char(20));
|
||||||
|
-- test the basic functionality of pg_stat_statements
|
||||||
|
SELECT pg_stat_statements_reset();
|
||||||
|
pg_stat_statements_reset
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT INTO test VALUES(generate_series(1, 10), 'aaa');
|
||||||
|
UPDATE test SET b = 'bbb' WHERE a > 5;
|
||||||
|
SELECT query, calls, rows from pg_stat_statements ORDER BY rows;
|
||||||
|
query | calls | rows
|
||||||
|
----------------------------------------------------+-------+------
|
||||||
|
SELECT pg_stat_statements_reset(); | 1 | 1
|
||||||
|
UPDATE test SET b = ? WHERE a > ?; | 1 | 5
|
||||||
|
INSERT INTO test VALUES(generate_series(?, ?), ?); | 1 | 10
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
DROP TABLE test;
|
||||||
|
DROP EXTENSION pg_stat_statements;
|
1
contrib/pg_stat_statements/pg_stat_statements.conf
Normal file
1
contrib/pg_stat_statements/pg_stat_statements.conf
Normal file
@ -0,0 +1 @@
|
|||||||
|
shared_preload_libraries = 'pg_stat_statements'
|
15
contrib/pg_stat_statements/sql/pg_stat_statements.sql
Normal file
15
contrib/pg_stat_statements/sql/pg_stat_statements.sql
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
CREATE EXTENSION pg_stat_statements;
|
||||||
|
|
||||||
|
CREATE TABLE test (a int, b char(20));
|
||||||
|
|
||||||
|
-- test the basic functionality of pg_stat_statements
|
||||||
|
SELECT pg_stat_statements_reset();
|
||||||
|
|
||||||
|
INSERT INTO test VALUES(generate_series(1, 10), 'aaa');
|
||||||
|
UPDATE test SET b = 'bbb' WHERE a > 5;
|
||||||
|
|
||||||
|
SELECT query, calls, rows from pg_stat_statements ORDER BY rows;
|
||||||
|
|
||||||
|
DROP TABLE test;
|
||||||
|
|
||||||
|
DROP EXTENSION pg_stat_statements;
|
Loading…
Reference in New Issue
Block a user