]> granicus.if.org Git - postgresql/commit
Ensure that a tsquery like '!foo' matches empty tsvectors.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 26 Jan 2017 17:17:47 +0000 (12:17 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 26 Jan 2017 17:17:47 +0000 (12:17 -0500)
commit2c1976a6cc4bc2447bfd1e422c5b9ebf2a4d893f
tree7b48f31f5a25b6e5d70b795589caa41b334b04a0
parentfb9d2ed6151d1220fc54b86142e3be85ce90ef9d
Ensure that a tsquery like '!foo' matches empty tsvectors.

!foo means "the tsvector does not contain foo", and therefore it should
match an empty tsvector.  ts_match_vq() overenthusiastically supposed
that an empty tsvector could never match any query, so it forcibly
returned FALSE, the wrong answer.  Remove the premature optimization.

Our behavior on this point was inconsistent, because while seqscans and
GIST index searches both failed to match empty tsvectors, GIN index
searches would find them, since GIN scans don't rely on ts_match_vq().
That makes this certainly a bug, not a debatable definition disagreement,
so back-patch to all supported branches.

Report and diagnosis by Tom Dunstan (bug #14515); added test cases by me.

Discussion: https://postgr.es/m/20170126025524.1434.97828@wrigleys.postgresql.org
src/backend/utils/adt/tsvector_op.c
src/test/regress/expected/tsearch.out
src/test/regress/expected/tstypes.out
src/test/regress/sql/tsearch.sql
src/test/regress/sql/tstypes.sql