Re: Cleaning up template 1 -> template0 cloning - Mailing list pgsql-sql

From Tom Lane
Subject Re: Cleaning up template 1 -> template0 cloning
Date
Msg-id 20276.1017891214@sss.pgh.pa.us
Whole thread Raw
In response to Re: Cleaning up template 1 -> template0 cloning  ("Josh Berkus" <josh@agliodbs.com>)
List pgsql-sql
"Josh Berkus" <josh@agliodbs.com> writes:
> Trying to remove template1 to restore it using an undamaged template0
>  seems to be a catch-22 with no way out.  Help!

There are defenses in place that are intended to prevent you from
accidentally shooting yourself in the foot.  Quoting from the source:
    * Disallow dropping a DB that is marked istemplate.  This is just to    * prevent people from accidentally dropping
template0or template1;    * they can do so if they're really determined ...
 

Offhand I think you have to (a) make sure you have a spare database
available to issue the DROP DATABASE from, and (b) clear the
datistemplate flag from template1's pg_database row.

("Ensign, engage primary destructor beam" ... "Engaged" ... "Fire!")

After you recreate a fresh template1 you should of course set
datistemplate for it, else non-superusers will have difficulty
creating new databases.
        regards, tom lane


pgsql-sql by date:

Previous
From: "Josh Berkus"
Date:
Subject: Re: Cleaning up template 1 -> template0 cloning
Next
From: Iklódi Lajos
Date:
Subject: Re: Update in trigger