diff options
author | Teodor Sigaev <teodor@sigaev.ru> | 2009-01-15 18:16:52 +0000 |
---|---|---|
committer | Teodor Sigaev <teodor@sigaev.ru> | 2009-01-15 18:16:52 +0000 |
commit | 696dbd873d05b7b8d095969eccf53e4333153c46 (patch) | |
tree | ac4b905b9b15e51f7cb1e3d137e7e2ece54712c6 /contrib | |
parent | 0cdeea0e546ec128daa813735d5c59374ea73145 (diff) | |
download | postgresql-696dbd873d05b7b8d095969eccf53e4333153c46.tar.gz postgresql-696dbd873d05b7b8d095969eccf53e4333153c46.zip |
Fix generation of too long headline with ShortWords.
Per http://archives.postgresql.org/pgsql-hackers/2008-09/msg01088.php
Diffstat (limited to 'contrib')
-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 58c5c810355..947c22fc519 100644 --- a/contrib/tsearch2/wparser_def.c +++ b/contrib/tsearch2/wparser_def.c @@ -298,12 +298,14 @@ prsd_headline(PG_FUNCTION_ARGS) 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) |