Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDHLb-0003ea-E8 for pgsql-bugs@arkaria.postgresql.org; Thu, 26 Sep 2019 00:09:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iDHLa-00023H-9i for pgsql-bugs@arkaria.postgresql.org; Thu, 26 Sep 2019 00:09:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDHLa-00022r-2B for pgsql-bugs@lists.postgresql.org; Thu, 26 Sep 2019 00:09:26 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDHLX-0002Fa-UB for pgsql-bugs@lists.postgresql.org; Thu, 26 Sep 2019 00:09:25 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x8Q09Lbv002415; Wed, 25 Sep 2019 20:09:21 -0400 From: Tom Lane To: kingsbury.matthew@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16025: pg_default tablespace is removable but not creatable In-reply-to: <16025-c86354bc1ad3e898@postgresql.org> References: <16025-c86354bc1ad3e898@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Wed, 25 Sep 2019 23:31:42 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2413.1569456561.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 25 Sep 2019 20:09:21 -0400 Message-ID: <2414.1569456561@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > I was able to rename pg_default to something else, accidentally. If you're superuser, yeah. Don't do that. > However, > there appears to be no mechanism to replace pg_default nor can one repla= ce > the pg_default after performing this action. [ shrug... ] There are innumerable unrecoverable things you can do as superuser. "DELETE FROM pg_database" is a fun example (*don't* try this at work). This isn't a bug, any more than it's a bug that root can destroy the whole filesystem. Cautious DBAs don't do more than they absolutely must as superuser. We've made efforts lately to reduce the number of tasks that require superuser as opposed to some more-restricted role, eg you can do a lot from a role with CREATEUSER privilege. FWIW, you can in fact get out of the described situation: regression=3D# ALTER TABLESPACE pg_default RENAME TO not_pg_default; ALTER TABLESPACE regression=3D# table pg_tablespace; oid | spcname | spcowner | spcacl | spcoptions = ------+----------------+----------+--------+------------ 1664 | pg_global | 10 | | = 1663 | not_pg_default | 10 | | = (2 rows) regression=3D# update pg_tablespace set spcname =3D 'pg_default' where spc= name =3D 'not_pg_default'; UPDATE 1 regression=3D# table pg_tablespace; oid | spcname | spcowner | spcacl | spcoptions = ------+------------+----------+--------+------------ 1664 | pg_global | 10 | | = 1663 | pg_default | 10 | | = (2 rows) Nonetheless, the bottom line is that PG superusers do not have training wheels. regards, tom lane