pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql@tomd.cc
Cc: pgsql-bugs@postgresql.org, Oleg Bartunov <obartunov@gmail.com>
Cc: Teodor Sigaev <teodor@sigaev.ru>
Subject: Re: BUG #14515: tsquery with only a negative term doesn't match empty tsvector
Date: Thu, 26 Jan 2017 10:36:36 -0500
Message-ID: <3145.1485444996@sss.pgh.pa.us> (raw)
In-Reply-To: <30721.1485401548@sss.pgh.pa.us>
References: <20170126025524.1434.97828@wrigleys.postgresql.org>
	<30721.1485401548@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

I wrote:
> pgsql@tomd.cc writes:
>> Basically while `select 'somethingelse'::tsvector @@ '!foo'::tsquery`
>> returns true, `select ''::tsvector @@ '!foo'::tsquery` returns false, which
>> was surprising to me.

> Not sure about this.  A plausible reading of '!foo' is "there is a lexeme
> that is not foo".  But even if that was Oleg & Teodor's intention,
> I would not want to swear that the tsquery stuff is totally consistent
> about it ...

After further poking at it, I found that a GIN index search will return
empty tsvectors, matching your expectation!  So indeed we are being
inconsistent, which means that there is certainly a bug here no matter
which interpretation you favor.

Also, while a GIST index search doesn't return empty entries, it turns
out that that's only because it always applies recheck, so that the
fast-path exit in ts_match_vq() is what's rejecting the empty value
in that case too.

Otherwise, it seems pretty clear to me that the interpretation (most of?)
the code is using is that "!foo" means "foo does not appear in the value".

A look around at other callers of TS_execute indicate that none of the
rest of them are trying to "optimize" empty value, only empty query.

In short, I now agree both that this is a bug, and that you've correctly
identified the cause.  Will patch.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (4+ messages)  latest in thread

Message-ID: <3145.1485444996@sss.pgh.pa.us>
Permalink:  ../3145.1485444996@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3145.1485444996@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, pgsql@tomd.cc, obartunov@gmail.com, teodor@sigaev.ru
  Subject: Re: BUG #14515: tsquery with only a negative term doesn't match empty tsvector
  In-Reply-To: <3145.1485444996@sss.pgh.pa.us>

* 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