diff -c -r -N src.orig/backend/tsearch/ts_parse.c src/backend/tsearch/ts_parse.c
*** src.orig/backend/tsearch/ts_parse.c	2009-07-28 15:19:21.000000000 +0400
--- src/backend/tsearch/ts_parse.c	2009-07-28 17:57:50.000000000 +0400
***************
*** 29,35 ****
  	int			type;
  	char	   *lemm;
  	int			lenlemm;
- 	bool		resfollow;
  	struct ParsedLex *next;
  } ParsedLex;
  
--- 29,34 ----
***************
*** 189,194 ****
--- 188,195 ----
  		while (ld->towork.head)
  		{
  			ParsedLex  *curVal = ld->towork.head;
+ 			char	   *curValLemm = curVal->lemm;
+ 			int	   		curValLenLemm = curVal->lenlemm;
  
  			map = ld->cfg->map + curVal->type;
  
***************
*** 208,215 ****
  				res = (TSLexeme *) DatumGetPointer(FunctionCall4(
  															 &(dict->lexize),
  											 PointerGetDatum(dict->dictData),
! 											   PointerGetDatum(curVal->lemm),
! 											  Int32GetDatum(curVal->lenlemm),
  											  PointerGetDatum(&ld->dictState)
  																 ));
  
--- 209,216 ----
  				res = (TSLexeme *) DatumGetPointer(FunctionCall4(
  															 &(dict->lexize),
  											 PointerGetDatum(dict->dictData),
! 											     PointerGetDatum(curValLemm),
! 											    Int32GetDatum(curValLenLemm),
  											  PointerGetDatum(&ld->dictState)
  																 ));
  
***************
*** 231,236 ****
--- 232,244 ----
  				if (!res)		/* dictionary doesn't know this lexeme */
  					continue;
  
+ 				if ( res->flags & TSL_FILTER )
+ 				{
+ 					curValLemm = res->lexeme;
+ 					curValLenLemm = strlen(res->lexeme);
+ 					continue;
+ 				}
+ 
  				RemoveHead(ld);
  				setCorrLex(ld, correspondLexem);
  				return res;
diff -c -r -N src.orig/include/tsearch/ts_public.h src/include/tsearch/ts_public.h
*** src.orig/include/tsearch/ts_public.h	2009-07-28 15:19:22.000000000 +0400
--- src/include/tsearch/ts_public.h	2009-07-28 17:57:50.000000000 +0400
***************
*** 101,106 ****
--- 101,107 ----
  
  #define TSL_ADDPOS		0x01
  #define TSL_PREFIX		0x02
+ #define TSL_FILTER		0x04
  
  /*
   * Struct for supporting complex dictionaries like thesaurus.
diff -c -r -N src.orig/test/regress/pg_regress.c src/test/regress/pg_regress.c
*** src.orig/test/regress/pg_regress.c	2009-07-28 15:19:26.000000000 +0400
--- src/test/regress/pg_regress.c	2009-07-28 17:57:50.000000000 +0400
***************
*** 1767,1775 ****
  	 */
  	header(_("creating database \"%s\""), dbname);
  	if (encoding)
! 		psql_command("postgres", "CREATE DATABASE \"%s\" TEMPLATE=template0 ENCODING='%s'", dbname, encoding);
  	else
! 		psql_command("postgres", "CREATE DATABASE \"%s\" TEMPLATE=template0", dbname);
  	psql_command(dbname,
  				 "ALTER DATABASE \"%s\" SET lc_messages TO 'C';"
  				 "ALTER DATABASE \"%s\" SET lc_monetary TO 'C';"
--- 1767,1777 ----
  	 */
  	header(_("creating database \"%s\""), dbname);
  	if (encoding)
! 		psql_command("postgres", "CREATE DATABASE \"%s\" TEMPLATE=template0 ENCODING='%s'%s", dbname, encoding,
! 					 (nolocale) ? " LC_COLLATE='C' LC_CTYPE='C'" : "");
  	else
! 		psql_command("postgres", "CREATE DATABASE \"%s\" TEMPLATE=template0%s", dbname,
! 					 (nolocale) ? " LC_COLLATE='C' LC_CTYPE='C'" : "");
  	psql_command(dbname,
  				 "ALTER DATABASE \"%s\" SET lc_messages TO 'C';"
  				 "ALTER DATABASE \"%s\" SET lc_monetary TO 'C';"
