From 91e3d2905fd5f0aa90f2486c1d0a4a129a53221d Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 28 Feb 2024 16:26:41 -0800 Subject: [PATCH] Fixed sort function for Postgres 12 --- src/hnswutils.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/hnswutils.c b/src/hnswutils.c index 766cae5..983fd11 100644 --- a/src/hnswutils.c +++ b/src/hnswutils.c @@ -860,12 +860,15 @@ HnswSearchLayer(char *base, Datum q, List *ep, int ef, int lc, Relation index, F static int #if PG_VERSION_NUM >= 130000 CompareCandidateDistances(const ListCell *a, const ListCell *b) +{ + HnswCandidate *hca = lfirst(a); + HnswCandidate *hcb = lfirst(b); #else CompareCandidateDistances(const void *a, const void *b) -#endif { - HnswCandidate *hca = lfirst((ListCell *) a); - HnswCandidate *hcb = lfirst((ListCell *) b); + HnswCandidate *hca = lfirst(*(ListCell **) a); + HnswCandidate *hcb = lfirst(*(ListCell **) b); +#endif if (hca->distance < hcb->distance) return 1; @@ -888,12 +891,15 @@ CompareCandidateDistances(const void *a, const void *b) static int #if PG_VERSION_NUM >= 130000 CompareCandidateDistancesOffset(const ListCell *a, const ListCell *b) +{ + HnswCandidate *hca = lfirst(a); + HnswCandidate *hcb = lfirst(b); #else CompareCandidateDistancesOffset(const void *a, const void *b) -#endif { - HnswCandidate *hca = lfirst((ListCell *) a); - HnswCandidate *hcb = lfirst((ListCell *) b); + HnswCandidate *hca = lfirst(*(ListCell **) a); + HnswCandidate *hcb = lfirst(*(ListCell **) b); +#endif if (hca->distance < hcb->distance) return 1;