Until PostgreSQL 9.1, it was possible to run ALTER TABLE ... SET STATISTICS without allow_system_table_mods. In PostgreSQL 9.2 and later, this no longer works. This change was apparently accidental. (I gave up after a while trying to bisect it exactly, but probably something related to 1489e2f26a4c0318938b3085f50976512f321d84.)

(It didn't work on mapped relations, so it wasn't all roses.)

A comment in ATPrepSetStatistics() still makes references to this being possible. I propose to remove this comment.

There was some discussion about (re-)allowing this and some other commands like this, but after the recent changes to make allow_system_table_mods easier to use, I think this has less urgency, so I'd rather get the comment correct in the meantime.

--
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From 203571a0402face9feb92a058d8423317501545e Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Wed, 4 Dec 2019 23:46:00 +0100
Subject: [PATCH] Remove comment about SET STATISTICS on system tables

It was once possible to do ALTER TABLE ... SET STATISTICS on system
tables without allow_sytem_table_mods.  This was changed apparently by
accident between PostgreSQL 9.1 and 9.2, but a code comment still
claimed this was possible.  Remove that comment.  (Maybe someone wants
to revive that functionality, but not right now.)
---
 src/backend/commands/tablecmds.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 5440eb9015..55b9b63336 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -6707,10 +6707,8 @@ static void
 ATPrepSetStatistics(Relation rel, const char *colName, int16 colNum, Node 
*newValue, LOCKMODE lockmode)
 {
        /*
-        * We do our own permission checking because (a) we want to allow SET
-        * STATISTICS on indexes (for expressional index columns), and (b) we 
want
-        * to allow SET STATISTICS on system catalogs without requiring
-        * allowSystemTableMods to be turned on.
+        * We do our own permission checking because we want to allow SET
+        * STATISTICS on indexes (for expressional index columns).
         */
        if (rel->rd_rel->relkind != RELKIND_RELATION &&
                rel->rd_rel->relkind != RELKIND_MATVIEW &&
-- 
2.24.0

Reply via email to