From 524cc0f638745489f55bafa12f3f93fe8944e027 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 25 May 2026 18:15:49 -0400 Subject: [PATCH] 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 Author: Man Zeng Reviewed-by: Tom Lane Discussion: https://postgr.es/m/19492-ddcd0e22399ef85a@postgresql.org Backpatch-through: 14 --- contrib/intarray/_int_selfuncs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/intarray/_int_selfuncs.c b/contrib/intarray/_int_selfuncs.c index 7fce743632f..c0161928074 100644 --- a/contrib/intarray/_int_selfuncs.c +++ b/contrib/intarray/_int_selfuncs.c @@ -151,7 +151,10 @@ _int_matchsel(PG_FUNCTION_ARGS) * query_int. */ if (vardata.vartype != INT4ARRAYOID) + { + ReleaseVariableStats(vardata); PG_RETURN_FLOAT8(DEFAULT_EQ_SEL); + } /* * Can't do anything useful if the something is not a constant, either.