From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Store empty stavalues when needed for expression statistics.
Date: Wed, 11 Nov 2026 16:04:19 +0000
Message-ID: <E1xRAo7-00000000KfE-2v5r@gemulon.postgresql.org> (raw)
Store empty stavalues when needed for expression statistics.
Commit 261f89a97 changed the API contract for update_attstats()
to store an empty array, not a NULL, if it's passed a nonnull
stavalues pointer along with a zero values count. We missed
that serialize_expr_stats() needs to be kept in sync with that,
so that now we get "unexpected null value" errors if statistics
on an expression hit one of the cases where the statistics
collection code requests that.
Rather than just adjusting serialize_expr_stats() to match, let's
avoid having duplicated code at all, by factoring out a routine
to build a pg_statistic tuple from a VacAttrStats structure.
Bug: #19849
Reported-by: Atish Prakash <125atishprak@gmail.com>
Author: Atish Prakash <125atishprak@gmail.com>
Co-authored-by: Shihao Zhong <zhong950419@gmail.com>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/19849-38b8bd2fea807154@postgresql.org
Backpatch-through: 19
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/ec41a0cf889131d0d71e5c7190f4971acd512392
Modified Files
--------------
src/backend/commands/analyze.c | 201 ++++++++++++++++++--------------
src/backend/statistics/extended_stats.c | 85 +-------------
src/include/commands/vacuum.h | 4 +
src/test/regress/expected/stats_ext.out | 18 +++
src/test/regress/sql/stats_ext.sql | 10 ++
5 files changed, 151 insertions(+), 167 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Store empty stavalues when needed for expression statistics.
In-Reply-To: <E1xRAo7-00000000KfE-2v5r@gemulon.postgresql.org>
References: <E1xRAo7-00000000KfE-2v5r@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox