PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID16388
PG Version11.7
OSUbuntu
Opened2020-04-24 20:06:41+00
Reported byCharles Offenbacher
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      16388
Logged by:          Charles Offenbacher
Email address:      (redacted)
PostgreSQL version: 11.7
Operating system:   Ubuntu
Description:        

Hi pgsql-bugs,

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? Simply enabling / disabling bitmapscan
changes the query results, which feels like a bug to me. Are there any
workarounds? I found one for my repro below (using NOT) but for some of the
complicated tsquery queries that I have in production, I'm not sure I can
make that work.

CREATE TABLE examples (content text);
CREATE INDEX ts_idx ON examples USING gin(to_tsvector('simple', content));
INSERT INTO examples VALUES ('Example with a word');

/* Incorrectly returns no results */
SET enable_seqscan = OFF;
SET enable_indexscan = OFF;
SET enable_bitmapscan = ON;
SELECT * FROM examples 
WHERE to_tsvector('simple', content) @@ to_tsquery('simple',
'!(example<->word)')

/* Correctly returns results */ 
SET enable_seqscan = OFF;
SET enable_indexscan = OFF;
SET enable_bitmapscan = OFF; /* disabled */
SELECT * FROM examples 
WHERE to_tsvector('simple', content) @@ to_tsquery('simple',
'!(example<->word)')

/* Also correctly returns results by using index and NOT keyword */ 
SET enable_seqscan = OFF;
SET enable_indexscan = OFF;
SET enable_bitmapscan = ON; /* enabled */
SELECT * FROM examples 
WHERE NOT to_tsvector('simple', content) @@ to_tsquery('simple',
'(example<->word)')

Thanks for your time, and any thoughts that you might have to spare.
-Charlie

Messages

DateAuthorSubject
2020-04-24 20:06:41+00PG Bug reporting formBUG #16388: Different results when bitmap scan enabled/disabled
2020-04-25 00:12:31+00Tom LaneRe: BUG #16388: Different results when bitmap scan enabled/disabled
2020-04-25 22:14:33+00Tom LaneRe: BUG #16388: Different results when bitmap scan enabled/disabled