Subject: pgsql: Fix missed ReleaseVariableStats() in intarray's _int_matchsel().

From: Tom Lane <[email-masked]>
Date: Mon, 25 May 2026 22:16:02 +0000

Fix missed ReleaseVariableStats() in intarray's _int_matchsel().

Given a WHERE clause like "int[] @@ query_int" or "query_int ~~ int[]"
where the query_int side is a table column having statistics,
_int_matchsel() exited without remembering to free the statistics
tuple.  This would typically lead to warnings about cache refcount
leakage, like
  WARNING:  resource was not closed: cache pg_statistic (73), tuple 42/12 has count 1
It's been wrong since this code was added, in commit c6fbe6d6f.

Bug: #19492
Reported-by: Man Zeng <[email-masked]>
Author: Man Zeng <[email-masked]>
Reviewed-by: Tom Lane <[email-masked]>
Discussion: https://postgr.es/m/[email-masked]
Backpatch-through: 14

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/524cc0f638745489f55bafa12f3f93fe8944e027

Modified Files
--------------
contrib/intarray/_int_selfuncs.c | 3 +++
1 file changed, 3 insertions(+)