| From: | Noah Misch <noah(at)leadboat(dot)com> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Reject pseudo-types in extended statistics expressions. |
| Date: | 2026-11-09 14:22:09 |
| Message-ID: | E1xQQG9-00000000419-3RNr@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Reject pseudo-types in extended statistics expressions.
Previously, CREATE STATISTICS accepted an expression of a pseudo-type.
So the statistics were built on a value whose row type is identified
only by a typmod assigned locally in the backend that ran ANALYZE.
Therefore, other sessions could read the statistics as the wrong data
type, which can crash the server or return wrong results.
Reject such expressions at CREATE STATISTICS time, including a type
that contains a pseudo-type, such as a composite type with an anyarray
column. An expression whose collation can't be determined is now
rejected too, but ANALYZE fails on such statistics anyway.
Since a statistics expression has no column name, teach the column type
check to report an error without one.
A statistics object built this way on an older minor release can still
exist on v18 and older, so in those branches also error out when such
statistics are used by the planner, their contents are read, or ANALYZE
builds them. Those objects should be dropped.
Backpatch to 14, where statistics on expressions were introduced.
Reported-by: Mehmet D. INCE <mehmet(at)mehmetince(dot)net>
Reviewed-by: Michael Paquier <michael(at)paquier(dot)xyz>
Reviewed-by: Andres Freund <andres(at)anarazel(dot)de>
Backpatch-through: 14
Security: CVE-2026-120148
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/033886653976a2f5055b5441ef8b7a933f7803d2
Author: Masahiko Sawada <msawada(at)postgresql(dot)org>
Modified Files
--------------
src/backend/catalog/heap.c | 21 +++++++++++++++++++--
src/backend/commands/statscmds.c | 11 ++++++++++-
src/backend/statistics/extended_stats.c | 19 +++++++++++++++++++
src/backend/statistics/mcv.c | 17 +++++++++++++++++
src/backend/utils/adt/ruleutils.c | 14 ++++++++++++++
src/backend/utils/adt/selfuncs.c | 17 +++++++++++++++++
src/test/regress/expected/stats_ext.out | 22 ++++++++++++++++++++++
src/test/regress/sql/stats_ext.sql | 16 ++++++++++++++++
8 files changed, 134 insertions(+), 3 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Noah Misch | 2026-11-09 14:22:10 | pgsql: Add tests for find_composite_type_dependencies() bugs |
| Previous Message | Noah Misch | 2026-11-09 14:22:08 | pgsql: Fix potential buffer overrun in ts_rank_cd(). |