summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeodor Sigaev <teodor@sigaev.ru>2009-01-15 18:05:04 +0000
committerTeodor Sigaev <teodor@sigaev.ru>2009-01-15 18:05:04 +0000
commitff25ee0c7ad4889bfd3da8a2bfb392aba1b7692b (patch)
tree0de77097d659454fb2c3625e850e0c7d7b2319be
parenta82832465b50ce674de39aa2a9030327f894fdba (diff)
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.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/contrib/tsearch2/wparser_def.c b/contrib/tsearch2/wparser_def.c
index 25e409786e6..8e84222dd9d 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)