Re: Add privileges test for pg_stat_statements to improve coverage - Mailing list pgsql-hackers

From kuroda.keisuke@nttcom.co.jp
Subject Re: Add privileges test for pg_stat_statements to improve coverage
Date
Msg-id b860741e6dc26ed7ee9526cef2dddb41@nttcom.co.jp
Whole thread Raw
In response to Re: Add privileges test for pg_stat_statements to improve coverage  (Fujii Masao <masao.fujii@oss.nttdata.com>)
Responses Re: Add privileges test for pg_stat_statements to improve coverage
List pgsql-hackers
Hi Fujii-san,
Thank you for your reply and comment!

attach v2 fixed patch.

> meson.build needs to be updated as well, like the Makefile.

Yes.
Update 'contrib/pg_stat_statements/meson.build'.

> For the privileges test, should we explicitly set 
> pg_stat_statements.track_utility
> at the start, as done in other pg_stat_statements tests, to make sure
> if utility command statistics are collected or not?

It certainly needs consideration.
I think the results of the utility commands are not needed in privileges 
test.
SET 'pg_stat_statements.track_utility = FALSE'.

> Can't we simplify "CASE ... END" to just "queryid <> 0"?

Yes.
If we add "queryid <> 0" to the WHERE clause, we can get the same 
result.
Change the SQL to the following:

+SELECT query, calls, rows FROM pg_stat_statements
+  WHERE queryid <> 0 ORDER BY query COLLATE "C";

> Should the test check not only queryid and query but also
> the statistics column like "calls"? Roles that aren't superusers
> or pg_read_all_stats should be able to see statistics but not
> query or queryid. So we should test that such roles can't see
> query or queryid but can see statistics. Thoughts?

I agree. We should test that such roles can't see
query or queryid but can see statistics.
Add the SQL to the test.
Test that calls and rows are displayed even if the queryid is NULL.

+-- regress_stats_user1 can read calls and rows
+-- executed by other users
+--
+
+SET ROLE regress_stats_user1;
+SELECT query, calls, rows FROM pg_stat_statements
+  WHERE queryid IS NULL ORDER BY query COLLATE "C";

Best Regards,
Keisuke Kuroda
NTT Comware

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Incremental backup from a streaming replication standby
Next
From: Pavel Stehule
Date:
Subject: Re: proposal: schema variables