postgresql/src/backend
Tom Lane 38bb3aef35 Convert tsginidx.c's GIN indexing logic to fully ternary operation.
Commit 2f2007fbb did this partially, but there were two remaining
warts.  checkcondition_gin handled some uncertain cases by setting
the out-of-band recheck flag, some by returning TS_MAYBE, and some
by doing both.  Meanwhile, TS_execute arbitrarily converted a
TS_MAYBE result to TS_YES.  Thus, if checkcondition_gin chose to
only return TS_MAYBE, the outcome would be TS_YES with no recheck
flag, potentially resulting in wrong query outputs.

The case where this'd happen is if there were GIN_MAYBE entries
in the indexscan results passed to gin_tsquery_[tri]consistent,
which so far as I can see would only happen if the tidbitmap used
to accumulate indexscan results grew large enough to become lossy.

I initially thought of fixing this by ensuring we always set the
recheck flag as well as returning TS_MAYBE in uncertain cases.
But that errs in the other direction, potentially forcing rechecks
of rows that provably match the query (since the recheck flag
remains set even if TS_execute later finds that the answer must be
TS_YES).  Instead, let's get rid of the out-of-band recheck flag
altogether and rely on returning TS_MAYBE.  This requires exporting
a version of TS_execute that will actually return the full ternary
result of the evaluation ... but we likely should have done that
to start with.

Unfortunately it doesn't seem practical to add a regression test case
that covers this: the amount of data needed to cause the GIN bitmap to
become lossy results in a longer runtime than I think we want to have
in the tests.  (I'm wondering about allowing smaller work_mem settings
to ameliorate that, but it'd be a matter for a separate patch.)

Per bug #16865 from Dimitri Nüscheler.  Back-patch to v13 where
the faulty commit came in.

Discussion: https://postgr.es/m/16865-4ffdc3e682e6d75b@postgresql.org
2021-02-16 12:07:14 -05:00
..
access Fix heap_page_prune() parameter order confusion introduced in dc7420c2c9. 2021-02-15 17:12:12 -08:00
bootstrap Update copyright for 2021 2021-01-02 13:06:25 -05:00
catalog Allow multiple xacts during table sync in logical replication. 2021-02-12 07:41:51 +05:30
commands Fix the warnings introduced in commit ce0fdbfe97. 2021-02-15 07:28:02 +05:30
executor Simplify loop logic in nodeIncrementalSort.c. 2021-02-15 10:17:58 -05:00
foreign Update copyright for 2021 2021-01-02 13:06:25 -05:00
jit Update copyright for 2021 2021-01-02 13:06:25 -05:00
lib Update copyright for 2021 2021-01-02 13:06:25 -05:00
libpq Add result size as argument of pg_cryptohash_final() for overflow checks 2021-02-15 10:18:34 +09:00
main Update copyright for 2021 2021-01-02 13:06:25 -05:00
nodes Remove [Merge]AppendPath.partitioned_rels. 2021-02-01 14:43:54 -05:00
optimizer Remove [Merge]AppendPath.partitioned_rels. 2021-02-01 14:43:54 -05:00
parser Remove no-longer-used RTE argument of markVarForSelectPriv(). 2021-02-11 11:23:25 -05:00
partitioning Remove [Merge]AppendPath.partitioned_rels. 2021-02-01 14:43:54 -05:00
po Translation updates 2020-05-18 12:49:30 +02:00
port Refactor Windows error message for easier translation 2021-02-04 13:31:13 +01:00
postmaster ReadNewTransactionId() -> ReadNextTransactionId(). 2021-02-15 13:17:02 +13:00
regex Minor fixes to improve regex debugging code. 2021-02-14 19:53:42 -05:00
replication Remove the unnecessary PrepareWrite in pgoutput. 2021-02-16 07:26:50 +05:30
rewrite Revert "Propagate CTE property flags when copying a CTE list into a rule." 2021-02-07 12:54:08 -05:00
snowball Update copyright for 2021 2021-01-02 13:06:25 -05:00
statistics Update copyright for 2021 2021-01-02 13:06:25 -05:00
storage Display the time when the process started waiting for the lock, in pg_locks, take 2 2021-02-15 15:13:37 +09:00
tcop Allow multiple xacts during table sync in logical replication. 2021-02-12 07:41:51 +05:30
tsearch Fix parsing of complex morphs to tsquery 2021-01-31 20:14:29 +03:00
utils Convert tsginidx.c's GIN indexing logic to fully ternary operation. 2021-02-16 12:07:14 -05:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Update copyright for 2021 2021-01-02 13:06:25 -05:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Add missing gettext triggers 2020-04-28 13:35:40 +02:00