Re: BUG #19097: System catalog modifications are allowed by alter - Mailing list pgsql-bugs

From Laurenz Albe
Subject Re: BUG #19097: System catalog modifications are allowed by alter
Date
Msg-id 7da7d6bed64d5b413eb0269363ec79602504e023.camel@cybertec.at
Whole thread Raw
In response to BUG #19097: System catalog modifications are allowed by alter  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
On Wed, 2025-10-29 at 04:41 +0000, PG Bug reporting form wrote:
>
> PostgreSQL version: 18.0
>
> ```sql
> create table pg_catalog.t (i int);
> ERROR:  permission denied to create "pg_catalog.t"
> DETAIL:  System catalog modifications are currently disallowed.
>
> create table t (i int);
> CREATE TABLE
>
> alter table t set schema pg_catalog;
> ALTER TABLE
>
> \dS+ t
>                                           Table "pg_catalog.t"
>  Column |  Type   | Collation | Nullable | Default | Storage | Compression |
> Stats target | Description
> --------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
>  i      | integer |           |          |         | plain   |             |
> >
> Replica Identity: NOTHING
> Access method: heap
>
> drop table pg_catalog.t;
> DROP TABLE
> ```

That is confusing, but it seems intentional.  See the following comment in
src/backend/catalog/heap.c:

    /*
     * Don't allow creating relations in pg_catalog directly, even though it
     * is allowed to move user defined relations there. Semantics with search
     * paths including pg_catalog are too confusing for now.
     *
     * But allow creating indexes on relations in pg_catalog even if
     * allow_system_table_mods = off, upper layers already guarantee it's on a
     * user defined relation, not a system one.
     */

This was deliberately added by commit 8e18d04d4daf.
I couldn't find the pertinent discussion in the archives.

I don't think it is necessary to document that...

Yours,
Laurenz Albe



pgsql-bugs by date:

Previous
From: Dilip Kumar
Date:
Subject: Re: BUG #19097: System catalog modifications are allowed by alter
Next
From: Kirill Reshke
Date:
Subject: Re: BUG #19098: Can't create unique gist index, where pg_indexes says that WITHOUT OVERLAPS does exacly that