pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #19849: queries fail after ANALYZE with expression stats on arrays
12+ messages / 5 participants
[nested] [flat]

Commits from this thread:
  2026-11-11 44cf2892bb ec41a0cf88  Store empty stavalues when needed for expression statistics.
* BUG #19849: queries fail after ANALYZE with expression stats on arrays
@ 2026-11-07 15:36 PG Bug reporting form <noreply@postgresql.org>
  2026-11-07 15:37 ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Atisss hh <125atishprak@gmail.com>
  0 siblings, 1 reply; 12+ messages in thread

From: PG Bug reporting form @ 2026-11-07 15:36 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: 125atishprak@gmail.com

The following bug has been logged on the website:

Bug reference:      19849
Logged by:          Atish Prakash
Email address:      125atishprak@gmail.com
PostgreSQL version: 18.6
Operating system:   Linux x86_64
Description:        

With extended statistics on an array or tsvector expression, once ANALYZE
finds no
elements common enough to store, queries that use the statistics fail at
planning
time with an internal error. Elements that are all distinct are enough to
trigger
this, as is a column of empty arrays.

    CREATE TABLE tags(id int, a int[]);
    INSERT INTO tags
        SELECT i, ARRAY[i, i + 1000000] FROM generate_series(1, 50000) i;
    CREATE STATISTICS s_a ON (a || a) FROM tags;
    ANALYZE tags;

    SELECT count(*) FROM tags WHERE (a || a) @> '{5}';

Actual, on 19rc1 and master:

    ERROR:  unexpected null value in cached tuple for catalog pg_statistic
column stavalues3

Expected, as on 18.6: the query runs and returns 1.

Also failing the same way:
- (t || t) on text[], with @>
- (v || v) on tsvector, with @@ (the message names stavalues1)
- the array operators && and <@, and = ANY

A range expression with no non-empty values also stores a NULL stavalues,
but the
query I tried, (a * a) && '[1,2)', did not fail.

A plain column with the same data, and an expression index with the same
data, do
not fail.

