aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/isolation/expected/vacuum-reltuples.out62
-rw-r--r--src/test/isolation/isolation_schedule1
-rw-r--r--src/test/isolation/specs/vacuum-reltuples.spec45
3 files changed, 108 insertions, 0 deletions
diff --git a/src/test/isolation/expected/vacuum-reltuples.out b/src/test/isolation/expected/vacuum-reltuples.out
new file mode 100644
index 00000000000..ee3adf58050
--- /dev/null
+++ b/src/test/isolation/expected/vacuum-reltuples.out
@@ -0,0 +1,62 @@
+Parsed test spec with 2 sessions
+
+starting permutation: modify vac stats
+step modify:
+ insert into smalltbl select max(id)+1 from smalltbl;
+ delete from smalltbl where id in (select min(id) from smalltbl);
+
+step vac:
+ vacuum smalltbl;
+
+step stats:
+ select relpages, reltuples from pg_class
+ where oid='smalltbl'::regclass;
+
+relpages reltuples
+
+1 20
+
+starting permutation: modify open fetch1 vac close stats
+step modify:
+ insert into smalltbl select max(id)+1 from smalltbl;
+ delete from smalltbl where id in (select min(id) from smalltbl);
+
+step open:
+ begin;
+ declare c1 cursor for select * from smalltbl;
+
+step fetch1:
+ fetch next from c1;
+
+id
+
+2
+step vac:
+ vacuum smalltbl;
+
+step close:
+ commit;
+
+step stats:
+ select relpages, reltuples from pg_class
+ where oid='smalltbl'::regclass;
+
+relpages reltuples
+
+1 20
+
+starting permutation: modify vac stats
+step modify:
+ insert into smalltbl select max(id)+1 from smalltbl;
+ delete from smalltbl where id in (select min(id) from smalltbl);
+
+step vac:
+ vacuum smalltbl;
+
+step stats:
+ select relpages, reltuples from pg_class
+ where oid='smalltbl'::regclass;
+
+relpages reltuples
+
+1 20
diff --git a/src/test/isolation/isolation_schedule b/src/test/isolation/isolation_schedule
index 2606a276247..8e404b7a355 100644
--- a/src/test/isolation/isolation_schedule
+++ b/src/test/isolation/isolation_schedule
@@ -56,4 +56,5 @@ test: alter-table-2
test: alter-table-3
test: create-trigger
test: async-notify
+test: vacuum-reltuples
test: timeouts
diff --git a/src/test/isolation/specs/vacuum-reltuples.spec b/src/test/isolation/specs/vacuum-reltuples.spec
new file mode 100644
index 00000000000..52bc405547a
--- /dev/null
+++ b/src/test/isolation/specs/vacuum-reltuples.spec
@@ -0,0 +1,45 @@
+# Test for vacuum's handling of reltuples when pages are skipped due
+# to page pins. We absolutely need to avoid setting reltuples=0 in
+# such cases, since that interferes badly with planning.
+
+setup {
+ create table smalltbl
+ as select i as id from generate_series(1,20) i;
+ alter table smalltbl set (autovacuum_enabled = off);
+}
+setup {
+ vacuum analyze smalltbl;
+}
+
+teardown {
+ drop table smalltbl;
+}
+
+session "worker"
+step "open" {
+ begin;
+ declare c1 cursor for select * from smalltbl;
+}
+step "fetch1" {
+ fetch next from c1;
+}
+step "close" {
+ commit;
+}
+step "stats" {
+ select relpages, reltuples from pg_class
+ where oid='smalltbl'::regclass;
+}
+
+session "vacuumer"
+step "vac" {
+ vacuum smalltbl;
+}
+step "modify" {
+ insert into smalltbl select max(id)+1 from smalltbl;
+ delete from smalltbl where id in (select min(id) from smalltbl);
+}
+
+permutation "modify" "vac" "stats"
+permutation "modify" "open" "fetch1" "vac" "close" "stats"
+permutation "modify" "vac" "stats"