Re: BUG #16388: Different results when bitmap scan enabled/disabled

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: charlie(at)torqinterface(dot)com
Subject: Re: BUG #16388: Different results when bitmap scan enabled/disabled
Date: 2020-04-25 22:14:33
Message-ID: 16254.1587852873@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
>> When Postgres uses a bitmap heap scan to evaluate a tsquery that includes !,
>> it is giving me different (and incorrect) results compared to when it
>> performs a seqscan.
>> Can anybody shed some light on this?

> It's a bug, without a doubt.

Here's a proposed patch that fixes it as I suggested yesterday, by
converting TS_execute and TS_phrase_execute to use honest ternary
results instead of trying to get by with bool. There's also a minor
bug fix in TS_execute_ternary; that doesn't show up with the one-row
example Charles posted, but it does show up with larger indexes.
I had worried that it might be necessary to change the exposed API
of TS_execute(), but in the event it seems we need not.

Possibly the most controversial aspect of this patch is that I changed
the test data file tsearch.data, by attaching lexeme position info
to a couple dozen rows. Without that, the test_tsvector test table is
next to useless for testing phrase search, since it has no rows with
position data. This does result in minor changes in one existing test
case for ts_stat(), but I see little wrong with that.

Also, the new test cases in tstypes.sql are mostly to ensure that
this patch didn't cause any changes in the behavior of phrase match;
they all pass on the existing code.

(Charles, if you want to test this locally to verify it fixes your
problem, the code changes should apply to v11; though there are a
couple of hunks in the regression test files that will not apply
because they change test stanzas that are new in HEAD.)

regards, tom lane

Attachment Content-Type Size
bug-16388-fix.patch text/x-diff 46.8 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Yang Yingjun(YFPOIT) 2020-04-26 02:12:02 BUG #16384: having trouble while installation
Previous Message Tom Lane 2020-04-25 21:49:40 Re: BUG #16390: Regression between 12.2 and 11.6 on a recursive query : very slow and overestimation of rows