Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: shihao zhong <zhong950419(at)gmail(dot)com>
Cc: Atisss hh <125atishprak(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays
Date: 2026-11-09 05:48:00
Message-ID: avFekPK2YMzo_l6V@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Nov 09, 2026 at 12:10:33AM -0500, shihao zhong wrote:
> Thanks for the report and the patch, Atish. I can reproduce it on
> master and 19rc1, and 18 works.
>
> 0001 is your fix plus the same change for stanumbers. Now
> serialize_expr_stats() matches update_attstats() again.
>
> 0002 adds a test to stats_ext with empty arrays and tsvectors.
>
> This came with 261f89a976b, so it should go to 19 too.

Hmm, yeah, that looks like an oversight in the serialization of the
expression stats, and we should map to a non-NULL check. I would not
call this error a expected:
ERROR: unexpected null value in cached tuple for catalog pg_statistic
column stavalues1

FWIW, I have been puzzled by this failure while looking a bit at the
surroundings of this code for a different bug, just today. when
dealing with empty arrays for MCEs:
https://www.postgresql.org/message-id/avFaBdhb4ONGhIjH%40paquier.xyz
And then noted that this thread already reported something..

Tom, any thoughts?
--
Michael

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Henson Choi 2026-11-09 05:54:05 Re: first_value()/nth_value() with IGNORE NULLS loop forever (EXCLUDE GROUP/TIES, frame past partition end, no ORDER BY)
Previous Message David Rowley 2026-11-09 05:34:43 Re: BUG: SIGSEGV in slot_getsomeattrs_int (populate_isnull_array two-pass deform) on 17.11 and 18.6 -- fix d260d7d was not backpatched below 19