pgsql: Lift range_bounds_histogram requirement in pg_restore_extended_s
pgsql: Lift range_bounds_histogram requirement in pg_restore_extended_s
От:
Michael Paquier <michael@paquier.xyz>
Дата:
Lift range_bounds_histogram requirement in pg_restore_extended_stats() pg_restore_extended_stats() required range_bounds_histogram, range_length_histogram and range_empty_frac to be either all set or all missing for an expression. This is an incorrect assumption, due to: * range_length_histogram and range_empty_frac sharing the STATISTIC_KIND_RANGE_LENGTH_HISTOGRAM slot. * range_bounds_histogram having its own STATISTIC_KIND_BOUNDS_HISTOGRAM slot. Only the first two need to be given together. Note that pg_restore_attribute_stats() already works this way. ANALYZE generates a bounds histogram only when there are at least two non-empty range values, and it always stores the length histogram slot with the fraction of empty ranges. An empty array of values for the histogram is used if there are fewer than two non-empty values. Hence, the statistics of an expression with fewer than two non-empty range values could never be restored, as the bounds histogram was missing. This is a pretty narrow case, unlikely going to be hit in practice. Its consequence was a failure when restoring the statistics of the extstats object being processed, in the shape of a warning and missing stats after an upgrade or the restore of a dump. Issue noticed by Corey, while digging into a separate issue. Author: Corey Huinker Discussion: https://postgr.es/m/19842-ca042326dd2430a4@postgresql.org Backpatch-through: 19 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3700d84c155475b1dd6c81c77ddf4fe46af773fb Modified Files -------------- src/backend/statistics/extended_stats_funcs.c | 20 ++++++----------- src/test/regress/expected/stats_import.out | 31 +++++++++++---------------- src/test/regress/sql/stats_import.sql | 19 ++++++++-------- 3 files changed, 29 insertions(+), 41 deletions(-)