File tree 3 files changed +60
-0
lines changed
contrib/pg_stat_statements
3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ REGRESS = select dml cursors utility level_tracking planning \
24
24
# which typical installcheck users do not have (e.g. buildfarm clients).
25
25
NO_INSTALLCHECK = 1
26
26
27
+ TAP_TESTS = 1
28
+
27
29
ifdef USE_PGXS
28
30
PG_CONFIG = pg_config
29
31
PGXS := $(shell $(PG_CONFIG ) --pgxs)
Original file line number Diff line number Diff line change @@ -60,4 +60,9 @@ tests += {
60
60
# runningcheck users do not have (e.g. buildfarm clients).
61
61
' runningcheck' : false ,
62
62
},
63
+ ' tap' : {
64
+ ' tests' : [
65
+ ' t/010_restart.pl' ,
66
+ ],
67
+ },
63
68
}
Original file line number Diff line number Diff line change
1
+ # Copyright (c) 2023, PostgreSQL Global Development Group
2
+
3
+ # Tests for checking that pg_stat_statements contents are preserved
4
+ # across restarts.
5
+
6
+ use strict;
7
+ use warnings;
8
+ use PostgreSQL::Test::Cluster;
9
+ use PostgreSQL::Test::Utils;
10
+ use Test::More;
11
+
12
+ my $node = PostgreSQL::Test::Cluster-> new(' main' );
13
+ $node -> init;
14
+ $node -> append_conf(' postgresql.conf' ,
15
+ " shared_preload_libraries = 'pg_stat_statements'" );
16
+ $node -> start;
17
+
18
+ $node -> safe_psql(' postgres' , ' CREATE EXTENSION pg_stat_statements' );
19
+
20
+ $node -> safe_psql(' postgres' , ' CREATE TABLE t1 (a int)' );
21
+ $node -> safe_psql(' postgres' , ' SELECT a FROM t1' );
22
+
23
+ is( $node -> safe_psql(
24
+ ' postgres' ,
25
+ " SELECT query FROM pg_stat_statements WHERE query NOT LIKE '%pg_stat_statements %' ORDER BY query"
26
+ ),
27
+ " CREATE TABLE t1 (a int)\n SELECT a FROM t1" ,
28
+ ' pg_stat_statements populated' );
29
+
30
+ $node -> restart;
31
+
32
+ is( $node -> safe_psql(
33
+ ' postgres' ,
34
+ " SELECT query FROM pg_stat_statements WHERE query NOT LIKE '%pg_stat_statements %' ORDER BY query"
35
+ ),
36
+ " CREATE TABLE t1 (a int)\n SELECT a FROM t1" ,
37
+ ' pg_stat_statements data kept across restart' );
38
+
39
+ $node -> append_conf(' postgresql.conf' , " pg_stat_statements.save = false" );
40
+ $node -> reload;
41
+
42
+ $node -> restart;
43
+
44
+ is( $node -> safe_psql(
45
+ ' postgres' ,
46
+ " SELECT count(*) FROM pg_stat_statements WHERE query NOT LIKE '%pg_stat_statements %'"
47
+ ),
48
+ ' 0' ,
49
+ ' pg_stat_statements data not kept across restart with .save=false' );
50
+
51
+ $node -> stop;
52
+
53
+ done_testing();
You can’t perform that action at this time.
0 commit comments