|
| 1 | +# Verify that work items work correctly |
| 2 | + |
| 3 | +use strict; |
| 4 | +use warnings; |
| 5 | + |
| 6 | +use TestLib; |
| 7 | +use Test::More tests => 2; |
| 8 | +use PostgresNode; |
| 9 | + |
| 10 | +my $node = get_new_node('tango'); |
| 11 | +$node->init; |
| 12 | +$node->append_conf('postgresql.conf', 'autovacuum_naptime=1s'); |
| 13 | +$node->start; |
| 14 | + |
| 15 | +$node->safe_psql('postgres', 'create extension pageinspect'); |
| 16 | + |
| 17 | +# Create a table with an autosummarizing BRIN index |
| 18 | +$node->safe_psql('postgres', |
| 19 | + 'create table brin_wi (a int) with (fillfactor = 10); |
| 20 | + create index brin_wi_idx on brin_wi using brin (a) with (pages_per_range=1, autosummarize=on); |
| 21 | + ' |
| 22 | +); |
| 23 | +my $count = $node->safe_psql('postgres', |
| 24 | + "select count(*) from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)" |
| 25 | +); |
| 26 | +is($count, '1', "initial index state is correct"); |
| 27 | + |
| 28 | +$node->safe_psql('postgres', |
| 29 | + 'insert into brin_wi select * from generate_series(1, 100)'); |
| 30 | + |
| 31 | +$node->poll_query_until('postgres', |
| 32 | + "select count(*) > 1 from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)", |
| 33 | + 't'); |
| 34 | + |
| 35 | +$count = $node->safe_psql('postgres', |
| 36 | + "select count(*) > 1 from brin_page_items(get_raw_page('brin_wi_idx', 2), 'brin_wi_idx'::regclass)" |
| 37 | +); |
| 38 | +is($count, 't', "index got summarized"); |
| 39 | +$node->stop; |
0 commit comments