|
14 | 14 | $node_primary->adjust_conf('postgresql.conf', 'max_connections', '25');
|
15 | 15 | $node_primary->append_conf('postgresql.conf',
|
16 | 16 | 'max_prepared_transactions = 10');
|
| 17 | + |
| 18 | +# Enable pg_stat_statements to force tests to do query jumbling. |
| 19 | +# pg_stat_statements.max should be large enough to hold all the entries |
| 20 | +# of the regression database. |
| 21 | +$node_primary->append_conf( |
| 22 | + 'postgresql.conf', |
| 23 | + qq{shared_preload_libraries = 'pg_stat_statements' |
| 24 | +pg_stat_statements.max = 50000 |
| 25 | +compute_query_id = 'regress' |
| 26 | +}); |
| 27 | + |
17 | 28 | # We'll stick with Cluster->new's small default shared_buffers, but since that
|
18 | 29 | # makes synchronized seqscans more probable, it risks changing the results of
|
19 | 30 | # some test queries. Disable synchronized seqscans to prevent that.
|
|
106 | 117 | [ 'diff', $outputdir . '/primary.dump', $outputdir . '/standby.dump' ],
|
107 | 118 | 'compare primary and standby dumps');
|
108 | 119 |
|
| 120 | +# Check some data from pg_stat_statements. |
| 121 | +$node_primary->safe_psql('postgres', 'CREATE EXTENSION pg_stat_statements'); |
| 122 | +# This gathers data based on the first characters for some common query types, |
| 123 | +# checking that reports are generated for SELECT, DMLs, and DDL queries with |
| 124 | +# CREATE. |
| 125 | +my $result = $node_primary->safe_psql( |
| 126 | + 'postgres', |
| 127 | + qq{WITH select_stats AS |
| 128 | + (SELECT upper(substr(query, 1, 6)) AS select_query |
| 129 | + FROM pg_stat_statements |
| 130 | + WHERE upper(substr(query, 1, 6)) IN ('SELECT', 'UPDATE', |
| 131 | + 'INSERT', 'DELETE', |
| 132 | + 'CREATE')) |
| 133 | + SELECT select_query, count(select_query) > 1 AS some_rows |
| 134 | + FROM select_stats |
| 135 | + GROUP BY select_query ORDER BY select_query;}); |
| 136 | +is( $result, qq(CREATE|t |
| 137 | +DELETE|t |
| 138 | +INSERT|t |
| 139 | +SELECT|t |
| 140 | +UPDATE|t), 'check contents of pg_stat_statements on regression database'); |
| 141 | + |
109 | 142 | $node_standby_1->stop;
|
110 | 143 | $node_primary->stop;
|
111 | 144 |
|
|
0 commit comments