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 <[email protected]>
Reviewed-by: Kirill Reshke <[email protected]>
Reviewed-by: Ayush Tiwari <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/42c6d2bc3f2e28be83bf9fda0bc4ac4f5a597963

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

Reply via email to