diff --git a/src/test/recovery/Makefile b/src/test/recovery/Makefile index 570bf42b58e..c60314d1955 100644 --- a/src/test/recovery/Makefile +++ b/src/test/recovery/Makefile @@ -9,7 +9,7 @@ # #------------------------------------------------------------------------- -EXTRA_INSTALL=contrib/test_decoding contrib/pg_prewarm +EXTRA_INSTALL=contrib/pg_prewarm contrib/pg_stat_statements contrib/test_decoding subdir = src/test/recovery top_builddir = ../../.. diff --git a/src/test/recovery/README b/src/test/recovery/README index 3ae3758d3b8..896df0ad05b 100644 --- a/src/test/recovery/README +++ b/src/test/recovery/README @@ -10,7 +10,8 @@ Running the tests NOTE: You must have given the --enable-tap-tests argument to configure. Also, to use "make installcheck", you must have built and installed -contrib/pg_prewarm and contrib/test_decoding in addition to the core code. +contrib/pg_prewarm, contrib/pg_stat_statements and contrib/test_decoding +in addition to the core code. Run make check diff --git a/src/test/recovery/t/027_stream_regress.pl b/src/test/recovery/t/027_stream_regress.pl index 13482adbafe..255c45a4ff1 100644 --- a/src/test/recovery/t/027_stream_regress.pl +++ b/src/test/recovery/t/027_stream_regress.pl @@ -14,6 +14,17 @@ $node_primary->init(allows_streaming => 1); $node_primary->adjust_conf('postgresql.conf', 'max_connections', '25'); $node_primary->append_conf('postgresql.conf', 'max_prepared_transactions = 10'); + +# Enable pg_stat_statements to force tests to do query jumbling. +# pg_stat_statements.max should be large enough to hold all the entries +# of the regression database. +$node_primary->append_conf( + 'postgresql.conf', + qq{shared_preload_libraries = 'pg_stat_statements' +pg_stat_statements.max = 50000 +compute_query_id = 'regress' +}); + # We'll stick with Cluster->new's small default shared_buffers, but since that # makes synchronized seqscans more probable, it risks changing the results of # some test queries. Disable synchronized seqscans to prevent that. @@ -106,6 +117,28 @@ command_ok( [ 'diff', $outputdir . '/primary.dump', $outputdir . '/standby.dump' ], 'compare primary and standby dumps'); +# Check some data from pg_stat_statements. +$node_primary->safe_psql('postgres', 'CREATE EXTENSION pg_stat_statements'); +# This gathers data based on the first characters for some common query types, +# checking that reports are generated for SELECT, DMLs, and DDL queries with +# CREATE. +my $result = $node_primary->safe_psql( + 'postgres', + qq{WITH select_stats AS + (SELECT upper(substr(query, 1, 6)) AS select_query + FROM pg_stat_statements + WHERE upper(substr(query, 1, 6)) IN ('SELECT', 'UPDATE', + 'INSERT', 'DELETE', + 'CREATE')) + SELECT select_query, count(select_query) > 1 AS some_rows + FROM select_stats + GROUP BY select_query ORDER BY select_query;}); +is( $result, qq(CREATE|t +DELETE|t +INSERT|t +SELECT|t +UPDATE|t), 'check contents of pg_stat_statements on regression database'); + $node_standby_1->stop; $node_primary->stop;