Cause: commit 261f89a976 ("Track the maximum possible frequency of non-MCE
array
elements") stores a statistics slot even when there are no values. It
changed the
test in update_attstats() from numvalues > 0 to stavalues != NULL, but
serialize_expr_stats() in extended_stats.c still tests numvalues[k] > 0, so
the slot
kind and numbers are stored with a NULL stavalues. get_attstatsslot() then
fails in
SysCacheGetAttrNotNull(). I identified the commit from the code and the
commit
message, and did not bisect.

A possible patch is attached
(0001-fix-expression-stats-empty-stavalues.patch). It
changes that test to match update_attstats(). With it, the queries above
return
correct results on master, and all 239 core regression tests pass. It adds
no new
test.

Found with statistics round-trip tests. I reproduced and checked the result
myself.







^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays
  2026-11-07 15:36 BUG #19849: queries fail after ANALYZE with expression stats on arrays PG Bug reporting form <noreply@postgresql.org>
@ 2026-11-07 15:37 ` Atisss hh <125atishprak@gmail.com>
  2026-11-09 05:10   ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Atisss hh @ 2026-11-07 15:37 UTC (permalink / raw)
  To: 125atishprak@gmail.com; pgsql-bugs@lists.postgresql.org

On Sat, 7 Nov 2026 at 21:07, PG Bug reporting form <noreply@postgresql.org>
wrote:

> The following bug has been logged on the website:
>
> Bug reference:      19849
> Logged by:          Atish Prakash
> Email address:      125atishprak@gmail.com
> PostgreSQL version: 18.6
> Operating system:   Linux x86_64
> Description:
>
> With extended statistics on an array or tsvector expression, once ANALYZE
> finds no
> elements common enough to store, queries that use the statistics fail at
> planning
> time with an internal error. Elements that are all distinct are enough to
> trigger
> this, as is a column of empty arrays.
>
>     CREATE TABLE tags(id int, a int[]);
>     INSERT INTO tags
>         SELECT i, ARRAY[i, i + 1000000] FROM generate_series(1, 50000) i;
>     CREATE STATISTICS s_a ON (a || a) FROM tags;
>     ANALYZE tags;
>
>     SELECT count(*) FROM tags WHERE (a || a) @> '{5}';
>
> Actual, on 19rc1 and master:
>
>     ERROR:  unexpected null value in cached tuple for catalog pg_statistic
> column stavalues3
>
> Expected, as on 18.6: the query runs and returns 1.
>
> Also failing the same way:
> - (t || t) on text[], with @>
> - (v || v) on tsvector, with @@ (the message names stavalues1)
> - the array operators && and <@, and = ANY
>
> A range expression with no non-empty values also stores a NULL stavalues,
> but the
> query I tried, (a * a) && '[1,2)', did not fail.
>
> A plain column with the same data, and an expression index with the same
> data, do
> not fail.
>
> Cause: commit 261f89a976 ("Track the maximum possible frequency of non-MCE
> array
> elements") stores a statistics slot even when there are no values. It
> changed the
> test in update_attstats() from numvalues > 0 to stavalues != NULL, but
> serialize_expr_stats() in extended_stats.c still tests numvalues[k] > 0, so
> the slot
> kind and numbers are stored with a NULL stavalues. get_attstatsslot() then
> fails in
> SysCacheGetAttrNotNull(). I identified the commit from the code and the
> commit
> message, and did not bisect.
>
> A possible patch is attached
> (0001-fix-expression-stats-empty-stavalues.patch). It
> changes that test to match update_attstats(). With it, the queries above
> return
> correct results on master, and all 239 core regression tests pass. It adds
> no new
> test.
>
> Found with statistics round-trip tests. I reproduced and checked the result
> myself.
>
>
>

Attachments:

0001-fix-expression-stats-empty-stavalues.patch (text/x-patch, 493B) download diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index b66a49a6fb..ce5c54507d 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -2427,7 +2427,7 @@ serialize_expr_stats(AnlExprData *exprdata, int nexprs) i = Anum_pg_statistic_stavalues1 - 1; for (k = 0; k < STATISTIC_NUM_SLOTS; k++) { - if (stats->numvalues[k] > 0) + if (stats->stavalues[k] != NULL) { ArrayType *arry;
^ permalink raw reply [nested|flat] 12+ messages in thread

* Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays
  2026-11-07 15:36 BUG #19849: queries fail after ANALYZE with expression stats on arrays PG Bug reporting form <noreply@postgresql.org>
  2026-11-07 15:37 ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Atisss hh <125atishprak@gmail.com>
@ 2026-11-09 05:10   ` shihao zhong <zhong950419@gmail.com>
  2026-11-09 05:48     ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 12+ messages in thread

From: shihao zhong @ 2026-11-09 05:10 UTC (permalink / raw)
  To: Atisss hh <125atishprak@gmail.com>; +Cc: pgsql-bugs@lists.postgresql.org, Tom Lane <tgl@sss.pgh.pa.us>; Michael Paquier <michael@paquier.xyz>

Hi,

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.

Thanks,
Shihao

Attachments: download all (2 files, .tar.gz)

v2-0001-Store-empty-stavalues-for-expression-statistics-as-A.patch (application/octet-stream, 1.5K) download From 9f8bafb25a5543adf09adb02a7d6f25dcca942ca Mon Sep 17 00:00:00 2001 From: Atish Prakash <125atishprak@gmail.com> Date: Sun, 8 Nov 2026 23:44:42 -0500 Subject: [PATCH 1/2] Store empty stavalues for expression statistics, as ANALYZE does Since 261f89a976b a slot can have no values. The planner rejects the NULL we stored then. Co-authored-by: Shihao Zhong <zhong950419@gmail.com> Discussion: https://postgr.es/m/19849-38b8bd2fea807154@postgresql.org --- src/backend/statistics/extended_stats.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index b66a49a6fb5..8537bc1cde2 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -2405,10 +2405,9 @@ serialize_expr_stats(AnlExprData *exprdata, int nexprs) i = Anum_pg_statistic_stanumbers1 - 1; for (k = 0; k < STATISTIC_NUM_SLOTS; k++) { - int nnum = stats->numnumbers[k]; - - if (nnum > 0) + if (stats->stanumbers[k] != NULL) { + int nnum = stats->numnumbers[k]; int n; Datum *numdatums = palloc_array(Datum, nnum); ArrayType *arry; @@ -2427,7 +2426,7 @@ serialize_expr_stats(AnlExprData *exprdata, int nexprs) i = Anum_pg_statistic_stavalues1 - 1; for (k = 0; k < STATISTIC_NUM_SLOTS; k++) { - if (stats->numvalues[k] > 0) + if (stats->stavalues[k] != NULL) { ArrayType *arry; -- 2.37.1 (Apple Git-137.1)
v2-0002-Test-expression-statistics-with-no-common-array-elem.patch (application/octet-stream, 1.9K) download From 23c5e1f71338d9e7403f2cd200a04e0736a2f8c6 Mon Sep 17 00:00:00 2001 From: shihao zhong <zhong950419@gmail.com> Date: Sun, 8 Nov 2026 23:44:42 -0500 Subject: [PATCH 2/2] Test expression statistics with no common array elements Discussion: https://postgr.es/m/19849-38b8bd2fea807154@postgresql.org --- src/test/regress/expected/stats_ext.out | 11 +++++++++++ src/test/regress/sql/stats_ext.sql | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out index 4512670d525..3d7249c5534 100644 --- a/src/test/regress/expected/stats_ext.out +++ b/src/test/regress/expected/stats_ext.out @@ -3738,3 +3738,14 @@ SELECT range_length_histogram, range_empty_frac, range_bounds_histogram (1 row) DROP TABLE stats_ext_tbl_range; +-- Expression statistics on arrays with no elements +CREATE TABLE stats_ext_tbl_mcelem (a int[]); +INSERT INTO stats_ext_tbl_mcelem VALUES ('{}'); +CREATE STATISTICS stats_ext_mcelem ON (a || a) FROM stats_ext_tbl_mcelem; +ANALYZE stats_ext_tbl_mcelem; +SELECT * FROM stats_ext_tbl_mcelem WHERE (a || a) @> '{1}'; + a +--- +(0 rows) + +DROP TABLE stats_ext_tbl_mcelem; diff --git a/src/test/regress/sql/stats_ext.sql b/src/test/regress/sql/stats_ext.sql index a9176e74f3c..1e83813fb8b 100644 --- a/src/test/regress/sql/stats_ext.sql +++ b/src/test/regress/sql/stats_ext.sql @@ -1928,3 +1928,11 @@ SELECT range_length_histogram, range_empty_frac, range_bounds_histogram FROM pg_stats_ext_exprs WHERE statistics_name = 'stats_ext_range'; DROP TABLE stats_ext_tbl_range; + +-- Expression statistics on arrays with no elements +CREATE TABLE stats_ext_tbl_mcelem (a int[]); +INSERT INTO stats_ext_tbl_mcelem VALUES ('{}'); +CREATE STATISTICS stats_ext_mcelem ON (a || a) FROM stats_ext_tbl_mcelem; +ANALYZE stats_ext_tbl_mcelem; +SELECT * FROM stats_ext_tbl_mcelem WHERE (a || a) @> '{1}'; +DROP TABLE stats_ext_tbl_mcelem; -- 2.37.1 (Apple Git-137.1)
^ permalink raw reply [nested|flat] 12+ messages in thread

* Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays
  2026-11-07 15:36 BUG #19849: queries fail after ANALYZE with expression stats on arrays PG Bug reporting form <noreply@postgresql.org>
  2026-11-07 15:37 ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Atisss hh <125atishprak@gmail.com>
  2026-11-09 05:10   ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
@ 2026-11-09 05:48     ` Michael Paquier <michael@paquier.xyz>
  2026-11-09 19:43       ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 12+ messages in thread

From: Michael Paquier @ 2026-11-09 05:48 UTC (permalink / raw)
  To: shihao zhong <zhong950419@gmail.com>; +Cc: Atisss hh <125atishprak@gmail.com>; pgsql-bugs@lists.postgresql.org, Tom Lane <tgl@sss.pgh.pa.us>

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

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays
  2026-11-07 15:36 BUG #19849: queries fail after ANALYZE with expression stats on arrays PG Bug reporting form <noreply@postgresql.org>
  2026-11-07 15:37 ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Atisss hh <125atishprak@gmail.com>
  2026-11-09 05:10   ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  2026-11-09 05:48     ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
@ 2026-11-09 19:43       ` Tom Lane <tgl@sss.pgh.pa.us>
  2026-11-09 23:09         ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Tom Lane @ 2026-11-09 19:43 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: shihao zhong <zhong950419@gmail.com>; Atisss hh <125atishprak@gmail.com>; pgsql-bugs@lists.postgresql.org

Michael Paquier <michael@paquier.xyz> writes:
> On Mon, Nov 09, 2026 at 12:10:33AM -0500, shihao zhong wrote:
>> 0001 is your fix plus the same change for stanumbers. Now
>> serialize_expr_stats() matches update_attstats() again.

Ugh.

> Tom, any thoughts?

I think it's unfortunate that we have two copies of largely the same
code that have to be kept in sync.  At the very least we ought to
install comments warning of that in both places.  But I wonder if
it's practical to refactor so that there's just one copy?

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays
  2026-11-07 15:36 BUG #19849: queries fail after ANALYZE with expression stats on arrays PG Bug reporting form <noreply@postgresql.org>
  2026-11-07 15:37 ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Atisss hh <125atishprak@gmail.com>
  2026-11-09 05:10   ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  2026-11-09 05:48     ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  2026-11-09 19:43       ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Tom Lane <tgl@sss.pgh.pa.us>
@ 2026-11-09 23:09         ` shihao zhong <zhong950419@gmail.com>
  2026-11-10 06:10           ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 12+ messages in thread

From: shihao zhong @ 2026-11-09 23:09 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Michael Paquier <michael@paquier.xyz>; Atisss hh <125atishprak@gmail.com>; pgsql-bugs@lists.postgresql.org

Hi folks,

Thanks for reviewing my patch.

> But I wonder if
> it's practical to refactor so that there's just one copy?

Thanks, Tom. The refactor turned out to be small. The code that fills
in the pg_statistic columns can move into one function in analyze.c,
and both places call it.

v3-00x goes to master
v3-REL_19 goes to 19

Thanks,
Shihao

Attachments: download all (5 files, .tar.gz)

v3-0001-Store-empty-stavalues-for-expression-statistics-a.patch (application/octet-stream, 2.7K) download From 8fe8176fa9fe62e4ff541154a2edc4f970a62acf Mon Sep 17 00:00:00 2001 From: Atish Prakash <125atishprak@gmail.com> Date: Sun, 8 Nov 2026 23:44:42 -0500 Subject: [PATCH v3 1/3] Store empty stavalues for expression statistics, as ANALYZE does Since 261f89a976b a slot can have no values. update_attstats() stores an empty array then, but serialize_expr_stats() still stored a NULL, which the planner rejects. The two functions build pg_statistic tuples the same way. Add comments to both saying they must be kept in sync. Co-authored-by: Shihao Zhong <zhong950419@gmail.com> Discussion: https://postgr.es/m/19849-38b8bd2fea807154@postgresql.org --- src/backend/commands/analyze.c | 5 ++++- src/backend/statistics/extended_stats.c | 14 +++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 518d7526255..ab3848443a7 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -1764,7 +1764,10 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats) continue; /* - * Construct a new pg_statistic tuple + * Construct a new pg_statistic tuple. + * + * serialize_expr_stats() in extended_stats.c builds pg_statistic + * tuples the same way, so keep the two in sync. */ for (i = 0; i < Natts_pg_statistic; ++i) { diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index b66a49a6fb5..14652a36331 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -2333,7 +2333,12 @@ build_expr_data(List *exprs, int stattarget) return exprdata; } -/* form an array of pg_statistic rows (per update_attstats) */ +/* + * Form an array of pg_statistic rows, one per expression. + * + * Each row is built the same way update_attstats() in analyze.c builds + * it, so keep the two in sync. + */ static Datum serialize_expr_stats(AnlExprData *exprdata, int nexprs) { @@ -2405,10 +2410,9 @@ serialize_expr_stats(AnlExprData *exprdata, int nexprs) i = Anum_pg_statistic_stanumbers1 - 1; for (k = 0; k < STATISTIC_NUM_SLOTS; k++) { - int nnum = stats->numnumbers[k]; - - if (nnum > 0) + if (stats->stanumbers[k] != NULL) { + int nnum = stats->numnumbers[k]; int n; Datum *numdatums = palloc_array(Datum, nnum); ArrayType *arry; @@ -2427,7 +2431,7 @@ serialize_expr_stats(AnlExprData *exprdata, int nexprs) i = Anum_pg_statistic_stavalues1 - 1; for (k = 0; k < STATISTIC_NUM_SLOTS; k++) { - if (stats->numvalues[k] > 0) + if (stats->stavalues[k] != NULL) { ArrayType *arry; -- 2.37.1 (Apple Git-137.1)
v3-0002-Test-expression-statistics-with-no-common-array-e.patch (application/octet-stream, 1.9K) download From d841bc637bf77237f579f00bc56e6ca37f41f6d4 Mon Sep 17 00:00:00 2001 From: shihao zhong <zhong950419@gmail.com> Date: Sun, 8 Nov 2026 23:44:42 -0500 Subject: [PATCH v3 2/3] Test expression statistics with no common array elements Discussion: https://postgr.es/m/19849-38b8bd2fea807154@postgresql.org --- src/test/regress/expected/stats_ext.out | 11 +++++++++++ src/test/regress/sql/stats_ext.sql | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out index 5b4bcfae4e2..910521e5ed5 100644 --- a/src/test/regress/expected/stats_ext.out +++ b/src/test/regress/expected/stats_ext.out @@ -3760,3 +3760,14 @@ SELECT range_length_histogram, range_empty_frac, range_bounds_histogram (1 row) DROP TABLE stats_ext_tbl_range; +-- Expression statistics on arrays with no elements +CREATE TABLE stats_ext_tbl_mcelem (a int[]); +INSERT INTO stats_ext_tbl_mcelem VALUES ('{}'); +CREATE STATISTICS stats_ext_mcelem ON (a || a) FROM stats_ext_tbl_mcelem; +ANALYZE stats_ext_tbl_mcelem; +SELECT * FROM stats_ext_tbl_mcelem WHERE (a || a) @> '{1}'; + a +--- +(0 rows) + +DROP TABLE stats_ext_tbl_mcelem; diff --git a/src/test/regress/sql/stats_ext.sql b/src/test/regress/sql/stats_ext.sql index 083a55fed2f..45fad70a84c 100644 --- a/src/test/regress/sql/stats_ext.sql +++ b/src/test/regress/sql/stats_ext.sql @@ -1944,3 +1944,11 @@ SELECT range_length_histogram, range_empty_frac, range_bounds_histogram FROM pg_stats_ext_exprs WHERE statistics_name = 'stats_ext_range'; DROP TABLE stats_ext_tbl_range; + +-- Expression statistics on arrays with no elements +CREATE TABLE stats_ext_tbl_mcelem (a int[]); +INSERT INTO stats_ext_tbl_mcelem VALUES ('{}'); +CREATE STATISTICS stats_ext_mcelem ON (a || a) FROM stats_ext_tbl_mcelem; +ANALYZE stats_ext_tbl_mcelem; +SELECT * FROM stats_ext_tbl_mcelem WHERE (a || a) @> '{1}'; +DROP TABLE stats_ext_tbl_mcelem; -- 2.37.1 (Apple Git-137.1)
v3-REL_19-0002-Test-expression-statistics-with-no-common-array-e.patch (application/octet-stream, 1.9K) download From d37b9dcff807e9513dafb646d9060667d13d3547 Mon Sep 17 00:00:00 2001 From: shihao zhong <zhong950419@gmail.com> Date: Sun, 8 Nov 2026 23:44:42 -0500 Subject: [PATCH REL_19 v3 2/2] Test expression statistics with no common array elements Discussion: https://postgr.es/m/19849-38b8bd2fea807154@postgresql.org --- src/test/regress/expected/stats_ext.out | 11 +++++++++++ src/test/regress/sql/stats_ext.sql | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out index 5b4bcfae4e2..910521e5ed5 100644 --- a/src/test/regress/expected/stats_ext.out +++ b/src/test/regress/expected/stats_ext.out @@ -3760,3 +3760,14 @@ SELECT range_length_histogram, range_empty_frac, range_bounds_histogram (1 row) DROP TABLE stats_ext_tbl_range; +-- Expression statistics on arrays with no elements +CREATE TABLE stats_ext_tbl_mcelem (a int[]); +INSERT INTO stats_ext_tbl_mcelem VALUES ('{}'); +CREATE STATISTICS stats_ext_mcelem ON (a || a) FROM stats_ext_tbl_mcelem; +ANALYZE stats_ext_tbl_mcelem; +SELECT * FROM stats_ext_tbl_mcelem WHERE (a || a) @> '{1}'; + a +--- +(0 rows) + +DROP TABLE stats_ext_tbl_mcelem; diff --git a/src/test/regress/sql/stats_ext.sql b/src/test/regress/sql/stats_ext.sql index 083a55fed2f..45fad70a84c 100644 --- a/src/test/regress/sql/stats_ext.sql +++ b/src/test/regress/sql/stats_ext.sql @@ -1944,3 +1944,11 @@ SELECT range_length_histogram, range_empty_frac, range_bounds_histogram FROM pg_stats_ext_exprs WHERE statistics_name = 'stats_ext_range'; DROP TABLE stats_ext_tbl_range; + +-- Expression statistics on arrays with no elements +CREATE TABLE stats_ext_tbl_mcelem (a int[]); +INSERT INTO stats_ext_tbl_mcelem VALUES ('{}'); +CREATE STATISTICS stats_ext_mcelem ON (a || a) FROM stats_ext_tbl_mcelem; +ANALYZE stats_ext_tbl_mcelem; +SELECT * FROM stats_ext_tbl_mcelem WHERE (a || a) @> '{1}'; +DROP TABLE stats_ext_tbl_mcelem; -- 2.37.1 (Apple Git-137.1)
v3-REL_19-0001-Store-empty-stavalues-for-expression-statistics-a.patch (application/octet-stream, 2.7K) download From d0cf1bd1dc5e812330c633fb2f13f039463179a3 Mon Sep 17 00:00:00 2001 From: Atish Prakash <125atishprak@gmail.com> Date: Sun, 8 Nov 2026 23:44:42 -0500 Subject: [PATCH REL_19 v3 1/2] Store empty stavalues for expression statistics, as ANALYZE does Since 261f89a976b a slot can have no values. update_attstats() stores an empty array then, but serialize_expr_stats() still stored a NULL, which the planner rejects. The two functions build pg_statistic tuples the same way. Add comments to both saying they must be kept in sync. Co-authored-by: Shihao Zhong <zhong950419@gmail.com> Discussion: https://postgr.es/m/19849-38b8bd2fea807154@postgresql.org --- src/backend/commands/analyze.c | 5 ++++- src/backend/statistics/extended_stats.c | 14 +++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index e7f664e4f89..cd5c95d957e 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -1766,7 +1766,10 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats) continue; /* - * Construct a new pg_statistic tuple + * Construct a new pg_statistic tuple. + * + * serialize_expr_stats() in extended_stats.c builds pg_statistic + * tuples the same way, so keep the two in sync. */ for (i = 0; i < Natts_pg_statistic; ++i) { diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index 1f9a25a3af0..f12d49bda4c 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -2339,7 +2339,12 @@ build_expr_data(List *exprs, int stattarget) return exprdata; } -/* form an array of pg_statistic rows (per update_attstats) */ +/* + * Form an array of pg_statistic rows, one per expression. + * + * Each row is built the same way update_attstats() in analyze.c builds + * it, so keep the two in sync. + */ static Datum serialize_expr_stats(AnlExprData *exprdata, int nexprs) { @@ -2411,10 +2416,9 @@ serialize_expr_stats(AnlExprData *exprdata, int nexprs) i = Anum_pg_statistic_stanumbers1 - 1; for (k = 0; k < STATISTIC_NUM_SLOTS; k++) { - int nnum = stats->numnumbers[k]; - - if (nnum > 0) + if (stats->stanumbers[k] != NULL) { + int nnum = stats->numnumbers[k]; int n; Datum *numdatums = (Datum *) palloc(nnum * sizeof(Datum)); ArrayType *arry; @@ -2433,7 +2437,7 @@ serialize_expr_stats(AnlExprData *exprdata, int nexprs) i = Anum_pg_statistic_stavalues1 - 1; for (k = 0; k < STATISTIC_NUM_SLOTS; k++) { - if (stats->numvalues[k] > 0) + if (stats->stavalues[k] != NULL) { ArrayType *arry; -- 2.37.1 (Apple Git-137.1)
v3-0003-Share-the-pg_statistic-tuple-building-code-with-e.patch (application/octet-stream, 10.2K) download From a1af0362f1215d5e6f2027888ff47ff7c35e9bac Mon Sep 17 00:00:00 2001 From: shihao zhong <zhong950419@gmail.com> Date: Mon, 9 Nov 2026 17:04:25 -0500 Subject: [PATCH v3 3/3] Share the pg_statistic tuple building code with expression stats update_attstats() and serialize_expr_stats() had two copies of the code that turns a VacAttrStats into pg_statistic column values. Bug #19849 came from changing only one of them. Move that code into a new function, fill_attstats_values(), and call it from both places. No behavior change. Discussion: https://postgr.es/m/19849-38b8bd2fea807154@postgresql.org --- src/backend/commands/analyze.c | 153 +++++++++++++----------- src/backend/statistics/extended_stats.c | 78 +----------- src/include/commands/vacuum.h | 2 + 3 files changed, 88 insertions(+), 145 deletions(-) diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index ab3848443a7..d5a3b2e9cef 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -1713,6 +1713,87 @@ acquire_inherited_sample_rows(Relation onerel, int elevel, } +/* + * fill_attstats_values() -- fill in pg_statistic columns from a VacAttrStats + * + * values[] and nulls[] must have room for Natts_pg_statistic entries. All + * columns are filled in except starelid, staattnum and stainherit, which + * the caller must set. This is used both for regular column statistics and + * for statistics on the expressions of extended statistics objects. + */ +void +fill_attstats_values(VacAttrStats *stats, Datum *values, bool *nulls) +{ + int i, + k; + + for (i = 0; i < Natts_pg_statistic; ++i) + { + nulls[i] = false; + values[i] = (Datum) 0; + } + + values[Anum_pg_statistic_stanullfrac - 1] = Float4GetDatum(stats->stanullfrac); + values[Anum_pg_statistic_stawidth - 1] = Int32GetDatum(stats->stawidth); + values[Anum_pg_statistic_stadistinct - 1] = Float4GetDatum(stats->stadistinct); + i = Anum_pg_statistic_stakind1 - 1; + for (k = 0; k < STATISTIC_NUM_SLOTS; k++) + { + values[i++] = Int16GetDatum(stats->stakind[k]); /* stakindN */ + } + i = Anum_pg_statistic_staop1 - 1; + for (k = 0; k < STATISTIC_NUM_SLOTS; k++) + { + values[i++] = ObjectIdGetDatum(stats->staop[k]); /* staopN */ + } + i = Anum_pg_statistic_stacoll1 - 1; + for (k = 0; k < STATISTIC_NUM_SLOTS; k++) + { + values[i++] = ObjectIdGetDatum(stats->stacoll[k]); /* stacollN */ + } + i = Anum_pg_statistic_stanumbers1 - 1; + for (k = 0; k < STATISTIC_NUM_SLOTS; k++) + { + if (stats->stanumbers[k] != NULL) + { + int nnum = stats->numnumbers[k]; + Datum *numdatums = palloc_array(Datum, nnum); + ArrayType *arry; + + for (int n = 0; n < nnum; n++) + numdatums[n] = Float4GetDatum(stats->stanumbers[k][n]); + arry = construct_array_builtin(numdatums, nnum, FLOAT4OID); + values[i++] = PointerGetDatum(arry); /* stanumbersN */ + } + else + { + nulls[i] = true; + values[i++] = (Datum) 0; + } + } + i = Anum_pg_statistic_stavalues1 - 1; + for (k = 0; k < STATISTIC_NUM_SLOTS; k++) + { + if (stats->stavalues[k] != NULL) + { + ArrayType *arry; + + arry = construct_array(stats->stavalues[k], + stats->numvalues[k], + stats->statypid[k], + stats->statyplen[k], + stats->statypbyval[k], + stats->statypalign[k]); + values[i++] = PointerGetDatum(arry); /* stavaluesN */ + } + else + { + nulls[i] = true; + values[i++] = (Datum) 0; + } + } +} + /* * update_attstats() -- update attribute statistics for one relation * @@ -1752,9 +1833,7 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats) VacAttrStats *stats = vacattrstats[attno]; HeapTuple stup, oldtup; - int i, - k, - n; + int i; Datum values[Natts_pg_statistic]; bool nulls[Natts_pg_statistic]; bool replaces[Natts_pg_statistic]; @@ -1764,79 +1843,15 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats) continue; /* - * Construct a new pg_statistic tuple. - * - * serialize_expr_stats() in extended_stats.c builds pg_statistic - * tuples the same way, so keep the two in sync. + * Construct a new pg_statistic tuple */ for (i = 0; i < Natts_pg_statistic; ++i) - { - nulls[i] = false; replaces[i] = true; - } + fill_attstats_values(stats, values, nulls); values[Anum_pg_statistic_starelid - 1] = ObjectIdGetDatum(relid); values[Anum_pg_statistic_staattnum - 1] = Int16GetDatum(stats->tupattnum); values[Anum_pg_statistic_stainherit - 1] = BoolGetDatum(inh); - values[Anum_pg_statistic_stanullfrac - 1] = Float4GetDatum(stats->stanullfrac); - values[Anum_pg_statistic_stawidth - 1] = Int32GetDatum(stats->stawidth); - values[Anum_pg_statistic_stadistinct - 1] = Float4GetDatum(stats->stadistinct); - i = Anum_pg_statistic_stakind1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - values[i++] = Int16GetDatum(stats->stakind[k]); /* stakindN */ - } - i = Anum_pg_statistic_staop1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - values[i++] = ObjectIdGetDatum(stats->staop[k]); /* staopN */ - } - i = Anum_pg_statistic_stacoll1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - values[i++] = ObjectIdGetDatum(stats->stacoll[k]); /* stacollN */ - } - i = Anum_pg_statistic_stanumbers1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - if (stats->stanumbers[k] != NULL) - { - int nnum = stats->numnumbers[k]; - Datum *numdatums = palloc_array(Datum, nnum); - ArrayType *arry; - - for (n = 0; n < nnum; n++) - numdatums[n] = Float4GetDatum(stats->stanumbers[k][n]); - arry = construct_array_builtin(numdatums, nnum, FLOAT4OID); - values[i++] = PointerGetDatum(arry); /* stanumbersN */ - } - else - { - nulls[i] = true; - values[i++] = (Datum) 0; - } - } - i = Anum_pg_statistic_stavalues1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - if (stats->stavalues[k] != NULL) - { - ArrayType *arry; - - arry = construct_array(stats->stavalues[k], - stats->numvalues[k], - stats->statypid[k], - stats->statyplen[k], - stats->statypbyval[k], - stats->statypalign[k]); - values[i++] = PointerGetDatum(arry); /* stavaluesN */ - } - else - { - nulls[i] = true; - values[i++] = (Datum) 0; - } - } /* Is there already a pg_statistic tuple for this attribute? */ oldtup = SearchSysCache3(STATRELATTINH, diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index 14652a36331..6211b23d729 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -2333,12 +2333,7 @@ build_expr_data(List *exprs, int stattarget) return exprdata; } -/* - * Form an array of pg_statistic rows, one per expression. - * - * Each row is built the same way update_attstats() in analyze.c builds - * it, so keep the two in sync. - */ +/* form an array of pg_statistic rows, one per expression */ static Datum serialize_expr_stats(AnlExprData *exprdata, int nexprs) { @@ -2360,8 +2355,6 @@ serialize_expr_stats(AnlExprData *exprdata, int nexprs) for (exprno = 0; exprno < nexprs; exprno++) { - int i, - k; VacAttrStats *stats = exprdata[exprno].vacattrstat; Datum values[Natts_pg_statistic]; @@ -2378,77 +2371,10 @@ serialize_expr_stats(AnlExprData *exprdata, int nexprs) continue; } - /* - * Construct a new pg_statistic tuple - */ - for (i = 0; i < Natts_pg_statistic; ++i) - { - nulls[i] = false; - } - + fill_attstats_values(stats, values, nulls); values[Anum_pg_statistic_starelid - 1] = ObjectIdGetDatum(InvalidOid); values[Anum_pg_statistic_staattnum - 1] = Int16GetDatum(InvalidAttrNumber); values[Anum_pg_statistic_stainherit - 1] = BoolGetDatum(false); - values[Anum_pg_statistic_stanullfrac - 1] = Float4GetDatum(stats->stanullfrac); - values[Anum_pg_statistic_stawidth - 1] = Int32GetDatum(stats->stawidth); - values[Anum_pg_statistic_stadistinct - 1] = Float4GetDatum(stats->stadistinct); - i = Anum_pg_statistic_stakind1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - values[i++] = Int16GetDatum(stats->stakind[k]); /* stakindN */ - } - i = Anum_pg_statistic_staop1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - values[i++] = ObjectIdGetDatum(stats->staop[k]); /* staopN */ - } - i = Anum_pg_statistic_stacoll1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - values[i++] = ObjectIdGetDatum(stats->stacoll[k]); /* stacollN */ - } - i = Anum_pg_statistic_stanumbers1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - if (stats->stanumbers[k] != NULL) - { - int nnum = stats->numnumbers[k]; - int n; - Datum *numdatums = palloc_array(Datum, nnum); - ArrayType *arry; - - for (n = 0; n < nnum; n++) - numdatums[n] = Float4GetDatum(stats->stanumbers[k][n]); - arry = construct_array_builtin(numdatums, nnum, FLOAT4OID); - values[i++] = PointerGetDatum(arry); /* stanumbersN */ - } - else - { - nulls[i] = true; - values[i++] = (Datum) 0; - } - } - i = Anum_pg_statistic_stavalues1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - if (stats->stavalues[k] != NULL) - { - ArrayType *arry; - - arry = construct_array(stats->stavalues[k], - stats->numvalues[k], - stats->statypid[k], - stats->statyplen[k], - stats->statypbyval[k], - stats->statypalign[k]); - values[i++] = PointerGetDatum(arry); /* stavaluesN */ - } - else - { - nulls[i] = true; - values[i++] = (Datum) 0; - } - } stup = heap_form_tuple(RelationGetDescr(sd), values, nulls); diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h index 89fa1fcd261..333d6451c2f 100644 --- a/src/include/commands/vacuum.h +++ b/src/include/commands/vacuum.h @@ -442,6 +442,8 @@ extern void analyze_rel(Oid relid, RangeVar *relation, extern bool attribute_is_analyzable(Relation onerel, int attnum, Form_pg_attribute attr, int *p_attstattarget); extern bool std_typanalyze(VacAttrStats *stats); +extern void fill_attstats_values(VacAttrStats *stats, Datum *values, + bool *nulls); /* in utils/misc/sampling.c --- duplicate of declarations in utils/sampling.h */ extern double anl_random_fract(void); -- 2.37.1 (Apple Git-137.1)
^ permalink raw reply [nested|flat] 12+ messages in thread

* Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays
  2026-11-07 15:36 BUG #19849: queries fail after ANALYZE with expression stats on arrays PG Bug reporting form <noreply@postgresql.org>
  2026-11-07 15:37 ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Atisss hh <125atishprak@gmail.com>
  2026-11-09 05:10   ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  2026-11-09 05:48     ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  2026-11-09 19:43       ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Tom Lane <tgl@sss.pgh.pa.us>
  2026-11-09 23:09         ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
@ 2026-11-10 06:10           ` Michael Paquier <michael@paquier.xyz>
  2026-11-10 18:53             ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 12+ messages in thread

From: Michael Paquier @ 2026-11-10 06:10 UTC (permalink / raw)
  To: shihao zhong <zhong950419@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Atisss hh <125atishprak@gmail.com>; pgsql-bugs@lists.postgresql.org

On Mon, Nov 09, 2026 at 06:09:19PM -0500, shihao zhong wrote:
> Thanks, Tom. The refactor turned out to be small. The code that fills
> in the pg_statistic columns can move into one function in analyze.c,
> and both places call it.

v3-0003's code cut looks tempting.  That would have prevented the
original issue.

@@ -2333,12 +2333,7 @@ build_expr_data(List *exprs, int stattarget)
         values[Anum_pg_statistic_starelid - 1] = ObjectIdGetDatum(InvalidOid);
         values[Anum_pg_statistic_staattnum - 1] = Int16GetDatum(InvalidAttrNumber);
         values[Anum_pg_statistic_stainherit - 1] = BoolGetDatum(false);
[...]
@@ -1764,79 +1843,15 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats)
         values[Anum_pg_statistic_starelid - 1] = ObjectIdGetDatum(relid);
         values[Anum_pg_statistic_staattnum - 1] = Int16GetDatum(stats->tupattnum);
         values[Anum_pg_statistic_stainherit - 1] = BoolGetDatum(inh);

