Skip to content

Commit a88a480

Browse files
committed
Introduce filtering dictionary support to tsearch. Propagate --nolocale option
to CREATE DATABASE command in pg_regress to allow correct checking of locale-sensitive contrib modules.
1 parent 77dfb64 commit a88a480

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

src/backend/tsearch/ts_parse.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/tsearch/ts_parse.c,v 1.13 2009/07/16 06:33:44 petere Exp $
10+
* $PostgreSQL: pgsql/src/backend/tsearch/ts_parse.c,v 1.14 2009/08/18 10:30:41 teodor Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -29,7 +29,6 @@ typedef struct ParsedLex
2929
int type;
3030
char *lemm;
3131
int lenlemm;
32-
bool resfollow;
3332
struct ParsedLex *next;
3433
} ParsedLex;
3534

@@ -189,6 +188,8 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
189188
while (ld->towork.head)
190189
{
191190
ParsedLex *curVal = ld->towork.head;
191+
char *curValLemm = curVal->lemm;
192+
int curValLenLemm = curVal->lenlemm;
192193

193194
map = ld->cfg->map + curVal->type;
194195

@@ -208,8 +209,8 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
208209
res = (TSLexeme *) DatumGetPointer(FunctionCall4(
209210
&(dict->lexize),
210211
PointerGetDatum(dict->dictData),
211-
PointerGetDatum(curVal->lemm),
212-
Int32GetDatum(curVal->lenlemm),
212+
PointerGetDatum(curValLemm),
213+
Int32GetDatum(curValLenLemm),
213214
PointerGetDatum(&ld->dictState)
214215
));
215216

@@ -231,6 +232,13 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
231232
if (!res) /* dictionary doesn't know this lexeme */
232233
continue;
233234

235+
if ( res->flags & TSL_FILTER )
236+
{
237+
curValLemm = res->lexeme;
238+
curValLenLemm = strlen(res->lexeme);
239+
continue;
240+
}
241+
234242
RemoveHead(ld);
235243
setCorrLex(ld, correspondLexem);
236244
return res;

src/include/tsearch/ts_public.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1998-2009, PostgreSQL Global Development Group
88
*
9-
* $PostgreSQL: pgsql/src/include/tsearch/ts_public.h,v 1.15 2009/07/16 06:33:45 petere Exp $
9+
* $PostgreSQL: pgsql/src/include/tsearch/ts_public.h,v 1.16 2009/08/18 10:30:41 teodor Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -101,6 +101,7 @@ typedef struct
101101

102102
#define TSL_ADDPOS 0x01
103103
#define TSL_PREFIX 0x02
104+
#define TSL_FILTER 0x04
104105

105106
/*
106107
* Struct for supporting complex dictionaries like thesaurus.

src/test/regress/pg_regress.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
14-
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.63 2009/06/11 14:49:15 momjian Exp $
14+
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.64 2009/08/18 10:30:41 teodor Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -1767,9 +1767,11 @@ create_database(const char *dbname)
17671767
*/
17681768
header(_("creating database \"%s\""), dbname);
17691769
if (encoding)
1770-
psql_command("postgres", "CREATE DATABASE \"%s\" TEMPLATE=template0 ENCODING='%s'", dbname, encoding);
1770+
psql_command("postgres", "CREATE DATABASE \"%s\" TEMPLATE=template0 ENCODING='%s'%s", dbname, encoding,
1771+
(nolocale) ? " LC_COLLATE='C' LC_CTYPE='C'" : "");
17711772
else
1772-
psql_command("postgres", "CREATE DATABASE \"%s\" TEMPLATE=template0", dbname);
1773+
psql_command("postgres", "CREATE DATABASE \"%s\" TEMPLATE=template0%s", dbname,
1774+
(nolocale) ? " LC_COLLATE='C' LC_CTYPE='C'" : "");
17731775
psql_command(dbname,
17741776
"ALTER DATABASE \"%s\" SET lc_messages TO 'C';"
17751777
"ALTER DATABASE \"%s\" SET lc_monetary TO 'C';"

0 commit comments

Comments
 (0)