From: Michael Paquier <michael@paquier.xyz>
To: Corey Huinker <corey.huinker@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Cc: 125atishprak@gmail.com
Subject: Re: BUG #19857: Stats restore rejects empty arrays, losing range and array stats
Date: Thu, 12 Nov 2026 10:26:00 +0900
Message-ID: <avUVqCF7nvfowMQW@paquier.xyz> (raw)
In-Reply-To: <avTu757_g0z96QA2@paquier.xyz>
References: <19857-6e808a09ff4b75d2@postgresql.org>
<CADkLM=dgnnbdMF3T4Him9O+h+-_MArPzZ13SMm4g8LpAXAqmeQ@mail.gmail.com>
<CADkLM=eyZKWTwFYh=Yyi-zqQwmkdZyVJaUD0tijoBZr=OTkFeQ@mail.gmail.com>
<CADkLM=fo1+1LwJo2Jbi3S-MS--4257Q9gA9Pt6tWhwFzzPh8Sg@mail.gmail.com>
<avQcPMvpFykeUGli@paquier.xyz>
<CADkLM=fB1qJJZswCzSs7M=fG3ayXn8hdHy2a6vsAcrgVMVNY-w@mail.gmail.com>
<avTu757_g0z96QA2@paquier.xyz>
On Thu, Nov 12, 2026 at 07:40:47AM +0900, Michael Paquier wrote:
> Yeah, I intend to wrap this one this morning.
Applied this down to v19, to match with the empty array cases that
have been introduced in 261f89a976b.
I think that this leaves an extra case, though... In v17 and v18, it
is possible for range_empty_frac to be stored with
range_length_histogram as NULL. On v19 and HEAD,
range_length_histogram is an empty array, so the two are always set.
The restore functions require the two together when upgrading to 18~,
meaning that some stats values could be lost when upgrading/dumping
the stats from a v17 or v18.
That's one pattern that Atish was mentioning originally in his report,
even if I got a bit lost in my mind due to the dump/upgrade mentions
with v19 and HEAD.
I cannot really get excited to allow this combination in the restore
functions, though, as it means being more lenient on
range_length_histogram forever, and the v19~ decision of using an
empty array is much better to me in the long term. An extra argument
is that this case is super narrow anyway, unlikely to be hit in
practice? As far as I can see, you need a [multi]range column with
less than *2* non-empty values..
I agree that we should move on with fixing the extstats restore
functions, of course, in terms of the handling of the empty array
values, to map now with what the attribute restores are able to do.
And fix this second issue down to v19. Let's do that on the other
thread, we are done here for me.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: michael@paquier.xyz, corey.huinker@gmail.com, 125atishprak@gmail.com
Subject: Re: BUG #19857: Stats restore rejects empty arrays, losing range and array stats
In-Reply-To: <avUVqCF7nvfowMQW@paquier.xyz>
References: <19857-6e808a09ff4b75d2@postgresql.org> <CADkLM=dgnnbdMF3T4Him9O+h+-_MArPzZ13SMm4g8LpAXAqmeQ@mail.gmail.com> <CADkLM=eyZKWTwFYh=Yyi-zqQwmkdZyVJaUD0tijoBZr=OTkFeQ@mail.gmail.com> <CADkLM=fo1+1LwJo2Jbi3S-MS--4257Q9gA9Pt6tWhwFzzPh8Sg@mail.gmail.com> <avQcPMvpFykeUGli@paquier.xyz> <CADkLM=fB1qJJZswCzSs7M=fG3ayXn8hdHy2a6vsAcrgVMVNY-w@mail.gmail.com> <avTu757_g0z96QA2@paquier.xyz> <avUVqCF7nvfowMQW@paquier.xyz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox