Re: Reject ill-formed range bounds histograms in pg_restore_attribute_stats()

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Ewan Young <kdbase.hack@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Corey Huinker <corey.huinker@gmail.com>
Date: 2026-07-07T08:27:08Z
Lists: pgsql-hackers
On Tue, Jul 07, 2026 at 04:13:30PM +0800, Ewan Young wrote:
> pg_restore_attribute_stats() (and pg_set_attribute_stats()) stores a
> STATISTIC_KIND_BOUNDS_HISTOGRAM verbatim from user input, checking only
> that the argument is a one-dimensional, NULL-free array of the right
> type.  It does not verify the invariant that ANALYZE's
> compute_range_stats() always establishes: the bounds histogram must
> contain no empty ranges, and its lower and upper bounds must each be
> sorted in ascending order.

I'll check that tomorrow.  Thanks for the report.
--
Michael

Commits

  1. Reject oversized MCV lists in pg_restore_extended_stats()