From 6599b104c7e09012982bac495afd5cd1405c7c2f Mon Sep 17 00:00:00 2001 From: Teodor Sigaev Date: Tue, 18 Aug 2009 10:30:41 +0000 Subject: [PATCH] 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. --- src/backend/tsearch/ts_parse.c | 14 +++++++++++--- src/include/tsearch/ts_public.h | 1 + src/test/regress/pg_regress.c | 6 ++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/backend/tsearch/ts_parse.c b/src/backend/tsearch/ts_parse.c index 532ae57898..f2440c43d0 100644 --- a/src/backend/tsearch/ts_parse.c +++ b/src/backend/tsearch/ts_parse.c @@ -29,7 +29,6 @@ typedef struct ParsedLex int type; char *lemm; int lenlemm; - bool resfollow; struct ParsedLex *next; } ParsedLex; @@ -189,6 +188,8 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem) while (ld->towork.head) { ParsedLex *curVal = ld->towork.head; + char *curValLemm = curVal->lemm; + int curValLenLemm = curVal->lenlemm; map = ld->cfg->map + curVal->type; @@ -208,8 +209,8 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem) res = (TSLexeme *) DatumGetPointer(FunctionCall4( &(dict->lexize), PointerGetDatum(dict->dictData), - PointerGetDatum(curVal->lemm), - Int32GetDatum(curVal->lenlemm), + PointerGetDatum(curValLemm), + Int32GetDatum(curValLenLemm), PointerGetDatum(&ld->dictState) )); @@ -231,6 +232,13 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem) 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 --git a/src/include/tsearch/ts_public.h b/src/include/tsearch/ts_public.h index 39efab4917..31558d6f3b 100644 --- a/src/include/tsearch/ts_public.h +++ b/src/include/tsearch/ts_public.h @@ -101,6 +101,7 @@ typedef struct #define TSL_ADDPOS 0x01 #define TSL_PREFIX 0x02 +#define TSL_FILTER 0x04 /* * Struct for supporting complex dictionaries like thesaurus. diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index 0a588400ec..f2f9603b21 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -1767,9 +1767,11 @@ create_database(const char *dbname) */ header(_("creating database \"%s\""), dbname); if (encoding) - psql_command("postgres", "CREATE DATABASE \"%s\" TEMPLATE=template0 ENCODING='%s'", dbname, 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", dbname); + 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';" -- 2.39.5