pgsql: Fix possible index corruption in pg_trgm GiST indexes

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix possible index corruption in pg_trgm GiST indexes
Date: 2026-11-04 02:21:11
Message-ID: E1xOQci-0000000065S-17Ea@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix possible index corruption in pg_trgm GiST indexes

Commit 911e7020770, which added configurable signature lengths,
introduced an error in how gist_trgm_ops index entries are combined.
Some entries could lose the flag identifying their format, causing
later inserts to treat them as empty and lose information about
existing entries. As a result, queries using these indexes could
miss matching rows.

Fix this by preserving the format flag when combining index entries,
so that subsequent inserts correctly retain the information they
represent.

This fix does not repair existing indexes. Users should REINDEX all
existing gist_trgm_ops indexes after upgrading to a release containing
this fix.

Backpatch to all supported versions.

Author: Nate Clark <natec425(at)gmail(dot)com>
Reviewed-by: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Reviewed-by: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/19720-b3e83f5e99c485c5@postgresql.org
Backpatch-through: 14

Branch
------
REL_19_STABLE

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

Modified Files
--------------
contrib/pg_trgm/trgm_gist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-11-04 02:21:22 pgsql: Fix memory leaks when freeing WAL readers
Previous Message Fujii Masao 2026-11-04 02:20:49 pgsql: Fix possible index corruption in pg_trgm GiST indexes