From 3975e212cc4cf1eec416b5f21d221f087e652c95 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 11 Dec 2025 13:26:36 -0800 Subject: [PATCH 1/4] Improved includes for ivfkmeans [skip ci] --- src/ivfkmeans.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ivfkmeans.c b/src/ivfkmeans.c index 9c79e64..2939228 100644 --- a/src/ivfkmeans.c +++ b/src/ivfkmeans.c @@ -1,17 +1,15 @@ #include "postgres.h" #include +#include #include -#include "bitvec.h" -#include "halfutils.h" -#include "halfvec.h" +#include "access/genam.h" +#include "fmgr.h" #include "ivfflat.h" #include "miscadmin.h" -#include "utils/builtins.h" -#include "utils/datum.h" #include "utils/memutils.h" -#include "vector.h" +#include "utils/relcache.h" #if PG_VERSION_NUM >= 160000 #include "varatt.h" From c711da411c4584260ad0b05865a58096e096c022 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 11 Dec 2025 15:35:37 -0800 Subject: [PATCH 2/4] Improved includes for indexes --- src/hnsw.c | 6 ++++++ src/hnsw.h | 2 ++ src/hnswbuild.c | 8 ++++++-- src/hnswinsert.c | 5 +++-- src/hnswscan.c | 11 ++++++++++- src/hnswutils.c | 6 ++++-- src/hnswvacuum.c | 5 +++-- src/ivfbuild.c | 15 ++++++++++++--- src/ivfflat.c | 5 +++++ src/ivfinsert.c | 5 +++++ src/ivfscan.c | 11 +++++++++++ src/ivfutils.c | 10 ++++++++-- src/ivfvacuum.c | 3 +++ 13 files changed, 78 insertions(+), 14 deletions(-) diff --git a/src/hnsw.c b/src/hnsw.c index 1d56ef6..891d070 100644 --- a/src/hnsw.c +++ b/src/hnsw.c @@ -1,18 +1,24 @@ #include "postgres.h" #include +#include #include #include "access/amapi.h" +#include "access/genam.h" #include "access/reloptions.h" #include "commands/progress.h" #include "commands/vacuum.h" +#include "fmgr.h" #include "hnsw.h" #include "miscadmin.h" +#include "nodes/pg_list.h" #include "utils/float.h" #include "utils/guc.h" +#include "utils/relcache.h" #include "utils/selfuncs.h" #include "utils/spccache.h" +#include "vector.h" #if PG_VERSION_NUM < 150000 #define MarkGUCPrefixReserved(x) EmitWarningsOnPlaceholders(x) diff --git a/src/hnsw.h b/src/hnsw.h index 16c7f0d..841af0f 100644 --- a/src/hnsw.h +++ b/src/hnsw.h @@ -3,6 +3,8 @@ #include "postgres.h" +#include + #include "access/genam.h" #include "access/parallel.h" #include "lib/pairingheap.h" diff --git a/src/hnswbuild.c b/src/hnswbuild.c index 939f48f..a32bf8f 100644 --- a/src/hnswbuild.c +++ b/src/hnswbuild.c @@ -36,11 +36,12 @@ */ #include "postgres.h" -#include - +#include "access/genam.h" #include "access/parallel.h" +#include "access/relscan.h" #include "access/table.h" #include "access/tableam.h" +#include "access/tupdesc.h" #include "access/xact.h" #include "access/xloginsert.h" #include "catalog/index.h" @@ -48,11 +49,14 @@ #include "commands/progress.h" #include "hnsw.h" #include "miscadmin.h" +#include "nodes/execnodes.h" #include "optimizer/optimizer.h" #include "storage/bufmgr.h" #include "tcop/tcopprot.h" #include "utils/datum.h" #include "utils/memutils.h" +#include "utils/rel.h" +#include "utils/snapmgr.h" #if PG_VERSION_NUM >= 160000 #include "varatt.h" diff --git a/src/hnswinsert.c b/src/hnswinsert.c index ddcead0..8bd4d24 100644 --- a/src/hnswinsert.c +++ b/src/hnswinsert.c @@ -1,13 +1,14 @@ #include "postgres.h" -#include - +#include "access/genam.h" #include "access/generic_xlog.h" #include "hnsw.h" +#include "nodes/execnodes.h" #include "storage/bufmgr.h" #include "storage/lmgr.h" #include "utils/datum.h" #include "utils/memutils.h" +#include "utils/rel.h" #if PG_VERSION_NUM >= 160000 #include "varatt.h" diff --git a/src/hnswscan.c b/src/hnswscan.c index 5c526f4..61a8d63 100644 --- a/src/hnswscan.c +++ b/src/hnswscan.c @@ -1,12 +1,21 @@ #include "postgres.h" +#include "access/genam.h" #include "access/relscan.h" #include "hnsw.h" +#include "lib/pairingheap.h" +#include "miscadmin.h" +#include "nodes/pg_list.h" #include "pgstat.h" -#include "storage/bufmgr.h" #include "storage/lmgr.h" #include "utils/float.h" #include "utils/memutils.h" +#include "utils/relcache.h" +#include "utils/snapmgr.h" + +#if PG_VERSION_NUM >= 160000 +#include "varatt.h" +#endif /* * Algorithm 5 from paper diff --git a/src/hnswutils.c b/src/hnswutils.c index 13ecb9d..64f449e 100644 --- a/src/hnswutils.c +++ b/src/hnswutils.c @@ -2,18 +2,20 @@ #include +#include "access/genam.h" #include "access/generic_xlog.h" -#include "catalog/pg_type.h" -#include "catalog/pg_type_d.h" #include "common/hashfn.h" #include "fmgr.h" #include "hnsw.h" #include "lib/pairingheap.h" +#include "nodes/pg_list.h" +#include "port/atomics.h" #include "sparsevec.h" #include "storage/bufmgr.h" #include "utils/datum.h" #include "utils/memdebug.h" #include "utils/rel.h" +#include "vector.h" #if PG_VERSION_NUM >= 160000 #include "varatt.h" diff --git a/src/hnswvacuum.c b/src/hnswvacuum.c index 1469874..5de9b43 100644 --- a/src/hnswvacuum.c +++ b/src/hnswvacuum.c @@ -1,13 +1,14 @@ #include "postgres.h" -#include - +#include "access/genam.h" #include "access/generic_xlog.h" #include "commands/vacuum.h" #include "hnsw.h" +#include "nodes/pg_list.h" #include "storage/bufmgr.h" #include "storage/lmgr.h" #include "utils/memutils.h" +#include "utils/rel.h" #if PG_VERSION_NUM >= 160000 #include "varatt.h" diff --git a/src/ivfbuild.c b/src/ivfbuild.c index 7166b7d..d3f3c24 100644 --- a/src/ivfbuild.c +++ b/src/ivfbuild.c @@ -2,23 +2,32 @@ #include +#include "access/genam.h" +#include "access/generic_xlog.h" +#include "access/itup.h" +#include "access/relscan.h" #include "access/table.h" #include "access/tableam.h" +#include "access/tupdesc.h" #include "access/parallel.h" #include "access/xact.h" -#include "bitvec.h" +#include "access/xloginsert.h" #include "catalog/index.h" #include "catalog/pg_operator_d.h" #include "catalog/pg_type_d.h" #include "commands/progress.h" -#include "halfvec.h" +#include "fmgr.h" #include "ivfflat.h" #include "miscadmin.h" +#include "nodes/execnodes.h" #include "optimizer/optimizer.h" #include "storage/bufmgr.h" #include "tcop/tcopprot.h" #include "utils/memutils.h" -#include "vector.h" +#include "utils/rel.h" +#include "utils/sampling.h" +#include "utils/snapmgr.h" +#include "utils/tuplesort.h" #if PG_VERSION_NUM >= 160000 #include "varatt.h" diff --git a/src/ivfflat.c b/src/ivfflat.c index 31c2f7d..49c1478 100644 --- a/src/ivfflat.c +++ b/src/ivfflat.c @@ -3,14 +3,19 @@ #include #include "access/amapi.h" +#include "access/genam.h" #include "access/reloptions.h" #include "commands/progress.h" #include "commands/vacuum.h" +#include "fmgr.h" #include "ivfflat.h" +#include "nodes/pg_list.h" #include "utils/float.h" #include "utils/guc.h" +#include "utils/relcache.h" #include "utils/selfuncs.h" #include "utils/spccache.h" +#include "vector.h" #if PG_VERSION_NUM < 150000 #define MarkGUCPrefixReserved(x) EmitWarningsOnPlaceholders(x) diff --git a/src/ivfinsert.c b/src/ivfinsert.c index ebc61e4..f9f08d8 100644 --- a/src/ivfinsert.c +++ b/src/ivfinsert.c @@ -2,11 +2,16 @@ #include +#include "access/genam.h" #include "access/generic_xlog.h" +#include "access/itup.h" +#include "fmgr.h" #include "ivfflat.h" +#include "nodes/execnodes.h" #include "storage/bufmgr.h" #include "storage/lmgr.h" #include "utils/memutils.h" +#include "utils/rel.h" /* * Find the list that minimizes the distance function diff --git a/src/ivfscan.c b/src/ivfscan.c index b42ada1..dda1da2 100644 --- a/src/ivfscan.c +++ b/src/ivfscan.c @@ -2,15 +2,26 @@ #include +#include "access/genam.h" +#include "access/itup.h" #include "access/relscan.h" +#include "access/tupdesc.h" #include "catalog/pg_operator_d.h" #include "catalog/pg_type_d.h" +#include "fmgr.h" #include "lib/pairingheap.h" #include "ivfflat.h" #include "miscadmin.h" #include "pgstat.h" #include "storage/bufmgr.h" #include "utils/memutils.h" +#include "utils/rel.h" +#include "utils/snapmgr.h" +#include "utils/tuplesort.h" + +#if PG_VERSION_NUM >= 160000 +#include "varatt.h" +#endif #define GetScanList(ptr) pairingheap_container(IvfflatScanList, ph_node, ptr) #define GetScanListConst(ptr) pairingheap_const_container(IvfflatScanList, ph_node, ptr) diff --git a/src/ivfutils.c b/src/ivfutils.c index 9596391..f1586dd 100644 --- a/src/ivfutils.c +++ b/src/ivfutils.c @@ -1,13 +1,19 @@ #include "postgres.h" +#include "access/genam.h" #include "access/generic_xlog.h" -#include "bitvec.h" -#include "catalog/pg_type.h" #include "fmgr.h" #include "halfutils.h" #include "halfvec.h" #include "ivfflat.h" #include "storage/bufmgr.h" +#include "utils/relcache.h" +#include "utils/varbit.h" +#include "vector.h" + +#if PG_VERSION_NUM >= 160000 +#include "varatt.h" +#endif /* * Allocate a vector array diff --git a/src/ivfvacuum.c b/src/ivfvacuum.c index 750cdd6..5408609 100644 --- a/src/ivfvacuum.c +++ b/src/ivfvacuum.c @@ -1,9 +1,12 @@ #include "postgres.h" +#include "access/genam.h" #include "access/generic_xlog.h" +#include "access/itup.h" #include "commands/vacuum.h" #include "ivfflat.h" #include "storage/bufmgr.h" +#include "utils/relcache.h" #if PG_VERSION_NUM >= 180000 #define vacuum_delay_point() vacuum_delay_point(false) From 3d6dd20469ef0e068e9678c89d16f7a6cd17b64d Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 11 Dec 2025 16:28:45 -0800 Subject: [PATCH 3/4] Removed unneeded check --- src/hnswutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hnswutils.c b/src/hnswutils.c index 64f449e..f4e4d82 100644 --- a/src/hnswutils.c +++ b/src/hnswutils.c @@ -928,7 +928,7 @@ HnswSearchLayer(char *base, HnswQuery * q, List *ep, int ef, int lc, Relation in continue; } - if (eElement == NULL || !(eDistance < f->distance || alwaysAdd)) + if (!(eDistance < f->distance || alwaysAdd)) { if (discarded != NULL) { From d557f1c9b1416fe004294f5fcdda64244a832e60 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 11 Dec 2025 23:22:56 -0800 Subject: [PATCH 4/4] Added link to pgvector-tcl [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a108520..8e44c1a 100644 --- a/README.md +++ b/README.md @@ -803,6 +803,7 @@ Raku | [pgvector-raku](https://github.com/pgvector/pgvector-raku) Ruby | [pgvector-ruby](https://github.com/pgvector/pgvector-ruby), [Neighbor](https://github.com/ankane/neighbor) Rust | [pgvector-rust](https://github.com/pgvector/pgvector-rust) Swift | [pgvector-swift](https://github.com/pgvector/pgvector-swift) +Tcl | [pgvector-tcl](https://github.com/pgvector/pgvector-tcl) Zig | [pgvector-zig](https://github.com/pgvector/pgvector-zig) ## Frequently Asked Questions