These two could also be passed down as arguments of your new
fill_attstats_values(), filling them within the routine instead of
letting the two callers do it.

+ * values[] and nulls[] must have room for Natts_pg_statistic entries.  All

One thing that always stresses me with this kind of assumption is that
an error means an out-of-bound write, and a CVE.  Here, we could also
use a palloc0'ed area worth Natts_pg_statistic, instead of expecting
the caller to do the right thing.  The ANALYZE and expression stats
code paths are not performance-critical.  Or ubsan would just catch
any problems?
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays
  2026-11-07 15:36 BUG #19849: queries fail after ANALYZE with expression stats on arrays PG Bug reporting form <noreply@postgresql.org>
  2026-11-07 15:37 ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Atisss hh <125atishprak@gmail.com>
  2026-11-09 05:10   ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  2026-11-09 05:48     ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  2026-11-09 19:43       ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Tom Lane <tgl@sss.pgh.pa.us>
  2026-11-09 23:09         ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  2026-11-10 06:10           ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
@ 2026-11-10 18:53             ` Tom Lane <tgl@sss.pgh.pa.us>
  2026-11-10 22:33               ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 12+ messages in thread

From: Tom Lane @ 2026-11-10 18:53 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: shihao zhong <zhong950419@gmail.com>; Atisss hh <125atishprak@gmail.com>; pgsql-bugs@lists.postgresql.org

Michael Paquier <michael@paquier.xyz> writes:
> These two could also be passed down as arguments of your new
> fill_attstats_values(), filling them within the routine instead of
> letting the two callers do it.
> + * values[] and nulls[] must have room for Natts_pg_statistic entries.  All
> One thing that always stresses me with this kind of assumption is that
> an error means an out-of-bound write, and a CVE.  Here, we could also
> use a palloc0'ed area worth Natts_pg_statistic, instead of expecting
> the caller to do the right thing.  The ANALYZE and expression stats
> code paths are not performance-critical.  Or ubsan would just catch
> any problems?

Yeah, I didn't love this particular refactorization either.  I think
it'd be nicer to have the values[] and nulls[] arrays totally inside
the shared function and do the tuple-building within it, as attached.

One thing that bugs me slightly about this is that it seems weird to
be passing starelid and stainherit explicitly while digging staattnum
out of the VacAttrStats struct.  It works, because examine_expression
is careful to set stats->tupattnum = InvalidAttrNumber, but maybe
it would be cleaner to pass all three parts of the primary key as
explicit arguments.  Does anyone else feel that way?

			regards, tom lane

Attachments:

v4-0001-Store-empty-stavalues-when-needed-for-expression-.patch (text/x-diff, 12.6K) download From 32f2fe04e43f57cdff4f0adec0af6d7bdb909e75 Mon Sep 17 00:00:00 2001 From: Tom Lane <tgl@sss.pgh.pa.us> Date: Tue, 10 Nov 2026 13:43:27 -0500 Subject: [PATCH v4] Store empty stavalues when needed for expression statistics. Commit 261f89a97 changed the API contract for update_attstats() to store an empty array, not a NULL, if it's passed a nonnull stavalues pointer along with a zero values count. We missed that serialize_expr_stats() needs to be kept in sync with that, so that we now get "unexpected null value" errors if statistics on an expression hit one of the cases where the statistics collection code requests that. Rather than just adjusting serialize_expr_stats() to match, let's avoid having duplicated code at all, by factoring out a routine to build a pg_statistic tuple from a VacAttrStats structure. Bug: #19849 Reported-by: Atish Prakash <125atishprak@gmail.com> Author: Atish Prakash <125atishprak@gmail.com> Co-authored-by: Shihao Zhong <zhong950419@gmail.com> Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/19849-38b8bd2fea807154@postgresql.org Backpatch-through: 19 --- src/backend/commands/analyze.c | 201 ++++++++++++++---------- src/backend/statistics/extended_stats.c | 84 +--------- src/include/commands/vacuum.h | 4 + 3 files changed, 122 insertions(+), 167 deletions(-) diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 518d7526255..01efa78cf76 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -1713,6 +1713,115 @@ acquire_inherited_sample_rows(Relation onerel, int elevel, } +/* + * build_statistic_tuple() -- build a pg_statistic tuple from a VacAttrStats + * + * relid is the Oid of the table being analyzed, inh indicates if these are + * inheritance-tree or table-only stats, stats contains the collected stats + * including the column number. + * + * tupdesc must be a tuple descriptor for pg_statistic. oldtup is the + * existing pg_statistic tuple we intend to replace, or NULL to build + * a new pg_statistic tuple. + * + * This is exported so that extended_stats.c can use it. (In that usage, + * relid is InvalidOid, so don't trust it for anything.) + */ +HeapTuple +build_statistic_tuple(Oid relid, bool inh, + VacAttrStats *stats, + TupleDesc tupdesc, + HeapTuple oldtup) +{ + HeapTuple stup; + Datum values[Natts_pg_statistic]; + bool nulls[Natts_pg_statistic]; + bool replaces[Natts_pg_statistic]; + int i, + k; + + for (i = 0; i < Natts_pg_statistic; ++i) + { + nulls[i] = false; + replaces[i] = true; + } + + values[Anum_pg_statistic_starelid - 1] = ObjectIdGetDatum(relid); + values[Anum_pg_statistic_staattnum - 1] = Int16GetDatum(stats->tupattnum); + values[Anum_pg_statistic_stainherit - 1] = BoolGetDatum(inh); + values[Anum_pg_statistic_stanullfrac - 1] = Float4GetDatum(stats->stanullfrac); + values[Anum_pg_statistic_stawidth - 1] = Int32GetDatum(stats->stawidth); + values[Anum_pg_statistic_stadistinct - 1] = Float4GetDatum(stats->stadistinct); + i = Anum_pg_statistic_stakind1 - 1; + for (k = 0; k < STATISTIC_NUM_SLOTS; k++) + { + values[i++] = Int16GetDatum(stats->stakind[k]); /* stakindN */ + } + i = Anum_pg_statistic_staop1 - 1; + for (k = 0; k < STATISTIC_NUM_SLOTS; k++) + { + values[i++] = ObjectIdGetDatum(stats->staop[k]); /* staopN */ + } + i = Anum_pg_statistic_stacoll1 - 1; + for (k = 0; k < STATISTIC_NUM_SLOTS; k++) + { + values[i++] = ObjectIdGetDatum(stats->stacoll[k]); /* stacollN */ + } + i = Anum_pg_statistic_stanumbers1 - 1; + for (k = 0; k < STATISTIC_NUM_SLOTS; k++) + { + if (stats->stanumbers[k] != NULL) + { + int nnum = stats->numnumbers[k]; + Datum *numdatums = palloc_array(Datum, nnum); + ArrayType *arry; + + for (int n = 0; n < nnum; n++) + numdatums[n] = Float4GetDatum(stats->stanumbers[k][n]); + arry = construct_array_builtin(numdatums, nnum, FLOAT4OID); + values[i++] = PointerGetDatum(arry); /* stanumbersN */ + } + else + { + nulls[i] = true; + values[i++] = (Datum) 0; + } + } + i = Anum_pg_statistic_stavalues1 - 1; + for (k = 0; k < STATISTIC_NUM_SLOTS; k++) + { + if (stats->stavalues[k] != NULL) + { + ArrayType *arry; + + arry = construct_array(stats->stavalues[k], + stats->numvalues[k], + stats->statypid[k], + stats->statyplen[k], + stats->statypbyval[k], + stats->statypalign[k]); + values[i++] = PointerGetDatum(arry); /* stavaluesN */ + } + else + { + nulls[i] = true; + values[i++] = (Datum) 0; + } + } + + /* Build a replacement or all-new tuple */ + if (HeapTupleIsValid(oldtup)) + stup = heap_modify_tuple(oldtup, + tupdesc, + values, + nulls, + replaces); + else + stup = heap_form_tuple(tupdesc, values, nulls); + + return stup; +} + /* * update_attstats() -- update attribute statistics for one relation * @@ -1752,88 +1861,14 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats) VacAttrStats *stats = vacattrstats[attno]; HeapTuple stup, oldtup; - int i, - k, - n; - Datum values[Natts_pg_statistic]; - bool nulls[Natts_pg_statistic]; - bool replaces[Natts_pg_statistic]; /* Ignore attr if we weren't able to collect stats */ if (!stats->stats_valid) continue; - /* - * Construct a new pg_statistic tuple - */ - for (i = 0; i < Natts_pg_statistic; ++i) - { - nulls[i] = false; - replaces[i] = true; - } - - values[Anum_pg_statistic_starelid - 1] = ObjectIdGetDatum(relid); - values[Anum_pg_statistic_staattnum - 1] = Int16GetDatum(stats->tupattnum); - values[Anum_pg_statistic_stainherit - 1] = BoolGetDatum(inh); - values[Anum_pg_statistic_stanullfrac - 1] = Float4GetDatum(stats->stanullfrac); - values[Anum_pg_statistic_stawidth - 1] = Int32GetDatum(stats->stawidth); - values[Anum_pg_statistic_stadistinct - 1] = Float4GetDatum(stats->stadistinct); - i = Anum_pg_statistic_stakind1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - values[i++] = Int16GetDatum(stats->stakind[k]); /* stakindN */ - } - i = Anum_pg_statistic_staop1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - values[i++] = ObjectIdGetDatum(stats->staop[k]); /* staopN */ - } - i = Anum_pg_statistic_stacoll1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - values[i++] = ObjectIdGetDatum(stats->stacoll[k]); /* stacollN */ - } - i = Anum_pg_statistic_stanumbers1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - if (stats->stanumbers[k] != NULL) - { - int nnum = stats->numnumbers[k]; - Datum *numdatums = palloc_array(Datum, nnum); - ArrayType *arry; - - for (n = 0; n < nnum; n++) - numdatums[n] = Float4GetDatum(stats->stanumbers[k][n]); - arry = construct_array_builtin(numdatums, nnum, FLOAT4OID); - values[i++] = PointerGetDatum(arry); /* stanumbersN */ - } - else - { - nulls[i] = true; - values[i++] = (Datum) 0; - } - } - i = Anum_pg_statistic_stavalues1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - if (stats->stavalues[k] != NULL) - { - ArrayType *arry; - - arry = construct_array(stats->stavalues[k], - stats->numvalues[k], - stats->statypid[k], - stats->statyplen[k], - stats->statypbyval[k], - stats->statypalign[k]); - values[i++] = PointerGetDatum(arry); /* stavaluesN */ - } - else - { - nulls[i] = true; - values[i++] = (Datum) 0; - } - } + /* Open index information when we know we need it */ + if (indstate == NULL) + indstate = CatalogOpenIndexes(sd); /* Is there already a pg_statistic tuple for this attribute? */ oldtup = SearchSysCache3(STATRELATTINH, @@ -1841,25 +1876,19 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats) Int16GetDatum(stats->tupattnum), BoolGetDatum(inh)); - /* Open index information when we know we need it */ - if (indstate == NULL) - indstate = CatalogOpenIndexes(sd); + /* Build the new or replacement tuple */ + stup = build_statistic_tuple(relid, inh, stats, + RelationGetDescr(sd), oldtup); if (HeapTupleIsValid(oldtup)) { /* Yes, replace it */ - stup = heap_modify_tuple(oldtup, - RelationGetDescr(sd), - values, - nulls, - replaces); ReleaseSysCache(oldtup); CatalogTupleUpdateWithInfo(sd, &stup->t_self, stup, indstate); } else { /* No, insert new tuple */ - stup = heap_form_tuple(RelationGetDescr(sd), values, nulls); CatalogTupleInsertWithInfo(sd, stup, indstate); } diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index b66a49a6fb5..da5e7264d25 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -2333,14 +2333,13 @@ build_expr_data(List *exprs, int stattarget) return exprdata; } -/* form an array of pg_statistic rows (per update_attstats) */ +/* form an array of pg_statistic rows, one per expression */ static Datum serialize_expr_stats(AnlExprData *exprdata, int nexprs) { int exprno; Oid typOid; Relation sd; - ArrayBuildState *astate = NULL; sd = table_open(StatisticRelationId, RowExclusiveLock); @@ -2355,12 +2354,7 @@ serialize_expr_stats(AnlExprData *exprdata, int nexprs) for (exprno = 0; exprno < nexprs; exprno++) { - int i, - k; VacAttrStats *stats = exprdata[exprno].vacattrstat; - - Datum values[Natts_pg_statistic]; - bool nulls[Natts_pg_statistic]; HeapTuple stup; if (!stats->stats_valid) @@ -2373,80 +2367,8 @@ serialize_expr_stats(AnlExprData *exprdata, int nexprs) continue; } - /* - * Construct a new pg_statistic tuple - */ - for (i = 0; i < Natts_pg_statistic; ++i) - { - nulls[i] = false; - } - - values[Anum_pg_statistic_starelid - 1] = ObjectIdGetDatum(InvalidOid); - values[Anum_pg_statistic_staattnum - 1] = Int16GetDatum(InvalidAttrNumber); - values[Anum_pg_statistic_stainherit - 1] = BoolGetDatum(false); - values[Anum_pg_statistic_stanullfrac - 1] = Float4GetDatum(stats->stanullfrac); - values[Anum_pg_statistic_stawidth - 1] = Int32GetDatum(stats->stawidth); - values[Anum_pg_statistic_stadistinct - 1] = Float4GetDatum(stats->stadistinct); - i = Anum_pg_statistic_stakind1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - values[i++] = Int16GetDatum(stats->stakind[k]); /* stakindN */ - } - i = Anum_pg_statistic_staop1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - values[i++] = ObjectIdGetDatum(stats->staop[k]); /* staopN */ - } - i = Anum_pg_statistic_stacoll1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - values[i++] = ObjectIdGetDatum(stats->stacoll[k]); /* stacollN */ - } - i = Anum_pg_statistic_stanumbers1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - int nnum = stats->numnumbers[k]; - - if (nnum > 0) - { - int n; - Datum *numdatums = palloc_array(Datum, nnum); - ArrayType *arry; - - for (n = 0; n < nnum; n++) - numdatums[n] = Float4GetDatum(stats->stanumbers[k][n]); - arry = construct_array_builtin(numdatums, nnum, FLOAT4OID); - values[i++] = PointerGetDatum(arry); /* stanumbersN */ - } - else - { - nulls[i] = true; - values[i++] = (Datum) 0; - } - } - i = Anum_pg_statistic_stavalues1 - 1; - for (k = 0; k < STATISTIC_NUM_SLOTS; k++) - { - if (stats->numvalues[k] > 0) - { - ArrayType *arry; - - arry = construct_array(stats->stavalues[k], - stats->numvalues[k], - stats->statypid[k], - stats->statyplen[k], - stats->statypbyval[k], - stats->statypalign[k]); - values[i++] = PointerGetDatum(arry); /* stavaluesN */ - } - else - { - nulls[i] = true; - values[i++] = (Datum) 0; - } - } - - stup = heap_form_tuple(RelationGetDescr(sd), values, nulls); + stup = build_statistic_tuple(InvalidOid, false, stats, + RelationGetDescr(sd), NULL); astate = accumArrayResult(astate, heap_copy_tuple_as_datum(stup, RelationGetDescr(sd)), diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h index 89fa1fcd261..3bcb7113762 100644 --- a/src/include/commands/vacuum.h +++ b/src/include/commands/vacuum.h @@ -441,6 +441,10 @@ extern void analyze_rel(Oid relid, RangeVar *relation, BufferAccessStrategy bstrategy); extern bool attribute_is_analyzable(Relation onerel, int attnum, Form_pg_attribute attr, int *p_attstattarget); +extern HeapTuple build_statistic_tuple(Oid relid, bool inh, + VacAttrStats *stats, + TupleDesc tupdesc, + HeapTuple oldtup); extern bool std_typanalyze(VacAttrStats *stats); /* in utils/misc/sampling.c --- duplicate of declarations in utils/sampling.h */ -- 2.52.0
^ permalink raw reply [nested|flat] 12+ messages in thread

* Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays
  2026-11-07 15:36 BUG #19849: queries fail after ANALYZE with expression stats on arrays PG Bug reporting form <noreply@postgresql.org>
  2026-11-07 15:37 ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Atisss hh <125atishprak@gmail.com>
  2026-11-09 05:10   ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  2026-11-09 05:48     ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  2026-11-09 19:43       ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Tom Lane <tgl@sss.pgh.pa.us>
  2026-11-09 23:09         ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  2026-11-10 06:10           ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  2026-11-10 18:53             ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Tom Lane <tgl@sss.pgh.pa.us>
@ 2026-11-10 22:33               ` Michael Paquier <michael@paquier.xyz>
  2026-11-11 01:17                 ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Michael Paquier @ 2026-11-10 22:33 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: shihao zhong <zhong950419@gmail.com>; Atisss hh <125atishprak@gmail.com>; pgsql-bugs@lists.postgresql.org

