postgres.git / summary / log / commit / refs

commit    90208cc2fbc613ed7bdacd80c064de51378786c1
Author:   Teodor Sigaev <teodor@sigaev.ru>
Date:     Thu Jan 15 17:05:39 2009 +0000
First released in: 7.4.24, 8.0.20, 8.1.16, 8.2.12, 8.3.6

    Fix generation of too long headline with ShortWords.
    Per http://archives.postgresql.org/pgsql-hackers/2008-09/msg01088.php


src/backend/tsearch/wparser_def.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/tsearch/wparser_def.c b/src/backend/tsearch/wparser_def.c index d444b76808b..24f371ab95d 100644 --- a/src/backend/tsearch/wparser_def.c +++ b/src/backend/tsearch/wparser_def.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tsearch/wparser_def.c,v 1.14.2.1 2008/10/17 17:32:59 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/tsearch/wparser_def.c,v 1.14.2.2 2009/01/15 17:05:39 teodor Exp $ * *------------------------------------------------------------------------- */ @@ -1799,12 +1799,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) [parent: 09156de6404b]