diff --git a/src/hnswscan.c b/src/hnswscan.c index b65f4c4..b3eded1 100644 --- a/src/hnswscan.c +++ b/src/hnswscan.c @@ -9,7 +9,7 @@ /* * Algorithm 5 from paper */ -static void +static List * GetScanItems(IndexScanDesc scan, Datum q) { HnswScanOpaque so = (HnswScanOpaque) scan->opaque; @@ -21,7 +21,7 @@ GetScanItems(IndexScanDesc scan, Datum q) HnswElement entryPoint = HnswGetEntryPoint(index); if (entryPoint == NULL) - return; + return NIL; ep = lappend(ep, HnswEntryCandidate(entryPoint, q, index, procinfo, collation, false)); @@ -31,7 +31,7 @@ GetScanItems(IndexScanDesc scan, Datum q) ep = w; } - so->w = HnswSearchLayer(q, ep, hnsw_ef_search, 0, index, procinfo, collation, false, NULL); + return HnswSearchLayer(q, ep, hnsw_ef_search, 0, index, procinfo, collation, false, NULL); } /* @@ -144,7 +144,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir) HnswNormValue(so->normprocinfo, so->collation, &value, NULL); } - GetScanItems(scan, value); + so->w = GetScanItems(scan, value); so->first = false; } diff --git a/test/expected/hnsw_l2.out b/test/expected/hnsw_l2.out index e8a16c8..4209661 100644 --- a/test/expected/hnsw_l2.out +++ b/test/expected/hnsw_l2.out @@ -27,4 +27,10 @@ SELECT COUNT(*) FROM t; 5 (1 row) +TRUNCATE t; +SELECT * FROM t ORDER BY val <-> '[3,3,3]'; + val +----- +(0 rows) + DROP TABLE t; diff --git a/test/sql/hnsw_l2.sql b/test/sql/hnsw_l2.sql index 8664cb3..70bb50a 100644 --- a/test/sql/hnsw_l2.sql +++ b/test/sql/hnsw_l2.sql @@ -10,4 +10,7 @@ SELECT * FROM t ORDER BY val <-> '[3,3,3]'; SELECT * FROM t ORDER BY val <-> (SELECT NULL::vector); SELECT COUNT(*) FROM t; +TRUNCATE t; +SELECT * FROM t ORDER BY val <-> '[3,3,3]'; + DROP TABLE t;