pgsql: Fix uninitialized cache use in gtsvector_picksplit()

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix uninitialized cache use in gtsvector_picksplit()
Date: 2026-11-11 00:31:30
Message-ID: E1xQwFO-00000000ExX-2Vha@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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 <exclusion(at)gmail(dot)com>
Author: Shihao Zhong <zhong950419(at)gmail(dot)com>
Reviewed-by: Michael Paquier <michael(at)paquier(dot)xyz>
Discussion: https://postgr.es/m/19780-93fb5c0e4ec2af18@postgresql.org
Backpatch-through: 15

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1d657c6e013e152ed37b42a22ee9f291179ee50f

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-11-11 00:54:00 pgsql: doc: Remove incorrect libpq environment reference from pg_combin
Previous Message Michael Paquier 2026-11-10 23:36:52 pgsql: Fix restart of interruptible bgworkers after database commands