Fix uninitialized cache use in gtsvector_picksplit()

When a page split involves two entries, the seed selection loop does not
run and the seeds default to entries 1 and 2.  The cache of the last
entry was filled only after the initial union keys were built from it,
hence the right side of the union could be computed from memory that was
not initialized.  This could cause index scans to miss matching rows.

This issue is fixed by filling the cache of the last entry before
forming the initial unions, by moving around a fillcache().

GiST indexes based on tsvector may need a REINDEX, if these are based on
a single column.

Issue spotted originally by valgrind.

Reported-by: Alexander Lakhin <[email protected]>
Author: Shihao Zhong <[email protected]>
Reviewed-by: Michael Paquier <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 15

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a9faa96b661fb17c5482bf1952a1740ce1622659

Modified Files
--------------
src/backend/utils/adt/tsgistidx.c     |  6 ++++--
src/test/regress/expected/tsearch.out | 17 +++++++++++++++++
src/test/regress/sql/tsearch.sql      | 13 +++++++++++++
3 files changed, 34 insertions(+), 2 deletions(-)

Reply via email to