Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4710b67

Browse files
committed
pg_stat_statements: Add TAP test for testing restarts
This tests that pg_stat_statement contents are successfully keptacross restart. (This similar tosrc/test/recovery/t/029_stats_restart.pl for the stats collector.)Reviewed-by: Michael Paquier <michael@paquier.xyz>Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>Discussion:https://www.postgresql.org/message-id/flat/40d1e4f2-835f-448f-a541-8ff5db75bf3d@eisentraut.org
1 parent742f6b3 commit4710b67

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

‎contrib/pg_stat_statements/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ REGRESS = select dml cursors utility level_tracking planning \
2424
# which typical installcheck users do not have (e.g. buildfarm clients).
2525
NO_INSTALLCHECK = 1
2626

27+
TAP_TESTS = 1
28+
2729
ifdefUSE_PGXS
2830
PG_CONFIG = pg_config
2931
PGXS :=$(shell$(PG_CONFIG) --pgxs)

‎contrib/pg_stat_statements/meson.build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,9 @@ tests += {
6060
# runningcheck users do not have (e.g. buildfarm clients).
6161
'runningcheck':false,
6262
},
63+
'tap': {
64+
'tests': [
65+
't/010_restart.pl',
66+
],
67+
},
6368
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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)\nSELECT 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)\nSELECT 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();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp