agora inbox for pgsql-committers@postgresql.orghelp / color / mirror / Atom feed
pgsql: Fix multirange type handling in pg_restore_attribute_stats() 3+ messages / 1 participants [nested] [flat]
* pgsql: Fix multirange type handling in pg_restore_attribute_stats() @ 2026-08-10 13:41 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 3+ messages in thread From: Noah Misch @ 2026-08-10 13:41 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix multirange type handling in pg_restore_attribute_stats() statatt_get_type() unconditionally converted multirange types to their underlying range type. This choice affected all the type information, like atttypid, atttyptype and operators. This made the bounds histogram work correctly (range type is required), but it was wrong for all the other stat kinds. MCV values for a multirange column should be parsed as multirange arrays, not range arrays. It also made the TYPTYPE_MULTIRANGE check for the range stats validation as dead code, since atttyptype was always TYPTYPE_RANGE after the conversion due to the centralized statatt_get_type(). pg_restore_extended_stats() handles the same case correctly: it keeps the original type and explicitly converts to the range type only at the point where range_histogram_bounds is built. The fix of this issue is simple: the multirange-to-range conversion needs to be moved from the centralized statatt_get_type() up to where attribute stats build their range_histogram_bounds, matching what is done for extended statistics restore. The regression tests for multiranges with attribute stats are extended to cover this case. Author: OpenAI Security Research Team Backpatch-through: 18 Security: CVE-2026-16238 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/57835938fa9a73db432f9d822649dd9824c3991b Author: Michael Paquier <michael@paquier.xyz> Modified Files -------------- src/backend/statistics/attribute_stats.c | 10 +++++++++- src/backend/statistics/stat_utils.c | 7 ------- src/test/regress/expected/stats_import.out | 20 ++++++++++++++++++++ src/test/regress/sql/stats_import.sql | 14 ++++++++++++++ 4 files changed, 43 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix multirange type handling in pg_restore_attribute_stats() @ 2026-08-10 13:41 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 3+ messages in thread From: Noah Misch @ 2026-08-10 13:41 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix multirange type handling in pg_restore_attribute_stats() statatt_get_type() unconditionally converted multirange types to their underlying range type. This choice affected all the type information, like atttypid, atttyptype and operators. This made the bounds histogram work correctly (range type is required), but it was wrong for all the other stat kinds. MCV values for a multirange column should be parsed as multirange arrays, not range arrays. It also made the TYPTYPE_MULTIRANGE check for the range stats validation as dead code, since atttyptype was always TYPTYPE_RANGE after the conversion due to the centralized statatt_get_type(). pg_restore_extended_stats() handles the same case correctly: it keeps the original type and explicitly converts to the range type only at the point where range_histogram_bounds is built. The fix of this issue is simple: the multirange-to-range conversion needs to be moved from the centralized statatt_get_type() up to where attribute stats build their range_histogram_bounds, matching what is done for extended statistics restore. The regression tests for multiranges with attribute stats are extended to cover this case. Author: OpenAI Security Research Team Backpatch-through: 18 Security: CVE-2026-16238 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/b3d9262bbddcbfd1be1dbd43a48bc155234d21e1 Author: Michael Paquier <michael@paquier.xyz> Modified Files -------------- src/backend/statistics/attribute_stats.c | 10 +++++++++- src/backend/statistics/stat_utils.c | 7 ------- src/test/regress/expected/stats_import.out | 20 ++++++++++++++++++++ src/test/regress/sql/stats_import.sql | 14 ++++++++++++++ 4 files changed, 43 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix multirange type handling in pg_restore_attribute_stats() @ 2026-08-10 13:41 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 3+ messages in thread From: Noah Misch @ 2026-08-10 13:41 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix multirange type handling in pg_restore_attribute_stats() statatt_get_type() unconditionally converted multirange types to their underlying range type. This choice affected all the type information, like atttypid, atttyptype and operators. This made the bounds histogram work correctly (range type is required), but it was wrong for all the other stat kinds. MCV values for a multirange column should be parsed as multirange arrays, not range arrays. It also made the TYPTYPE_MULTIRANGE check for the range stats validation as dead code, since atttyptype was always TYPTYPE_RANGE after the conversion due to the centralized statatt_get_type(). pg_restore_extended_stats() handles the same case correctly: it keeps the original type and explicitly converts to the range type only at the point where range_histogram_bounds is built. The fix of this issue is simple: the multirange-to-range conversion needs to be moved from the centralized statatt_get_type() up to where attribute stats build their range_histogram_bounds, matching what is done for extended statistics restore. The regression tests for multiranges with attribute stats are extended to cover this case. Author: OpenAI Security Research Team Backpatch-through: 18 Security: CVE-2026-16238 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/08454e8b2defdf8a0b61e550606f78b8f184f2e6 Author: Michael Paquier <michael@paquier.xyz> Modified Files -------------- src/backend/statistics/attribute_stats.c | 17 +++++++++-------- src/test/regress/expected/stats_import.out | 20 ++++++++++++++++++++ src/test/regress/sql/stats_import.sql | 14 ++++++++++++++ 3 files changed, 43 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-08-10 13:41 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-08-10 13:41 pgsql: Fix multirange type handling in pg_restore_attribute_stats() Noah Misch <noah@leadboat.com> 2026-08-10 13:41 pgsql: Fix multirange type handling in pg_restore_attribute_stats() Noah Misch <noah@leadboat.com> 2026-08-10 13:41 pgsql: Fix multirange type handling in pg_restore_attribute_stats() Noah Misch <noah@leadboat.com>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox