From: pgsql@tomd.cc
To: pgsql-bugs@postgresql.org
Subject: BUG #14515: tsquery with only a negative term doesn't match empty tsvector
Date: Thu, 26 Jan 2017 02:55:24 +0000
Message-ID: <20170126025524.1434.97828@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 14515
Logged by: Tom Dunstan
Email address: pgsql@tomd.cc
PostgreSQL version: 9.5.5
Operating system: Linux
Description:
Hi all
Not sure if this is a bug or just ambiguity in the docs, but I certainly
found it counter-intuitive.
Basically while `select 'somethingelse'::tsvector @@ '!foo'::tsquery`
returns true, `select ''::tsvector @@ '!foo'::tsquery` returns false, which
was surprising to me.
I would expect a tsvector (empty or not) that doesn't contain foo to match
!foo.
It seems like the behaviour is "match a term that isn't foo" rather than
"match if no terms match foo".
Not sure if this is intentional (in which case maybe the docs could be a bit
more clear) or if it's just a bug. IMO the former behaviour isn't very
useful as it forces us to either code around it by writing extra SQL to
handle the case, or insert a dummy term to match against. Neither is very
nice.
It may be unintentional: there's a fast-path out of the match function here
https://github.com/postgres/postgres/blob/f21a563d25dbae153937aec062161184189478b8/src/backend/utils...
that returns false when the vector is empty. Perhaps it just wasn't taking
the negative-only case into account.
Cheers
Tom
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: pgsql@tomd.cc
Subject: Re: BUG #14515: tsquery with only a negative term doesn't match empty tsvector
In-Reply-To: <20170126025524.1434.97828@wrigleys.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