1# Test for vacuum's handling of reltuples when pages are skipped due
2# to page pins. We absolutely need to avoid setting reltuples=0 in
3# such cases, since that interferes badly with planning.
4#
5# Expected result in second permutation is 20 tuples rather than 21 as
6# for the others, because vacuum should leave the previous result
7# (from before the insert) in place.
8
9setup {
10    create table smalltbl
11        as select i as id from generate_series(1,20) i;
12    alter table smalltbl set (autovacuum_enabled = off);
13}
14setup {
15    vacuum analyze smalltbl;
16}
17
18teardown {
19    drop table smalltbl;
20}
21
22session worker
23step open {
24    begin;
25    declare c1 cursor for select 1 as dummy from smalltbl;
26}
27step fetch1 {
28    fetch next from c1;
29}
30step close {
31    commit;
32}
33step stats {
34    select relpages, reltuples from pg_class
35     where oid='smalltbl'::regclass;
36}
37
38session vacuumer
39step vac {
40    vacuum smalltbl;
41}
42step modify {
43    insert into smalltbl select max(id)+1 from smalltbl;
44}
45
46permutation modify vac stats
47permutation modify open fetch1 vac close stats
48permutation modify vac stats
49