Fix StatisticsObjIsVisibleExt() for pg_temp. master github/master
authorNoah Misch <noah@leadboat.com>
Mon, 29 Sep 2025 18:15:44 +0000 (11:15 -0700)
committerNoah Misch <noah@leadboat.com>
Mon, 29 Sep 2025 18:15:44 +0000 (11:15 -0700)
commita95393ecdb23563bd47eeb2c943640c88592d82b
tree199b2a7f0c1a71996e13fdf94ff6f23ab57b584b
parent5668fff3c512a61b7f8a2b9bf04270578cf5665a
Fix StatisticsObjIsVisibleExt() for pg_temp.

Neighbor get_statistics_object_oid() ignores objects in pg_temp, as has
been the standard for non-relation, non-type namespace searches since
CVE-2007-2138.  Hence, most operations that name a statistics object
correctly decline to map an unqualified name to a statistics object in
pg_temp.  StatisticsObjIsVisibleExt() did not.  Consequently,
pg_statistics_obj_is_visible() wrongly returned true for such objects,
psql \dX wrongly listed them, and getObjectDescription()-based ereport()
and pg_describe_object() wrongly omitted namespace qualification.  Any
malfunction beyond that would depend on how a human or application acts
on those wrong indications.  Commit
d99d58cdc8c0b5b50ee92995e8575c100b1a458a introduced this.  Back-patch to
v13 (all supported versions).

Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://postgr.es/m/20250920162116.2e.nmisch@google.com
Backpatch-through: 13
src/backend/catalog/namespace.c
src/test/regress/expected/stats_ext.out
src/test/regress/sql/stats_ext.sql