Skip to content

Navigation Menu

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

Appearance settings

Commit de2aca2

Browse filesBrowse files
committed
Expand regression tests of pg_stat_statements for utility queries
This commit adds more coverage for utility statements so as it is possible to track down all the effects of query normalization done for all the queries that use either Const or A_Const nodes, which are the nodes where normalization makes the most sense as they apply to constants (well, most of the time, really). This set of queries is extracted from an analysis done while looking at full dumps of the regression database when applying different levels of normalization to either Const or A_Const nodes for utilities, as of a minimal set of these, for: - All relkinds (CREATE, ALTER, DROP) - Policies - Cursors - Triggers - Types - Rules - Statistics - CALL - Transaction statements (isolation level, options) - EXPLAIN - COPY Note that pg_stat_statements is not switched yet to show any normalization for utilities, still it improves the default coverage of the query jumbling code (not by as much as enabling query jumbling on the main regression test suite, though): - queryjumblefuncs.funcs.c: 36.8% => 48.5% - queryjumblefuncs.switch.c: 33.2% => 43.1% Reviewed-by: Bertrand Drouvot Discussion: https://postgr.es/m/Y+MRdEq9W9XVa2AB@paquier.xyz
1 parent e8dbdb1 commit de2aca2
Copy full SHA for de2aca2

File tree

6 files changed

+774
-30
lines changed
Filter options

6 files changed

+774
-30
lines changed

‎contrib/pg_stat_statements/Makefile

Copy file name to clipboardExpand all lines: contrib/pg_stat_statements/Makefile
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ PGFILEDESC = "pg_stat_statements - execution statistics of SQL statements"
1717
LDFLAGS_SL += $(filter -lm, $(LIBS))
1818

1919
REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/pg_stat_statements/pg_stat_statements.conf
20-
REGRESS = pg_stat_statements utility level_tracking planning cleanup oldextversions
20+
REGRESS = pg_stat_statements cursors utility level_tracking planning \
21+
cleanup oldextversions
2122
# Disabled because these tests require "shared_preload_libraries=pg_stat_statements",
2223
# which typical installcheck users do not have (e.g. buildfarm clients).
2324
NO_INSTALLCHECK = 1
+70Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
--
2+
-- Cursors
3+
--
4+
-- These tests require track_utility to be enabled.
5+
SET pg_stat_statements.track_utility = TRUE;
6+
SELECT pg_stat_statements_reset();
7+
pg_stat_statements_reset
8+
--------------------------
9+
10+
(1 row)
11+
12+
-- DECLARE
13+
-- SELECT is normalized.
14+
DECLARE cursor_stats_1 CURSOR WITH HOLD FOR SELECT 1;
15+
CLOSE cursor_stats_1;
16+
DECLARE cursor_stats_1 CURSOR WITH HOLD FOR SELECT 2;
17+
CLOSE cursor_stats_1;
18+
SELECT calls, rows, query FROM pg_stat_statements ORDER BY query COLLATE "C";
19+
calls | rows | query
20+
-------+------+------------------------------------------------------
21+
2 | 0 | CLOSE cursor_stats_1
22+
2 | 0 | DECLARE cursor_stats_1 CURSOR WITH HOLD FOR SELECT 1
23+
1 | 1 | SELECT pg_stat_statements_reset()
24+
(3 rows)
25+
26+
SELECT pg_stat_statements_reset();
27+
pg_stat_statements_reset
28+
--------------------------
29+
30+
(1 row)
31+
32+
-- FETCH
33+
BEGIN;
34+
DECLARE cursor_stats_1 CURSOR WITH HOLD FOR SELECT 2;
35+
DECLARE cursor_stats_2 CURSOR WITH HOLD FOR SELECT 3;
36+
FETCH 1 IN cursor_stats_1;
37+
?column?
38+
----------
39+
2
40+
(1 row)
41+
42+
FETCH 1 IN cursor_stats_2;
43+
?column?
44+
----------
45+
3
46+
(1 row)
47+
48+
CLOSE cursor_stats_1;
49+
CLOSE cursor_stats_2;
50+
COMMIT;
51+
SELECT calls, rows, query FROM pg_stat_statements ORDER BY query COLLATE "C";
52+
calls | rows | query
53+
-------+------+------------------------------------------------------
54+
1 | 0 | BEGIN
55+
1 | 0 | CLOSE cursor_stats_1
56+
1 | 0 | CLOSE cursor_stats_2
57+
1 | 0 | COMMIT
58+
1 | 0 | DECLARE cursor_stats_1 CURSOR WITH HOLD FOR SELECT 2
59+
1 | 0 | DECLARE cursor_stats_2 CURSOR WITH HOLD FOR SELECT 3
60+
1 | 1 | FETCH 1 IN cursor_stats_1
61+
1 | 1 | FETCH 1 IN cursor_stats_2
62+
1 | 1 | SELECT pg_stat_statements_reset()
63+
(9 rows)
64+
65+
SELECT pg_stat_statements_reset();
66+
pg_stat_statements_reset
67+
--------------------------
68+
69+
(1 row)
70+

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.