agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
pgsql: Fix import of statistics for domains over [multi]range types and
3+ messages / 1 participants
[nested] [flat]

* pgsql: Fix import of statistics for domains over [multi]range types and
@ 2026-09-26 00:28  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 3+ messages in thread

From: Michael Paquier @ 2026-09-26 00:28 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix import of statistics for domains over [multi]range types and tsvector

pg_restore_attribute_stats() rejected range_length_histogram,
range_empty_frac and range_bounds_histogram for a column whose type is a
domain over a range or a multirange type.  The same issue existed for
most_common_elems and elem_count_histogram for a domain over tsvector.
pg_restore_extended_stats() had the same set of problems for expressions
whose type is a domain over a range, a multirange type, or tsvector.

ANALYZE is able to generate such stats, incorporating the knowledge to
handle domains in the in-core typanalyze callbacks.

This problem is resolved by being more aggressive with the fetch of the
base type of a domain in the early phases of restore for attribute and
extended stats (special tip to Jian He for pointing out the unnecessary
typcache lookups), reflecting on the surrounding helper routines shared
by both code paths.  The fix for v18 is local to attribute_stats.c, as
only attribute stats need to be touched.

Tests are included in a fashion consistent with the surroundings.  The
consequence of this issue was the rejection of stats that ANALYZE was
able to build, which was not critical but annoying as it would lead to a
gap in the stats restored.

Reported-by: Qifan Liu <imchifan@163.com>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Jian He <jian.universality@gmail.com>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://postgr.es/m/19715-b8be35083016f289@postgresql.org
Backpatch-through: 18

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/142fd8ff13dee8ff6665615027386908e9768d43

Modified Files
--------------
src/backend/statistics/attribute_stats.c      |  21 +-
src/backend/statistics/extended_stats_funcs.c |  33 ++-
src/backend/statistics/stat_utils.c           |  64 +++--
src/include/statistics/stat_utils.h           |   9 +-
src/test/regress/expected/stats_import.out    | 332 +++++++++++++++++++++++++-
src/test/regress/sql/stats_import.sql         | 251 +++++++++++++++++++
6 files changed, 663 insertions(+), 47 deletions(-)



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

* pgsql: Fix import of statistics for domains over [multi]range types and
@ 2026-09-26 00:28  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 3+ messages in thread

From: Michael Paquier @ 2026-09-26 00:28 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix import of statistics for domains over [multi]range types and tsvector

pg_restore_attribute_stats() rejected range_length_histogram,
range_empty_frac and range_bounds_histogram for a column whose type is a
domain over a range or a multirange type.  The same issue existed for
most_common_elems and elem_count_histogram for a domain over tsvector.
pg_restore_extended_stats() had the same set of problems for expressions
whose type is a domain over a range, a multirange type, or tsvector.

ANALYZE is able to generate such stats, incorporating the knowledge to
handle domains in the in-core typanalyze callbacks.

This problem is resolved by being more aggressive with the fetch of the
base type of a domain in the early phases of restore for attribute and
extended stats (special tip to Jian He for pointing out the unnecessary
typcache lookups), reflecting on the surrounding helper routines shared
by both code paths.  The fix for v18 is local to attribute_stats.c, as
only attribute stats need to be touched.

Tests are included in a fashion consistent with the surroundings.  The
consequence of this issue was the rejection of stats that ANALYZE was
able to build, which was not critical but annoying as it would lead to a
gap in the stats restored.

Reported-by: Qifan Liu <imchifan@163.com>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Jian He <jian.universality@gmail.com>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://postgr.es/m/19715-b8be35083016f289@postgresql.org
Backpatch-through: 18

Branch
------
REL_19_STABLE

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

Modified Files
--------------
src/backend/statistics/attribute_stats.c      |  21 +-
src/backend/statistics/extended_stats_funcs.c |  33 ++-
src/backend/statistics/stat_utils.c           |  64 +++--
src/include/statistics/stat_utils.h           |   9 +-
src/test/regress/expected/stats_import.out    | 332 +++++++++++++++++++++++++-
src/test/regress/sql/stats_import.sql         | 251 +++++++++++++++++++
6 files changed, 663 insertions(+), 47 deletions(-)



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

* pgsql: Fix import of statistics for domains over [multi]range types and
@ 2026-09-26 00:28  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 3+ messages in thread

From: Michael Paquier @ 2026-09-26 00:28 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix import of statistics for domains over [multi]range types and tsvector

pg_restore_attribute_stats() rejected range_length_histogram,
range_empty_frac and range_bounds_histogram for a column whose type is a
domain over a range or a multirange type.  The same issue existed for
most_common_elems and elem_count_histogram for a domain over tsvector.
pg_restore_extended_stats() had the same set of problems for expressions
whose type is a domain over a range, a multirange type, or tsvector.

ANALYZE is able to generate such stats, incorporating the knowledge to
handle domains in the in-core typanalyze callbacks.

This problem is resolved by being more aggressive with the fetch of the
base type of a domain in the early phases of restore for attribute and
extended stats (special tip to Jian He for pointing out the unnecessary
typcache lookups), reflecting on the surrounding helper routines shared
by both code paths.  The fix for v18 is local to attribute_stats.c, as
only attribute stats need to be touched.

Tests are included in a fashion consistent with the surroundings.  The
consequence of this issue was the rejection of stats that ANALYZE was
able to build, which was not critical but annoying as it would lead to a
gap in the stats restored.

Reported-by: Qifan Liu <imchifan@163.com>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Jian He <jian.universality@gmail.com>
Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://postgr.es/m/19715-b8be35083016f289@postgresql.org
Backpatch-through: 18

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/753057e340da8f22e57c9a409ea7a235fd6a46bd

Modified Files
--------------
src/backend/statistics/attribute_stats.c   |  85 +++++++++++-----
src/test/regress/expected/stats_import.out | 155 ++++++++++++++++++++++++++++-
src/test/regress/sql/stats_import.sql      | 113 +++++++++++++++++++++
3 files changed, 327 insertions(+), 26 deletions(-)



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


end of thread, other threads:[~2026-09-26 00:28 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-09-26 00:28 pgsql: Fix import of statistics for domains over [multi]range types and Michael Paquier <michael@paquier.xyz>
2026-09-26 00:28 pgsql: Fix import of statistics for domains over [multi]range types and Michael Paquier <michael@paquier.xyz>
2026-09-26 00:28 pgsql: Fix import of statistics for domains over [multi]range types and Michael Paquier <michael@paquier.xyz>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox