From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Ron <ronljohnsonjr@gmail.com>
Cc: pgsql-admin@lists.postgresql.org
Subject: Re: vacuumdb maintenance-db??
Date: Wed, 09 Nov 2022 16:42:03 -0500
Message-ID: <37463.1668030123@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwYfAHsQhieDoxVpmQH8yBCmjgGUjm1S25_BRxh8ipd_+Q@mail.gmail.com>
References: <36bb2141-52e0-e75a-ea4a-5f2236b76c26@gmail.com>
<CAKFQuwZyzOjF9_89t253TMhvwNSUfDrroBV_o_y3YQNRynd2BA@mail.gmail.com>
<92175f50-42f4-bb90-83cd-02b3407c0b56@gmail.com>
<CAKFQuwYfAHsQhieDoxVpmQH8yBCmjgGUjm1S25_BRxh8ipd_+Q@mail.gmail.com>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Wed, Nov 9, 2022 at 1:54 PM Ron <ronljohnsonjr@gmail.com> wrote:
>> But this raises a different question: when does the postgres database not
>> exist?
> You are giving it too much specialness. Both ALTER DATABASE ... RENAME and
> DROP DATABASE can be used on it.
The template databases aren't all that special either. There is a defense
against dropping them accidentally:
regression=# drop database template1;
ERROR: cannot drop a template database
but you can override that if you really mean it:
regression=# alter database template1 with is_template false;
ALTER DATABASE
regression=# drop database template1;
DROP DATABASE
This might seem pretty scary, but it's intentional, per the comments
in IsPinnedObject:
* Databases are never pinned. It might seem that it'd be prudent to pin
* at least template0; but we do this intentionally so that template0 and
* template1 can be rebuilt from each other, thus letting them serve as
* mutual backups (as long as you've not modified template1, anyway).
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, ronljohnsonjr@gmail.com, pgsql-admin@lists.postgresql.org
Subject: Re: vacuumdb maintenance-db??
In-Reply-To: <37463.1668030123@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox