Re: pg_stat_statements: more test coverage

Поиск
Список
Период
Сортировка
От Julien Rouhaud
Тема Re: pg_stat_statements: more test coverage
Дата
Msg-id CAOBaU_YvCnJ0aEcSE-KTRp8YZjyf5OS_=L1RHkjo6RbF4JhqZQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: pg_stat_statements: more test coverage  (Peter Eisentraut <peter@eisentraut.org>)
Ответы Re: pg_stat_statements: more test coverage
Список 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)



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Nisha Moond
Дата:
Сообщение: Re: Intermittent failure with t/003_logical_slots.pl test on windows
Следующее
От: Richard Guo
Дата:
Сообщение: Revise the Asserts added to bimapset manipulation functions