You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
$node->psql('postgres',"CREATE TABLE aqo_test0(a int, b int, c int, d int);
43
42
WITH RECURSIVE t(a, b, c, d)
@@ -48,18 +47,47 @@
48
47
) INSERT INTO aqo_test0 (SELECT * FROM t);
49
48
CREATE INDEX aqo_test0_idx_a ON aqo_test0 (a);
50
49
ANALYZE aqo_test0;");
51
-
$node->psql('postgres',"
52
-
ALTER SYSTEM SET aqo.mode = 'controlled';
53
-
");
50
+
54
51
$res =$node->safe_psql('postgres',"SELECT * FROM aqo_test0");
55
52
$res =$node->safe_psql('postgres',"SELECT count(*) FROM pg_stat_statements where query = 'SELECT * FROM aqo_test0'");
56
-
is($res, 1);# The same query add in pg_stat_statements
57
-
$res =$node->safe_psql('postgres',"SELECT count(*) from aqo_query_texts where query_text = 'SELECT * FROM aqo_test0'");
58
-
is($res, 0);# The same query isn't add in aqo_query_texts
59
-
$query_id =$node->safe_psql('postgres',"SELECT queryid FROM pg_stat_statements where query = 'SELECT * FROM aqo_test0'");
60
-
$res =$node->safe_psql('postgres',"insert into aqo_queries values ($query_id,'f','f',$query_id,'f')");
61
-
# Add query in aqo_query_texts
62
-
$res =$node->safe_psql('postgres',"insert into aqo_query_texts values ($query_id,'SELECT * FROM aqo_test0')");
63
-
$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
53
+
54
+
# Check number of queries which logged in both extensions.
55
+
$res =$node->safe_psql('postgres',"
56
+
SELECT count(*) FROM aqo_query_texts aqt, pg_stat_statements pgss
57
+
WHERE aqt.query_hash = pgss.queryid
58
+
");
59
+
is($res, 3);
60
+
61
+
# TODO: Maybe AQO should parameterize query text too?
62
+
$res =$node->safe_psql('postgres',"
63
+
SELECT count(*) FROM aqo_query_texts aqt, pg_stat_statements pgss
64
+
WHERE aqt.query_hash = pgss.queryid AND aqt.query_text = pgss.query
65
+
");
64
66
is($res, 1);
65
-
$node->stop();
67
+
68
+
# Just fix a number of differences
69
+
$res =$node->safe_psql('postgres',"
70
+
SELECT count(*) FROM aqo_query_texts
71
+
WHERE query_hash NOT IN (SELECT queryid FROM pg_stat_statements)
72
+
");
73
+
is($res, 1);
74
+
75
+
$res =$node->safe_psql('postgres',"
76
+
SELECT query_text FROM aqo_query_texts
77
+
WHERE query_hash NOT IN (SELECT queryid FROM pg_stat_statements)
78
+
");
79
+
note($res);# Just see differences
80
+
81
+
$res =$node->safe_psql('postgres',"
82
+
SELECT count(*) FROM pg_stat_statements
83
+
WHERE queryid NOT IN (SELECT query_hash FROM aqo_query_texts)
84
+
");
85
+
is($res, 8);
86
+
87
+
$res =$node->safe_psql('postgres',"
88
+
SELECT query FROM pg_stat_statements
89
+
WHERE queryid NOT IN (SELECT query_hash FROM aqo_query_texts)