Re: pg_stat_statements: more test coverage
Julien Rouhaud <rjuju123@gmail.com>
From: Julien Rouhaud <rjuju123@gmail.com>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: Michael Paquier <michael@paquier.xyz>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2023-12-27T08:08:37Z
Lists: pgsql-hackers
Hi,
On Tue, Dec 26, 2023 at 10:03 PM Peter Eisentraut <peter@eisentraut.org> wrote:
>
> On 24.12.23 03:03, Michael Paquier wrote:
> > - Use a DO block of a PL function, say with something like that to
> > ensure an amount of N queries? Say with something like that after
> > tweaking pg_stat_statements.track:
> > CREATE OR REPLACE FUNCTION create_tables(num_tables int)
> > RETURNS VOID AS
> > $func$
> > BEGIN
> > FOR i IN 1..num_tables LOOP
> > EXECUTE format('
> > CREATE TABLE IF NOT EXISTS %I (id int)', 't_' || i);
> > END LOOP;
> > END
> > $func$ LANGUAGE plpgsql;
>
> I tried it like this first, but this doesn't register as separately
> executed commands for pg_stat_statements.
I was a bit surprised by that so I checked locally. It does work as
expected provided that you set pg_stat_statements.track to all:
=# select create_tables(5);
=# select queryid, query from pg_stat_statements where query like 'CREATE%';
queryid | query
----------------------+-----------------------------------------
-4985234599080337259 | CREATE TABLE IF NOT EXISTS t_5 (id int)
-790506371630237058 | CREATE TABLE IF NOT EXISTS t_2 (id int)
-1104545884488896333 | CREATE TABLE IF NOT EXISTS t_3 (id int)
-2961032912789520428 | CREATE TABLE IF NOT EXISTS t_4 (id int)
7273321309563119428 | CREATE TABLE IF NOT EXISTS t_1 (id int)
Commits
-
Revert "pg_stat_statements: Add coverage for entry_dealloc()"
- 1141e29b61e9 17.0 landed
-
pg_stat_statements: Add TAP test for testing restarts
- 4710b67d4d35 17.0 landed
-
pg_stat_statements: Add coverage for entry_dealloc()
- 742f6b3e6df9 17.0 landed
-
pg_stat_statements: Add test coverage for pg_stat_statements_1_8()
- 3727b8d0e3f1 17.0 landed
-
pg_stat_statements: Add test coverage for pg_stat_statements_reset_1_7
- 3e527aeeedb0 17.0 landed