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

Commit a62744a

Browse files
Alena0704Andrey Lepikhov
authored and
Andrey Lepikhov
committed
add query_hash as getting query_id, test for joint use pg_stat_statements and aqo, function for ignoring string with Query Identifier in aqo_gucs and aqo_fdw tests
1 parent 8a71d50 commit a62744a

File tree

2 files changed

+70
-4
lines changed

2 files changed

+70
-4
lines changed

‎Makefile‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ REGRESS = aqo_disabled \
2626
top_queries
2727

2828
fdw_srcdir = $(top_srcdir)/contrib/postgres_fdw
29-
PG_CPPFLAGS += -I$(libpq_srcdir) -I$(fdw_srcdir)
29+
stat_srcdir = $(top_srcdir)/contrib/pg_stat_statements
30+
PG_CPPFLAGS += -I$(libpq_srcdir) -I$(fdw_srcdir) -I$(stat_srcdir)
3031
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
31-
EXTRA_INSTALL = contrib/postgres_fdw
32+
EXTRA_INSTALL = contrib/postgres_fdw contrib/pg_stat_statements
3233

3334
DATA = aqo--1.0.sql aqo--1.0--1.1.sql aqo--1.1--1.2.sql aqo--1.2.sql \
3435
aqo--1.2--1.3.sql
@@ -42,5 +43,4 @@ subdir = contrib/aqo
4243
top_builddir = ../..
4344
include $(top_builddir)/src/Makefile.global
4445
include $(top_srcdir)/contrib/contrib-global.mk
45-
endif
46-
46+
endif

‎t/002_pg_stat_statements_aqo.pl‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
use strict;
2+
use warnings;
3+
use PostgreSQL::Test::Cluster;
4+
use PostgreSQL::Test::Utils;
5+
use Test::More tests => 3;
6+
print "start";
7+
my $node = PostgreSQL::Test::Cluster->new('profiling');
8+
$node->init;
9+
print "create conf";
10+
11+
$node->append_conf('postgresql.conf', qq{
12+
aqo.mode = 'disabled'
13+
aqo.profile_classes = -1
14+
aqo.profile_enable = 'true'
15+
aqo.force_collect_stat = 'false'
16+
aqo.log_ignorance = 'off'
17+
log_statement = 'ddl' # reduce size of logs.
18+
});
19+
# Test constants.
20+
my $TRANSACTIONS = 100;
21+
my $CLIENTS = 10;
22+
my $THREADS = 10;
23+
my $query_id;
24+
25+
# General purpose variables.
26+
my $res;
27+
my $total_classes;
28+
$node->start();
29+
# ERROR: AQO allow to load library only on startup
30+
print "create extantion aqo";
31+
$node->psql('postgres', "CREATE EXTENSION aqo");
32+
$node->psql('postgres', "CREATE EXTENSION pg_stat_statements");
33+
print "create preload libraries";
34+
$node->append_conf('postgresql.conf', qq{shared_preload_libraries = 'aqo, pg_stat_statements'});
35+
$node->restart();
36+
$node->psql('postgres', "CREATE EXTENSION aqo");
37+
$node->psql('postgres', "CREATE EXTENSION pg_stat_statements");
38+
$node->psql('postgres', "
39+
ALTER SYSTEM SET aqo.profile_enable = 'true';
40+
SELECT pg_reload_conf();
41+
");
42+
43+
$node->psql('postgres', "CREATE TABLE aqo_test0(a int, b int, c int, d int);
44+
WITH RECURSIVE t(a, b, c, d)
45+
AS (
46+
VALUES (0, 0, 0, 0)
47+
UNION ALL
48+
SELECT t.a + 1, t.b + 1, t.c + 1, t.d + 1 FROM t WHERE t.a < 2000
49+
) INSERT INTO aqo_test0 (SELECT * FROM t);
50+
CREATE INDEX aqo_test0_idx_a ON aqo_test0 (a);
51+
ANALYZE aqo_test0;");
52+
$node->psql('postgres', "
53+
ALTER SYSTEM SET aqo.mode = 'controlled';
54+
");
55+
$res = $node->safe_psql('postgres', "SELECT * FROM aqo_test0");
56+
$res = $node->safe_psql('postgres', "SELECT count(*) FROM pg_stat_statements where query = 'SELECT * FROM aqo_test0'");
57+
is($res, 1); # The same query add in pg_stat_statements
58+
$res = $node->safe_psql('postgres', "SELECT count(*) from aqo_query_texts where query_text = 'SELECT * FROM aqo_test0'");
59+
is($res, 0); # The same query isn't add in aqo_query_texts
60+
$query_id = $node->safe_psql('postgres', "SELECT queryid FROM pg_stat_statements where query = 'SELECT * FROM aqo_test0'");
61+
$res = $node->safe_psql('postgres', "insert into aqo_queries values ($query_id,'f','f',$query_id,'f')");
62+
# Add query in aqo_query_texts
63+
$res = $node->safe_psql('postgres', "insert into aqo_query_texts values ($query_id,'SELECT * FROM aqo_test0')");
64+
$res = $node->safe_psql('postgres', "SELECT count(*) from aqo_query_texts where query_text = 'SELECT * FROM aqo_test0'"); # The same query is in aqo_query_texts
65+
is($res, 1);
66+
$node->stop();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /