diff -c -r -N src.orig/backend/access/gin/ginget.c src/backend/access/gin/ginget.c
*** src.orig/backend/access/gin/ginget.c	2008-12-19 12:29:15.000000000 +0300
--- src/backend/access/gin/ginget.c	2008-12-19 12:44:35.000000000 +0300
***************
*** 172,178 ****
      	cmp = DatumGetInt32(FunctionCall3(&btree->ginstate->comparePartialFn[scanEntry->attnum-1],
  										  scanEntry->entry,
  										  idatum,
! 										  UInt16GetDatum(scanEntry->strategy)));
  
  		if ( cmp > 0 )
  			return true;
--- 172,178 ----
      	cmp = DatumGetInt32(FunctionCall3(&btree->ginstate->comparePartialFn[scanEntry->attnum-1],
  										  scanEntry->entry,
  										  idatum,
! 										  PointerGetDatum(scanEntry->extra_data)));
  
  		if ( cmp > 0 )
  			return true;
***************
*** 659,669 ****
  		*keyrecheck = true;
  
  		oldCtx = MemoryContextSwitchTo(tempCtx);
! 		res = DatumGetBool(FunctionCall4(&ginstate->consistentFn[key->attnum-1],
  										 PointerGetDatum(key->entryRes),
  										 UInt16GetDatum(key->strategy),
  										 key->query,
! 										 PointerGetDatum(keyrecheck)));
  		MemoryContextSwitchTo(oldCtx);
  		MemoryContextReset(tempCtx);
  	} while (!res);
--- 659,670 ----
  		*keyrecheck = true;
  
  		oldCtx = MemoryContextSwitchTo(tempCtx);
! 		res = DatumGetBool(FunctionCall5(&ginstate->consistentFn[key->attnum-1],
  										 PointerGetDatum(key->entryRes),
  										 UInt16GetDatum(key->strategy),
  										 key->query,
! 										 PointerGetDatum(keyrecheck),
! 										 PointerGetDatum(key->extra_data)));
  		MemoryContextSwitchTo(oldCtx);
  		MemoryContextReset(tempCtx);
  	} while (!res);
diff -c -r -N src.orig/backend/access/gin/ginscan.c src/backend/access/gin/ginscan.c
*** src.orig/backend/access/gin/ginscan.c	2008-12-19 12:29:15.000000000 +0300
--- src/backend/access/gin/ginscan.c	2008-12-19 12:44:35.000000000 +0300
***************
*** 38,44 ****
  static void
  fillScanKey(GinState *ginstate, GinScanKey key, OffsetNumber attnum, Datum query,
  			Datum *entryValues, bool *partial_matches, uint32 nEntryValues, 
! 			StrategyNumber strategy)
  {
  	uint32		i,
  				j;
--- 38,44 ----
  static void
  fillScanKey(GinState *ginstate, GinScanKey key, OffsetNumber attnum, Datum query,
  			Datum *entryValues, bool *partial_matches, uint32 nEntryValues, 
! 			StrategyNumber strategy, void **extra_data)
  {
  	uint32		i,
  				j;
***************
*** 48,53 ****
--- 48,54 ----
  	key->scanEntry = (GinScanEntry) palloc(sizeof(GinScanEntryData) * nEntryValues);
  	key->strategy = strategy;
  	key->attnum = attnum;
+ 	key->extra_data = extra_data;
  	key->query = query;
  	key->firstCall = TRUE;
  	ItemPointerSet(&(key->curItem), InvalidBlockNumber, InvalidOffsetNumber);
***************
*** 57,62 ****
--- 58,64 ----
  		key->scanEntry[i].pval = key->entryRes + i;
  		key->scanEntry[i].entry = entryValues[i];
  		key->scanEntry[i].attnum = attnum;
+ 		key->scanEntry[i].extra_data = (extra_data) ? extra_data[i] : NULL;
  		ItemPointerSet(&(key->scanEntry[i].curItem), InvalidBlockNumber, InvalidOffsetNumber);
  		key->scanEntry[i].offset = InvalidOffsetNumber;
  		key->scanEntry[i].buffer = InvalidBuffer;
***************
*** 165,182 ****
  		Datum	   *entryValues;
  		int32		nEntryValues;
  		bool		*partial_matches = NULL;
  
  		/* XXX can't we treat nulls by just setting isVoidRes? */
  		/* This would amount to assuming that all GIN operators are strict */
  		if (scankey[i].sk_flags & SK_ISNULL)
  			elog(ERROR, "GIN doesn't support NULL as scan key");
  
! 		entryValues = (Datum *) DatumGetPointer(FunctionCall4(
  												&so->ginstate.extractQueryFn[scankey[i].sk_attno - 1],
  												scankey[i].sk_argument,
  												PointerGetDatum(&nEntryValues),
  												UInt16GetDatum(scankey[i].sk_strategy),
! 												PointerGetDatum(&partial_matches)));
  		if (nEntryValues < 0)
  		{
  			/*
--- 167,186 ----
  		Datum	   *entryValues;
  		int32		nEntryValues;
  		bool		*partial_matches = NULL;
+ 		void		**extra_data = NULL;
  
  		/* XXX can't we treat nulls by just setting isVoidRes? */
  		/* This would amount to assuming that all GIN operators are strict */
  		if (scankey[i].sk_flags & SK_ISNULL)
  			elog(ERROR, "GIN doesn't support NULL as scan key");
  
! 		entryValues = (Datum *) DatumGetPointer(FunctionCall5(
  												&so->ginstate.extractQueryFn[scankey[i].sk_attno - 1],
  												scankey[i].sk_argument,
  												PointerGetDatum(&nEntryValues),
  												UInt16GetDatum(scankey[i].sk_strategy),
! 												PointerGetDatum(&partial_matches),
! 												PointerGetDatum(&extra_data)));
  		if (nEntryValues < 0)
  		{
  			/*
***************
*** 195,201 ****
  			continue;
  
  		fillScanKey(&so->ginstate, &(so->keys[nkeys]), scankey[i].sk_attno, scankey[i].sk_argument,
! 					entryValues, partial_matches, nEntryValues, scankey[i].sk_strategy);
  		nkeys++;
  	}
  
--- 199,205 ----
  			continue;
  
  		fillScanKey(&so->ginstate, &(so->keys[nkeys]), scankey[i].sk_attno, scankey[i].sk_argument,
! 					entryValues, partial_matches, nEntryValues, scankey[i].sk_strategy, extra_data);
  		nkeys++;
  	}
  
diff -c -r -N src.orig/backend/utils/adt/tsginidx.c src/backend/utils/adt/tsginidx.c
*** src.orig/backend/utils/adt/tsginidx.c	2008-12-19 12:29:20.000000000 +0300
--- src/backend/utils/adt/tsginidx.c	2008-12-19 12:44:35.000000000 +0300
***************
*** 42,48 ****
  	text    *a = PG_GETARG_TEXT_PP(0);
  	text    *b = PG_GETARG_TEXT_PP(1);
  #ifdef NOT_USED
! 	StrategyNumber strategy = PG_GETARG_UINT16(2);
  #endif
  	int     cmp;
  
--- 42,48 ----
  	text    *a = PG_GETARG_TEXT_PP(0);
  	text    *b = PG_GETARG_TEXT_PP(1);
  #ifdef NOT_USED
! 	void 	*extra_data = PG_GETARG_POINTER(2);
  #endif
  	int     cmp;
  
***************
*** 96,101 ****
--- 96,102 ----
  	int32	   *nentries = (int32 *) PG_GETARG_POINTER(1);
  	/* StrategyNumber strategy = PG_GETARG_UINT16(2); */
  	bool      **ptr_partialmatch = (bool**) PG_GETARG_POINTER(3);
+ 	void	  ***extra_data = (void ***) PG_GETARG_POINTER(4);
  	Datum	   *entries = NULL;
  	bool       *partialmatch;
  
***************
*** 124,129 ****
--- 125,136 ----
  
  		entries = (Datum *) palloc(sizeof(Datum) * (*nentries));
  		partialmatch = *ptr_partialmatch = (bool*) palloc(sizeof(bool) * (*nentries));
+ 		/*
+ 		 * Allocate memory for GinChkVal.mapped_check to prevent
+ 		 * allocation in gin_tsquery_consistent().
+ 		 * Suppose sizeof(void*)>=sizeof(bool).
+ 		 */
+ 		*extra_data = (void**) palloc(sizeof(void*)*(*nentries));
  
  		for (i = 0; i < query->size; i++)
  			if (item[i].type == QI_VAL)
***************
*** 174,179 ****
--- 181,187 ----
  	/* StrategyNumber strategy = PG_GETARG_UINT16(1); */
  	TSQuery		query = PG_GETARG_TSQUERY(2);
  	bool	   *recheck = (bool *) PG_GETARG_POINTER(3);
+ 	void	   **extra_data = (void **) PG_GETARG_POINTER(4);
  	bool		res = FALSE;
  
  	/* The query requires recheck only if it involves weights */
***************
*** 195,201 ****
  		 */
  
  		gcv.frst = item = GETQUERY(query);
! 		gcv.mapped_check = (bool *) palloc(sizeof(bool) * query->size);
  		gcv.need_recheck = recheck;
  
  		for (i = 0; i < query->size; i++)
--- 203,209 ----
  		 */
  
  		gcv.frst = item = GETQUERY(query);
! 		gcv.mapped_check = (bool *) extra_data;
  		gcv.need_recheck = recheck;
  
  		for (i = 0; i < query->size; i++)
diff -c -r -N src.orig/include/access/gin.h src/include/access/gin.h
*** src.orig/include/access/gin.h	2008-12-19 12:29:25.000000000 +0300
--- src/include/access/gin.h	2008-12-19 12:44:35.000000000 +0300
***************
*** 370,375 ****
--- 370,376 ----
  	/* entry, got from extractQueryFn */
  	Datum		entry;
  	OffsetNumber	attnum;
+ 	void			*extra_data;
  
  	/* Current page in posting tree */
  	Buffer		buffer;
***************
*** 403,408 ****
--- 404,410 ----
  
  	/* array of scans per entry */
  	GinScanEntry scanEntry;
+ 	void		 **extra_data;
  
  	/* for calling consistentFn(GinScanKey->entryRes, strategy, query) */
  	StrategyNumber strategy;
diff -c -r -N src.orig/include/catalog/pg_proc.h src/include/catalog/pg_proc.h
*** src.orig/include/catalog/pg_proc.h	2008-12-19 12:29:25.000000000 +0300
--- src/include/catalog/pg_proc.h	2008-12-19 12:47:48.000000000 +0300
***************
*** 4144,4152 ****
  /* GIN array support */
  DATA(insert OID = 2743 (  ginarrayextract	 PGNSP PGUID 12 1 0 0 f f t f i 2 0 2281 "2277 2281" _null_ _null_ _null_ _null_	ginarrayextract _null_ _null_ _null_ ));
  DESCR("GIN array support");
! DATA(insert OID = 2774 (  ginqueryarrayextract	PGNSP PGUID 12 1 0 0 f f t f i 4 0 2281 "2277 2281 21 2281" _null_ _null_ _null_ _null_ ginqueryarrayextract _null_ _null_ _null_ ));
  DESCR("GIN array support");
! DATA(insert OID = 2744 (  ginarrayconsistent PGNSP PGUID 12 1 0 0 f f t f i 4 0 16 "2281 21 2281 2281" _null_ _null_ _null_ _null_	ginarrayconsistent _null_ _null_ _null_ ));
  DESCR("GIN array support");
  
  /* overlap/contains/contained */
--- 4144,4152 ----
  /* GIN array support */
  DATA(insert OID = 2743 (  ginarrayextract	 PGNSP PGUID 12 1 0 0 f f t f i 2 0 2281 "2277 2281" _null_ _null_ _null_ _null_	ginarrayextract _null_ _null_ _null_ ));
  DESCR("GIN array support");
! DATA(insert OID = 2774 (  ginqueryarrayextract	PGNSP PGUID 12 1 0 0 f f t f i 5 0 2281 "2277 2281 21 2281 2281" _null_ _null_ _null_ _null_ ginqueryarrayextract _null_ _null_ _null_ ));
  DESCR("GIN array support");
! DATA(insert OID = 2744 (  ginarrayconsistent PGNSP PGUID 12 1 0 0 f f t f i 5 0 16 "2281 21 2281 2281 2281" _null_ _null_ _null_ _null_	ginarrayconsistent _null_ _null_ _null_ ));
  DESCR("GIN array support");
  
  /* overlap/contains/contained */
***************
*** 4385,4397 ****
  
  DATA(insert OID = 3656 (  gin_extract_tsvector	PGNSP PGUID 12 1 0 0 f f t f i 2 0 2281 "3614 2281" _null_ _null_ _null_ _null_	gin_extract_tsvector _null_ _null_ _null_ ));
  DESCR("GIN tsvector support");
! DATA(insert OID = 3657 (  gin_extract_tsquery	PGNSP PGUID 12 1 0 0 f f t f i 4 0 2281 "3615 2281 21 2281" _null_ _null_ _null_ _null_ gin_extract_tsquery _null_ _null_ _null_ ));
  DESCR("GIN tsvector support");
! DATA(insert OID = 3658 (  gin_tsquery_consistent PGNSP PGUID 12 1 0 0 f f t f i 4 0 16 "2281 21 3615 2281" _null_ _null_ _null_ _null_	gin_tsquery_consistent _null_ _null_ _null_ ));
  DESCR("GIN tsvector support");
  DATA(insert OID = 3724 (  gin_cmp_tslexeme      PGNSP PGUID 12 1 0 0 f f t f i 2 0 23 "25 25" _null_ _null_ _null_ _null_ gin_cmp_tslexeme _null_ _null_ _null_ ));
  DESCR("GIN tsvector support");
! DATA(insert OID = 2700 (  gin_cmp_prefix        PGNSP PGUID 12 1 0 0 f f t f i 3 0 23 "25 25 21" _null_ _null_ _null_ _null_ gin_cmp_prefix _null_ _null_ _null_ ));
  DESCR("GIN tsvector support");
  
  DATA(insert OID = 3662 (  tsquery_lt			PGNSP PGUID 12 1 0 0 f f t f i 2 0 16 "3615 3615" _null_ _null_ _null_ _null_ tsquery_lt _null_ _null_ _null_ ));
--- 4385,4397 ----
  
  DATA(insert OID = 3656 (  gin_extract_tsvector	PGNSP PGUID 12 1 0 0 f f t f i 2 0 2281 "3614 2281" _null_ _null_ _null_ _null_	gin_extract_tsvector _null_ _null_ _null_ ));
  DESCR("GIN tsvector support");
! DATA(insert OID = 3657 (  gin_extract_tsquery	PGNSP PGUID 12 1 0 0 f f t f i 5 0 2281 "3615 2281 21 2281 2281" _null_ _null_ _null_ _null_ gin_extract_tsquery _null_ _null_ _null_ ));
  DESCR("GIN tsvector support");
! DATA(insert OID = 3658 (  gin_tsquery_consistent PGNSP PGUID 12 1 0 0 f f t f i 5 0 16 "2281 21 3615 2281 2281" _null_ _null_ _null_ _null_	gin_tsquery_consistent _null_ _null_ _null_ ));
  DESCR("GIN tsvector support");
  DATA(insert OID = 3724 (  gin_cmp_tslexeme      PGNSP PGUID 12 1 0 0 f f t f i 2 0 23 "25 25" _null_ _null_ _null_ _null_ gin_cmp_tslexeme _null_ _null_ _null_ ));
  DESCR("GIN tsvector support");
! DATA(insert OID = 2700 (  gin_cmp_prefix        PGNSP PGUID 12 1 0 0 f f t f i 3 0 23 "25 25 2281" _null_ _null_ _null_ _null_ gin_cmp_prefix _null_ _null_ _null_ ));
  DESCR("GIN tsvector support");
  
  DATA(insert OID = 3662 (  tsquery_lt			PGNSP PGUID 12 1 0 0 f f t f i 2 0 16 "3615 3615" _null_ _null_ _null_ _null_ tsquery_lt _null_ _null_ _null_ ));
diff -c -r -N doc.orig/src/sgml/gin.sgml doc/src/sgml/gin.sgml
*** doc.orig/src/sgml/gin.sgml	2008-12-19 12:29:31.000000000 +0300
--- doc/src/sgml/gin.sgml	2008-12-19 12:44:35.000000000 +0300
***************
*** 88,94 ****
  
      <varlistentry>
       <term>Datum *extractQuery(Datum query, int32 *nkeys,
!         StrategyNumber n, bool **pmatch)</term>
       <listitem>
        <para>
         Returns an array of keys given a value to be queried; that is,
--- 88,94 ----
  
      <varlistentry>
       <term>Datum *extractQuery(Datum query, int32 *nkeys,
!         StrategyNumber n, bool *pmatch[], void ** extra_data[])</term>
       <listitem>
        <para>
         Returns an array of keys given a value to be queried; that is,
***************
*** 114,126 ****
         is not required.  The variable is initialized to NULL before call,
         so this argument can simply be ignored by operator classes that do
         not support partial match.
        </para>
  
       </listitem>
      </varlistentry>
  
      <varlistentry>
!      <term>bool consistent(bool check[], StrategyNumber n, Datum query, bool *recheck)</term>
       <listitem>
        <para>
         Returns TRUE if the indexed value satisfies the query operator with
--- 114,131 ----
         is not required.  The variable is initialized to NULL before call,
         so this argument can simply be ignored by operator classes that do
         not support partial match.
+ 	   <literal>extra_data</> is an output  array of additional data. The whole array
+ 	   is an argument for <function>consistent</> method, and each element as a
+ 	   third argument for <function>comparePartial</> method. To use it, 
+ 	   <function>extractQuery</> must allocate  an array of <literal>*nkeys</> 
+ 	   pointers and store it in *extra_data. 
        </para>
  
       </listitem>
      </varlistentry>
  
      <varlistentry>
!      <term>bool consistent(bool check[], StrategyNumber n, Datum query, bool *recheck, void *extra_data[])</term>
       <listitem>
        <para>
         Returns TRUE if the indexed value satisfies the query operator with
***************
*** 135,141 ****
         passed in case the <function>consistent</> method needs to consult it.
         On success, <literal>*recheck</> should be set to TRUE if the heap
         tuple needs to be rechecked against the query operator, or FALSE if
!        the index test is exact.
        </para>
       </listitem>
      </varlistentry>
--- 140,147 ----
         passed in case the <function>consistent</> method needs to consult it.
         On success, <literal>*recheck</> should be set to TRUE if the heap
         tuple needs to be rechecked against the query operator, or FALSE if
!        the index test is exact. <literal>extra_data</> is exactly the
! 	   same array as it was made by <function>extractQuery</>
        </para>
       </listitem>
      </varlistentry>
***************
*** 150,156 ****
    <variablelist>
  
      <varlistentry>
!      <term>int comparePartial(Datum partial_key, Datum key, StrategyNumber n)</term>
       <listitem>
        <para>
         Compare a partial-match query to an index key.  Returns an integer
--- 156,162 ----
    <variablelist>
  
      <varlistentry>
!      <term>int comparePartial(Datum partial_key, Datum key, void *extra_data)</term>
       <listitem>
        <para>
         Compare a partial-match query to an index key.  Returns an integer
***************
*** 158,166 ****
         does not match the query, but the index scan should continue; zero
         means that the index key does match the query; greater than zero
         indicates that the index scan should stop because no more matches
!        are possible.  The strategy number <literal>n</> of the operator
!        that generated the partial match query is provided, in case its
!        semantics are needed to determine when to end the scan.
        </para>
       </listitem>
      </varlistentry>
--- 164,171 ----
         does not match the query, but the index scan should continue; zero
         means that the index key does match the query; greater than zero
         indicates that the index scan should stop because no more matches
!        are possible. <literal>extra_data</> is a correspoding element of 
! 	   array made by <function>extractQuery</>.  
        </para>
       </listitem>
      </varlistentry>
diff -c -r -N contrib.orig/pg_trgm/pg_trgm.sql.in contrib/pg_trgm/pg_trgm.sql.in
*** contrib.orig/pg_trgm/pg_trgm.sql.in	2008-12-19 12:29:34.000000000 +0300
--- contrib/pg_trgm/pg_trgm.sql.in	2008-12-19 12:44:35.000000000 +0300
***************
*** 110,121 ****
  AS 'MODULE_PATHNAME'
  LANGUAGE C IMMUTABLE;
  
! CREATE OR REPLACE FUNCTION gin_extract_trgm(text, internal, internal)
  RETURNS internal
  AS 'MODULE_PATHNAME'
  LANGUAGE C IMMUTABLE;
  
! CREATE OR REPLACE FUNCTION gin_trgm_consistent(internal, int2, text, internal)
  RETURNS internal
  AS 'MODULE_PATHNAME'
  LANGUAGE C IMMUTABLE;
--- 110,121 ----
  AS 'MODULE_PATHNAME'
  LANGUAGE C IMMUTABLE;
  
! CREATE OR REPLACE FUNCTION gin_extract_trgm(text, internal, internal, internal, internal)
  RETURNS internal
  AS 'MODULE_PATHNAME'
  LANGUAGE C IMMUTABLE;
  
! CREATE OR REPLACE FUNCTION gin_trgm_consistent(internal, int2, text, internal, internal)
  RETURNS internal
  AS 'MODULE_PATHNAME'
  LANGUAGE C IMMUTABLE;
***************
*** 127,132 ****
          OPERATOR        1       % (text, text),
          FUNCTION        1       btint4cmp (int4, int4),
          FUNCTION        2       gin_extract_trgm (text, internal),
!         FUNCTION        3       gin_extract_trgm (text, internal, internal),
!         FUNCTION        4       gin_trgm_consistent (internal, int2, text, internal),
          STORAGE         int4;
--- 127,132 ----
          OPERATOR        1       % (text, text),
          FUNCTION        1       btint4cmp (int4, int4),
          FUNCTION        2       gin_extract_trgm (text, internal),
!         FUNCTION        3       gin_extract_trgm (text, internal, internal, internal, internal),
!         FUNCTION        4       gin_trgm_consistent (internal, int2, text, internal, internal),
          STORAGE         int4;
diff -c -r -N contrib.orig/pg_trgm/trgm_gin.c contrib/pg_trgm/trgm_gin.c
*** contrib.orig/pg_trgm/trgm_gin.c	2008-12-19 12:29:34.000000000 +0300
--- contrib/pg_trgm/trgm_gin.c	2008-12-19 12:44:35.000000000 +0300
***************
*** 47,67 ****
  
  			ptr++;
  		}
  	}
  
  	PG_RETURN_POINTER(entries);
  }
  
- /*
-  * Per call strage for consistent functions to
-  * cache computed value from query
-  */
- typedef struct PerCallConsistentStorage {
- 	int		trglen;
- 	text	data[1]; /* query */
- } PerCallConsistentStorage;
- #define PCCSHDR_SZ  offsetof(PerCallConsistentStorage, data)
- 
  Datum
  gin_trgm_consistent(PG_FUNCTION_ARGS)
  {
--- 47,68 ----
  
  			ptr++;
  		}
+ 		if ( PG_NARGS() > 2 )
+ 		{
+ 			/*
+ 			 * Function called from query extracting
+ 			 */
+ 			void      ***extra_data = (void ***) PG_GETARG_POINTER(4);
+ 
+ 			*extra_data = (void**) palloc(sizeof(void*)*(*nentries));
+ 
+ 			*(int32*)(*extra_data) = trglen;
+ 		}
  	}
  
  	PG_RETURN_POINTER(entries);
  }
  
  Datum
  gin_trgm_consistent(PG_FUNCTION_ARGS)
  {
***************
*** 69,99 ****
  	/* StrategyNumber strategy = PG_GETARG_UINT16(1); */
  	text	   *query = PG_GETARG_TEXT_P(2);
  	bool	   *recheck = (bool *) PG_GETARG_POINTER(3);
  	bool		res = FALSE;
  	int4		i,
  				trglen,
  				ntrue = 0;
- 	PerCallConsistentStorage  *pccs = (PerCallConsistentStorage*) fcinfo->flinfo->fn_extra;
  
  	/* All cases served by this function are inexact */
  	*recheck = true;
  
! 	if ( pccs == NULL || VARSIZE(pccs->data) != VARSIZE(query) || memcmp( pccs->data, query, VARSIZE(query) ) !=0  )
! 	{
! 		TRGM	   *trg = generate_trgm(VARDATA(query), VARSIZE(query) - VARHDRSZ);
! 
! 		if ( pccs )
! 			pfree(pccs);
! 
! 		fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, 
! 									VARSIZE(query) + PCCSHDR_SZ);
! 		pccs = (PerCallConsistentStorage*) fcinfo->flinfo->fn_extra;
! 
! 		pccs->trglen = ARRNELEM(trg);
! 		memcpy( pccs->data, query, VARSIZE(query) );
! 	}
! 
! 	trglen = pccs->trglen;
  
  	for (i = 0; i < trglen; i++)
  		if (check[i])
--- 70,85 ----
  	/* StrategyNumber strategy = PG_GETARG_UINT16(1); */
  	text	   *query = PG_GETARG_TEXT_P(2);
  	bool	   *recheck = (bool *) PG_GETARG_POINTER(3);
+ 	void       **extra_data = (void **) PG_GETARG_POINTER(4);
  	bool		res = FALSE;
  	int4		i,
  				trglen,
  				ntrue = 0;
  
  	/* All cases served by this function are inexact */
  	*recheck = true;
  
! 	trglen = *(int32*)extra_data;
  
  	for (i = 0; i < trglen; i++)
  		if (check[i])
