mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-05 04:22:56 +00:00
## Problem Both these versions are binary compatible, but the way pgvector structures the SQL files forbids installing 0.7.4 if you have a 0.8.0 distribution. Yet, some users may need a previous version for backward compatibility, e.g., restoring the dump. See this thread for discussion https://neondb.slack.com/archives/C04DGM6SMTM/p1735911490242919?thread_ts=1731343604.259169&cid=C04DGM6SMTM ## Summary of changes Put `vector--0.7.4.sql` file into compute image to allow installing this version as well. Tested on staging and it seems to be working as expected: ```sql select * from pg_available_extensions where name = 'vector'; name | default_version | installed_version | comment --------+-----------------+-------------------+------------------------------------------------------ vector | 0.8.0 | (null) | vector data type and ivfflat and hnsw access methods create extension vector version '0.7.4'; select * from pg_available_extensions where name = 'vector'; name | default_version | installed_version | comment --------+-----------------+-------------------+------------------------------------------------------ vector | 0.8.0 | 0.7.4 | vector data type and ivfflat and hnsw access methods alter extension vector update; select * from pg_available_extensions where name = 'vector'; name | default_version | installed_version | comment --------+-----------------+-------------------+------------------------------------------------------ vector | 0.8.0 | 0.8.0 | vector data type and ivfflat and hnsw access methods drop extension vector; create extension vector; select * from pg_available_extensions where name = 'vector'; name | default_version | installed_version | comment --------+-----------------+-------------------+------------------------------------------------------ vector | 0.8.0 | 0.8.0 | vector data type and ivfflat and hnsw access methods ``` If we find out it's a good approach, we can adopt the same for other extensions with a stable ABI -- support both `current` and `current - 1` releases.
79 lines
2.6 KiB
Diff
79 lines
2.6 KiB
Diff
diff --git a/Makefile b/Makefile
|
|
index 7a4b88c..56678af 100644
|
|
--- a/Makefile
|
|
+++ b/Makefile
|
|
@@ -3,7 +3,10 @@ EXTVERSION = 0.8.0
|
|
|
|
MODULE_big = vector
|
|
DATA = $(wildcard sql/*--*--*.sql)
|
|
-DATA_built = sql/$(EXTENSION)--$(EXTVERSION).sql
|
|
+# This change is needed to install different per-version SQL files
|
|
+# like pgvector--0.8.0.sql and pgvector--0.7.4.sql
|
|
+# The corresponding file is downloaded during the Docker image build process
|
|
+DATA_built = sql/$(EXTENSION)--$(EXTVERSION).sql sql/vector--0.7.4.sql
|
|
OBJS = src/bitutils.o src/bitvec.o src/halfutils.o src/halfvec.o src/hnsw.o src/hnswbuild.o src/hnswinsert.o src/hnswscan.o src/hnswutils.o src/hnswvacuum.o src/ivfbuild.o src/ivfflat.o src/ivfinsert.o src/ivfkmeans.o src/ivfscan.o src/ivfutils.o src/ivfvacuum.o src/sparsevec.o src/vector.o
|
|
HEADERS = src/halfvec.h src/sparsevec.h src/vector.h
|
|
|
|
diff --git a/src/hnswbuild.c b/src/hnswbuild.c
|
|
index b667478..fc1897c 100644
|
|
--- a/src/hnswbuild.c
|
|
+++ b/src/hnswbuild.c
|
|
@@ -843,9 +843,17 @@ HnswParallelBuildMain(dsm_segment *seg, shm_toc *toc)
|
|
|
|
hnswarea = shm_toc_lookup(toc, PARALLEL_KEY_HNSW_AREA, false);
|
|
|
|
+#ifdef NEON_SMGR
|
|
+ smgr_start_unlogged_build(RelationGetSmgr(indexRel));
|
|
+#endif
|
|
+
|
|
/* Perform inserts */
|
|
HnswParallelScanAndInsert(heapRel, indexRel, hnswshared, hnswarea, false);
|
|
|
|
+#ifdef NEON_SMGR
|
|
+ smgr_finish_unlogged_build_phase_1(RelationGetSmgr(indexRel));
|
|
+#endif
|
|
+
|
|
/* Close relations within worker */
|
|
index_close(indexRel, indexLockmode);
|
|
table_close(heapRel, heapLockmode);
|
|
@@ -1100,12 +1108,38 @@ BuildIndex(Relation heap, Relation index, IndexInfo *indexInfo,
|
|
SeedRandom(42);
|
|
#endif
|
|
|
|
+#ifdef NEON_SMGR
|
|
+ smgr_start_unlogged_build(RelationGetSmgr(index));
|
|
+#endif
|
|
+
|
|
InitBuildState(buildstate, heap, index, indexInfo, forkNum);
|
|
|
|
BuildGraph(buildstate, forkNum);
|
|
|
|
- if (RelationNeedsWAL(index) || forkNum == INIT_FORKNUM)
|
|
+#ifdef NEON_SMGR
|
|
+ smgr_finish_unlogged_build_phase_1(RelationGetSmgr(index));
|
|
+#endif
|
|
+
|
|
+ if (RelationNeedsWAL(index) || forkNum == INIT_FORKNUM) {
|
|
log_newpage_range(index, forkNum, 0, RelationGetNumberOfBlocksInFork(index, forkNum), true);
|
|
+#ifdef NEON_SMGR
|
|
+ {
|
|
+#if PG_VERSION_NUM >= 160000
|
|
+ RelFileLocator rlocator = RelationGetSmgr(index)->smgr_rlocator.locator;
|
|
+#else
|
|
+ RelFileNode rlocator = RelationGetSmgr(index)->smgr_rnode.node;
|
|
+#endif
|
|
+
|
|
+ SetLastWrittenLSNForBlockRange(XactLastRecEnd, rlocator,
|
|
+ MAIN_FORKNUM, 0, RelationGetNumberOfBlocks(index));
|
|
+ SetLastWrittenLSNForRelation(XactLastRecEnd, rlocator, MAIN_FORKNUM);
|
|
+ }
|
|
+#endif
|
|
+ }
|
|
+
|
|
+#ifdef NEON_SMGR
|
|
+ smgr_end_unlogged_build(RelationGetSmgr(index));
|
|
+#endif
|
|
|
|
FreeBuildState(buildstate);
|
|
}
|