blob: b745dc69eaecf849d14dde825848eb645b89c640 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
CREATE EXTENSION pg_buffercache;
select count(*) = (select setting::bigint
from pg_settings
where name = 'shared_buffers')
from pg_buffercache;
?column?
----------
t
(1 row)
select buffers_used + buffers_unused > 0,
buffers_dirty <= buffers_used,
buffers_pinned <= buffers_used
from pg_buffercache_summary();
?column? | ?column? | ?column?
----------+----------+----------
t | t | t
(1 row)
SELECT count(*) > 0 FROM pg_buffercache_usage_counts() WHERE buffers >= 0;
?column?
----------
t
(1 row)
-- Check that the functions / views can't be accessed by default. To avoid
-- having to create a dedicated user, use the pg_database_owner pseudo-role.
SET ROLE pg_database_owner;
SELECT * FROM pg_buffercache;
ERROR: permission denied for view pg_buffercache
SELECT * FROM pg_buffercache_pages() AS p (wrong int);
ERROR: permission denied for function pg_buffercache_pages
SELECT * FROM pg_buffercache_summary();
ERROR: permission denied for function pg_buffercache_summary
SELECT * FROM pg_buffercache_usage_counts();
ERROR: permission denied for function pg_buffercache_usage_counts
RESET role;
-- Check that pg_monitor is allowed to query view / function
SET ROLE pg_monitor;
SELECT count(*) > 0 FROM pg_buffercache;
?column?
----------
t
(1 row)
SELECT buffers_used + buffers_unused > 0 FROM pg_buffercache_summary();
?column?
----------
t
(1 row)
SELECT count(*) > 0 FROM pg_buffercache_usage_counts();
?column?
----------
t
(1 row)
|