postgres.git / summary / log / commit / refs

commit    8ef710eb30d9848b2b57040dc06d1a762151549f
Author:   Fujii Masao <fujii@postgresql.org>
Date:     Wed Nov 04 02:18:49 2026 +0000
First released in: 14.25, 15.20, 16.16, 17.12, 18.7, 19.0

    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@gmail.com>
    Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
    Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
    Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
    Discussion: https://postgr.es/m/19720-b3e83f5e99c485c5@postgresql.org
    Backpatch-through: 14


contrib/pg_trgm/trgm_gist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/pg_trgm/trgm_gist.c b/contrib/pg_trgm/trgm_gist.c index bd9b9237d9c..50fb381c099 100644 --- a/contrib/pg_trgm/trgm_gist.c +++ b/contrib/pg_trgm/trgm_gist.c @@ -575,7 +575,7 @@ gtrgm_union(PG_FUNCTION_ARGS) { if (unionkey(base, GETENTRY(entryvec, i), siglen)) { - result->flag = ALLISTRUE; + result->flag |= ALLISTRUE; SET_VARSIZE(result, CALCGTSIZE(ALLISTRUE, siglen)); break; } [parent: 4c271dc21606]