[PATCH] fix GIN index search sometimes losing results

Pavel Borisov <pashkin.elfe@gmail.com>

From: Pavel Borisov <pashkin.elfe@gmail.com>
To: pgsql-hackers@lists.postgresql.org
Date: 2020-05-07T13:26:17Z
Lists: pgsql-hackers

Attachments

Hi, all

It appeared than GIN index sometimes lose results if simultaneously:


1 if query operand contains weight marks

2 if weight-marked operand is negated by ! operator

3 if there are only logical (not phrase) operators from this negation
towards the root of query tree.


e.g. '!crew:A'::tsquery refuse to find 'crew:BCD'::tsvector


Seems it is in all versions of PG.


The patch is intended to deal with the issue. Also it contains tests for
these rare condition.


Pavel Borisov.

Commits

  1. Replace TS_execute's TS_EXEC_CALC_NOT flag with TS_EXEC_SKIP_NOT.

  2. Fix assorted bugs by changing TS_execute's callback API to ternary logic.