From 13469e1bf07961f33ad1f66610a945a317db5e1b Mon Sep 17 00:00:00 2001 From: Teodor Sigaev Date: Fri, 13 Nov 2015 00:40:44 +0300 Subject: [PATCH] fix support nulls for versions >= 9.1 --- gevel.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gevel.c b/gevel.c index b464de0..f0e3738 100644 --- a/gevel.c +++ b/gevel.c @@ -625,7 +625,7 @@ refindPosition(GinStatState *st) #endif if ( cmp == 0 ) { - if ( !st->index->rd_att->attrs[st->attnum]->attbyval ) + if ( st->curval && !st->index->rd_att->attrs[st->attnum]->attbyval ) pfree( (void*) st->curval ); return true; } @@ -683,14 +683,24 @@ gin_setup_firstcall(FuncCallContext *funcctx, text *name, int attnum) { static void processTuple( FuncCallContext *funcctx, GinStatState *st, IndexTuple itup ) { MemoryContext oldcontext; -#if PG_VERSION_NUM < 80400 +#if PG_VERSION_NUM >= 90100 + Datum key; +#elif PG_VERSION_NUM < 80400 bool isnull; #endif oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); + +#if PG_VERSION_NUM >= 90100 + key = gintuple_get_key(&st->ginstate, itup, &st->category); + + if (st->category != GIN_CAT_NORM_KEY) + st->curval = (Datum)0; + else +#endif st->curval = datumCopy( #if PG_VERSION_NUM >= 90100 - gintuple_get_key(&st->ginstate, itup, &st->category), + key, #elif PG_VERSION_NUM >= 80400 gin_index_getattr(&st->ginstate, itup), #else -- 2.46.1