On Tue, Nov 10, 2026 at 01:53:01PM -0500, Tom Lane wrote:
> Yeah, I didn't love this particular refactorization either.  I think
> it'd be nicer to have the values[] and nulls[] arrays totally inside
> the shared function and do the tuple-building within it, as attached.

Including the tuple build in the routine sounds good here.  That takes
care of my worries with the previous patch.

> One thing that bugs me slightly about this is that it seems weird to
> be passing starelid and stainherit explicitly while digging staattnum
> out of the VacAttrStats struct.  It works, because examine_expression
> is careful to set stats->tupattnum = InvalidAttrNumber, but maybe
> it would be cleaner to pass all three parts of the primary key as
> explicit arguments.  Does anyone else feel that way?

None here.  Passing down tupattnum as an argument coming from "stats"
also felt a bit strange..
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays
  2026-11-07 15:36 BUG #19849: queries fail after ANALYZE with expression stats on arrays PG Bug reporting form <noreply@postgresql.org>
  2026-11-07 15:37 ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Atisss hh <125atishprak@gmail.com>
  2026-11-09 05:10   ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  2026-11-09 05:48     ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  2026-11-09 19:43       ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Tom Lane <tgl@sss.pgh.pa.us>
  2026-11-09 23:09         ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  2026-11-10 06:10           ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  2026-11-10 18:53             ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Tom Lane <tgl@sss.pgh.pa.us>
  2026-11-10 22:33               ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
@ 2026-11-11 01:17                 ` shihao zhong <zhong950419@gmail.com>
  2026-11-11 16:05                   ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 12+ messages in thread

From: shihao zhong @ 2026-11-11 01:17 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Atisss hh <125atishprak@gmail.com>; pgsql-bugs@lists.postgresql.org

Hi Tom,

Thanks for v4. Keeping the arrays inside the function is nicer than
my version.

> Does anyone else feel that way?
I’d pass all three key columns because it is weird that two come from the
arguments and one comes from stats.

Thanks,
Shihao

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays
  2026-11-07 15:36 BUG #19849: queries fail after ANALYZE with expression stats on arrays PG Bug reporting form <noreply@postgresql.org>
  2026-11-07 15:37 ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Atisss hh <125atishprak@gmail.com>
  2026-11-09 05:10   ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  2026-11-09 05:48     ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  2026-11-09 19:43       ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Tom Lane <tgl@sss.pgh.pa.us>
  2026-11-09 23:09         ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  2026-11-10 06:10           ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  2026-11-10 18:53             ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Tom Lane <tgl@sss.pgh.pa.us>
  2026-11-10 22:33               ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  2026-11-11 01:17                 ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
@ 2026-11-11 16:05                   ` Tom Lane <tgl@sss.pgh.pa.us>
  2026-11-11 22:34                     ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 12+ messages in thread

From: Tom Lane @ 2026-11-11 16:05 UTC (permalink / raw)
  To: shihao zhong <zhong950419@gmail.com>; +Cc: Michael Paquier <michael@paquier.xyz>; Atisss hh <125atishprak@gmail.com>; pgsql-bugs@lists.postgresql.org

shihao zhong <zhong950419@gmail.com> writes:
>> Does anyone else feel that way?

> I’d pass all three key columns because it is weird that two come from the
> arguments and one comes from stats.

Done like that, then.

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays
  2026-11-07 15:36 BUG #19849: queries fail after ANALYZE with expression stats on arrays PG Bug reporting form <noreply@postgresql.org>
  2026-11-07 15:37 ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Atisss hh <125atishprak@gmail.com>
  2026-11-09 05:10   ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  2026-11-09 05:48     ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  2026-11-09 19:43       ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Tom Lane <tgl@sss.pgh.pa.us>
  2026-11-09 23:09         ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  2026-11-10 06:10           ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  2026-11-10 18:53             ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Tom Lane <tgl@sss.pgh.pa.us>
  2026-11-10 22:33               ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Michael Paquier <michael@paquier.xyz>
  2026-11-11 01:17                 ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays shihao zhong <zhong950419@gmail.com>
  2026-11-11 16:05                   ` Re: BUG #19849: queries fail after ANALYZE with expression stats on arrays Tom Lane <tgl@sss.pgh.pa.us>
@ 2026-11-11 22:34                     ` Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 12+ messages in thread

