summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera2017-09-23 12:05:57 +0000
committerAlvaro Herrera2017-09-23 12:15:06 +0000
commit404ba54e8fd3036eee0f9241f68b17092ce734ee (patch)
tree8778066924ebc2f8dc10ef42758258ea635e1cb1
parentaa6b7b72d9bcf967cbccd378de4bc5cef33d02f9 (diff)
Test BRIN autosummarization
There was no coverage for this code. Reported-by: Nikolay Shaplov, Tom Lane Discussion: https://postgr.es/m/2700647.XEouBYNZic@x200m https://postgr.es/m/[email protected]
-rw-r--r--src/test/modules/brin/Makefile7
-rw-r--r--src/test/modules/brin/t/01_workitems.pl39
2 files changed, 44 insertions, 2 deletions
diff --git a/src/test/modules/brin/Makefile b/src/test/modules/brin/Makefile
index dda84c23c7..18c5cafd5e 100644
--- a/src/test/modules/brin/Makefile
+++ b/src/test/modules/brin/Makefile
@@ -16,7 +16,7 @@ include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif
-check: isolation-check
+check: isolation-check prove-check
isolation-check: | submake-isolation
$(MKDIR_P) isolation_output
@@ -24,7 +24,10 @@ isolation-check: | submake-isolation
--outputdir=./isolation_output \
$(ISOLATIONCHECKS)
-.PHONY: check isolation-check
+prove-check:
+ $(prove_check)
+
+.PHONY: check isolation-check prove-check
submake-isolation:
$(MAKE) -C $(top_builddir)/src/test/isolation all
diff --git a/src/test/modules/brin/t/01_workitems.pl b/src/test/modules/brin/t/01_workitems.pl
new file mode 100644
index 0000000000..11c9981d40
--- /dev/null
+++ b/src/test/modules/brin/t/01_workitems.pl
@@ -0,0 +1,39 @@
+# Verify that work items work correctly
+
+use strict;
+use warnings;
+
+use TestLib;
+use Test::More tests => 2;
+use PostgresNode;
+
+my $node = get_new_node('tango');
+$node->init;
+$node->append_conf('postgresql.conf', 'autovacuum_naptime=1s');
+$node->start;
+
+$node->safe_psql('postgres', 'create extension pageinspect');
+
+# Create a table with an autosummarizing BRIN index
+$node->safe_psql('postgres',
+ 'create table brin_wi (a int) with (fillfactor = 10);
+ create index brin_wi_idx on brin_wi using brin (a) with (pages_per_range=1, autosummarize=on);
+ '
+);
+my $count = $node->safe_psql('postgres',
+ "select count(*) from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)"
+);
+is($count, '1', "initial index state is correct");
+
+$node->safe_psql('postgres',
+ 'insert into brin_wi select * from generate_series(1, 100)');
+
+$node->poll_query_until('postgres',
+ "select count(*) > 1 from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)",
+ 't');
+
+$count = $node->safe_psql('postgres',
+ "select count(*) > 1 from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)"
+);
+is($count, 't', "index got summarized");
+$node->stop;