]> granicus.if.org Git - postgresql/commitdiff
Fix generation of too long headline with ShortWords.
authorTeodor Sigaev <teodor@sigaev.ru>
Thu, 15 Jan 2009 18:05:04 +0000 (18:05 +0000)
committerTeodor Sigaev <teodor@sigaev.ru>
Thu, 15 Jan 2009 18:05:04 +0000 (18:05 +0000)
Per http://archives.postgresql.org/pgsql-hackers/2008-09/msg01088.php

contrib/tsearch2/wparser_def.c

index 25e409786e6311dda8d8305f544d8e70622250d9..8e84222dd9dda49b102b6cae49f89466dfd4d492 100644 (file)
@@ -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)