From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Ensure that a tsquery like '!foo' matches empty tsvectors.
Date: Thu, 26 Jan 2017 17:18:21 +0000
Message-ID: <E1cWngj-0004Oy-2S@gemulon.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>
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
Branch
------
REL9_3_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/2e024f83bd428fe32a2284452f31288c163a1190
Modified Files
--------------
src/backend/utils/adt/tsvector_op.c | 3 +-
src/test/regress/expected/tsearch.out | 137 ++++++++++++++++++++++++++++++++++
src/test/regress/expected/tstypes.out | 12 +++
src/test/regress/sql/tsearch.sql | 33 ++++++++
src/test/regress/sql/tstypes.sql | 3 +
5 files changed, 187 insertions(+), 1 deletion(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Ensure that a tsquery like '!foo' matches empty tsvectors.
In-Reply-To: <E1cWngj-0004Oy-2S@gemulon.postgresql.org>
References: <E1cWngj-0004Oy-2S@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox