-- Setup
create extension if not exists pg_buffercache;
create table vactest (id int) with (autovacuum_enabled=off);
insert into vactest select g from generate_series(1, 10000) g;

vacuum freeze vactest;

checkpoint;

-- All pages should be all clean after the checkpoint.
select count(*), isdirty from pg_buffercache
where relfilenode = (select relfilenode from pg_class where relname='vactest')
group by isdirty;

-- Run vacuum again. Everything's already frozen, so it will just scan through
-- table but not change anything.
vacuum (disable_page_skipping) vactest;

-- All the pages should still be all clean. But on v16 and above, a
-- lot of pages are are dirtied!
select count(*), isdirty from pg_buffercache
where relfilenode = (select relfilenode from pg_class where relname='vactest')
group by isdirty;

