diff options
Diffstat (limited to 'src/backend/utils/adt/tsvector_op.c')
-rw-r--r-- | src/backend/utils/adt/tsvector_op.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/backend/utils/adt/tsvector_op.c b/src/backend/utils/adt/tsvector_op.c index 524ade87fed..a5b02cbf559 100644 --- a/src/backend/utils/adt/tsvector_op.c +++ b/src/backend/utils/adt/tsvector_op.c @@ -1325,12 +1325,13 @@ checkcondition_str(void *checkval, QueryOperand *val, ExecPhraseData *data) WordEntry *StopLow = chkval->arrb; WordEntry *StopHigh = chkval->arre; WordEntry *StopMiddle = StopHigh; - int difference = -1; bool res = false; /* Loop invariant: StopLow <= val < StopHigh */ while (StopLow < StopHigh) { + int difference; + StopMiddle = StopLow + (StopHigh - StopLow) / 2; difference = tsCompareString(chkval->operand + val->distance, val->length, @@ -1396,6 +1397,11 @@ checkcondition_str(void *checkval, QueryOperand *val, ExecPhraseData *data) memcpy(allpos + npos, data->pos, sizeof(WordEntryPos) * data->npos); npos += data->npos; } + else + { + /* at loop exit, res must be true if we found matches */ + res = (npos > 0); + } } else { |