- PerCallConsistentStorage *pccs = NULL;
- bool *recheck = (bool *) PG_GETARG_POINTER(5);
-
- *recheck = true;
-
- pccs = (PerCallConsistentStorage*) fcinfo->flinfo->fn_extra;
-
- if ( pccs == NULL || pccs->datasz != VARSIZE(query) || memcmp( pccs->data, query, pccs->datasz) !=0 )
- {
- bool *pmatch = NULL;
-
- /*
- * we need to fill our cache, we'll get it by regular way
- * and store it in function context
- */
-
- pccs = (PerCallConsistentStorage*) MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
- PCCSHDR_SZ + VARSIZE(query) );
- pccs->datasz = VARSIZE(query);
- memcpy( pccs->data, query, pccs->datasz);
-
- DirectFunctionCall6(
- gin_extract_wildcard,
- PointerGetDatum(query),
- PointerGetDatum( &pccs->nentries ), /* &nentries */
- PG_GETARG_DATUM(1), /* strategy */
- PointerGetDatum( &pmatch ),
- PointerGetDatum(NULL),
- PointerGetDatum( &pccs->needRecheck )
- );
-
- fcinfo->flinfo->fn_extra = (void*)pccs;
- }