Skip to content

Commit

Permalink
add partition tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mla committed May 24, 2021
1 parent 4c759f8 commit cdf8df2
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions t/pg_sample.t
Original file line number Diff line number Diff line change
Expand Up @@ -193,28 +193,25 @@ $dbh->do(qq{

### Partitioning

$dbh->do(qq{
CREATE TABLE partition_parent (
id int PRIMARY KEY
)
});

$dbh->do(qq{
CREATE TABLE partition_child1 (CHECK (id BETWEEN 0 AND 10))
INHERITS (partition_parent)
});

$dbh->do(qq{
CREATE TABLE partition_child2 (CHECK (id BETWEEN 10 AND 20))
INHERITS (partition_parent)
});

$dbh->do(qq{
INSERT INTO partition_parent VALUES (5)
});
$dbh->do(qq{
INSERT INTO partition_parent VALUES (15)
});
eval {
$dbh->do(qq{
CREATE TABLE partition_parent (
id int PRIMARY KEY
) PARTITION BY RANGE(id)
});
};
if ($@) {
diag "Skipping declarative partition tests";
} else {
$dbh->do(qq{
CREATE TABLE partition_child PARTITION OF partition_parent
FOR VALUES FROM (0) TO (100)
});

$dbh->do(qq{
INSERT INTO partition_parent VALUES (10)
});
}

### End Parititions

Expand All @@ -234,7 +231,7 @@ $template1_dbh->do("DROP DATABASE $opt{db_name}");
$template1_dbh->do("CREATE DATABASE $opt{db_name}");
$dbh = connect_db();

$cmd = "psql -q $opt{db_name} < sample.sql";
$cmd = "psql -q -X -v ON_ERROR_STOP=1 $opt{db_name} < sample.sql";
system($cmd) == 0 or die "pg_sample failed: $?";

foreach (1..10) {
Expand Down

0 comments on commit cdf8df2

Please sign in to comment.