Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4ca765f

Browse files
committed
Ignore too long lexeme
1 parent cf87eb4 commit 4ca765f

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

contrib/tsearch2/ts_cfg.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "common.h"
2222
#include "tsvector.h"
2323

24+
#define IGNORE_LONGLEXEME 1
25+
2426
/*********top interface**********/
2527

2628
static void *plan_getcfg_bylocale = NULL;
@@ -288,10 +290,18 @@ parsetext_v2(TSCfgInfo * cfg, PRSTEXT * prs, char *buf, int4 buflen)
288290
PointerGetDatum(&lenlemm)))) != 0)
289291
{
290292

291-
if (lenlemm >= MAXSTRLEN)
293+
if (lenlemm >= MAXSTRLEN) {
294+
#ifdef IGNORE_LONGLEXEME
295+
ereport(NOTICE,
296+
(errcode(ERRCODE_SYNTAX_ERROR),
297+
errmsg("word is too long")));
298+
continue;
299+
#else
292300
ereport(ERROR,
293301
(errcode(ERRCODE_SYNTAX_ERROR),
294302
errmsg("word is too long")));
303+
#endif
304+
}
295305

296306
if (type >= cfg->len) /* skip this type of lexem */
297307
continue;
@@ -414,10 +424,18 @@ hlparsetext(TSCfgInfo * cfg, HLPRSTEXT * prs, QUERYTYPE * query, char *buf, int4
414424
PointerGetDatum(&lenlemm)))) != 0)
415425
{
416426

417-
if (lenlemm >= MAXSTRLEN)
427+
if (lenlemm >= MAXSTRLEN) {
428+
#ifdef IGNORE_LONGLEXEME
429+
ereport(NOTICE,
430+
(errcode(ERRCODE_SYNTAX_ERROR),
431+
errmsg("word is too long")));
432+
continue;
433+
#else
418434
ereport(ERROR,
419435
(errcode(ERRCODE_SYNTAX_ERROR),
420436
errmsg("word is too long")));
437+
#endif
438+
}
421439

422440
hladdword(prs, lemm, lenlemm, type);
423441

0 commit comments

Comments
 (0)