aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/tsearch/wparser_def.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/tsearch/wparser_def.c b/src/backend/tsearch/wparser_def.c
index de6ff79489a..eae1f4f7943 100644
--- a/src/backend/tsearch/wparser_def.c
+++ b/src/backend/tsearch/wparser_def.c
@@ -2038,6 +2038,9 @@ hlCover(HeadlineParsedText *prs, TSQuery query, int max_cover,
nextpmax;
hlCheck ch;
+ if (query->size <= 0)
+ return false; /* empty query matches nothing */
+
/*
* We look for the earliest, shortest substring of prs->words that
* satisfies the query. Both the pmin and pmax indices must be words
@@ -2342,7 +2345,8 @@ mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, bool highlightall,
/* show the first min_words words if we have not marked anything */
if (num_f <= 0)
{
- startpos = endpos = curlen = 0;
+ startpos = curlen = 0;
+ endpos = -1;
for (i = 0; i < prs->curwords && curlen < min_words; i++)
{
if (!NONWORDTOKEN(prs->words[i].type))
@@ -2497,7 +2501,7 @@ mark_hl_words(HeadlineParsedText *prs, TSQuery query, bool highlightall,
if (bestlen < 0)
{
curlen = 0;
- pose = 0;
+ pose = -1;
for (i = 0; i < prs->curwords && curlen < min_words; i++)
{
if (!NONWORDTOKEN(prs->words[i].type))