1 # Test generic xlog record work for bloom index replication.
6 use Test::More tests => 31;
11 # Run few queries on both master and standby and check their results match.
16 # Wait for standby to catch up
17 my $applname = $node_standby->name;
19 "SELECT pg_current_xlog_location() <= write_location FROM pg_stat_replication WHERE application_name = '$applname';";
20 $node_master->poll_query_until('postgres', $caughtup_query)
21 or die "Timed out while waiting for standby 1 to catch up";
23 my $queries = qq(SET enable_seqscan=off;
24 SET enable_bitmapscan=on;
25 SET enable_indexscan=on;
26 SELECT * FROM tst WHERE i = 0;
27 SELECT * FROM tst WHERE i = 3;
28 SELECT * FROM tst WHERE t = 'b';
29 SELECT * FROM tst WHERE t = 'f';
30 SELECT * FROM tst WHERE i = 3 AND t = 'c';
31 SELECT * FROM tst WHERE i = 7 AND t = 'e';
34 # Run test queries and compare their result
35 my $master_result = $node_master->psql("postgres", $queries);
36 my $standby_result = $node_standby->psql("postgres", $queries);
38 is($master_result, $standby_result, "$test_name: query result matches");
41 # Initialize master node
42 $node_master = get_new_node('master');
43 $node_master->init(allows_streaming => 1);
45 my $backup_name = 'my_backup';
48 $node_master->backup($backup_name);
50 # Create streaming standby linking to master
51 $node_standby = get_new_node('standby');
52 $node_standby->init_from_backup($node_master, $backup_name,
56 # Create some bloom index on master
57 $node_master->psql("postgres", "CREATE EXTENSION bloom;");
58 $node_master->psql("postgres", "CREATE TABLE tst (i int4, t text);");
59 $node_master->psql("postgres", "INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,100000) i;");
60 $node_master->psql("postgres", "CREATE INDEX bloomidx ON tst USING bloom (i, t) WITH (col1 = 3);");
62 # Test that queries give same result
63 test_index_replay('initial');
65 # Run 10 cycles of table modification. Run test queries after each modification.
68 $node_master->psql("postgres", "DELETE FROM tst WHERE i = $i;");
69 test_index_replay("delete $i");
70 $node_master->psql("postgres", "VACUUM tst;");
71 test_index_replay("vacuum $i");
72 my ($start, $end) = (100001 + ($i - 1) * 10000, 100000 + $i * 10000);
73 $node_master->psql("postgres", "INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series($start,$end) i;");
74 test_index_replay("insert $i");