Check for CREATE privilege on the schema in CREATE STATISTICS.
authorNathan Bossart <[email protected]>
Mon, 10 Nov 2025 15:00:00 +0000 (09:00 -0600)
committerNathan Bossart <[email protected]>
Mon, 10 Nov 2025 15:00:00 +0000 (09:00 -0600)
commit2393d374ae9c0bc8327adc80fe4490edb05be167
tree405a4876cdb7145ffbfd9aee3ccde6d0cefe385f
parent91421565febbf99c1ea2341070878dc50ab0afef
Check for CREATE privilege on the schema in CREATE STATISTICS.

This omission allowed table owners to create statistics in any
schema, potentially leading to unexpected naming conflicts.  For
ALTER TABLE commands that require re-creating statistics objects,
skip this check in case the user has since lost CREATE on the
schema.  The addition of a second parameter to CreateStatistics()
breaks ABI compatibility, but we are unaware of any impacted
third-party code.

Reported-by: Jelte Fennema-Nio <[email protected]>
Author: Jelte Fennema-Nio <[email protected]>
Co-authored-by: Nathan Bossart <[email protected]>
Reviewed-by: Noah Misch <[email protected]>
Reviewed-by: Álvaro Herrera <[email protected]>
Security: CVE-2025-12817
Backpatch-through: 13
src/backend/commands/statscmds.c
src/backend/commands/tablecmds.c
src/backend/tcop/utility.c
src/include/commands/defrem.h
src/test/regress/expected/stats_ext.out
src/test/regress/sql/stats_ext.sql