diff --git a/src/hnswutils.c b/src/hnswutils.c index e082808..6d2cf4f 100644 --- a/src/hnswutils.c +++ b/src/hnswutils.c @@ -163,9 +163,9 @@ HnswGetType(Relation index) Oid typid = TupleDescAttr(index->rd_att, 0)->atttypid; HeapTuple tuple; Form_pg_type type; - int result; + HnswType result; - if (typid == BITOID || typid == VARBITOID) + if (typid == BITOID) return HNSW_TYPE_BIT; tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); @@ -180,7 +180,10 @@ HnswGetType(Relation index) else if (strcmp(NameStr(type->typname), "sparsevec") == 0) result = HNSW_TYPE_SPARSEVEC; else - elog(ERROR, "Unsupported type"); + { + ReleaseSysCache(tuple); + elog(ERROR, "type not supported for hnsw index"); + } ReleaseSysCache(tuple); diff --git a/test/expected/hnsw_bit_hamming.out b/test/expected/hnsw_bit_hamming.out index 0483281..bda949e 100644 --- a/test/expected/hnsw_bit_hamming.out +++ b/test/expected/hnsw_bit_hamming.out @@ -19,3 +19,9 @@ SELECT COUNT(*) FROM (SELECT * FROM t ORDER BY val <~> (SELECT NULL::bit)) t2; (1 row) DROP TABLE t; +-- TODO move +CREATE TABLE t (val varbit(3)); +CREATE INDEX ON t USING hnsw (val bit_hamming_ops); +ERROR: type not supported for hnsw index +CREATE INDEX ON t USING hnsw ((val::bit(3)) bit_hamming_ops); +DROP TABLE t; diff --git a/test/sql/hnsw_bit_hamming.sql b/test/sql/hnsw_bit_hamming.sql index fb21511..5319461 100644 --- a/test/sql/hnsw_bit_hamming.sql +++ b/test/sql/hnsw_bit_hamming.sql @@ -10,3 +10,9 @@ SELECT * FROM t ORDER BY val <~> B'111'; SELECT COUNT(*) FROM (SELECT * FROM t ORDER BY val <~> (SELECT NULL::bit)) t2; DROP TABLE t; + +-- TODO move +CREATE TABLE t (val varbit(3)); +CREATE INDEX ON t USING hnsw (val bit_hamming_ops); +CREATE INDEX ON t USING hnsw ((val::bit(3)) bit_hamming_ops); +DROP TABLE t;