Re: Fwd: Identify system databases - Mailing list pgsql-general

From Laurenz Albe
Subject Re: Fwd: Identify system databases
Date
Msg-id 2dffe860b085b927726a052bcfe16ede704ab923.camel@cybertec.at
Whole thread Raw
In response to Re: Fwd: Identify system databases  (Dominique Devienne <ddevienne@gmail.com>)
Responses Re: Fwd: Identify system databases
List pgsql-general
On Wed, 2025-04-16 at 10:09 +0200, Dominique Devienne wrote:
> On Wed, Apr 16, 2025 at 9:32 AM Laurenz Albe <laurenz.albe@cybertec.at> wrote:
> > On Tue, 2025-04-15 at 17:24 -0700, Adrian Klaver wrote:
> > But then you fortunately cannot drop all databases, because you cannot
> > drop the database you are connected to.
> >
> > Still, a cluster that is missing "postgres" will give beginners trouble
>
> Right. Given shared "cluster-wide" objects like roles, databases, etc...
> I'm always found it weird that one must know "a priori" the name of one
> database to connect to, to do anything with PostgreSQL.

It is documented, and it is the default database if you are connecting
with the default database user "postgres", so it is not that bad.

Also, tools like "createdb" connect to that database by default.

> Not being able to drop the DB one's connected to is also a pita.
> If one have the right to do it, then it should just be done, and the
> connection closed.

No, it is a life saver, at least in my opinion.

> Authentication is cluster-wide, not DB specific, so I'd welcome a way to connect
> to the cluster, not a specific DB, and introspect shared-objects,
> including databases
> I'm allowed to connect to, which could be an empty list.

It is deep in the DNA of PostgreSQL that you always have to connect to
a database, unless you establish a replication connection.
I am surprised that you perceive that as a problem or limitation.

> FWIW. And a little OT. And implicit cluster-level mini-DB given access
> just to a subset of catalogs, or at least some limited queries like
> my databases and my roles, nothing else, would be very welcome IMHO. --DD

Well, that's the "postgres" database.

Yours,
Laurenz Albe



pgsql-general by date:

Previous
From: Anton Shepelev
Date:
Subject: Cannot turn track_counts on
Next
From: Ron Johnson
Date:
Subject: Re: Best Tool for PostgreSQL Auditing and Storing Audit Logs Separately