Re: Extension Enhancement: Buffer Invalidation in pg_buffercache

jian he <jian.universality@gmail.com>

From: jian he <jian.universality@gmail.com>
To: Thomas Munro <thomas.munro@gmail.com>, Palak Chaturvedi <chaturvedipalak1911@gmail.com>, Japin Li <japinli@hotmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-07-05T01:14:59Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add pg_buffercache_evict() function for testing.

On Sat, Jul 1, 2023 at 6:09 AM Thomas Munro <thomas.munro@gmail.com> wrote:
>
>
> It should be restricted by role, but I wonder which role it should be.
> Testing for superuser is now out of fashion.
>

as pg_buffercache/pg_buffercache--1.2--1.3.sql. You need pg_maintain
privilege to use pg_buffercache.
The following query works on a single user. Obviously you need a role who
can gain pg_monitor privilege.

begin;
create role test login nosuperuser;
grant select, insert on onek to test;
grant pg_monitor to test;
set role test;
select count(*) from onek;
insert into onek values(default);
(SELECT count(*) FROM pg_buffercache WHERE relfilenode =
pg_relation_filenode('onek'::regclass))
except
(
select count(pg_buffercache_invalidate(bufferid))
from    pg_buffercache   where relfilenode =
pg_relation_filenode('onek'::regclass)
);

rollback;