Re: pg_stat_statements: more test coverage

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_stat_statements: more test coverage
Date: 2023-12-27 12:53:06
Message-ID: 3ec31fed-044f-4dcf-98be-3b1692a00f60@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 27.12.23 09:08, Julien Rouhaud wrote:
> Hi,
>
> On Tue, Dec 26, 2023 at 10:03 PM Peter Eisentraut <peter(at)eisentraut(dot)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:

Ok, here is an updated patch set that does it that way.

I have committed the patches 0002 and 0003 from the previous patch set
already.

I have also enhanced the TAP test a bit to check the actual content of
the output across restarts.

I'm not too hung up on the 0001 patch if others don't like that approach.

Attachment Content-Type Size
v2-0001-pg_stat_statements-Exclude-from-lcov-functions-th.patch text/plain 2.2 KB
v2-0002-pg_stat_statements-Add-coverage-for-entry_dealloc.patch text/plain 5.1 KB
v2-0003-pg_stat_statements-Add-TAP-test-for-testing-resta.patch text/plain 3.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robins Tharakan 2023-12-27 13:28:01 Re: pg_upgrade failing for 200+ million Large Objects
Previous Message Peter Eisentraut 2023-12-27 12:42:17 Re: Add support for __attribute__((returns_nonnull))