From: Michael Paquier @ 2026-11-11 22:34 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: shihao zhong <zhong950419@gmail.com>; Atisss hh <125atishprak@gmail.com>; pgsql-bugs@lists.postgresql.org

On Wed, Nov 11, 2026 at 11:05:19AM -0500, Tom Lane wrote:
> Done like that, then.

Thanks.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 12+ messages in thread


end of thread, other threads:[~2026-11-11 22:34 UTC | newest]

Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-07 15:36 BUG #19849: queries fail after ANALYZE with expression stats on arrays PG Bug reporting form <noreply@postgresql.org>
2026-11-07 15:37 ` Atisss hh <125atishprak@gmail.com>
2026-11-09 05:10   ` shihao zhong <zhong950419@gmail.com>
2026-11-09 05:48     ` Michael Paquier <michael@paquier.xyz>
2026-11-09 19:43       ` Tom Lane <tgl@sss.pgh.pa.us>
2026-11-09 23:09         ` shihao zhong <zhong950419@gmail.com>
2026-11-10 06:10           ` Michael Paquier <michael@paquier.xyz>
2026-11-10 18:53             ` Tom Lane <tgl@sss.pgh.pa.us>
2026-11-10 22:33               ` Michael Paquier <michael@paquier.xyz>
2026-11-11 01:17                 ` shihao zhong <zhong950419@gmail.com>
2026-11-11 16:05                   ` Tom Lane <tgl@sss.pgh.pa.us>
2026-11-11 22:34                     ` Michael Paquier <michael@paquier.xyz>

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