From 67f9a3e61c44cf956cbf9ff4d0cf405dca5b0381 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 9 Oct 2024 19:30:04 -0700 Subject: [PATCH] Init collation as well [skip ci] --- src/hnsw.h | 2 +- src/hnswbuild.c | 3 +-- src/hnswinsert.c | 4 ++-- src/hnswscan.c | 3 +-- src/hnswutils.c | 4 +++- src/hnswvacuum.c | 3 +-- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/hnsw.h b/src/hnsw.h index 9efb53f..3c3d1b1 100644 --- a/src/hnsw.h +++ b/src/hnsw.h @@ -406,7 +406,7 @@ bool HnswLoadNeighborTids(HnswElement element, ItemPointerData *indextids, Rela void HnswInitLockTranche(void); const HnswTypeInfo *HnswGetTypeInfo(Relation index); PGDLLEXPORT void HnswParallelBuildMain(dsm_segment *seg, shm_toc *toc); -void HnswInitProcinfo(FmgrInfo **procinfo, Relation index); +void HnswInitProcinfo(FmgrInfo **procinfo, Oid **collation, Relation index); bool HnswIndexTupleIsEqual(IndexTuple a, IndexTuple b, TupleDesc tupdesc); /* Index access methods */ diff --git a/src/hnswbuild.c b/src/hnswbuild.c index bda90ca..adf32f3 100644 --- a/src/hnswbuild.c +++ b/src/hnswbuild.c @@ -753,9 +753,8 @@ InitBuildState(HnswBuildState * buildstate, Relation heap, Relation index, Index buildstate->indtuples = 0; /* Get support functions */ - HnswInitProcinfo(buildstate->procinfo, index); + HnswInitProcinfo(buildstate->procinfo, &buildstate->collation, index); buildstate->normprocinfo = HnswOptionalProcInfo(index, HNSW_NORM_PROC); - buildstate->collation = index->rd_indcollation; InitGraph(&buildstate->graphData, NULL, (Size) maintenance_work_mem * 1024L); buildstate->graph = &buildstate->graphData; diff --git a/src/hnswinsert.c b/src/hnswinsert.c index 62ff0e1..7759f1d 100644 --- a/src/hnswinsert.c +++ b/src/hnswinsert.c @@ -699,11 +699,11 @@ HnswInsertTupleOnDisk(Relation index, Datum value, Datum *values, bool *isnull, int m; int efConstruction = HnswGetEfConstruction(index); FmgrInfo *procinfo[2]; - Oid *collation = index->rd_indcollation; + Oid *collation; LOCKMODE lockmode = ShareLock; char *base = NULL; - HnswInitProcinfo(procinfo, index); + HnswInitProcinfo(procinfo, &collation, index); /* * Get a shared lock. This allows vacuum to ensure no in-flight inserts diff --git a/src/hnswscan.c b/src/hnswscan.c index efb693a..2925060 100644 --- a/src/hnswscan.c +++ b/src/hnswscan.c @@ -88,9 +88,8 @@ hnswbeginscan(Relation index, int nkeys, int norderbys) ALLOCSET_DEFAULT_SIZES); /* Set support functions */ - HnswInitProcinfo(so->procinfo, index); + HnswInitProcinfo(so->procinfo, &so->collation, index); so->normprocinfo = HnswOptionalProcInfo(index, HNSW_NORM_PROC); - so->collation = index->rd_indcollation; scan->opaque = so; diff --git a/src/hnswutils.c b/src/hnswutils.c index 09b73ed..233d54c 100644 --- a/src/hnswutils.c +++ b/src/hnswutils.c @@ -157,12 +157,14 @@ HnswOptionalProcInfo(Relation index, uint16 procnum) * Init procinfo */ void -HnswInitProcinfo(FmgrInfo **procinfo, Relation index) +HnswInitProcinfo(FmgrInfo **procinfo, Oid **collation, Relation index) { procinfo[0] = index_getprocinfo(index, 1, HNSW_DISTANCE_PROC); if (IndexRelationGetNumberOfKeyAttributes(index) > 1) procinfo[1] = index_getprocinfo(index, 2, HNSW_ATTRIBUTE_DISTANCE_PROC); + + *collation = index->rd_indcollation; } /* diff --git a/src/hnswvacuum.c b/src/hnswvacuum.c index 09cf8e8..00e1494 100644 --- a/src/hnswvacuum.c +++ b/src/hnswvacuum.c @@ -581,8 +581,7 @@ InitVacuumState(HnswVacuumState * vacuumstate, IndexVacuumInfo *info, IndexBulkD vacuumstate->callback_state = callback_state; vacuumstate->efConstruction = HnswGetEfConstruction(index); vacuumstate->bas = GetAccessStrategy(BAS_BULKREAD); - HnswInitProcinfo(vacuumstate->procinfo, index); - vacuumstate->collation = index->rd_indcollation; + HnswInitProcinfo(vacuumstate->procinfo, &vacuumstate->collation, index); vacuumstate->ntup = palloc0(HNSW_TUPLE_ALLOC_SIZE); vacuumstate->tmpCtx = AllocSetContextCreate(CurrentMemoryContext, "Hnsw vacuum temporary context",