Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o6QlK-0005Eg-NY for pgsql-admin@arkaria.postgresql.org; Wed, 29 Jun 2022 06:01:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o6QlJ-00064s-8k for pgsql-admin@arkaria.postgresql.org; Wed, 29 Jun 2022 06:01:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o6QlI-00064j-UX for pgsql-admin@lists.postgresql.org; Wed, 29 Jun 2022 06:01:16 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o6QlG-000725-S3 for pgsql-admin@postgresql.org; Wed, 29 Jun 2022 06:01:16 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 25T61CAL2991349; Wed, 29 Jun 2022 02:01:12 -0400 From: Tom Lane To: Praneel Devisetty cc: pgsql-admin@postgresql.org Subject: Re: Renamed pg_catalog schema In-reply-to: References: Comments: In-reply-to Praneel Devisetty message dated "Wed, 29 Jun 2022 11:07:46 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2991347.1656482472.1@sss.pgh.pa.us> Date: Wed, 29 Jun 2022 02:01:12 -0400 Message-ID: <2991348.1656482472@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Praneel Devisetty writes: > pg_catalog schema has been accidentally renamed in a PG database. "Accidentally"? Anyone who was doing that kind of fooling around in a valuable database really ought not be trusted with admin privileges. > Renaming it back to pg_catalog is failing with error: > ERROR: unacceptable schema name "pg_catalog" > DETAIL: The prefix "pg_" is reserved for system schemas. > Is there any way to bypass this? regression=# create database breakme; CREATE DATABASE regression=# \c breakme You are now connected to database "breakme" as user "postgres". breakme=# alter schema pg_catalog rename to broken; ALTER SCHEMA breakme=# \d ERROR: relation "pg_catalog.pg_class" does not exist LINE 5: FROM pg_catalog.pg_class c ^ ... oops, it's pretty broken alright ... breakme=# alter schema broken rename to pg_catalog; ERROR: unacceptable schema name "pg_catalog" DETAIL: The prefix "pg_" is reserved for system schemas. ... as you said. But: breakme=# set allow_system_table_mods = 1; SET breakme=# alter schema broken rename to pg_catalog; ALTER SCHEMA breakme=# \d Did not find any relations. Needless to say, running with allow_system_table_mods on opens the door to even more dangerous changes, some of which you will absolutely not be able to recover from. (For example, "delete from pg_class" is about as bad as "rm -rf /" ...) Again, whoever broke this for you needs a bit of re-education before they are trusted with superuser privileges in any DB you care about. regards, tom lane