}
}
+ /*
+ * Now that we have the estimates for the entry frequencies, finish
+ * initializing the scan keys.
+ */
for (i = 0; i < so->nkeys; i++)
startScanKey(ginstate, so, so->keys + i);
}
}
-#define GinIsNewKey(s) ( ((GinScanOpaque) scan->opaque)->keys == NULL )
#define GinIsVoidRes(s) ( ((GinScanOpaque) scan->opaque)->isVoidRes )
Datum
{
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
TIDBitmap *tbm = (TIDBitmap *) PG_GETARG_POINTER(1);
+ GinScanOpaque so = (GinScanOpaque) scan->opaque;
int64 ntids;
ItemPointerData iptr;
bool recheck;
/*
* Set up the scan keys, and check for unsatisfiable query.
*/
- if (GinIsNewKey(scan))
- ginNewScanKey(scan);
+ ginFreeScanKeys(so); /* there should be no keys yet, but just to be sure */
+ ginNewScanKey(scan);
if (GinIsVoidRes(scan))
PG_RETURN_INT64(0);
key->curItemMatches = false;
key->recheckCurItem = false;
key->isFinished = false;
+ key->nrequired = 0;
+ key->nadditional = 0;
+ key->requiredEntries = NULL;
+ key->additionalEntries = NULL;
ginInitConsistentFunction(ginstate, key);
}
}
-static void
-freeScanKeys(GinScanOpaque so)
+void
+ginFreeScanKeys(GinScanOpaque so)
{
uint32 i;
pfree(key->scanEntry);
pfree(key->entryRes);
+ if (key->requiredEntries)
+ pfree(key->requiredEntries);
+ if (key->additionalEntries)
+ pfree(key->additionalEntries);
}
pfree(so->keys);
/* remaining arguments are ignored */
GinScanOpaque so = (GinScanOpaque) scan->opaque;
- freeScanKeys(so);
+ ginFreeScanKeys(so);
if (scankey && scan->numberOfKeys > 0)
{
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
GinScanOpaque so = (GinScanOpaque) scan->opaque;
- freeScanKeys(so);
+ ginFreeScanKeys(so);
MemoryContextDelete(so->tempCtx);
extern Datum ginmarkpos(PG_FUNCTION_ARGS);
extern Datum ginrestrpos(PG_FUNCTION_ARGS);
extern void ginNewScanKey(IndexScanDesc scan);
+extern void ginFreeScanKeys(GinScanOpaque so);
/* ginget.c */
extern Datum gingetbitmap(PG_FUNCTION_ARGS);