8000 Moved procinfo initialization for inserts [skip ci] · postgrespro/pgvector@064db12 · GitHub
[go: up one dir, main page]

Skip to content

Commit 064db12

Browse files
committed
Moved procinfo initialization for inserts [skip ci]
1 parent 45a6eef commit 064db12

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

src/hnsw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ void HnswSetNeighborTuple(char *base, HnswNeighborTuple ntup, HnswElement e, in
389389
void HnswAddHeapTid(HnswElement element, ItemPointer heaptid);
390390
HnswNeighborArray *HnswInitNeighborArray(int lm, HnswAllocator * allocator);
391391
void HnswInitNeighbors(char *base, HnswElement element, int m, HnswAllocator * alloc);
392-
bool HnswInsertTupleOnDisk(Relation index, Datum value, ItemPointer heaptid, bool building);
392+
bool HnswInsertTupleOnDisk(Relation index, FmgrInfo *procinfo, Oid collation, Datum value, ItemPointer heaptid, bool building);
393393
void HnswUpdateNeighborsOnDisk(Relation index, FmgrInfo *procinfo, Oid collation, HnswElement e, int m, bool checkExisting, bool building);
394394
void HnswLoadElementFromTuple(HnswElement element, HnswElementTuple etup, bool loadHeaptids, bool loadVec);
395395
void HnswLoadElement(HnswElement element, double *distance, Datum *q, Relation index, FmgrInfo *procinfo, Oid collation, bool loadVec, double *maxDistance);

src/hnswbuild.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,14 +476,16 @@ InsertTuple(Relation index, Datum *values, bool *isnull, ItemPointer heaptid, Hn
476476
HnswGraph *graph = buildstate->graph;
477477
HnswElement element;
478478
HnswAllocator *allocator = &buildstate->allocator;
479+
FmgrInfo *procinfo = buildstate->procinfo;
480+
Oid collation = buildstate->collation;
479481
Size valueSize;
480482
Pointer valuePtr;
481483
LWLock *flushLock = &graph->flushLock;
482484
char *base = buildstate->hnswarea;
483485
Datum value;
484486

485487
/* Form index value */
486-
if (!HnswFormIndexValue(&value, values, isnull, buildstate->typeInfo, buildstate->normprocinfo, buildstate->collation))
488+
if (!HnswFormIndexValue(&value, values, isnull, buildstate->typeInfo, buildstate->normprocinfo, collation))
487489
return false;
488490

489491
/* Get datum size */
@@ -497,7 +499,7 @@ InsertTuple(Relation index, Datum *values, bool *isnull, ItemPointer heaptid, Hn
497499
{
498500
LWLockRelease(flushLock);
499501

500-
return HnswInsertTupleOnDisk(index, value, heaptid, true);
502+
return HnswInsertTupleOnDisk(index, procinfo, collation, value, heaptid, true);
501503
}
502504

503505
/*
@@ -529,7 +531,7 @@ InsertTuple(Relation index, Datum *values, bool *isnull, ItemPointer heaptid, Hn
529531

530532
LWLockRelease(flushLock);
531533

532-
return HnswInsertTupleOnDisk(index, value, heaptid, true);
534+
return HnswInsertTupleOnDisk(index, procinfo, collation, value, heaptid, true);
533535
}
534536

535537
/* Ok, we can proceed to allocate the element */

src/hnswinsert.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -679,19 +679,15 @@ UpdateGraphOnDisk(Relation index, FmgrInfo *procinfo, Oid collation, HnswElement
679679
* Insert a tuple into the index
680680
*/
681681
bool
682-
HnswInsertTupleOnDisk(Relation index, Datum value, ItemPointer heaptid, bool building)
682+
HnswInsertTupleOnDisk(Relation index, FmgrInfo *procinfo, Oid collation, Datum value, ItemPointer heaptid, bool building)
683683
{
684684
HnswElement entryPoint;
685685
HnswElement element;
686686
int m;
687687
int efConstruction = HnswGetEfConstruction(index);
688-
FmgrInfo *procinfo;
689-
Oid collation;
690688
LOCKMODE lockmode = ShareLock;
691689
char *base = NULL;
692690

693-
HnswSetProcinfo(index, &procinfo, NULL, &collation);
694-
695691
/*
696692
* Get a shared lock. This allows vacuum to ensure no in-flight inserts
697693
* before repairing graph. Use a page lock so it does not interfere with
@@ -740,14 +736,17 @@ HnswInsertTuple(Relation index, Datum *values, bool *isnull, ItemPointer heaptid
740736
{
741737
Datum value;
742738
const HnswTypeInfo *typeInfo = HnswGetTypeInfo(index);
743-
FmgrInfo *normprocinfo = HnswOptionalProcInfo(index, HNSW_NORM_PROC);
744-
Oid collation = index->rd_indcollation[0];
739+
FmgrInfo *procinfo;
740+
FmgrInfo *normprocinfo;
741+
Oid collation;
742+
743+
HnswSetProcinfo(index, &procinfo, &normprocinfo, &collation);
745744

746745
/* Form index value */
747746
if (!HnswFormIndexValue(&value, values, isnull, typeInfo, normprocinfo, collation))
748747
return;
749748

750-
HnswInsertTupleOnDisk(index, value, heaptid, false);
749+
HnswInsertTupleOnDisk(index, procinfo, collation, value, heaptid, false);
751750
}
752751

753752
/*

0 commit comments

Comments
 (0)
0