From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
Cc: | Igor Korot <ikorot01(at)gmail(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Fwd: Identify system databases |
Date: | 2025-04-15 18:35:34 |
Message-ID: | CAKFQuwYpY7urAHuns26cw=9TKTZJU4JdVBrXWoSH_nHfZ_s3Ww@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Apr 15, 2025 at 11:20 AM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:
> On 4/15/25 09:48, David G. Johnston wrote:
> > On Tue, Apr 15, 2025 at 9:31 AM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com
> > <mailto:adrian(dot)klaver(at)aklaver(dot)com>> wrote:
> >
>
> >
> > Agreed.
> >
> > The fact that initdb creates the template0, template1 and postgres
> > databases and you can't change that makes them system not user
> > databases.
> >
> >
> > Based on that definition there is a boundary in the system where OIDs
> > are considered bootstrap/system OIDs versus user OIDs. Key off of
> > that. Though since the names never change, and there are always/only
> > three, it seems pointless to use the OID aspect of initdb as a basis.
> >
> > My definition of a "system database" would be a database that, if it
> > didn't exist, would cause the system to break. i.e., is a database
> > whose presence is integral to the operations of the system. None of
> > these qualify under that definition. Which is why there is no column in
> > pg_database identifying system databases - there are none.
>
> 1) Try connecting(not using single user mode) to a cluster without them.
>
I did. Here, the full test.
-- freshly initdb cluster exists and is running
❯ cat ~/Downloads/test-drops.bash
createdb mydb
psql -c 'alter database template0 is_template false;' mydb
dropdb template0
psql -c 'alter database template1 is_template false;' mydb
dropdb template1
dropdb --maintenance-db mydb postgres
psql -c '\l' mydb
❯ bash ~/Downloads/test-drops.bash
ALTER DATABASE
ALTER DATABASE
List of databases
Name | Owner | Encoding | Locale Provider | Collate | Ctype |
Locale | ICU Rules | Access privileges
------+--------+----------+-----------------+------------+------------+--------+-----------+-------------------
mydb | davidj | UTF8 | libc | en_US.utf8 | en_US.utf8 |
| |
(1 row)
> 2) Trying creating a database or databases to replace them without them
> existing in the first place.
>
Why?
> If what you say is true why does initdb lack an option to not create
> them on creating a cluster?
>
Well, it has to create one database because it is not possible to connect
to the cluster without naming a specific database.
initdb could allow the user to specify the initial database name and only
create that single database. It would work.
By creating the initial three databases the system is more usable due to
having established conventions. They are conventional databases, not
system ones.
Plus, it leaves the cluster in a state that is generally much more
user-friendly. And, as shown, people who dislike the convention can
rearrange things into whatever form they desire.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2025-04-15 19:10:53 | Re: Fwd: Identify system databases |
Previous Message | Adrian Klaver | 2025-04-15 18:20:08 | Re: Fwd: Identify system databases |