Added test for bit with duplicate centers

This commit is contained in:
Andrew Kane
2024-04-25 10:29:28 -07:00
parent c39cb25c32
commit c67dc6f9b0

View File

@@ -0,0 +1,40 @@
use strict;
use warnings;
use PostgresNode;
use TestLib;
use Test::More;
# Initialize node
my $node = get_new_node('node');
$node->init;
$node->start;
# Create table
$node->safe_psql("postgres", "CREATE EXTENSION vector;");
$node->safe_psql("postgres", "CREATE TABLE tst (i int4, v bit(3));");
$node->safe_psql("postgres",
"INSERT INTO tst SELECT i, floor(random() * 8)::bigint::bit(3) FROM generate_series(1, 100) i;"
);
my $counts = $node->safe_psql("postgres", "SELECT v, COUNT(*) FROM tst GROUP BY 1 ORDER BY 1");
my @rows = split("\n", $counts);
is(scalar(@rows), 8);
# Create index with more lists than distinct values
$node->safe_psql("postgres", "CREATE INDEX ON tst USING ivfflat (v bit_hamming_ops) WITH (lists = 100);");
for my $row (@rows)
{
my ($v, $count) = split(/\|/, $row);
my $actual = $node->safe_psql("postgres", qq(
SET enable_seqscan = off;
SELECT i FROM tst ORDER BY v <~> '$v' LIMIT 100;
));
my @actual_ids = split("\n", $actual);
# Test results are always found
is(scalar(@actual_ids), $count);
}
done_testing();