From: Teodor Sigaev Date: Tue, 25 Nov 2003 13:40:16 +0000 (+0000) Subject: Ignore too long lexeme X-Git-Tag: REL7_4_1~92 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0527540896ead1ced4acd2d3cef90e4391ea549a;p=postgresql Ignore too long lexeme --- diff --git a/contrib/tsearch2/ts_cfg.c b/contrib/tsearch2/ts_cfg.c index 6ff25b2b16..0898b91924 100644 --- a/contrib/tsearch2/ts_cfg.c +++ b/contrib/tsearch2/ts_cfg.c @@ -21,6 +21,8 @@ #include "common.h" #include "tsvector.h" +#define IGNORE_LONGLEXEME 1 + /*********top interface**********/ static void *plan_getcfg_bylocale = NULL; @@ -288,10 +290,18 @@ parsetext_v2(TSCfgInfo * cfg, PRSTEXT * prs, char *buf, int4 buflen) PointerGetDatum(&lenlemm)))) != 0) { - if (lenlemm >= MAXSTRLEN) + if (lenlemm >= MAXSTRLEN) { +#ifdef IGNORE_LONGLEXEME + ereport(NOTICE, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("word is too long"))); + continue; +#else ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("word is too long"))); +#endif + } if (type >= cfg->len) /* skip this type of lexem */ continue; @@ -414,10 +424,18 @@ hlparsetext(TSCfgInfo * cfg, HLPRSTEXT * prs, QUERYTYPE * query, char *buf, int4 PointerGetDatum(&lenlemm)))) != 0) { - if (lenlemm >= MAXSTRLEN) + if (lenlemm >= MAXSTRLEN) { +#ifdef IGNORE_LONGLEXEME + ereport(NOTICE, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("word is too long"))); + continue; +#else ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("word is too long"))); +#endif + } hladdword(prs, lemm, lenlemm, type);