pgsql: Fix import of statistics for domains over [multi]range types and - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Fix import of statistics for domains over [multi]range types and
Date
Msg-id E1xAGHa-00000001HLf-2bJJ@gemulon.postgresql.org
Whole thread
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Doc: clarify there's no log_line_prefix in csvlog or jsonlog out
Next
From: Amit Langote
Date:
Subject: pgsql: Check EXECUTE privilege on functions invoked by the RI fast path