agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix import of statistics for domains over [multi]range types and
Date: Sat, 26 Sep 2026 00:28:50 +0000
Message-ID: <E1xAGHa-00000001HLd-2W2X@gemulon.postgresql.org> (raw)
Fix import of statistics for domains over [multi]range types and tsvector
pg_restore_attribute_stats() rejected range_length_histogram,
range_empty_frac and range_bounds_histogram for a column whose type is a
domain over a range or a multirange type. The same issue existed for
most_common_elems and elem_count_histogram for a domain over tsvector.
pg_restore_extended_stats() had the same set of problems for expressions
whose type is a domain over a range, a multirange type, or tsvector.
ANALYZE is able to generate such stats, incorporating the knowledge to
handle domains in the in-core typanalyze callbacks.
This problem is resolved by being more aggressive with the fetch of the
base type of a domain in the early phases of restore for attribute and
extended stats (special tip to Jian He for pointing out the unnecessary
typcache lookups), reflecting on the surrounding helper routines shared
by both code paths. The fix for v18 is local to attribute_stats.c, as
only attribute stats need to be touched.
Tests are included in a fashion consistent with the surroundings. The
consequence of this issue was the rejection of stats that ANALYZE was
able to build, which was not critical but annoying as it would lead to a
gap in the stats restored.
Reported-by: Qifan Liu <imchifan@163.com>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Jian He <jian.universality@gmail.com>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://postgr.es/m/19715-b8be35083016f289@postgresql.org
Backpatch-through: 18
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/aa60617b6931210e78fffb7b45a3a0abcc451afd
Modified Files
--------------
src/backend/statistics/attribute_stats.c | 21 +-
src/backend/statistics/extended_stats_funcs.c | 33 ++-
src/backend/statistics/stat_utils.c | 64 +++--
src/include/statistics/stat_utils.h | 9 +-
src/test/regress/expected/stats_import.out | 332 +++++++++++++++++++++++++-
src/test/regress/sql/stats_import.sql | 251 +++++++++++++++++++
6 files changed, 663 insertions(+), 47 deletions(-)
view thread (3+ messages) latest in thread
Message-ID: <E1xAGHa-00000001HLd-2W2X@gemulon.postgresql.org>
Permalink: ../E1xAGHa-00000001HLd-2W2X@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1xAGHa-00000001HLd-2W2X@gemulon.postgresql.org
reply
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 using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix import of statistics for domains over [multi]range types and
In-Reply-To: <E1xAGHa-00000001HLd-2W2X@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox