Fix YA text phrase search bug.
authorTom Lane <[email protected]>
Thu, 7 May 2020 19:59:52 +0000 (15:59 -0400)
committerTom Lane <[email protected]>
Thu, 7 May 2020 19:59:52 +0000 (15:59 -0400)
commit26cf16a9336101504c17e4bf7f6b6208c71bfa47
treea4dfa85d1c661c1ba725d08246a984818aca7ba7
parent4d21263fffd2d5aebeb2e52dbaaa31d3ba16d51e
Fix YA text phrase search bug.

checkcondition_str() failed to report multiple matches for a prefix
pattern correctly: it would dutifully merge the match positions, but
then after exiting that loop, if the last prefix-matching word had
had no suitable positions, it would report there were no matches.
The upshot would be failing to recognize a match that the query
should match.

It looks like you need all of these conditions to see the bug:
* a phrase search (else we don't ask for match position details)
* a prefix search item (else we don't get to this code)
* a weight restriction (else checkclass_str won't fail)

Noted while investigating a problem report from Pavel Borisov,
though this is distinct from the issue he was on about.

Back-patch to 9.6 where phrase search was added.
src/backend/utils/adt/tsvector_op.c
src/test/regress/expected/tstypes.out
src/test/regress/sql/tstypes.sql