From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Ensure that a tsquery like '!foo' matches empty tsvectors. |
Date: | 2017-01-26 17:18:21 |
Message-ID: | E1cWngj-0004P0-2W@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-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_2_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/fe6120f9b359d3ac20f235fbf9938bcd850b1598
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(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Simon Riggs | 2017-01-26 18:18:17 | pgsql: Reset hot standby xmin on master after restart |
Previous Message | Robert Haas | 2017-01-26 17:09:05 | Re: [COMMITTERS] pgsql: Reindent table partitioning code. |