diff options
author | Teodor Sigaev <teodor@sigaev.ru> | 2009-01-15 18:29:47 +0000 |
---|---|---|
committer | Teodor Sigaev <teodor@sigaev.ru> | 2009-01-15 18:29:47 +0000 |
commit | f58cccb0b5b09790a2539845c9e0bfe23c8eca3c (patch) | |
tree | 0ed7cd6e76dcff7efa8dd1f15ed2fb2cc321cd3e | |
parent | b379d53c3055e14fc1cce5a09bc4b4c7471a884f (diff) | |
download | postgresql-f58cccb0b5b09790a2539845c9e0bfe23c8eca3c.tar.gz postgresql-f58cccb0b5b09790a2539845c9e0bfe23c8eca3c.zip |
Fix generation of too long headline with ShortWords.
Per http://archives.postgresql.org/pgsql-hackers/2008-09/msg01088.php
-rw-r--r-- | contrib/tsearch2/wparser_def.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/contrib/tsearch2/wparser_def.c b/contrib/tsearch2/wparser_def.c index 352fae298c4..53199992c8e 100644 --- a/contrib/tsearch2/wparser_def.c +++ b/contrib/tsearch2/wparser_def.c @@ -280,11 +280,13 @@ prsd_headline(PG_FUNCTION_ARGS) break; } if ( curlen < min_words && i>=prs->curwords ) { /* got end of text and our cover is shoter than min_words */ - for(i=p; i>= 0; i--) { + for(i=p-1; i>= 0; i--) { if (!NONWORDTOKEN(prs->words[i].type)) curlen++; if (prs->words[i].item && !prs->words[i].repeated) poslen++; + if ( curlen >= max_words ) + break; if (NOENDTOKEN(prs->words[i].type) || prs->words[i].len <= shortword) continue; if (curlen >= min_words) |