aboutsummaryrefslogtreecommitdiff
path: root/contrib/pg_buffercache/expected/pg_buffercache.out
blob: 635f01e3b21bda1b8c66db69bd7d6f8b57cab207 (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
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)

-- 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
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)