-- Dead tuples on all-frozen pages.
truncate vm;
insert into vm select generate_series(1, 10000);
vacuum freeze vm;
select * from pg_visibility_map_summary('vm');
delete from vm where col % 1000 = 0;
select * from pg_visibility_map_summary('vm');
select count(*) from set_vm_status('vm', true, true);
select * from pg_visibility_map_summary('vm');
select * from pg_check_visible('vm'); -- expects 10 rows
select * from pg_check_frozen('vm');  -- expects 10 rows

-- Non-frozen tuples on all-frozen pages.
truncate vm;
insert into vm select generate_series(1, 10000);
select * from pg_visibility_map_summary('vm');
select count(*) from set_vm_status('vm', true, true);
select * from pg_visibility_map_summary('vm');
select count(*) from pg_check_visible('vm'); -- expects 0 row
select count(*) from pg_check_frozen('vm'); -- expects 10000 rows

-- Not-all-visible tuples on all-visible pages.
truncate vm;
insert into vm select generate_series(1, 10000);
VACUUM vm;
select * from pg_visibility_map_summary('vm');
delete from vm where col % 1000 = 0;
select * from pg_visibility_map_summary('vm');
select count(*) from set_vm_status('vm', true, false);
select * from pg_visibility_map_summary('vm');
select * from pg_check_visible('vm'); -- expects 10 row
select count(*) from pg_check_frozen('vm'); -- expects 0 rows

-- Frozen tuples on all-visible pages.
truncate vm;
insert into vm select generate_series(1, 10000);
VACUUM FREEZE vm;
select * from pg_visibility_map_summary('vm');
select count(*) from set_vm_status('vm', true, false);
select * from pg_visibility_map_summary('vm');
select count(*) from pg_check_visible('vm'); -- expects 0 row
select count(*) from pg_check_frozen('vm'); -- expects 0 row
