pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Allow empty arrays of values in pg_restore_attribute_stats()
4+ messages / 1 participants
[nested] [flat]

* pgsql: Allow empty arrays of values in pg_restore_attribute_stats()
@ 2026-11-12 00:54 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 4+ messages in thread

From: Michael Paquier @ 2026-11-12 00:54 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Allow empty arrays of values in pg_restore_attribute_stats()

ANALYZE can store an empty array of values for range_length_histogram
and most_common_elems, which pg_dump emits as '{}', since 261f89a976b.
These were rejected by pg_restore_attribute_stats(), as an empty array
has no dimensions, and the statistics were lost after a dump/restore or
an upgrade *from* v19 or HEAD.  Empty arrays are not possible for these
two properties in v18 and older versions.

This commit allows empty arrays for these two cases only.  Arrays stored
as stanumbers are still required to be non-empty, as ANALYZE never
generates them.  get_attstatsslot() fails on them.

Some tests are added to cover both the authorized and non-authorized
patterns, in case somebody has a change of mind in the future regarding
one or more of them.

Reported-by: Atish Prakash <125atishprak@gmail.com>
Author: Corey Huinker <corey.huinker@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/19857-6e808a09ff4b75d2@postgresql.org
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2656f664616dac41e99495b39e2bc3bc1d81b1e7

Modified Files
--------------
src/backend/statistics/attribute_stats.c   | 10 ++--
src/backend/statistics/stat_utils.c        | 24 ++++++---
src/include/statistics/stat_utils.h        |  3 +-
src/test/regress/expected/stats_import.out | 81 ++++++++++++++++++++++++++++++
src/test/regress/sql/stats_import.sql      | 48 ++++++++++++++++++
5 files changed, 154 insertions(+), 12 deletions(-)



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

* pgsql: Allow empty arrays of values in pg_restore_attribute_stats()
@ 2026-11-12 00:54 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 4+ messages in thread

From: Michael Paquier @ 2026-11-12 00:54 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Allow empty arrays of values in pg_restore_attribute_stats()

ANALYZE can store an empty array of values for range_length_histogram
and most_common_elems, which pg_dump emits as '{}', since 261f89a976b.
These were rejected by pg_restore_attribute_stats(), as an empty array
has no dimensions, and the statistics were lost after a dump/restore or
an upgrade *from* v19 or HEAD.  Empty arrays are not possible for these
two properties in v18 and older versions.

This commit allows empty arrays for these two cases only.  Arrays stored
as stanumbers are still required to be non-empty, as ANALYZE never
generates them.  get_attstatsslot() fails on them.

Some tests are added to cover both the authorized and non-authorized
patterns, in case somebody has a change of mind in the future regarding
one or more of them.

Reported-by: Atish Prakash <125atishprak@gmail.com>
Author: Corey Huinker <corey.huinker@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/19857-6e808a09ff4b75d2@postgresql.org
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a3f99652ee250d3c1c23b13761b16e3ce8a33864

Modified Files
--------------
src/backend/statistics/attribute_stats.c   | 10 ++--
src/backend/statistics/stat_utils.c        | 24 ++++++---
src/include/statistics/stat_utils.h        |  3 +-
src/test/regress/expected/stats_import.out | 81 ++++++++++++++++++++++++++++++
src/test/regress/sql/stats_import.sql      | 48 ++++++++++++++++++
5 files changed, 154 insertions(+), 12 deletions(-)



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

* pgsql: Allow empty arrays of values in pg_restore_extended_stats()
@ 2026-11-13 04:26 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 4+ messages in thread

From: Michael Paquier @ 2026-11-13 04:26 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Allow empty arrays of values in pg_restore_extended_stats()

ANALYZE can store an empty array of values for range_length_histogram
and most_common_elems in the statistics of an expression, which pg_dump
emits as '{}', since 261f89a976b.  These were rejected by
pg_restore_extended_stats(), as an empty array has no dimensions, and
the statistics of the expression were lost after a dump/restore or an
upgrade *from* v19 or HEAD.  Empty arrays are not possible for these two
properties in v18 and older versions.

This commit allows empty arrays for these two cases only, like
2656f664616d did for pg_restore_attribute_stats().  Arrays stored as
stanumbers are still required to be non-empty, as ANALYZE never
generates them.  In terms of range_length_histogram, this commit
completes 13eb56409f5b, as ANALYZE never generates a bounds histogram
when the length histogram is empty.

Some tests are added to cover all the new patterns involving empty
arrays.

Reported-by: Chunling Qin <303677365@qq.com>
Author: Corey Huinker <corey.huinker@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/19842-ca042326dd2430a4@postgresql.org
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/87524d0dd8470819ce8aa3708a9bf3fa3f1d34fd

Modified Files
--------------
src/backend/statistics/extended_stats_funcs.c | 42 +++++++++-----
src/test/regress/expected/stats_import.out    | 82 +++++++++++++++++++++++++++
src/test/regress/sql/stats_import.sql         | 54 ++++++++++++++++++
3 files changed, 163 insertions(+), 15 deletions(-)



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

* pgsql: Allow empty arrays of values in pg_restore_extended_stats()
@ 2026-11-13 04:26 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 4+ messages in thread

From: Michael Paquier @ 2026-11-13 04:26 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Allow empty arrays of values in pg_restore_extended_stats()

ANALYZE can store an empty array of values for range_length_histogram
and most_common_elems in the statistics of an expression, which pg_dump
emits as '{}', since 261f89a976b.  These were rejected by
pg_restore_extended_stats(), as an empty array has no dimensions, and
the statistics of the expression were lost after a dump/restore or an
upgrade *from* v19 or HEAD.  Empty arrays are not possible for these two
properties in v18 and older versions.

This commit allows empty arrays for these two cases only, like
2656f664616d did for pg_restore_attribute_stats().  Arrays stored as
stanumbers are still required to be non-empty, as ANALYZE never
generates them.  In terms of range_length_histogram, this commit
completes 13eb56409f5b, as ANALYZE never generates a bounds histogram
when the length histogram is empty.

Some tests are added to cover all the new patterns involving empty
arrays.

Reported-by: Chunling Qin <303677365@qq.com>
Author: Corey Huinker <corey.huinker@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/19842-ca042326dd2430a4@postgresql.org
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/adc471e8ecc0b51c24e4fa34e00fa553746ab86a

Modified Files
--------------
src/backend/statistics/extended_stats_funcs.c | 42 +++++++++-----
src/test/regress/expected/stats_import.out    | 82 +++++++++++++++++++++++++++
src/test/regress/sql/stats_import.sql         | 54 ++++++++++++++++++
3 files changed, 163 insertions(+), 15 deletions(-)



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


end of thread, other threads:[~2026-11-13 04:26 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12 00:54 pgsql: Allow empty arrays of values in pg_restore_attribute_stats() Michael Paquier <michael@paquier.xyz>
2026-11-12 00:54 pgsql: Allow empty arrays of values in pg_restore_attribute_stats() Michael Paquier <michael@paquier.xyz>
2026-11-13 04:26 pgsql: Allow empty arrays of values in pg_restore_extended_stats() Michael Paquier <michael@paquier.xyz>
2026-11-13 04:26 pgsql: Allow empty arrays of values in pg_restore_extended_stats() 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