mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-07-17 23:51:10 +02:00
There are a lot of Perl scripts in the tree, mostly code generation and TAP tests. Occasionally, these scripts produce warnings. These are probably always mistakes on the developer side (true positives). Typical examples are warnings from genbki.pl or related when you make a mess in the catalog files during development, or warnings from tests when they massage a config file that looks different on different hosts, or mistakes during merges (e.g., duplicate subroutine definitions), or just mistakes that weren't noticed because there is a lot of output in a verbose build. This changes all warnings into fatal errors, by replacing use warnings; by use warnings FATAL => 'all'; in all Perl files. Discussion: https://www.postgresql.org/message-id/flat/06f899fd-1826-05ab-42d6-adeb1fd5e200%40eisentraut.org
85 lines
2.6 KiB
Perl
85 lines
2.6 KiB
Perl
|
|
# Copyright (c) 2021-2023, PostgreSQL Global Development Group
|
|
|
|
# Test generic xlog record work for bloom index replication.
|
|
use strict;
|
|
use warnings FATAL => 'all';
|
|
use PostgreSQL::Test::Cluster;
|
|
use PostgreSQL::Test::Utils;
|
|
use Test::More;
|
|
|
|
my $node_primary;
|
|
my $node_standby;
|
|
|
|
# Run few queries on both primary and standby and check their results match.
|
|
sub test_index_replay
|
|
{
|
|
my ($test_name) = @_;
|
|
|
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
|
|
|
# Wait for standby to catch up
|
|
$node_primary->wait_for_catchup($node_standby);
|
|
|
|
my $queries = qq(SET enable_seqscan=off;
|
|
SET enable_bitmapscan=on;
|
|
SET enable_indexscan=on;
|
|
SELECT * FROM tst WHERE i = 0;
|
|
SELECT * FROM tst WHERE i = 3;
|
|
SELECT * FROM tst WHERE t = 'b';
|
|
SELECT * FROM tst WHERE t = 'f';
|
|
SELECT * FROM tst WHERE i = 3 AND t = 'c';
|
|
SELECT * FROM tst WHERE i = 7 AND t = 'e';
|
|
);
|
|
|
|
# Run test queries and compare their result
|
|
my $primary_result = $node_primary->safe_psql("postgres", $queries);
|
|
my $standby_result = $node_standby->safe_psql("postgres", $queries);
|
|
|
|
is($primary_result, $standby_result, "$test_name: query result matches");
|
|
return;
|
|
}
|
|
|
|
# Initialize primary node
|
|
$node_primary = PostgreSQL::Test::Cluster->new('primary');
|
|
$node_primary->init(allows_streaming => 1);
|
|
$node_primary->start;
|
|
my $backup_name = 'my_backup';
|
|
|
|
# Take backup
|
|
$node_primary->backup($backup_name);
|
|
|
|
# Create streaming standby linking to primary
|
|
$node_standby = PostgreSQL::Test::Cluster->new('standby');
|
|
$node_standby->init_from_backup($node_primary, $backup_name,
|
|
has_streaming => 1);
|
|
$node_standby->start;
|
|
|
|
# Create some bloom index on primary
|
|
$node_primary->safe_psql("postgres", "CREATE EXTENSION bloom;");
|
|
$node_primary->safe_psql("postgres", "CREATE TABLE tst (i int4, t text);");
|
|
$node_primary->safe_psql("postgres",
|
|
"INSERT INTO tst SELECT i%10, substr(encode(sha256(i::text::bytea), 'hex'), 1, 1) FROM generate_series(1,10000) i;"
|
|
);
|
|
$node_primary->safe_psql("postgres",
|
|
"CREATE INDEX bloomidx ON tst USING bloom (i, t) WITH (col1 = 3);");
|
|
|
|
# Test that queries give same result
|
|
test_index_replay('initial');
|
|
|
|
# Run 10 cycles of table modification. Run test queries after each modification.
|
|
for my $i (1 .. 10)
|
|
{
|
|
$node_primary->safe_psql("postgres", "DELETE FROM tst WHERE i = $i;");
|
|
test_index_replay("delete $i");
|
|
$node_primary->safe_psql("postgres", "VACUUM tst;");
|
|
test_index_replay("vacuum $i");
|
|
my ($start, $end) = (100001 + ($i - 1) * 10000, 100000 + $i * 10000);
|
|
$node_primary->safe_psql("postgres",
|
|
"INSERT INTO tst SELECT i%10, substr(encode(sha256(i::text::bytea), 'hex'), 1, 1) FROM generate_series($start,$end) i;"
|
|
);
|
|
test_index_replay("insert $i");
|
|
}
|
|
|
|
done_testing();
|