Re: BUG #19857: Stats restore rejects empty arrays, losing range and array stats

From: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: 125atishprak(at)gmail(dot)com, Michael Paquier <michael(at)paquier(dot)xyz>
Subject: Re: BUG #19857: Stats restore rejects empty arrays, losing range and array stats
Date: 2026-11-10 21:36:28
Message-ID: CADkLM=eyZKWTwFYh=Yyi-zqQwmkdZyVJaUD0tijoBZr=OTkFeQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>
>
>>
>>
> Looking into this, probably a duplicate of 19842
>

It's definitely a duplicate of 19842, but because it would need to be
backported to 18, we'd want to handle this one first, and build
the 19842-stuff on top of that.

I have relaxed the test in stats_check_required_arg() to allow for empty
arrays, which itself creates a burden of checking the number of dimensions
of an array before asking for the number of vals in the 0th dimension,
which needs to be done twice in attribute_statistics_update_internal() and
nowhere else, mostly because there are only two arrays (most_common_values
and most common_freqs) that need to have an equal number of values (MCELEM
has additional values over its freqs, and range_length_hisotgram is paired
with the scalar range_null_frac as a way to save slots, I presume.

Added additional test cases to show that the length agreement requirement
still works on MCV/MCF when one is empty, and that both store empty arrays
without complaint.

Attachment Content-Type Size
v1-0001-Allow-empty-arrays-as-input-for-pg_restore_attrib.patch text/x-patch 7.0 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2026-11-10 22:33:30 Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays
Previous Message Tom Lane 2026-11-10 18:53:01 Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays