agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: 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-00000001HLf-2bJJ@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_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/753057e340da8f22e57c9a409ea7a235fd6a46bd

Modified Files
--------------
src/backend/statistics/attribute_stats.c   |  85 +++++++++++-----
src/test/regress/expected/stats_import.out | 155 ++++++++++++++++++++++++++++-
src/test/regress/sql/stats_import.sql      | 113 +++++++++++++++++++++
3 files changed, 327 insertions(+), 26 deletions(-)



view thread (3+ messages)

Message-ID: <E1xAGHa-00000001HLf-2bJJ@gemulon.postgresql.org>
Permalink:  ../E1xAGHa-00000001HLf-2bJJ@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xAGHa-00000001HLf-2bJJ@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-00000001HLf-2bJJ@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